From c94a0129259a4a4cd64554c96e2e15b79b1999ab Mon Sep 17 00:00:00 2001 From: Davor Gajic Date: Wed, 6 Dec 2023 13:51:50 +0100 Subject: [PATCH] delete git auth secret when app creation fails --- create/application.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/create/application.go b/create/application.go index 76cc37b..d06aeeb 100644 --- a/create/application.go +++ b/create/application.go @@ -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.New(err.Error() + fmt.Errorf("unable to delete git auth secret, please contact support: %w", gitErr).Error()) + } + } + return err }