@@ -91,7 +91,7 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
91
91
92
92
secretCredName := bucketAccess .Spec .CredentialsSecretName
93
93
if secretCredName == "" {
94
- return errors . New ( "CredentialsSecretName not defined in the BucketAccess" )
94
+ return consts . ErrUndefinedSecretName
95
95
}
96
96
97
97
bucketAccessClass , err := bal .bucketAccessClasses ().Get (ctx , bucketAccessClassName , metav1.GetOptions {})
@@ -119,7 +119,7 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
119
119
}
120
120
121
121
if bucketClaim .Status .BucketName == "" || bucketClaim .Status .BucketReady != true {
122
- err := errors . New ( "BucketName cannot be empty or BucketNotReady in bucketClaim" )
122
+ err := consts . ErrInvalidBucketState
123
123
klog .V (3 ).ErrorS (err ,
124
124
"Invalid arguments" ,
125
125
"bucketClaim" , bucketClaim .Name ,
@@ -156,7 +156,7 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
156
156
157
157
if bucket .Status .BucketReady != true || bucket .Status .BucketID == "" {
158
158
bal .recordEvent (inputBucketAccess , v1 .EventTypeWarning , events .WaitingForBucket , "BucketAccess can't be granted to Bucket %q not in Ready state (isReady? %t) or without a bucketID (ID empty? %t)." , bucket .Name , bucket .Status .BucketReady , bucket .Status .BucketID == "" )
159
- return errors . New ( "BucketAccess can't be granted to bucket not in Ready state and without a bucketID" )
159
+ return consts . ErrInvalidBucketState
160
160
}
161
161
162
162
accountName := consts .AccountNamePrefix + string (bucketAccess .UID )
@@ -179,14 +179,14 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
179
179
}
180
180
181
181
if rsp .AccountId == "" {
182
- err = errors . New ( "AccountId not defined in DriverGrantBucketAccess" )
182
+ err = consts . ErrUndefinedAccountID
183
183
klog .V (3 ).ErrorS (err , "BucketAccess" , bucketAccess .ObjectMeta .Name )
184
184
return errors .Wrap (err , fmt .Sprintf ("BucketAccess %s" , bucketAccess .ObjectMeta .Name ))
185
185
}
186
186
187
187
credentials := rsp .Credentials
188
188
if len (credentials ) != 1 {
189
- err = errors . New ( "Credentials returned in DriverGrantBucketAccessResponse should be of length 1" )
189
+ err = consts . ErrInvalidCredentials
190
190
klog .V (3 ).ErrorS (err , "BucketAccess" , bucketAccess .ObjectMeta .Name )
191
191
return errors .Wrap (err , fmt .Sprintf ("BucketAccess %s" , bucketAccess .ObjectMeta .Name ))
192
192
}
@@ -230,7 +230,7 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
230
230
231
231
stringData , err := json .Marshal (bucketInfo )
232
232
if err != nil {
233
- return errors . New ( "Error converting bucketinfo into secret" )
233
+ return consts . ErrBucketInfoConversionFailed
234
234
}
235
235
236
236
if _ , err := bal .secrets (namespace ).Get (ctx , secretCredName , metav1.GetOptions {}); err != nil {
0 commit comments