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

KUBESAW-250: Updating GolangCiLint to v1.63.1 #612

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 .github/workflows/ci-golang-sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.56.2
version: v1.63.1
skip-pkg-cache: true
skip-build-cache: true
args: --config=./.golangci.yml --verbose
Expand Down
2 changes: 1 addition & 1 deletion controllers/memberstatus/memberstatus_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestNoMemberStatusFound(t *testing.T) {
getHostClusterFunc := newGetHostClusterReady
reconciler, req, fakeClient := prepareReconcile(t, requestName, getHostClusterFunc, allNamespacesCl, mockLastGitHubAPICall, defaultGitHubClient)
fakeClient.MockGet = func(ctx context.Context, key types.NamespacedName, obj client.Object, opts ...client.GetOption) error {
return fmt.Errorf(expectedErrMsg)
return fmt.Errorf("%s", expectedErrMsg)
}

// when
Expand Down
5 changes: 2 additions & 3 deletions controllers/nstemplateset/space_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"context"
"encoding/json"
"fmt"
"reflect"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
Expand Down Expand Up @@ -79,15 +78,15 @@
sr, err := json.Marshal(nsTmplSet.Spec.SpaceRoles)
if err != nil {
return false, r.wrapErrorWithStatusUpdate(lctx, nsTmplSet, r.setStatusProvisionFailed, err,
fmt.Sprintf("failed to marshal space roles to update '%s' annotation on namespace", toolchainv1alpha1.LastAppliedSpaceRolesAnnotationKey))
"failed to marshal space roles to update '%s' annotation on namespace", toolchainv1alpha1.LastAppliedSpaceRolesAnnotationKey)

Check warning on line 81 in controllers/nstemplateset/space_roles.go

View check run for this annotation

Codecov / codecov/patch

controllers/nstemplateset/space_roles.go#L81

Added line #L81 was not covered by tests
}
if ns.Annotations == nil {
ns.Annotations = map[string]string{}
}
ns.Annotations[toolchainv1alpha1.LastAppliedSpaceRolesAnnotationKey] = string(sr)
if err := r.Client.Update(ctx, &ns); err != nil {
return false, r.wrapErrorWithStatusUpdate(lctx, nsTmplSet, r.setStatusProvisionFailed, err,
fmt.Sprintf("failed to update namespace with '%s' annotation", toolchainv1alpha1.LastAppliedSpaceRolesAnnotationKey))
"failed to update namespace with '%s' annotation", toolchainv1alpha1.LastAppliedSpaceRolesAnnotationKey)

Check warning on line 89 in controllers/nstemplateset/space_roles.go

View check run for this annotation

Codecov / codecov/patch

controllers/nstemplateset/space_roles.go#L89

Added line #L89 was not covered by tests
}
logger.Info("updated annotation on namespace", toolchainv1alpha1.LastAppliedSpaceRolesAnnotationKey, string(sr))
return true, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/mutatingwebhook/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func handleMutate(logger logr.Logger, w http.ResponseWriter, r *http.Request, mu

func writeResponse(logger logr.Logger, responseCode int, w http.ResponseWriter, respBody []byte) {
w.WriteHeader(responseCode)
if _, err := io.WriteString(w, string(respBody)); err != nil {
if _, err := io.Writer.Write(w, respBody); err != nil { //using 'io.Writer.Write' as per the static check SA6006: use io.Writer.Write instead of converting from []byte to string to use io.WriteString (staticcheck)
logger.Error(err, "unable to write adm review response")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (v RoleBindingRequestValidator) HandleValidate(w http.ResponseWriter, r *ht
respBody = v.validate(r.Context(), body)
w.WriteHeader(http.StatusOK)
}
if _, err := io.WriteString(w, string(respBody)); err != nil {
if _, err := io.Writer.Write(w, respBody); err != nil { //using 'io.Writer.Write' as per the static check SA6006: use io.Writer.Write instead of converting from []byte to string to use io.WriteString (staticcheck)
log.Error(err, "unable to write response")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
respBody = v.validate(r.Context(), body)
w.WriteHeader(http.StatusOK)
}
if _, err := io.WriteString(w, string(respBody)); err != nil {
if _, err := io.Writer.Write(w, respBody); err != nil { //using 'io.Writer.Write' as per the static check SA6006: use io.Writer.Write instead of converting from []byte to string to use io.WriteString (staticcheck)

Check warning on line 45 in pkg/webhook/validatingwebhook/validate_spacebindingrequest.go

View check run for this annotation

Codecov / codecov/patch

pkg/webhook/validatingwebhook/validate_spacebindingrequest.go#L45

Added line #L45 was not covered by tests
log.Error(err, "unable to write response")
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/validatingwebhook/validate_ssp_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (v SSPRequestValidator) HandleValidate(w http.ResponseWriter, r *http.Reque
respBody = v.validate(r.Context(), body)
w.WriteHeader(http.StatusOK)
}
if _, err := io.WriteString(w, string(respBody)); err != nil {
if _, err := io.Writer.Write(w, respBody); err != nil { //using 'io.Writer.Write' as per the static check SA6006: use io.Writer.Write instead of converting from []byte to string to use io.WriteString (staticcheck)
log.Error(err, "unable to write response")
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/validatingwebhook/validate_vm_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (v VMRequestValidator) HandleValidate(w http.ResponseWriter, r *http.Reques
respBody = v.validate(body)
w.WriteHeader(http.StatusOK)
}
if _, err := io.WriteString(w, string(respBody)); err != nil {
if _, err := io.Writer.Write(w, respBody); err != nil { //using 'io.Writer.Write' as per the static check SA6006: use io.Writer.Write instead of converting from []byte to string to use io.WriteString (staticcheck)
log.Error(err, "unable to write response")
}
}
Expand Down
Loading