Skip to content

Commit

Permalink
fix: allow enabling git auth using update command
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ctrox committed Oct 27, 2023
1 parent 9873487 commit 1a1fc79
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion update/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1a1fc79

Please sign in to comment.