From 977a1d8ad77bd31c8fc9f809ffad6eced21017a5 Mon Sep 17 00:00:00 2001 From: Cyrill Troxler Date: Fri, 27 Oct 2023 16:53:02 +0200 Subject: [PATCH] fix: allow enabling git auth using update command the update command just updates the secret if it already exists, meaning it fails if you want to enable git auth after creating the app. This will call create if the secret could not be found. --- update/application.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/update/application.go b/update/application.go index e76cd13..a94f743 100644 --- a/update/application.go +++ b/update/application.go @@ -9,6 +9,7 @@ import ( apps "github.com/ninech/apis/apps/v1alpha1" "github.com/ninech/nctl/api" "github.com/ninech/nctl/api/util" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -83,6 +84,15 @@ func (cmd *applicationCmd) Run(ctx context.Context, client *api.Client) error { if auth.Enabled() { secret := auth.Secret(app) if err := client.Get(ctx, client.Name(secret.Name), secret); err != nil { + if errors.IsNotFound(err) { + auth.UpdateSecret(secret) + if err := client.Create(ctx, secret); err != nil { + return err + } + + return nil + } + return err }