diff --git a/.github/workflows/pr-golangci-lint.yaml b/.github/workflows/pr-golangci-lint.yaml index 0c8915b863c1..5e6d284ce3d7 100644 --- a/.github/workflows/pr-golangci-lint.yaml +++ b/.github/workflows/pr-golangci-lint.yaml @@ -30,6 +30,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # tag=v3.7.0 with: - version: v1.55.2 + version: v1.56.0 args: --out-format=colored-line-number working-directory: ${{matrix.working-directory}} diff --git a/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go b/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go index 653b4da552e8..67b4f51cd764 100644 --- a/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go +++ b/bootstrap/kubeadm/api/v1beta1/kubeadm_types.go @@ -569,7 +569,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error { // String returns the string representation of the BootstrapTokenString. func (bts BootstrapTokenString) String() string { - if len(bts.ID) > 0 && len(bts.Secret) > 0 { + if bts.ID != "" && bts.Secret != "" { return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret) } return "" diff --git a/bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go b/bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go index 98aacc8852ea..e8d1e562d84c 100644 --- a/bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go +++ b/bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go @@ -156,7 +156,7 @@ func roundtrip(input string, bts *BootstrapTokenString) error { var err error newbts := &BootstrapTokenString{} // If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string - if len(input) > 0 { + if input != "" { if err := json.Unmarshal([]byte(input), newbts); err != nil { return errors.Wrap(err, "expected no unmarshal error, got error") } diff --git a/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring.go b/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring.go index 0dca2e0b3b0a..2ad57c137bd0 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring.go +++ b/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring.go @@ -62,7 +62,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error { // String returns the string representation of the BootstrapTokenString. func (bts BootstrapTokenString) String() string { - if len(bts.ID) > 0 && len(bts.Secret) > 0 { + if bts.ID != "" && bts.Secret != "" { return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret) } return "" diff --git a/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring_test.go b/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring_test.go index 154ab8540ef1..c6f33b0430c1 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring_test.go +++ b/bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring_test.go @@ -98,7 +98,7 @@ func roundtrip(input string, bts *BootstrapTokenString) error { var err error newbts := &BootstrapTokenString{} // If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string - if len(input) > 0 { + if input != "" { if err := json.Unmarshal([]byte(input), newbts); err != nil { return errors.Wrap(err, "expected no unmarshal error, got error") } diff --git a/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring.go b/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring.go index 2bb4fda07254..5b0b0aebc3ff 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring.go +++ b/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring.go @@ -60,7 +60,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error { // String returns the string representation of the BootstrapTokenString. func (bts BootstrapTokenString) String() string { - if len(bts.ID) > 0 && len(bts.Secret) > 0 { + if bts.ID != "" && bts.Secret != "" { return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret) } return "" diff --git a/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring_test.go b/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring_test.go index 640c581a6dea..202244fa4e7d 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring_test.go +++ b/bootstrap/kubeadm/types/upstreamv1beta3/bootstraptokenstring_test.go @@ -105,7 +105,7 @@ func roundtrip(input string, bts *BootstrapTokenString) error { var err error newbts := &BootstrapTokenString{} // If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string - if len(input) > 0 { + if input != "" { if err := json.Unmarshal([]byte(input), newbts); err != nil { return errors.Wrap(err, "expected no unmarshal error, got error") } diff --git a/cmd/clusterctl/client/cluster/mover.go b/cmd/clusterctl/client/cluster/mover.go index ca18608d60e4..0232aba2b8b7 100644 --- a/cmd/clusterctl/client/cluster/mover.go +++ b/cmd/clusterctl/client/cluster/mover.go @@ -967,7 +967,7 @@ func (o *objectMover) createTargetObject(ctx context.Context, nodeToCreate *node // FIXME Workaround for https://github.com/kubernetes/kubernetes/issues/32220. Remove when the issue is fixed. // If the resource already exists, the API server ordinarily returns an AlreadyExists error. Due to the above issue, if the resource has a non-empty metadata.generateName field, the API server returns a ServerTimeoutError. To ensure that the API server returns an AlreadyExists error, we set the metadata.generateName field to an empty string. - if len(obj.GetName()) > 0 && len(obj.GetGenerateName()) > 0 { + if obj.GetName() != "" && obj.GetGenerateName() != "" { obj.SetGenerateName("") } diff --git a/cmd/clusterctl/cmd/util.go b/cmd/clusterctl/cmd/util.go index 59e1d50e9535..01b65357fd44 100644 --- a/cmd/clusterctl/cmd/util.go +++ b/cmd/clusterctl/cmd/util.go @@ -63,7 +63,7 @@ func printVariablesOutput(template client.Template, options client.GetClusterTem if variableMap[name] != nil { v := *variableMap[name] // Add quotes around any unquoted strings - if len(v) > 0 && !strings.HasPrefix(v, "\"") { + if v != "" && !strings.HasPrefix(v, "\"") { v = fmt.Sprintf("%q", v) variableMap[name] = &v } diff --git a/cmd/clusterctl/log/logger.go b/cmd/clusterctl/log/logger.go index a64e2bb657cd..34435cdea22e 100644 --- a/cmd/clusterctl/log/logger.go +++ b/cmd/clusterctl/log/logger.go @@ -106,7 +106,7 @@ func (l *logger) V(level int) logr.LogSink { // WithName adds a new element to the logger's name. func (l *logger) WithName(name string) logr.LogSink { nl := l.clone() - if len(l.prefix) > 0 { + if l.prefix != "" { nl.prefix = l.prefix + "/" } nl.prefix += name diff --git a/internal/controllers/topology/cluster/desired_state.go b/internal/controllers/topology/cluster/desired_state.go index 34a7b52a24f9..3e6542d6d062 100644 --- a/internal/controllers/topology/cluster/desired_state.go +++ b/internal/controllers/topology/cluster/desired_state.go @@ -1274,7 +1274,7 @@ func templateToObject(in templateToInput) (*unstructured.Unstructured, error) { return nil, errors.Wrapf(err, "failed to generate name for %s", object.GetKind()) } object.SetName(name) - if in.currentObjectRef != nil && len(in.currentObjectRef.Name) > 0 { + if in.currentObjectRef != nil && in.currentObjectRef.Name != "" { object.SetName(in.currentObjectRef.Name) } @@ -1338,7 +1338,7 @@ func templateToTemplate(in templateToInput) (*unstructured.Unstructured, error) return nil, errors.Wrapf(err, "failed to generate name for %s", template.GetKind()) } template.SetName(name) - if in.currentObjectRef != nil && len(in.currentObjectRef.Name) > 0 { + if in.currentObjectRef != nil && in.currentObjectRef.Name != "" { template.SetName(in.currentObjectRef.Name) }