From dd782c0fc48dd58e0ee756cfec10de613a125023 Mon Sep 17 00:00:00 2001 From: Haim Kortovich Date: Tue, 21 May 2024 19:20:48 -0500 Subject: [PATCH] Add oidcapp clientsecretname [ZITADOPER-1] --- src/api/v1alpha1/oidcapp_types.go | 4 ++++ src/internal/controller/oidcapp_controller.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api/v1alpha1/oidcapp_types.go b/src/api/v1alpha1/oidcapp_types.go index 21db63b..f5f57fa 100644 --- a/src/api/v1alpha1/oidcapp_types.go +++ b/src/api/v1alpha1/oidcapp_types.go @@ -143,6 +143,10 @@ func (d *OIDCApp) Project(ctx context.Context, refresolver *RefResolver) (*Proje return project, nil } +func (d *OIDCApp) ClientSecretName() string { + return d.Name + "-client-secret" +} + //+kubebuilder:object:root=true // OIDCAppList contains a list of OIDCApp diff --git a/src/internal/controller/oidcapp_controller.go b/src/internal/controller/oidcapp_controller.go index f029a14..44476bb 100644 --- a/src/internal/controller/oidcapp_controller.go +++ b/src/internal/controller/oidcapp_controller.go @@ -117,6 +117,7 @@ func (wr *wrappedOIDCAppReconciler) Reconcile(ctx context.Context, ztdClient *ma for _, r := range wr.OIDCApp.Spec.GrantTypes { grantTypes = append(grantTypes, app.OIDCGrantType(app.OIDCGrantType_value[string(r)])) } + if wr.OIDCApp.Status.AppId != "" { appResp, err := ztdClient.GetAppByID(middleware.SetOrgID(ctx, org.Status.OrgId), &pb.GetAppByIDRequest{ ProjectId: project.Status.ProjectId, @@ -180,7 +181,7 @@ func (wr *wrappedOIDCAppReconciler) Reconcile(ctx context.Context, ztdClient *ma return fmt.Errorf("error creating OIDCApp in Zitadel: %v", err) } key := types.NamespacedName{ - Name: wr.OIDCApp.Name + "-client-secret", + Name: wr.OIDCApp.ClientSecretName(), Namespace: wr.OIDCApp.Namespace, }