@@ -29,6 +29,7 @@ import (
29
29
kubecorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
30
30
"k8s.io/klog/v2"
31
31
32
+ cosiapi "sigs.k8s.io/container-object-storage-interface-api/apis"
32
33
"sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1"
33
34
buckets "sigs.k8s.io/container-object-storage-interface-api/clientset"
34
35
bucketapi "sigs.k8s.io/container-object-storage-interface-api/clientset/typed/objectstorage.k8s.io/v1alpha1"
@@ -176,6 +177,24 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
176
177
177
178
}
178
179
180
+ bucketInfo := cosiapi.BucketInfo {
181
+ ObjectMeta : metav1.ObjectMeta {
182
+ name : ,
183
+ },
184
+ BucketInfoSpec : cosiapi.BucketInfoSpec {
185
+ BucketName : ,
186
+ AuthenticationType : ,
187
+ Endpoint : ,
188
+ Region : ,
189
+ Protocol : ,
190
+ }
191
+ }
192
+
193
+ srtingData , err := json .Marshal (bucketInfo )
194
+ if err != nil {
195
+ return errors .New ("Error converting bucketinfo into secret" )
196
+ }
197
+
179
198
if _ , err := bal .Secrets (namespace ).Get (ctx , secretCredName , metav1.GetOptions {}); err != nil {
180
199
if ! kubeerrors .IsNotFound (err ) {
181
200
klog .ErrorS (err ,
@@ -185,16 +204,13 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
185
204
return errors .Wrap (err , "failed to fetch secrets" )
186
205
}
187
206
188
- // if secret doesn't exist, create it
189
- credentials := rsp .Credentials
190
-
191
207
if _ , err := bal .Secrets (namespace ).Create (ctx , & corev1.Secret {
192
208
ObjectMeta : metav1.ObjectMeta {
193
209
Name : secretCredName ,
194
210
Namespace : namespace ,
195
211
},
196
212
StringData : map [string ]string {
197
- Credentials : credentials ,
213
+ BucketInfo : string ( stringData ) ,
198
214
},
199
215
Type : corev1 .SecretTypeOpaque ,
200
216
}, metav1.CreateOptions {}); err != nil {
0 commit comments