Skip to content

Commit

Permalink
feat: add prompting to confirm project window deletion (#20656)
Browse files Browse the repository at this point in the history
* feat: add prompting to confirm project window deletion

Signed-off-by: pashakostohrys <[email protected]>

* feat: add prompting to confirm project window deletion

Signed-off-by: pashakostohrys <[email protected]>

* feat: add prompting to confirm project window deletion

Signed-off-by: pashakostohrys <[email protected]>

---------

Signed-off-by: pashakostohrys <[email protected]>
  • Loading branch information
pasha-codefresh authored Nov 4, 2024
1 parent 621330c commit 2620593
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions cmd/argocd/commands/projectwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"

"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/headless"
"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/utils"
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
projectpkg "github.com/argoproj/argo-cd/v2/pkg/apiclient/project"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
Expand Down Expand Up @@ -235,8 +236,14 @@ argocd proj windows delete new-project 1`,
err = proj.Spec.DeleteWindow(id)
errors.CheckError(err)

_, err = projIf.Update(ctx, &projectpkg.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
promptUtil := utils.NewPrompt(clientOpts.PromptsEnabled)
canDelete := promptUtil.Confirm("Are you sure you want to delete sync window? [y/n]")
if canDelete {
_, err = projIf.Update(ctx, &projectpkg.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
} else {
fmt.Printf("The command to delete the sync window was cancelled\n")
}
},
}
return command
Expand Down
14 changes: 11 additions & 3 deletions cmd/argocd/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"

"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/headless"
"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/utils"
cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
repositorypkg "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository"
Expand Down Expand Up @@ -254,10 +255,17 @@ func NewRepoRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command
}
conn, repoIf := headless.NewClientOrDie(clientOpts, c).NewRepoClientOrDie()
defer io.Close(conn)

promptUtil := utils.NewPrompt(clientOpts.PromptsEnabled)
for _, repoURL := range args {
_, err := repoIf.DeleteRepository(ctx, &repositorypkg.RepoQuery{Repo: repoURL, AppProject: project})
errors.CheckError(err)
fmt.Printf("Repository '%s' removed\n", repoURL)
canDelete := promptUtil.Confirm(fmt.Sprintf("Are you sure you want to delete repository '%s'? [y/n]", repoURL))
if canDelete {
_, err := repoIf.DeleteRepository(ctx, &repositorypkg.RepoQuery{Repo: repoURL, AppProject: project})
errors.CheckError(err)
fmt.Printf("Repository '%s' removed\n", repoURL)
} else {
fmt.Printf("The command to delete '%s' was cancelled.\n", repoURL)
}
}
},
}
Expand Down

0 comments on commit 2620593

Please sign in to comment.