@@ -286,6 +286,18 @@ func (r *GlanceAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
286286 return err
287287 }
288288
289+ // index authAppCredSecretField
290+ if err := mgr .GetFieldIndexer ().IndexField (context .Background (), & glancev1.GlanceAPI {}, authAppCredSecretField , func (rawObj client.Object ) []string {
291+ // Extract the application credential secret name from the spec, if one is provided
292+ cr := rawObj .(* glancev1.GlanceAPI )
293+ if cr .Spec .Auth .ApplicationCredentialSecret == "" {
294+ return nil
295+ }
296+ return []string {cr .Spec .Auth .ApplicationCredentialSecret }
297+ }); err != nil {
298+ return err
299+ }
300+
289301 // Watch for changes to any CustomServiceConfigSecrets. Global secrets
290302 svcSecretFn := func (_ context.Context , o client.Object ) []reconcile.Request {
291303 var namespace = o .GetNamespace ()
@@ -1285,6 +1297,28 @@ func (r *GlanceAPIReconciler) generateServiceConfig(
12851297 "Wsgi" : wsgi ,
12861298 }
12871299
1300+ // Try to get Application Credential from the secret specified in the CR
1301+ if instance .Spec .Auth .ApplicationCredentialSecret != "" {
1302+ acSecretObj , _ , err := secret .GetSecret (ctx , h , instance .Spec .Auth .ApplicationCredentialSecret , instance .Namespace )
1303+ if err != nil {
1304+ if k8s_errors .IsNotFound (err ) {
1305+ Log .Info ("ApplicationCredential secret not found, waiting" , "secret" , instance .Spec .Auth .ApplicationCredentialSecret )
1306+ return fmt .Errorf ("%w: %s" , ErrACSecretNotFound , instance .Spec .Auth .ApplicationCredentialSecret )
1307+ }
1308+ Log .Error (err , "Failed to get ApplicationCredential secret" , "secret" , instance .Spec .Auth .ApplicationCredentialSecret )
1309+ return err
1310+ }
1311+ acID , okID := acSecretObj .Data [keystonev1 .ACIDSecretKey ]
1312+ acSecretData , okSecret := acSecretObj .Data [keystonev1 .ACSecretSecretKey ]
1313+ if okID && len (acID ) > 0 && okSecret && len (acSecretData ) > 0 {
1314+ templateParameters ["ApplicationCredentialID" ] = string (acID )
1315+ templateParameters ["ApplicationCredentialSecret" ] = string (acSecretData )
1316+ Log .Info ("Using ApplicationCredentials auth" , "secret" , instance .Spec .Auth .ApplicationCredentialSecret )
1317+ } else {
1318+ return fmt .Errorf ("%w: %s" , ErrACSecretMissingKeys , instance .Spec .Auth .ApplicationCredentialSecret )
1319+ }
1320+ }
1321+
12881322 // (OSPRH-18291)Only set EndpointID parameter when the Endpoint has been
12891323 // created and the associated ID is set in the keystoneapi CR. Because we
12901324 // have the Keystone CR, we get the Region parameter mirrored in its
0 commit comments