From 1a1fc797922c322d02598ced72cef9709e74528c Mon Sep 17 00:00:00 2001 From: Cyrill Troxler Date: Fri, 27 Oct 2023 16:48:06 +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, 9 insertions(+), 1 deletion(-) diff --git a/update/application.go b/update/application.go index e76cd13..b1a364d 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,7 +84,14 @@ 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 { - return err + if !errors.IsNotFound(err) { + return err + } + + auth.UpdateSecret(secret) + if err := client.Create(ctx, secret); err != nil { + return err + } } auth.UpdateSecret(secret)