Skip to content

Commit ab3927b

Browse files
authored
Unit Tests for main.go and controller-server Create Volume method (#198)
* minor updates for uts Signed-off-by: Ashima-Ashima1 <[email protected]> * node server UTs Signed-off-by: Ashima-Ashima1 <[email protected]> * node server UTs Signed-off-by: Ashima-Ashima1 <[email protected]> * main uts Signed-off-by: Ashima-Ashima1 <[email protected]> * main uts Signed-off-by: Ashima-Ashima1 <[email protected]> * fix travis Signed-off-by: Ashima-Ashima1 <[email protected]> * unit tests of controller server Signed-off-by: Ashima-Ashima1 <[email protected]> * unit tests of controller server Signed-off-by: Ashima-Ashima1 <[email protected]> * unit tests of controller server Signed-off-by: Ashima-Ashima1 <[email protected]> * unit tests of controller server Signed-off-by: Ashima-Ashima1 <[email protected]> --------- Signed-off-by: Ashima-Ashima1 <[email protected]>
1 parent b883d73 commit ab3927b

14 files changed

+360
-115
lines changed

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-06-11T14:13:17Z",
6+
"generated_at": "2025-06-12T14:52:30Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -172,7 +172,7 @@
172172
{
173173
"hashed_secret": "7e6a3680012346b94b54731e13d8a9ffa3790645",
174174
"is_verified": false,
175-
"line_number": 192,
175+
"line_number": 239,
176176
"type": "Secret Keyword",
177177
"verified_result": null
178178
}
@@ -270,7 +270,7 @@
270270
{
271271
"hashed_secret": "c7c6508b19455e3e8040e60e9833fbede92e5d8e",
272272
"is_verified": false,
273-
"line_number": 353,
273+
"line_number": 355,
274274
"type": "Secret Keyword",
275275
"verified_result": null
276276
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
dist: bionic
33
language: go
44
go:
5-
- 1.24.3
5+
- 1.24.4
66

77
group: bluezone
88

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FROM registry.access.redhat.com/ubi8/ubi AS rclone-builder
3030
RUN yum install wget git gcc -y
3131

3232
ENV ARCH=amd64
33-
ENV GO_VERSION=1.24.3
33+
ENV GO_VERSION=1.24.4
3434

3535
RUN echo $ARCH $GO_VERSION
3636

Dockerfile.builder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.3
1+
FROM golang:1.24.4
22

33
WORKDIR /go/src/github.com/IBM/ibm-object-csi-driver
44
ADD . /go/src/github.com/IBM/ibm-object-csi-driver

cmd/main_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"os"
6+
"testing"
7+
"time"
8+
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestGetOptions_Defaults(t *testing.T) {
13+
os.Args = []string{"cmd"}
14+
options := getOptions()
15+
16+
assert.Equal(t, "unix:/tmp/csi.sock", options.Endpoint)
17+
assert.Equal(t, "controller", options.ServerMode)
18+
assert.Equal(t, "host01", options.NodeID)
19+
assert.Equal(t, "0.0.0.0:9080", options.MetricsAddress)
20+
}
21+
22+
func TestGetEnv(t *testing.T) {
23+
_ = os.Setenv("TEST_KEY", "test-value")
24+
defer func() {
25+
_ = os.Unsetenv("TEST_KEY")
26+
}()
27+
28+
val := getEnv("test_key")
29+
assert.Equal(t, "test-value", val)
30+
}
31+
32+
func TestGetConfigBool(t *testing.T) {
33+
logger := getZapLogger()
34+
_ = os.Setenv("DEBUG_TRACE", "true")
35+
val := getConfigBool("DEBUG_TRACE", false, *logger)
36+
assert.True(t, val)
37+
38+
_ = os.Setenv("DEBUG_TRACE", "notbool")
39+
val = getConfigBool("DEBUG_TRACE", false, *logger)
40+
assert.False(t, val)
41+
_ = os.Unsetenv("DEBUG_TRACE")
42+
43+
val = getConfigBool("DEBUG_TRACE", true, *logger)
44+
assert.True(t, val)
45+
}
46+
47+
func TestServeMetrics(t *testing.T) {
48+
logger := getZapLogger()
49+
addr := "127.0.0.1:19191"
50+
51+
serveMetrics(addr, logger)
52+
53+
time.Sleep(200 * time.Millisecond)
54+
55+
resp, err := http.Get("http://" + addr + "/metrics")
56+
assert.NoError(t, err)
57+
defer func() {
58+
_ = resp.Body.Close()
59+
}()
60+
61+
assert.Equal(t, http.StatusOK, resp.StatusCode)
62+
}

go.mod

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/IBM/ibm-object-csi-driver
22

3-
go 1.24.3
3+
go 1.24.4
44

55
require (
6-
github.com/IBM/go-sdk-core/v5 v5.20.0
6+
github.com/IBM/go-sdk-core/v5 v5.20.1
77
github.com/IBM/ibm-cos-sdk-go v1.12.2
88
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.3.0
99
github.com/IBM/ibm-csi-common v1.1.20
@@ -14,7 +14,7 @@ require (
1414
github.com/google/uuid v1.6.0
1515
github.com/kubernetes-csi/csi-test/v5 v5.3.1
1616
github.com/mitchellh/go-ps v1.0.0
17-
github.com/onsi/ginkgo/v2 v2.23.4
17+
github.com/onsi/ginkgo/v2 v2.23.3
1818
github.com/onsi/gomega v1.37.0
1919
github.com/prometheus/client_golang v1.22.0
2020
github.com/stretchr/testify v1.10.0
@@ -84,7 +84,7 @@ require (
8484
github.com/google/cel-go v0.23.2 // indirect
8585
github.com/google/gnostic-models v0.6.9 // indirect
8686
github.com/google/go-cmp v0.7.0 // indirect
87-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
87+
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
8888
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
8989
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
9090
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
@@ -139,7 +139,6 @@ require (
139139
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
140140
go.opentelemetry.io/otel/trace v1.34.0 // indirect
141141
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
142-
go.uber.org/automaxprocs v1.6.0 // indirect
143142
go.uber.org/multierr v1.11.0 // indirect
144143
golang.org/x/arch v0.8.0 // indirect
145144
golang.org/x/crypto v0.38.0 // indirect
@@ -150,7 +149,7 @@ require (
150149
golang.org/x/term v0.32.0 // indirect
151150
golang.org/x/text v0.25.0 // indirect
152151
golang.org/x/time v0.9.0 // indirect
153-
golang.org/x/tools v0.31.0 // indirect
152+
golang.org/x/tools v0.30.0 // indirect
154153
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
155154
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
156155
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect

go.sum

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ cel.dev/expr v0.20.0 h1:OunBvVCfvpWlt4dN7zg3FM6TDkzOePe1+foGJ9AXeeI=
22
cel.dev/expr v0.20.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
33
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
44
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
5-
github.com/IBM/go-sdk-core/v5 v5.20.0 h1:rG1fn5GmJfFzVtpDKndsk6MgcarluG8YIWf89rVqLP8=
6-
github.com/IBM/go-sdk-core/v5 v5.20.0/go.mod h1:Q3BYO6iDA2zweQPDGbNTtqft5tDcEpm6RTuqMlPcvbw=
5+
github.com/IBM/go-sdk-core/v5 v5.20.1 h1:dzeyifh1kfRLw8VfAIIS5okZYuqLTqplPZP/Kcsgdlo=
6+
github.com/IBM/go-sdk-core/v5 v5.20.1/go.mod h1:Q3BYO6iDA2zweQPDGbNTtqft5tDcEpm6RTuqMlPcvbw=
77
github.com/IBM/ibm-cos-sdk-go v1.12.2 h1:71A4tDl8u6BZ548h71ecEe7fw5bBA7ECTVqYmeSQWQA=
88
github.com/IBM/ibm-cos-sdk-go v1.12.2/go.mod h1:ODYcmrmdpjo5hVguq9RbD6xmC8xb1XZMG7NefUbJNcc=
99
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.3.0 h1:956Nqk0eKI3lq+AkzWXZDid4UZHRz0wWh1LwkleBsWk=
@@ -144,8 +144,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
144144
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
145145
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
146146
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
147-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
148-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
147+
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg=
148+
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
149149
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
150150
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
151151
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo=
@@ -228,8 +228,8 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
228228
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
229229
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
230230
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
231-
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
232-
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
231+
github.com/onsi/ginkgo/v2 v2.23.3 h1:edHxnszytJ4lD9D5Jjc4tiDkPBZ3siDeJJkUZJJVkp0=
232+
github.com/onsi/ginkgo/v2 v2.23.3/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM=
233233
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
234234
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
235235
github.com/opencontainers/cgroups v0.0.1 h1:MXjMkkFpKv6kpuirUa4USFBas573sSAY082B4CiHEVA=
@@ -249,8 +249,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
249249
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
250250
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
251251
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
252-
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
253-
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
254252
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
255253
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
256254
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
@@ -317,8 +315,6 @@ go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC
317315
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
318316
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
319317
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
320-
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
321-
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
322318
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
323319
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
324320
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
@@ -378,8 +374,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
378374
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
379375
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
380376
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
381-
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
382-
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
377+
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
378+
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
383379
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
384380
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
385381
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

pkg/constants/constants.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const (
3535
MounterConfigPathOnPodS3fs = "/var/lib/ibmc-s3fs"
3636
MounterConfigPathOnPodRclone = "/root/.config/rclone"
3737

38+
PVCNameKey = "csi.storage.k8s.io/pvc/name"
39+
PVCNamespaceKey = "csi.storage.k8s.io/pvc/namespace"
40+
SecretNameKey = "cos.csi.driver/secret"
41+
SecretNamespaceKey = "cos.csi.driver/secret-namespace"
42+
43+
BucketVersioning = "bucketVersioning"
44+
3845
IsNodeServer = "IS_NODE_SERVER"
3946
KubeNodeName = "KUBE_NODE_NAME"
4047
)

pkg/driver/controllerserver.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
9090
if len(secretMap) == 0 {
9191
klog.Info("Did not find the secret that matches pvc name. Fetching custom secret from PVC annotations")
9292

93-
pvcName = params["csi.storage.k8s.io/pvc/name"]
94-
pvcNamespace = params["csi.storage.k8s.io/pvc/namespace"]
93+
pvcName = params[constants.PVCNameKey]
94+
pvcNamespace = params[constants.PVCNamespaceKey]
9595

9696
if pvcName == "" {
9797
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("pvcName not specified, could not fetch the secret %v", err))
@@ -101,7 +101,7 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
101101
pvcNamespace = constants.DefaultNamespace
102102
}
103103

104-
pvcRes, err := utils.GetPVC(pvcName, pvcNamespace)
104+
pvcRes, err := cs.Stats.GetPVC(pvcName, pvcNamespace)
105105
if err != nil {
106106
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("PVC resource not found %v", err))
107107
}
@@ -110,8 +110,8 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
110110

111111
pvcAnnotations := pvcRes.Annotations
112112

113-
customSecretName = pvcAnnotations["cos.csi.driver/secret"]
114-
secretNamespace := pvcAnnotations["cos.csi.driver/secret-namespace"]
113+
customSecretName = pvcAnnotations[constants.SecretNameKey]
114+
secretNamespace := pvcAnnotations[constants.SecretNamespaceKey]
115115

116116
if customSecretName == "" {
117117
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("secretName annotation 'cos.csi.driver/secret' not specified in the PVC annotations, could not fetch the secret %v", err))
@@ -122,7 +122,7 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
122122
secretNamespace = constants.DefaultNamespace
123123
}
124124

125-
secret, err := utils.GetSecret(customSecretName, secretNamespace)
125+
secret, err := cs.Stats.GetSecret(customSecretName, secretNamespace)
126126
if err != nil {
127127
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Secret resource not found %v", err))
128128
}
@@ -168,14 +168,14 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
168168
}
169169

170170
// Check for bucketVersioning parameter
171-
if val, ok := secretMap["bucketVersioning"]; ok && val != "" {
171+
if val, ok := secretMap[constants.BucketVersioning]; ok && val != "" {
172172
enable := strings.ToLower(strings.TrimSpace(val))
173173
if enable != "true" && enable != "false" {
174174
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Invalid BucketVersioning value in secret: %s. Value set %s. Must be 'true' or 'false'", customSecretName, val))
175175
}
176176
bucketVersioning = enable
177177
klog.Infof("BucketVersioning value that will be set via secret: %s", bucketVersioning)
178-
} else if val, ok := params["bucketVersioning"]; ok && val != "" {
178+
} else if val, ok := params[constants.BucketVersioning]; ok && val != "" {
179179
enable := strings.ToLower(strings.TrimSpace(val))
180180
if enable != "true" && enable != "false" {
181181
return nil, status.Error(codes.InvalidArgument,
@@ -314,7 +314,7 @@ func (cs *controllerServer) DeleteVolume(_ context.Context, req *csi.DeleteVolum
314314

315315
klog.Info("secret details found. secret-name: ", secretName, "\tsecret-namespace: ", secretNamespace)
316316

317-
secret, err := utils.GetSecret(secretName, secretNamespace)
317+
secret, err := cs.Stats.GetSecret(secretName, secretNamespace)
318318
if err != nil {
319319
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Secret resource not found %v", err))
320320
}
@@ -534,7 +534,7 @@ func parseCustomSecret(secret *v1.Secret) map[string]string {
534534
locationConstraint = string(bytesVal)
535535
}
536536

537-
if bytesVal, ok := secret.Data["bucketVersioning"]; ok {
537+
if bytesVal, ok := secret.Data[constants.BucketVersioning]; ok {
538538
bucketVersioning = string(bytesVal)
539539
}
540540

@@ -547,7 +547,7 @@ func parseCustomSecret(secret *v1.Secret) map[string]string {
547547
secretMapCustom["iamEndpoint"] = iamEndpoint
548548
secretMapCustom["cosEndpoint"] = cosEndpoint
549549
secretMapCustom["locationConstraint"] = locationConstraint
550-
secretMapCustom["bucketVersioning"] = bucketVersioning
550+
secretMapCustom[constants.BucketVersioning] = bucketVersioning
551551

552552
return secretMapCustom
553553
}

0 commit comments

Comments
 (0)