From a238d6a362f73cb53f0658a584342c4d08e2adf0 Mon Sep 17 00:00:00 2001 From: Nitesh-Rewatkar <90749010+nitesh3108@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:03:10 +0530 Subject: [PATCH] Update go version to 1.22 (#191) Signed-off-by: nitesh3108 Co-authored-by: mdutka-dell <115641913+mdutka-dell@users.noreply.github.com> Co-authored-by: Chiman Jain Co-authored-by: Bartosz Ciesielczyk <120648697+cbartoszDell@users.noreply.github.com> --- .github/workflows/development.yaml | 20 +++++++++++-------- csm-common.mk | 4 ++++ go.mod | 2 +- pkg/config/config_test.go | 1 + pkg/internal/transport/transport_test.go | 3 +++ pkg/provisioner/driverset_test.go | 6 ++++++ pkg/provisioner/factory_test.go | 1 + .../objectscale/objectscale_test.go | 4 ++++ tests/integration/steps/bucket_steps.go | 6 ++++++ tests/integration/steps/kubernetes_steps.go | 1 + 10 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 csm-common.mk diff --git a/.github/workflows/development.yaml b/.github/workflows/development.yaml index 810eb9b4..486c7a5f 100644 --- a/.github/workflows/development.yaml +++ b/.github/workflows/development.yaml @@ -32,15 +32,15 @@ jobs: go-version: "1.22" cache: false - name: Checkout the code - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4 - name: Vendor packages run: | go mod vendor - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.53 + version: v1.56.2 skip-cache: true malware-security-scan: @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4 - name: Malware Scanner uses: dell/common-github-actions/malware-scanner@main with: @@ -60,7 +60,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4 - name: Run the forbidden words scan uses: dell/common-github-actions/code-sanitizer@main with: @@ -71,7 +71,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4 - name: Run Hadolint uses: hadolint/hadolint-action@v3.1.0 @@ -105,7 +105,11 @@ jobs: git config --global url."https://csmbot:$TOKEN@github.com".insteadOf "https://github.com" echo "machine github.com login csmbot password $TOKEN" >> ~/.netrc - name: Checkout the code - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: false - name: Vendor packages run: | go mod vendor @@ -136,7 +140,7 @@ jobs: go-version: "1.22" cache: false - name: Checkout the code - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4 - name: "Vendor packages" run: | go mod vendor diff --git a/csm-common.mk b/csm-common.mk new file mode 100644 index 00000000..0a891450 --- /dev/null +++ b/csm-common.mk @@ -0,0 +1,4 @@ +# Common base image for all CSM images. When base image is upgraded, update the following 3 lines with URL, Version, and DEFAULT_BASEIMAGE variable. +# URL: https://catalog.redhat.com/software/containers/ubi9/ubi-micro/615bdf943f6014fa45ae1b58?architecture=amd64&image=65425acee668a4a85da08f2e +# Version: ubi9/ubi-micro 9.3-6 +DEFAULT_BASEIMAGE="registry.access.redhat.com/ubi9/ubi-micro@sha256:b7d8fd2840e92e8adc68414e13d859763ef33c3d4c4e27f910e939c00d642c29" diff --git a/go.mod b/go.mod index 03ecdbd5..8cf4c60c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/dell/cosi -go 1.21 +go 1.22 require ( github.com/aws/aws-sdk-go v1.45.1 diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index fc97a084..7a4af670 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -223,6 +223,7 @@ func TestNew(t *testing.T) { testFile, err := tc.file.Write() defer os.RemoveAll(path.Dir(testFile)) + if err != nil { // unexpected error, should panic panic(err) diff --git a/pkg/internal/transport/transport_test.go b/pkg/internal/transport/transport_test.go index b3e00ee3..5297f2af 100644 --- a/pkg/internal/transport/transport_test.go +++ b/pkg/internal/transport/transport_test.go @@ -310,9 +310,12 @@ func TestNew(t *testing.T) { if assert.Error(t, err) { assert.Regexp(t, tc.errorMessage, err.Error()) } + return } + assert.NoError(t, err) + if assert.NotNil(t, transport) && assert.NotNil(t, transport.TLSClientConfig) { assert.Equal(t, tc.config.Insecure, transport.TLSClientConfig.InsecureSkipVerify) diff --git a/pkg/provisioner/driverset_test.go b/pkg/provisioner/driverset_test.go index 407c2a8a..04372d2b 100644 --- a/pkg/provisioner/driverset_test.go +++ b/pkg/provisioner/driverset_test.go @@ -55,10 +55,12 @@ func TestDriversetAdd(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() + err := tc.driverset.Add(tc.driver) if err != nil { assert.ErrorContains(t, err, tc.wantErrorMsg) } + compareSyncMaps(t, &tc.want.drivers, &tc.driverset.drivers) }) } @@ -126,10 +128,12 @@ func TestDriversetGet(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() + got, err := tc.driverset.Get(tc.id) if err != nil { assert.ErrorContains(t, err, tc.wantErrorMsg) } + assert.Equal(t, tc.want, got) }) } @@ -154,6 +158,7 @@ func TestErrDriverDuplicate(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() + err := ErrDriverDuplicate{tc.id} assert.Equal(t, err.Error(), tc.want) }) @@ -179,6 +184,7 @@ func TestErrNotConfigured(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() + err := ErrNotConfigured{tc.id} assert.Equal(t, err.Error(), tc.want) }) diff --git a/pkg/provisioner/factory_test.go b/pkg/provisioner/factory_test.go index f4ccc9ae..6e6e81b0 100644 --- a/pkg/provisioner/factory_test.go +++ b/pkg/provisioner/factory_test.go @@ -69,6 +69,7 @@ func TestExactlyOne(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() + actual := exactlyOne(tc.nillables...) assert.Equal(t, tc.expected, actual) }) diff --git a/pkg/provisioner/objectscale/objectscale_test.go b/pkg/provisioner/objectscale/objectscale_test.go index 30e86096..52e32167 100644 --- a/pkg/provisioner/objectscale/objectscale_test.go +++ b/pkg/provisioner/objectscale/objectscale_test.go @@ -162,15 +162,18 @@ func testDriverNew(t *testing.T) { defer cancel() driver, err := New(tc.config) + switch tc.result { case ok: assert.NoError(t, err) + if assert.NotNil(t, driver) { assert.Equal(t, tc.config.Id, driver.ID()) } case warning: assert.NoError(t, err) + if assert.NotNil(t, driver) { assert.Equal(t, strings.ReplaceAll(tc.config.Id, "-", "_"), driver.ID()) } @@ -262,6 +265,7 @@ func testParsePolicyStatement(t *testing.T) { t.Run(scenario.description, func(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() + updatedPolicy := parsePolicyStatement(ctx, scenario.inputStatements, scenario.awsBucketResourceARN, scenario.awsPrincipalString) assert.Equalf(t, scenario.expectedOutput, updatedPolicy, "not equal") }) diff --git a/tests/integration/steps/bucket_steps.go b/tests/integration/steps/bucket_steps.go index 17f3a860..5df4fdd4 100644 --- a/tests/integration/steps/bucket_steps.go +++ b/tests/integration/steps/bucket_steps.go @@ -107,6 +107,7 @@ func CheckBucketAccessStatus(ctx context.Context, bucketClient *bucketclientset. err := retry(ctx, attempts, sleep, func() error { var err error + myBucketAccess, err = bucketClient.ObjectstorageV1alpha1().BucketAccesses(bucketAccess.Namespace).Get(ctx, bucketAccess.Name, v1.GetOptions{}) if err != nil { return err @@ -115,6 +116,7 @@ func CheckBucketAccessStatus(ctx context.Context, bucketClient *bucketclientset. if !myBucketAccess.Status.AccessGranted { return fmt.Errorf("AccessGranted is false") } + return nil }) @@ -139,6 +141,7 @@ func GetBucketResource(ctx context.Context, bucketClient *bucketclientset.Client err := retry(ctx, attempts, sleep, func() error { var err error + myBucketClaim, err = bucketClient.ObjectstorageV1alpha1().BucketClaims(bucketClaim.Namespace).Get(ctx, bucketClaim.Name, v1.GetOptions{}) if err != nil { return err @@ -147,6 +150,7 @@ func GetBucketResource(ctx context.Context, bucketClient *bucketclientset.Client if myBucketClaim.Status.BucketName == "" && myBucketClaim.Spec.ExistingBucketName == "" { return fmt.Errorf("BucketName and ExistingBucketName are empty") } + return nil }) @@ -156,6 +160,7 @@ func GetBucketResource(ctx context.Context, bucketClient *bucketclientset.Client err = retry(ctx, attempts, sleep, func() error { var err error + name := "" if myBucketClaim.Spec.ExistingBucketName != "" { name = myBucketClaim.Spec.ExistingBucketName @@ -192,6 +197,7 @@ func CheckBucketStatusEmpty(ctx context.Context, bucketClient *bucketclientset.C err := retry(ctx, attempts, sleep, func() error { var err error myBucketClaim, err = bucketClient.ObjectstorageV1alpha1().BucketClaims(bucketClaim.Namespace).Get(ctx, bucketClaim.Name, v1.GetOptions{}) + return err }) diff --git a/tests/integration/steps/kubernetes_steps.go b/tests/integration/steps/kubernetes_steps.go index 6f52b03d..3866f79e 100644 --- a/tests/integration/steps/kubernetes_steps.go +++ b/tests/integration/steps/kubernetes_steps.go @@ -74,6 +74,7 @@ func CheckSecret(ctx context.Context, clientset *kubernetes.Clientset, inputSecr err := retry(ctx, attempts, sleep, func() error { var err error + k8sSecret, err = clientset.CoreV1().Secrets(inputSecret.Namespace).Get(ctx, inputSecret.Name, metav1.GetOptions{}) if err != nil { return err