Skip to content

Commit

Permalink
chore: Bump golangci-lint make and action (#1346)
Browse files Browse the repository at this point in the history
* chore: Bump golangci-lint make and action

* retrigger jobs

* retrigger jobs

* try referencing by full semver

* adapt one arg sprints fmts

* gofumpt with latest version

* extract constant negating func

* remove default rules
  • Loading branch information
lindnerby authored Mar 4, 2024
1 parent 0022757 commit 386e15e
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
go-version-file: 'go.mod'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4.0.0
with:
version: v1.55.0
version: v1.56.2
args: --verbose
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ linters-settings:
- github.com/onsi/ginkgo/v2
- github.com/onsi/gomega
revive:
enable-all-rules: false
severity: error
rules:
- name: comment-spacings
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ GOLANG_CI_LINT = $(LOCALBIN)/golangci-lint
## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
CONTROLLER_TOOLS_VERSION ?= v0.13.0
GOLANG_CI_LINT_VERSION ?= v1.55.0
GOLANG_CI_LINT_VERSION ?= v1.56.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func dropStoredVersion(mgr manager.Manager, versionToBeRemoved string) {
kcpClient, err := clientset.NewForConfig(cfg)
if err != nil {
setupLog.V(log.DebugLevel).Error(err,
fmt.Sprintf("unable to initialize client to remove %s", versionToBeRemoved))
"unable to initialize client to remove "+versionToBeRemoved)
}
ctx := context.TODO()
var crdList *apiextensionsv1.CustomResourceDefinitionList
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/kyma_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (r *KymaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
status.InitConditions(kyma, r.SyncKymaEnabled(kyma), r.WatcherEnabled(kyma))

if kyma.SkipReconciliation() {
logger.V(log.DebugLevel).Info(fmt.Sprintf("skipping reconciliation for Kyma: %s", kyma.Name))
logger.V(log.DebugLevel).Info("skipping reconciliation for Kyma: " + kyma.Name)
return ctrl.Result{RequeueAfter: r.RequeueIntervals.Success}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r *MandatoryModuleReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}

if kyma.SkipReconciliation() {
logger.V(log.DebugLevel).Info(fmt.Sprintf("skipping mandatory modules reconciliation for Kyma: %s", kyma.Name))
logger.V(log.DebugLevel).Info("skipping mandatory modules reconciliation for Kyma: " + kyma.Name)
return ctrl.Result{RequeueAfter: r.RequeueIntervals.Success}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/declarative/v2/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (r *Reconciler) checkTargetReadiness(
}

if crStateInfo.State == shared.StateProcessing {
waitingMsg := fmt.Sprintf("waiting for resources to become ready: %s", crStateInfo.Info)
waitingMsg := "waiting for resources to become ready: " + crStateInfo.Info
r.Event(manifest, "Normal", "ResourceReadyCheck", waitingMsg)
manifest.SetStatus(status.WithState(shared.StateProcessing).WithOperation(waitingMsg))
return ErrInstallationConditionRequiresUpdate
Expand Down
7 changes: 1 addition & 6 deletions internal/declarative/v2/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,8 @@ func (c *ConcurrentDefaultSSA) serverSideApply(
) {
start := time.Now()
logger := logf.FromContext(ctx, "owner", c.owner)

logger.V(internal.TraceLogLevel).Info(
fmt.Sprintf("apply %s", resource.ObjectName()),
)

logger.V(internal.TraceLogLevel).Info("apply " + resource.ObjectName())
results <- c.serverSideApplyResourceInfo(ctx, resource)

logger.V(internal.TraceLogLevel).Info(
fmt.Sprintf("apply %s finished", resource.ObjectName()),
"time", time.Since(start),
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/metrics/kyma.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (k *KymaMetrics) CleanupNonExistingKymaCrsMetrics(ctx context.Context, kcpC
continue
}
if _, exists := kymaNames[currentKymaName]; !exists {
logs.FromContext(ctx).Info(fmt.Sprintf("Deleting a metric for non-existing Kyma: %s", currentKymaName))
logs.FromContext(ctx).Info("Deleting a metric for non-existing Kyma: " + currentKymaName)
k.KymaStateGauge.DeletePartialMatch(prometheus.Labels{
KymaNameLabel: currentKymaName,
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/img/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func getOCIRef(
layerRef.Repo = fmt.Sprintf("%s/%s", repo.Name(), repoSubpath)
layerRef.Name = descriptor.GetName()
case genericocireg.OCIRegistryDigestMapping:
layerRef.Repo = fmt.Sprintf("%s/", repo.Name())
layerRef.Repo = repo.Name() + "/"
layerRef.Name = sha256sum(descriptor.GetName())
default:
return nil, fmt.Errorf(
Expand Down
1 change: 0 additions & 1 deletion pkg/remote/kyma_synchronization_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (c *KymaSynchronizationContext) CreateOrUpdateCRD(ctx context.Context, plur
Name: fmt.Sprintf("%s.%s", plural, v1beta2.GroupVersion.Group),
}, crd,
)

if err != nil {
return fmt.Errorf("failed to get kyma CRDs on kcp: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/remote/remote_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func (c *RemoteCatalog) CreateModuleTemplateCRDInRuntime(ctx context.Context, pl
// name changes, this also has to be adjusted here. We can think of making this configurable later
Name: fmt.Sprintf("%s.%s", plural, v1beta2.GroupVersion.Group),
}, crd)

if err != nil {
return fmt.Errorf("failed to get module template CRD from kcp: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/testutils/klm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func CheckKLMLogs(ctx context.Context,

_, err = getPodLogs(ctx, runtimeConfig,
runtimeClient, remoteNamespace, watcher.SkrResourceName, watcherPodContainer, logsSince)

if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutils/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func PushToRemoteOCIRegistry(server *httptest.Server, manifestFilePath, layerNam
return err
}
if gotHash != digest {
return fmt.Errorf("has not equal to digest")
return errors.New("has not equal to digest")
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/watcher/skr_webhook_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func generateValidatingWebhookConfigFromWatchers(webhookObjKey,
for _, watcher := range watchers {
moduleName := watcher.GetModuleName()
webhookName := fmt.Sprintf("%s.%s.%s", watcher.Namespace, watcher.Name, shared.OperatorGroup)
svcPath := fmt.Sprintf("/validate/%s", moduleName)
svcPath := "/validate/" + moduleName
watchableResources := ResolveWebhookRuleResources(watcher.Spec.ResourceToWatch.Resource, watcher.Spec.Field)
sideEffects := admissionregistrationv1.SideEffectClassNoneOnDryRun
failurePolicy := admissionregistrationv1.Ignore
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/ca_certificate_rotation_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package e2e_test

import (
"fmt"
"time"

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
Expand All @@ -28,7 +27,7 @@ var _ = Describe("CA Certificate Rotation", Ordered, func() {

Context("Given KCP Cluster and rotated CA certificate", func() {
kcpNamespacedSecretName := types.NamespacedName{
Name: fmt.Sprintf("%s-webhook-tls", kyma.Name),
Name: kyma.Name + "-webhook-tls",
Namespace: "istio-system",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@ func mandatoryModuleTemplateFinalizerExists(ctx context.Context, clnt client.Cli
if controllerutil.ContainsFinalizer(&template, "operator.kyma-project.io/mandatory-module") {
return nil
}
return fmt.Errorf("ModuleTemplate does not contain mandatory finalizer")
return errors.New("ModuleTemplate does not contain mandatory finalizer")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package withwatcher_test
import (
"context"
"errors"
"fmt"
"io"
"os"

Expand Down Expand Up @@ -173,11 +172,11 @@ func createWatcherCR(managerInstanceName string, statusOnly bool) *v1beta2.Watch
Spec: v1beta2.WatcherSpec{
ServiceInfo: v1beta2.Service{
Port: 8082,
Name: fmt.Sprintf("%s-svc", managerInstanceName),
Name: managerInstanceName + "-svc",
Namespace: apimetav1.NamespaceDefault,
},
LabelsToWatch: map[string]string{
fmt.Sprintf("%s-watchable", managerInstanceName): "true",
managerInstanceName + "-watchable": "true",
},
ResourceToWatch: v1beta2.WatchableGVR{
Group: v1beta2.GroupVersionResource.Group,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/declarative/declarative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var _ = Describe(
var cfg *rest.Config
var testClient client.Client
BeforeAll(func() {
runID = fmt.Sprintf("run-%s", rand.String(4))
runID = "run-" + rand.String(4)
env, cfg = StartEnv()
testClient = GetTestClient(cfg)
ctx, cancel = context.WithCancel(context.TODO())
Expand Down Expand Up @@ -160,7 +160,7 @@ var _ = Describe("Test Manifest Reconciliation for module deletion", Ordered, fu
var testClient client.Client
const ocirefSynced = "sha256:synced"

runID := fmt.Sprintf("run-%s", rand.String(4))
runID := "run-" + rand.String(4)
obj := &declarativetest.TestAPI{Spec: declarativetest.TestAPISpec{ManifestName: "deletion-manifest"}}
obj.SetLabels(k8slabels.Set{testRunLabel: runID})
obj.SetNamespace(customResourceNamespace.Name)
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/declarative/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ func (matcher *BeInStateMatcher) FailureMessage(actual interface{}) string {
}

func (matcher *BeInStateMatcher) NegatedFailureMessage(actual interface{}) string {
return format.Message(
actual, fmt.Sprintf("not %s", matcher.FailureMessage(actual)),
)
return negateMessage(actual, matcher.FailureMessage(actual))
}

func HaveConditionWithStatus(
Expand Down Expand Up @@ -75,9 +73,7 @@ func (matcher *HaveConditionMatcher) FailureMessage(actual interface{}) string {
}

func (matcher *HaveConditionMatcher) NegatedFailureMessage(actual interface{}) string {
return format.Message(
actual, fmt.Sprintf("not %s", matcher.FailureMessage(actual)),
)
return negateMessage(actual, matcher.FailureMessage(actual))
}

func EventuallyDeclarativeStatusShould(ctx context.Context, key client.ObjectKey, testClient client.Client,
Expand Down Expand Up @@ -144,5 +140,9 @@ func (matcher *SyncedResourcesExistingMatcher) FailureMessage(actual interface{}
}

func (matcher *SyncedResourcesExistingMatcher) NegatedFailureMessage(actual interface{}) string {
return format.Message(actual, fmt.Sprintf("not %s", matcher.FailureMessage(actual)))
return negateMessage(actual, matcher.FailureMessage(actual))
}

func negateMessage(actual interface{}, message string) string {
return format.Message(actual, "not "+message)
}

0 comments on commit 386e15e

Please sign in to comment.