@@ -230,6 +230,37 @@ func (self *Bootstrapper) bootstrapTeam(ctx context.Context) error {
230
230
return fmt .Errorf ("failed to query team count: %w" , err )
231
231
}
232
232
if teamCount > 0 {
233
+ // Bootstrap registry secrets if needed
234
+ registries , err := self .repos .Ent ().Registry .Query ().All (ctx )
235
+ if err != nil {
236
+ return fmt .Errorf ("failed to query registries: %w" , err )
237
+ }
238
+ teams , err := self .repos .Ent ().Team .Query ().All (ctx )
239
+ if err != nil {
240
+ return fmt .Errorf ("failed to query teams: %w" , err )
241
+ }
242
+ for _ , reg := range registries {
243
+ for _ , team := range teams {
244
+ if reg .KubernetesSecret != "" {
245
+ // Check existence
246
+ secretName := reg .KubernetesSecret
247
+ _ , err := self .kubeClient .GetSecret (ctx , secretName , team .Namespace , self .kubeClient .GetInternalClient ())
248
+ if err != nil {
249
+ if ! errors .IsNotFound (err ) {
250
+ return fmt .Errorf ("failed to get secret %s in team namespace %s: %w" , secretName , team .Namespace , err )
251
+ }
252
+ }
253
+ if errors .IsNotFound (err ) {
254
+ // Copy
255
+ _ , err = self .kubeClient .CopySecret (ctx , secretName , self .cfg .SystemNamespace , team .Namespace , self .kubeClient .GetInternalClient ())
256
+ if err != nil {
257
+ log .Warnf ("Failed to copy registry secret %s to team namespace %s: %v" , secretName , team .Namespace , err )
258
+ }
259
+ }
260
+ }
261
+ }
262
+ }
263
+
233
264
return nil
234
265
}
235
266
0 commit comments