From a26a723f123fd814bd834d7d86bc0e22adbff302 Mon Sep 17 00:00:00 2001 From: Zach Aller Date: Tue, 4 Oct 2022 12:55:39 -0500 Subject: [PATCH] chore: upgrade golang to 1.19 (#2219) * chore: upgrade golang to 1.19 Signed-off-by: zachaller * Upgrade golangci-lint Signed-off-by: zachaller * Upgrade golangci-lint in github action Signed-off-by: zachaller * fix linting Signed-off-by: zachaller * Add nolint to test functions Signed-off-by: zachaller * Cleanup Signed-off-by: zachaller * github trigger re-run Signed-off-by: zachaller Signed-off-by: zachaller --- .github/workflows/e2e.yaml | 2 +- .github/workflows/gh-pages.yaml | 2 +- .github/workflows/go.yml | 4 +- .github/workflows/release.yaml | 2 +- .golangci.yml | 4 +- Dockerfile | 6 +- Dockerfile.dev | 2 +- analysis/analysis_test.go | 2 +- analysis/controller_test.go | 10 +-- experiments/controller_test.go | 8 +-- experiments/replicaset_test.go | 3 +- go.mod | 2 +- metricproviders/cloudwatch/cloudwatch.go | 2 +- metricproviders/kayenta/kayenta_test.go | 61 ++++++++++--------- metricproviders/newrelic/newrelic.go | 6 +- .../clientset/versioned/fake/register.go | 14 ++--- .../clientset/versioned/scheme/register.go | 14 ++--- rollout/analysis_test.go | 12 ++-- rollout/bluegreen_test.go | 4 +- rollout/controller_test.go | 8 +-- rollout/sync.go | 12 ++-- rollout/trafficrouting/istio/istio_test.go | 3 +- test/fixtures/common.go | 1 - utils/analysis/factory_test.go | 2 +- utils/conditions/experiments.go | 2 +- utils/replicaset/replicaset.go | 6 +- 26 files changed, 96 insertions(+), 98 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 8f933b5bbd..48c2efb8a7 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -37,7 +37,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - uses: actions/checkout@v2 - name: Setup k3s run: | diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yaml index 3b054e9d82..b55b66d04d 100644 --- a/.github/workflows/gh-pages.yaml +++ b/.github/workflows/gh-pages.yaml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: build run: | pip install mkdocs mkdocs_material diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ff2d356420..1f9dc1a91c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,7 +9,7 @@ on: - "master" env: # Golang version to use across CI steps - GOLANG_VERSION: '1.18' + GOLANG_VERSION: '1.19' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -38,7 +38,7 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.47.2 + version: v1.49.0 args: --timeout 5m build: name: Build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0905ed3af1..dfdf35c2ec 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -106,7 +106,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: Generate release artifacts run: | diff --git a/.golangci.yml b/.golangci.yml index 1acbb8badd..c59d635e9c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,9 +13,7 @@ linters: - vet - gofmt - goimports - - deadcode - - varcheck - - structcheck + - unused - ineffassign - unconvert - misspell diff --git a/Dockerfile b/Dockerfile index 19553e355e..c2809aba6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image # Also used as the image in CI jobs so needs all dependencies #################################################################################################### -FROM --platform=$BUILDPLATFORM golang:1.18 as builder +FROM --platform=$BUILDPLATFORM golang:1.19 as builder RUN apt-get update && apt-get install -y \ wget \ @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Install golangci-lint -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.2 && \ +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 && \ golangci-lint linters COPY .golangci.yml ${GOPATH}/src/dummy/.golangci.yml @@ -40,7 +40,7 @@ RUN NODE_ENV='production' yarn build #################################################################################################### # Rollout Controller Build stage which performs the actual build of argo-rollouts binaries #################################################################################################### -FROM --platform=$BUILDPLATFORM golang:1.18 as argo-rollouts-build +FROM --platform=$BUILDPLATFORM golang:1.19 as argo-rollouts-build WORKDIR /go/src/github.com/argoproj/argo-rollouts diff --git a/Dockerfile.dev b/Dockerfile.dev index 4694dda836..2da9591a0e 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,7 +1,7 @@ #################################################################################################### # argo-rollouts-dev #################################################################################################### -FROM golang:1.17 as builder +FROM golang:1.19 as builder RUN apt-get update && apt-get install -y \ ca-certificates && \ diff --git a/analysis/analysis_test.go b/analysis/analysis_test.go index a88bb1085c..ed12da2dca 100644 --- a/analysis/analysis_test.go +++ b/analysis/analysis_test.go @@ -1279,7 +1279,7 @@ func TestSecretContentReferenceProviderError(t *testing.T) { assert.True(t, strings.Contains(logMessage, "*****")) } -//TestSecretContentReferenceAndMultipleArgResolutionSuccess verifies that both secret and non-secret arguments are resolved properly +// TestSecretContentReferenceAndMultipleArgResolutionSuccess verifies that both secret and non-secret arguments are resolved properly func TestSecretContentReferenceAndMultipleArgResolutionSuccess(t *testing.T) { f := newFixture(t) secretName, secretKey, secretValue := "web-metric-secret", "apikey", "12345" diff --git a/analysis/controller_test.go b/analysis/controller_test.go index 4e3f571b8e..289992ad19 100644 --- a/analysis/controller_test.go +++ b/analysis/controller_test.go @@ -144,7 +144,7 @@ func (f *fixture) run(analysisRunName string) { f.runController(analysisRunName, true, false, c, i, k8sI) } -func (f *fixture) runExpectError(analysisRunName string, startInformers bool) { +func (f *fixture) runExpectError(analysisRunName string, startInformers bool) { //nolint:unused c, i, k8sI := f.newController(noResyncPeriodFunc) f.runController(analysisRunName, startInformers, true, c, i, k8sI) } @@ -238,14 +238,14 @@ func filterInformerActions(actions []core.Action) []core.Action { return ret } -func (f *fixture) expectUpdateAnalysisRunAction(analysisRun *v1alpha1.AnalysisRun) int { +func (f *fixture) expectUpdateAnalysisRunAction(analysisRun *v1alpha1.AnalysisRun) int { //nolint:unused action := core.NewUpdateAction(schema.GroupVersionResource{Resource: "analysisrun"}, analysisRun.Namespace, analysisRun) len := len(f.actions) f.actions = append(f.actions, action) return len } -func (f *fixture) getUpdatedAnalysisRun(index int) *v1alpha1.AnalysisRun { +func (f *fixture) getUpdatedAnalysisRun(index int) *v1alpha1.AnalysisRun { //nolint:unused action := filterInformerActions(f.client.Actions())[index] updateAction, ok := action.(core.UpdateAction) if !ok { @@ -259,7 +259,7 @@ func (f *fixture) getUpdatedAnalysisRun(index int) *v1alpha1.AnalysisRun { return ar } -func (f *fixture) expectPatchAnalysisRunAction(analysisRun *v1alpha1.AnalysisRun) int { +func (f *fixture) expectPatchAnalysisRunAction(analysisRun *v1alpha1.AnalysisRun) int { //nolint:unused analysisRunSchema := schema.GroupVersionResource{ Resource: "analysisruns", Version: "v1alpha1", @@ -269,7 +269,7 @@ func (f *fixture) expectPatchAnalysisRunAction(analysisRun *v1alpha1.AnalysisRun return len } -func (f *fixture) getPatchedAnalysisRun(index int) v1alpha1.AnalysisRun { +func (f *fixture) getPatchedAnalysisRun(index int) v1alpha1.AnalysisRun { //nolint:unused action := filterInformerActions(f.client.Actions())[index] patchAction, ok := action.(core.PatchAction) if !ok { diff --git a/experiments/controller_test.go b/experiments/controller_test.go index d86889c550..70fa70ca1c 100644 --- a/experiments/controller_test.go +++ b/experiments/controller_test.go @@ -535,7 +535,7 @@ func filterInformerActions(actions []core.Action) []core.Action { return ret } -func (f *fixture) expectCreateServiceAction(service *corev1.Service) int { +func (f *fixture) expectCreateServiceAction(service *corev1.Service) int { //nolint:unused len := len(f.kubeactions) f.kubeactions = append(f.kubeactions, core.NewCreateAction(schema.GroupVersionResource{Resource: "services"}, service.Namespace, service)) return len @@ -559,13 +559,13 @@ func (f *fixture) expectUpdateReplicaSetAction(r *appsv1.ReplicaSet) int { return len } -func (f *fixture) expectGetExperimentAction(experiment *v1alpha1.Experiment) int { +func (f *fixture) expectGetExperimentAction(experiment *v1alpha1.Experiment) int { //nolint:unused len := len(f.actions) f.actions = append(f.actions, core.NewGetAction(schema.GroupVersionResource{Resource: "experiments"}, experiment.Namespace, experiment.Name)) return len } -func (f *fixture) expectUpdateExperimentAction(experiment *v1alpha1.Experiment) int { +func (f *fixture) expectUpdateExperimentAction(experiment *v1alpha1.Experiment) int { //nolint:unused action := core.NewUpdateAction(schema.GroupVersionResource{Resource: "experiments"}, experiment.Namespace, experiment) len := len(f.actions) f.actions = append(f.actions, action) @@ -675,7 +675,7 @@ func (f *fixture) getUpdatedReplicaSet(index int) *appsv1.ReplicaSet { return rs } -func (f *fixture) getUpdatedExperiment(index int) *v1alpha1.Experiment { +func (f *fixture) getUpdatedExperiment(index int) *v1alpha1.Experiment { //nolint:unused action := filterInformerActions(f.client.Actions())[index] updateAction, ok := action.(core.UpdateAction) if !ok { diff --git a/experiments/replicaset_test.go b/experiments/replicaset_test.go index f834d47a0f..e4d1cdf231 100644 --- a/experiments/replicaset_test.go +++ b/experiments/replicaset_test.go @@ -129,7 +129,8 @@ func TestNameCollision(t *testing.T) { } // TestNameCollisionWithEquivalentPodTemplateAndControllerUID verifies we consider the annotations -// of the replicaset when encountering name collisions +// +// of the replicaset when encountering name collisions func TestNameCollisionWithEquivalentPodTemplateAndControllerUID(t *testing.T) { templates := generateTemplates("bar") e := newExperiment("foo", templates, "") diff --git a/go.mod b/go.mod index ca2591fc13..d9cca58136 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/argoproj/argo-rollouts -go 1.18 +go 1.19 require ( github.com/antonmedv/expr v1.9.0 diff --git a/metricproviders/cloudwatch/cloudwatch.go b/metricproviders/cloudwatch/cloudwatch.go index 49e318e666..2bb6c2aaad 100644 --- a/metricproviders/cloudwatch/cloudwatch.go +++ b/metricproviders/cloudwatch/cloudwatch.go @@ -115,7 +115,7 @@ func (p *Provider) GarbageCollect(run *v1alpha1.AnalysisRun, metric v1alpha1.Met return nil } -//NewCloudWatchProvider creates a new CloudWatch provider +// NewCloudWatchProvider creates a new CloudWatch provider func NewCloudWatchProvider(api CloudWatchClientAPI, logCtx log.Entry) *Provider { return &Provider{ api: api, diff --git a/metricproviders/kayenta/kayenta_test.go b/metricproviders/kayenta/kayenta_test.go index 5830d8294f..6cb8fde82b 100644 --- a/metricproviders/kayenta/kayenta_test.go +++ b/metricproviders/kayenta/kayenta_test.go @@ -19,35 +19,36 @@ func newAnalysisRun() *v1alpha1.AnalysisRun { /* spec: - inputs: - - name: start-time #2019-03-29T01:08:34Z - - name: end-time #2019-03-29T01:38:34Z - - name: stable-hash #xxxx - - name: canary-hash #yyyy - metrics: - - name: mann-whitney - kayenta: - address: https://kayenta.example.com - application: guestbook - canaryConfigName: my-test - metricsAccountName: wavefront-prod - configurationAccountName: intuit-kayenta - storageAccountName: intuit-kayenta - thresholds: - pass: 90 - marginal: 75 - scopes: - - name: default - controlScope: - scope: app=guestbook and rollouts-pod-template-hash={{inputs.stable-hash}} - step: 60 - start: "{{inputs.start-time}}" - end: "{{inputs.end-time}}" - experimentScope: - scope: app=guestbook and rollouts-pod-template-hash={{inputs.canary-hash}} - step: 60 - start: "{{inputs.start-time}}" - end: "{{inputs.end-time}}" + + inputs: + - name: start-time #2019-03-29T01:08:34Z + - name: end-time #2019-03-29T01:38:34Z + - name: stable-hash #xxxx + - name: canary-hash #yyyy + metrics: + - name: mann-whitney + kayenta: + address: https://kayenta.example.com + application: guestbook + canaryConfigName: my-test + metricsAccountName: wavefront-prod + configurationAccountName: intuit-kayenta + storageAccountName: intuit-kayenta + thresholds: + pass: 90 + marginal: 75 + scopes: + - name: default + controlScope: + scope: app=guestbook and rollouts-pod-template-hash={{inputs.stable-hash}} + step: 60 + start: "{{inputs.start-time}}" + end: "{{inputs.end-time}}" + experimentScope: + scope: app=guestbook and rollouts-pod-template-hash={{inputs.canary-hash}} + step: 60 + start: "{{inputs.start-time}}" + end: "{{inputs.end-time}}" */ func buildMetric() v1alpha1.Metric { return v1alpha1.Metric{ @@ -731,7 +732,7 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { return f(req), nil } -//NewTestClient returns *http.Client with Transport replaced to avoid making real calls +// NewTestClient returns *http.Client with Transport replaced to avoid making real calls func NewTestClient(fn RoundTripFunc) http.Client { return http.Client{ Transport: fn, diff --git a/metricproviders/newrelic/newrelic.go b/metricproviders/newrelic/newrelic.go index 6ec122f5df..eca410b6e7 100644 --- a/metricproviders/newrelic/newrelic.go +++ b/metricproviders/newrelic/newrelic.go @@ -39,7 +39,7 @@ type NewRelicClient struct { AccountID int } -//Query executes a NRQL query against the given New Relic account +// Query executes a NRQL query against the given New Relic account func (n *NewRelicClient) Query(query string) ([]nrdb.NRDBResult, error) { results, err := n.Nrdb.Query(n.AccountID, nrdb.NRQL(query)) if err != nil { @@ -136,7 +136,7 @@ func (p *Provider) GetMetadata(metric v1alpha1.Metric) map[string]string { return nil } -//NewNewRelicProvider creates a new NewRelic provider +// NewNewRelicProvider creates a new NewRelic provider func NewNewRelicProvider(api NewRelicClientAPI, logCtx log.Entry) *Provider { return &Provider{ logCtx: logCtx, @@ -144,7 +144,7 @@ func NewNewRelicProvider(api NewRelicClientAPI, logCtx log.Entry) *Provider { } } -//NewNewRelicAPIClient creates a new NewRelic API client from metric configuration +// NewNewRelicAPIClient creates a new NewRelic API client from metric configuration func NewNewRelicAPIClient(metric v1alpha1.Metric, kubeclientset kubernetes.Interface) (NewRelicClientAPI, error) { ns := defaults.Namespace() profileSecret := DefaultNewRelicProfileSecretName diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 5fe45cf684..682ab54195 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 98cb91d939..ddfe37336b 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/rollout/analysis_test.go b/rollout/analysis_test.go index 46fe961fec..87a30123ff 100644 --- a/rollout/analysis_test.go +++ b/rollout/analysis_test.go @@ -1650,8 +1650,8 @@ func TestCreatePrePromotionAnalysisRun(t *testing.T) { assert.Equal(t, calculatePatch(r2, expectedPatch), patch) } -//TestDoNotCreatePrePromotionAnalysisProgressedRollout ensures a pre-promotion analysis is not created after a Rollout -//points the active service at the new ReplicaSet +// TestDoNotCreatePrePromotionAnalysisProgressedRollout ensures a pre-promotion analysis is not created after a Rollout +// points the active service at the new ReplicaSet func TestDoNotCreatePrePromotionAnalysisAfterPromotionRollout(t *testing.T) { f := newFixture(t) defer f.Close() @@ -1700,8 +1700,8 @@ func TestDoNotCreatePrePromotionAnalysisAfterPromotionRollout(t *testing.T) { } -//TestDoNotCreatePrePromotionAnalysisRunOnNewRollout ensures that a pre-promotion analysis is not created -//if the Rollout does not have a stable ReplicaSet +// TestDoNotCreatePrePromotionAnalysisRunOnNewRollout ensures that a pre-promotion analysis is not created +// if the Rollout does not have a stable ReplicaSet func TestDoNotCreatePrePromotionAnalysisRunOnNewRollout(t *testing.T) { f := newFixture(t) defer f.Close() @@ -1731,8 +1731,8 @@ func TestDoNotCreatePrePromotionAnalysisRunOnNewRollout(t *testing.T) { f.run(getKey(r, t)) } -//TestDoNotCreatePrePromotionAnalysisRunOnNotReadyReplicaSet ensures that a pre-promotion analysis is not created until -//the new ReplicaSet is saturated +// TestDoNotCreatePrePromotionAnalysisRunOnNotReadyReplicaSet ensures that a pre-promotion analysis is not created until +// the new ReplicaSet is saturated func TestDoNotCreatePrePromotionAnalysisRunOnNotReadyReplicaSet(t *testing.T) { f := newFixture(t) defer f.Close() diff --git a/rollout/bluegreen_test.go b/rollout/bluegreen_test.go index 8ad0b1f838..42b521a565 100644 --- a/rollout/bluegreen_test.go +++ b/rollout/bluegreen_test.go @@ -144,7 +144,7 @@ func TestBlueGreenCreatesReplicaSet(t *testing.T) { assert.Equal(t, expectedPatch, patch) } -//TestBlueGreenSetPreviewService ensures the preview service is set to the desired ReplicaSet +// TestBlueGreenSetPreviewService ensures the preview service is set to the desired ReplicaSet func TestBlueGreenSetPreviewService(t *testing.T) { f := newFixture(t) defer f.Close() @@ -232,7 +232,7 @@ func TestBlueGreenProgressDeadlineAbort(t *testing.T) { } } -//TestSetServiceManagedBy ensures the managed by annotation is set in the service is set +// TestSetServiceManagedBy ensures the managed by annotation is set in the service is set func TestSetServiceManagedBy(t *testing.T) { f := newFixture(t) defer f.Close() diff --git a/rollout/controller_test.go b/rollout/controller_test.go index 0e97a405e9..6738900856 100644 --- a/rollout/controller_test.go +++ b/rollout/controller_test.go @@ -810,7 +810,7 @@ func (f *fixture) expectListPodAction(namespace string) int { return len } -func (f *fixture) expectGetRolloutAction(rollout *v1alpha1.Rollout) int { +func (f *fixture) expectGetRolloutAction(rollout *v1alpha1.Rollout) int { //nolint:unused len := len(f.actions) f.kubeactions = append(f.actions, core.NewGetAction(schema.GroupVersionResource{Resource: "rollouts"}, rollout.Namespace, rollout.Name)) return len @@ -823,7 +823,7 @@ func (f *fixture) expectCreateExperimentAction(ex *v1alpha1.Experiment) int { return len } -func (f *fixture) expectUpdateExperimentAction(ex *v1alpha1.Experiment) int { +func (f *fixture) expectUpdateExperimentAction(ex *v1alpha1.Experiment) int { //nolint:unused action := core.NewUpdateAction(schema.GroupVersionResource{Resource: "experiments"}, ex.Namespace, ex) len := len(f.actions) f.actions = append(f.actions, action) @@ -1000,7 +1000,7 @@ func (f *fixture) getUpdatedRollout(index int) *v1alpha1.Rollout { return rollout } -func (f *fixture) getPatchedAnalysisRun(index int) *v1alpha1.AnalysisRun { +func (f *fixture) getPatchedAnalysisRun(index int) *v1alpha1.AnalysisRun { //nolint:unused action := filterInformerActions(f.client.Actions())[index] patchAction, ok := action.(core.PatchAction) if !ok { @@ -1120,7 +1120,7 @@ func (f *fixture) expectDeleteReplicaSetAction(rs *appsv1.ReplicaSet) int { return len } -func (f *fixture) getDeletedReplicaSet(index int) string { +func (f *fixture) getDeletedReplicaSet(index int) string { //nolint:unused action := filterInformerActions(f.kubeclient.Actions())[index] deleteAction, ok := action.(core.DeleteAction) if !ok { diff --git a/rollout/sync.go b/rollout/sync.go index b9bc616552..8300cdfccc 100644 --- a/rollout/sync.go +++ b/rollout/sync.go @@ -33,12 +33,12 @@ import ( // getAllReplicaSetsAndSyncRevision returns all the replica sets for the provided rollout (new and all old), with new RS's and rollout's revision updated. // -// 1. Get all old RSes this rollout targets, and calculate the max revision number among them (maxOldV). -// 2. Get new RS this rollout targets (whose pod template matches rollout's), and update new RS's revision number to (maxOldV + 1), -// only if its revision number is smaller than (maxOldV + 1). If this step failed, we'll update it in the next rollout sync loop. -// 3. Copy new RS's revision number to rollout (update rollout's revision). If this step failed, we'll update it in the next rollout sync loop. -// 4. If there's no existing new RS and createIfNotExisted is true, create one with appropriate revision number (maxOldRevision + 1) and replicas. -// Note that the pod-template-hash will be added to adopted RSes and pods. +// 1. Get all old RSes this rollout targets, and calculate the max revision number among them (maxOldV). +// 2. Get new RS this rollout targets (whose pod template matches rollout's), and update new RS's revision number to (maxOldV + 1), +// only if its revision number is smaller than (maxOldV + 1). If this step failed, we'll update it in the next rollout sync loop. +// 3. Copy new RS's revision number to rollout (update rollout's revision). If this step failed, we'll update it in the next rollout sync loop. +// 4. If there's no existing new RS and createIfNotExisted is true, create one with appropriate revision number (maxOldRevision + 1) and replicas. +// Note that the pod-template-hash will be added to adopted RSes and pods. // // Note that currently the rollout controller is using caches to avoid querying the server for reads. // This may lead to stale reads of replica sets, thus incorrect v status. diff --git a/rollout/trafficrouting/istio/istio_test.go b/rollout/trafficrouting/istio/istio_test.go index a348923fde..6404852f55 100644 --- a/rollout/trafficrouting/istio/istio_test.go +++ b/rollout/trafficrouting/istio/istio_test.go @@ -753,7 +753,6 @@ func TestHttpReconcileHeaderRouteHostBased(t *testing.T) { func TestHttpReconcileHeaderRouteSubsetBased(t *testing.T) { ro := rolloutWithDestinationRule() - const RolloutService = "rollout-service" const StableSubsetName = "stable-subset" const CanarySubsetName = "canary-subset" ro.Spec.Strategy.Canary.TrafficRouting.Istio.VirtualService.Name = "vsvc" @@ -2242,7 +2241,7 @@ func TestMultipleVirtualServiceConfigured(t *testing.T) { assert.Equal(t, false, mvsvc) } -//This Testcase validates the reconcileVirtualService using VirtualServices configuration +// This Testcase validates the reconcileVirtualService using VirtualServices configuration func TestMultipleVirtualServiceReconcileWeightsBaseCase(t *testing.T) { multipleVirtualService := []v1alpha1.IstioVirtualService{{ Name: "vsvc", diff --git a/test/fixtures/common.go b/test/fixtures/common.go index 370c80724e..890a3794a2 100644 --- a/test/fixtures/common.go +++ b/test/fixtures/common.go @@ -48,7 +48,6 @@ import ( //nolint:structcheck type Common struct { Context context.Context - testInstanceID string t *testing.T namespace string log *log.Entry diff --git a/utils/analysis/factory_test.go b/utils/analysis/factory_test.go index c485081999..d3fe7dfec1 100644 --- a/utils/analysis/factory_test.go +++ b/utils/analysis/factory_test.go @@ -430,7 +430,7 @@ func TestResolveMetricArgs(t *testing.T) { assert.Equal(t, fmt.Sprintf("result < %s", arg2), newMetric2.SuccessCondition) } -//TestResolveMetricArgsWithQuotes verifies that metric arguments with quotes are resolved +// TestResolveMetricArgsWithQuotes verifies that metric arguments with quotes are resolved func TestResolveMetricArgsWithQuotes(t *testing.T) { arg := "foo \"bar\" baz" diff --git a/utils/conditions/experiments.go b/utils/conditions/experiments.go index e424c5df15..d146de834d 100644 --- a/utils/conditions/experiments.go +++ b/utils/conditions/experiments.go @@ -90,7 +90,7 @@ func RemoveExperimentCondition(status *v1alpha1.ExperimentStatus, condType v1alp status.Conditions = filterOutExperimentCondition(status.Conditions, condType) } -//ExperimentProgressing determines if the experiment has made any progress +// ExperimentProgressing determines if the experiment has made any progress func ExperimentProgressing(experiment *v1alpha1.Experiment, newStatus v1alpha1.ExperimentStatus) bool { oldStatusMap := experimentutil.GetTemplateStatusMapping(experiment.Status) newStatusMap := experimentutil.GetTemplateStatusMapping(newStatus) diff --git a/utils/replicaset/replicaset.go b/utils/replicaset/replicaset.go index 333b5117fd..4a0b56b5a5 100644 --- a/utils/replicaset/replicaset.go +++ b/utils/replicaset/replicaset.go @@ -503,9 +503,9 @@ func ResetCurrentStepIndex(rollout *v1alpha1.Rollout) *int32 { // PodTemplateEqualIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] // We ignore pod-template-hash because: -// 1. The hash result would be different upon podTemplateSpec API changes -// (e.g. the addition of a new field will cause the hash code to change) -// 2. The deployment template won't have hash labels +// 1. The hash result would be different upon podTemplateSpec API changes +// (e.g. the addition of a new field will cause the hash code to change) +// 2. The deployment template won't have hash labels // // NOTE: This is a modified version of deploymentutil.EqualIgnoreHash, but modified to perform // defaulting on the desired spec. This is so that defaulted fields by the replicaset controller