Skip to content

Commit

Permalink
*: fix non-constant format strings
Browse files Browse the repository at this point in the history
printf: non-constant format string in call to (*github.com/sirupsen/logrus.Entry).Warnf (govet)

Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov committed Feb 7, 2025
1 parent 88960c9 commit 18cf165
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.
8 changes: 7 additions & 1 deletion pkg/api/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,17 @@ const (

// NewCloudError returns a new CloudError
func NewCloudError(statusCode int, code, target, message string, a ...interface{}) *CloudError {
var msg string
if len(a) == 0 {
msg = fmt.Sprint(message)
} else {
msg = fmt.Sprintf(msg, a...)
}
return &CloudError{
StatusCode: statusCode,
CloudErrorBody: &CloudErrorBody{
Code: code,
Message: fmt.Sprintf(message, a...),
Message: msg,
Target: target,
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/gatherlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (m *manager) logClusterOperators(ctx context.Context) (interface{}, error)
errs = append(errs, err)
continue
}
m.log.Infof(string(json))
m.log.Info(string(json))
}

return strings.Join(lines, "\n"), errors.Join(errs...)
Expand Down Expand Up @@ -217,7 +217,7 @@ func (m *manager) logIngressControllers(ctx context.Context) (interface{}, error
errs = append(errs, err)
continue
}
m.log.Infof(string(json))
m.log.Info(string(json))
}

return strings.Join(lines, "\n"), errors.Join(errs...)
Expand Down
4 changes: 2 additions & 2 deletions pkg/frontend/admin_openshiftcluster_etcdcertificaterenew.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@ func (e *etcdrenew) isEtcdRevised(ctx context.Context) (bool, error) {
isAtRevision := true
rawEtcd, err := e.k.KubeGet(ctx, "etcd.operator.openshift.io", "", "cluster")
if err != nil {
e.log.Warnf(err.Error())
e.log.Warn(err.Error())
return false, nil
}
etcd := &operatorv1.Etcd{}
err = codec.NewDecoderBytes(rawEtcd, &codec.JsonHandle{}).Decode(etcd)
if err != nil {
e.log.Warnf(err.Error())
e.log.Warn(err.Error())
return false, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ func TestReconcile(t *testing.T) {
}

if condition.Status != tt.wantConditionStatus {
t.Errorf(string(condition.Status))
t.Error(string(condition.Status))
}

if condition.Message != tt.wantConditionMessage {
t.Errorf(condition.Message)
t.Error(condition.Message)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func TestReconcile(t *testing.T) {
}

if condition.Status != tt.wantConditionStatus {
t.Errorf(string(condition.Status))
t.Error(string(condition.Status))
}

if condition.Message != tt.wantConditionMessage {
t.Errorf(condition.Message)
t.Error(condition.Message)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (r *checker) Check(URLs []string) error {
}
if len(errsAll) != 0 {
// TODO: Consider replacing with multi error wrapping with Go 1.20: https://github.com/golang/go/issues/53435#issuecomment-1320343377
return fmt.Errorf(strings.Join(errsAll, "\n"))
return fmt.Errorf("%s", strings.Join(errsAll, "\n"))
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func TestReconcile(t *testing.T) {
}

if condition.Status != tt.wantConditionStatus {
t.Errorf(string(condition.Status))
t.Error(string(condition.Status))
}

if condition.Message != tt.wantConditionMessage {
t.Errorf(condition.Message)
t.Error(condition.Message)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ func TestEnsureGlobalPullSecret(t *testing.T) {
s, err := r.ensureGlobalPullSecret(ctx, tt.operatorPullSecret, tt.pullSecret)
utilerror.AssertErrorMessage(t, err, tt.wantError)

if !reflect.DeepEqual(s, tt.wantSecret) {
t.Fatalf(cmp.Diff(s, tt.wantSecret))
if diff := cmp.Diff(s, tt.wantSecret); diff != "" {
t.Fatalf("Unexpected pull secret (-want, +got): %s", diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/controllers/subnets/subnets_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (r *reconcileManager) reconcileSubnets(ctx context.Context) error {
}

if len(combinedErrors) > 0 {
return fmt.Errorf(strings.Join(combinedErrors, "\n"))
return fmt.Errorf("%s", strings.Join(combinedErrors, "\n"))
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions test/util/kubeadminkubeconfig/kubetoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func parseTokenResponse(location string) (string, error) {
}

if v.Get("error") != "" {
return "", fmt.Errorf(v.Get("error_description"))
return "", fmt.Errorf("%s", v.Get("error_description"))
}

v, err = url.ParseQuery(locURL.Fragment)
Expand All @@ -36,7 +36,7 @@ func parseTokenResponse(location string) (string, error) {
}

if v.Get("error") != "" {
return "", fmt.Errorf(v.Get("error_description"))
return "", fmt.Errorf("%s", v.Get("error_description"))
}

return v.Get("access_token"), nil
Expand Down

0 comments on commit 18cf165

Please sign in to comment.