Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: unnecessary use of fmt.Sprintf (S1039) #2168

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/check-gke-ingress/app/ingress/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func CheckRuleHostOverwrite(c *IngressChecker) (string, string, string) {
}
hostSet[rule.Host] = struct{}{}
}
return RuleHostOverwriteCheck, report.Passed, fmt.Sprintf("Ingress rule hosts are unique")
return RuleHostOverwriteCheck, report.Passed, "Ingress rule hosts are unique"
}

// CheckServiceExistence checks whether a service exists.
Expand Down
2 changes: 1 addition & 1 deletion cmd/e2e-test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestFrontendResourceDeletion(t *testing.T) {
t.Logf("Echo service created (%s/%s)", s.Namespace, svcName)

// Create SSL certificate.
certName := fmt.Sprintf("cert-1")
certName := "cert-1"
cert, err := e2e.NewCert(certName, host, e2e.K8sCert, false)
if err != nil {
t.Fatalf("e2e.NewCert(%q, %q, _, %t) = %v, want nil", certName, host, false, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func TestGetProbeCrossNamespace(t *testing.T) {
// path is different. If this pod was created in the same ns, it
// would become the health check.
Labels: map[string]string{"app-3001": "test"},
Name: fmt.Sprintf("test-pod-new-ns"),
Name: "test-pod-new-ns",
Namespace: "new-ns",
CreationTimestamp: metav1.NewTime(firstPodCreationTime.Add(-time.Duration(time.Hour))),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/neg/readiness/reflector.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (r *readinessReflector) syncPod(podKey string, neg, backendService *meta.Ke
func (r *readinessReflector) getExpectedNegCondition(pod *v1.Pod, neg, backendService *meta.Key) v1.PodCondition {
expectedCondition := v1.PodCondition{Type: shared.NegReadinessGate}
if pod == nil {
expectedCondition.Message = fmt.Sprintf("Unknown status for unknown pod.")
expectedCondition.Message = "Unknown status for unknown pod."
return expectedCondition
}

Expand Down
17 changes: 9 additions & 8 deletions pkg/neg/readiness/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ package readiness
import (
"context"
"fmt"
"k8s.io/api/core/v1"
"net"
"reflect"
"testing"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/fake"
negtypes "k8s.io/ingress-gce/pkg/neg/types"
"k8s.io/ingress-gce/pkg/neg/types/shared"
"net"
"reflect"
"testing"
)

const (
Expand Down Expand Up @@ -272,23 +273,23 @@ func TestPatchPodStatus(t *testing.T) {
{
"no change",
func(input v1.PodStatus) v1.PodStatus { return input },
[]byte(fmt.Sprintf(`{}`)),
[]byte(`{}`),
},
{
"message change",
func(input v1.PodStatus) v1.PodStatus {
input.Message = "random message"
return input
},
[]byte(fmt.Sprintf(`{"status":{"message":"random message"}}`)),
[]byte(`{"status":{"message":"random message"}}`),
},
{
"pod condition change",
func(input v1.PodStatus) v1.PodStatus {
input.Conditions[0].Status = v1.ConditionFalse
return input
},
[]byte(fmt.Sprintf(`{"status":{"$setElementOrder/conditions":[{"type":"Ready"},{"type":"PodScheduled"}],"conditions":[{"status":"False","type":"Ready"}]}}`)),
[]byte(`{"status":{"$setElementOrder/conditions":[{"type":"Ready"},{"type":"PodScheduled"}],"conditions":[{"status":"False","type":"Ready"}]}}`),
},
{
"additional init container condition",
Expand All @@ -301,7 +302,7 @@ func TestPatchPodStatus(t *testing.T) {
}
return input
},
[]byte(fmt.Sprintf(`{"status":{"initContainerStatuses":[{"image":"","imageID":"","lastState":{},"name":"init-container","ready":true,"restartCount":0,"state":{}}]}}`)),
[]byte(`{"status":{"initContainerStatuses":[{"image":"","imageID":"","lastState":{},"name":"init-container","ready":true,"restartCount":0,"state":{}}]}}`),
},
}
for _, tc := range testCases {
Expand Down