Skip to content

Commit

Permalink
delete git auth secret when app creation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Davor Gajic committed Dec 7, 2023
1 parent 2135486 commit 5439ce6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.21'
- run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
version: v1.54
args: --timeout=10m
test:
name: test
Expand All @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.21'
- run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- name: Get dependencies
run: go get -v -t -d ./...
Expand Down
7 changes: 7 additions & 0 deletions create/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ func (app *applicationCmd) Run(ctx context.Context, client *api.Client) error {
defer cancel()

if err := c.createResource(appWaitCtx); err != nil {
if auth.Enabled() {
secret := auth.Secret(newApp)
if gitErr := client.Delete(ctx, secret); err != nil {
return errors.Join(err, fmt.Errorf("unable to delete git auth secret, please contact support: %w", gitErr))
}
}

return err
}

Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module github.com/ninech/nctl

go 1.20
go 1.21

require (
github.com/alecthomas/kong v0.7.0
github.com/crossplane/crossplane-runtime v0.15.1
github.com/docker/docker v20.10.23+incompatible
github.com/fatih/color v1.14.1
github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48
github.com/gobuffalo/flect v0.2.3
github.com/goccy/go-yaml v1.11.0
github.com/golang-jwt/jwt v3.2.2+incompatible
Expand All @@ -17,6 +16,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/int128/kubelogin v1.25.3
github.com/lucasepe/codename v0.2.0
github.com/mattn/go-isatty v0.0.19
github.com/moby/moby v24.0.1+incompatible
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
github.com/ninech/apis v0.0.0-20230905134643-5501080a23f9
Expand Down Expand Up @@ -119,7 +119,6 @@ require (
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.50 // indirect
Expand Down
Loading

0 comments on commit 5439ce6

Please sign in to comment.