From 148d48e742fc52c56a56cb3f20ee8322b03f7ac4 Mon Sep 17 00:00:00 2001 From: Haim Kortovich Date: Wed, 15 May 2024 16:51:00 -0500 Subject: [PATCH] Fix key creation apiAPP [ZITADOPER-1] --- src/internal/controller/apiapp_controller.go | 6 +++--- src/internal/controller/project_controller.go | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/internal/controller/apiapp_controller.go b/src/internal/controller/apiapp_controller.go index 0097ad3..baf712d 100644 --- a/src/internal/controller/apiapp_controller.go +++ b/src/internal/controller/apiapp_controller.go @@ -198,14 +198,14 @@ func (wr *wrappedAPIAppReconciler) reconcileKeys(ctx context.Context, ztdClient return err } if wr.APIApp.Status.KeyId != "" { - _, err = ztdClient.GetAppKey(middleware.SetOrgID(ctx, org.Status.OrgId), &pb.GetAppKeyRequest{ + _, err := ztdClient.GetAppKey(middleware.SetOrgID(ctx, org.Status.OrgId), &pb.GetAppKeyRequest{ ProjectId: project.Status.ProjectId, AppId: wr.APIApp.Status.AppId, KeyId: wr.APIApp.Status.KeyId, }) if err != nil { - if strings.Contains(err.Error(), "AlreadyExists") { - return nil + if !strings.Contains(err.Error(), "not found") { + return fmt.Errorf("Could not get key: %v", err) } } } diff --git a/src/internal/controller/project_controller.go b/src/internal/controller/project_controller.go index 9bf998d..c8e9b6f 100644 --- a/src/internal/controller/project_controller.go +++ b/src/internal/controller/project_controller.go @@ -142,7 +142,9 @@ func (wr *wrappedProjectReconciler) reconcileProject(ctx context.Context, ztdCli return nil } if err != nil { - return fmt.Errorf("Error getting project: %v", err) + if !strings.Contains(err.Error(), "not found") { + return fmt.Errorf("Error getting project: %v", err) + } } }