@@ -29,6 +29,7 @@ import (
2929 kubecorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
3030 "k8s.io/klog/v2"
3131
32+ cosiapi "sigs.k8s.io/container-object-storage-interface-api/apis"
3233 "sigs.k8s.io/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1"
3334 buckets "sigs.k8s.io/container-object-storage-interface-api/clientset"
3435 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
176177
177178 }
178179
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+
179198 if _ , err := bal .Secrets (namespace ).Get (ctx , secretCredName , metav1.GetOptions {}); err != nil {
180199 if ! kubeerrors .IsNotFound (err ) {
181200 klog .ErrorS (err ,
@@ -185,16 +204,13 @@ func (bal *BucketAccessListener) Add(ctx context.Context, inputBucketAccess *v1a
185204 return errors .Wrap (err , "failed to fetch secrets" )
186205 }
187206
188- // if secret doesn't exist, create it
189- credentials := rsp .Credentials
190-
191207 if _ , err := bal .Secrets (namespace ).Create (ctx , & corev1.Secret {
192208 ObjectMeta : metav1.ObjectMeta {
193209 Name : secretCredName ,
194210 Namespace : namespace ,
195211 },
196212 StringData : map [string ]string {
197- Credentials : credentials ,
213+ BucketInfo : string ( stringData ) ,
198214 },
199215 Type : corev1 .SecretTypeOpaque ,
200216 }, metav1.CreateOptions {}); err != nil {
0 commit comments