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 977a1d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 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,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
}

Expand Down

0 comments on commit 977a1d8

Please sign in to comment.