|
7 | 7 | log "github.com/sirupsen/logrus"
|
8 | 8 | "github.com/spf13/cobra"
|
9 | 9 |
|
| 10 | + "github.com/argoproj/argo-cd/v2/cmd/argocd/commands/utils" |
10 | 11 | argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
|
11 | 12 | "github.com/argoproj/argo-cd/v2/util/errors"
|
12 | 13 | "github.com/argoproj/argo-cd/v2/util/localconfig"
|
@@ -35,19 +36,26 @@ $ argocd logout
|
35 | 36 | log.Fatalf("Nothing to logout from")
|
36 | 37 | }
|
37 | 38 |
|
38 |
| - ok := localCfg.RemoveToken(context) |
39 |
| - if !ok { |
40 |
| - log.Fatalf("Context %s does not exist", context) |
| 39 | + promptUtil := utils.NewPrompt(globalClientOpts.PromptsEnabled) |
| 40 | + |
| 41 | + canLogout := promptUtil.Confirm(fmt.Sprintf("Are you sure you want to log out from '%s'?", context)) |
| 42 | + if canLogout { |
| 43 | + ok := localCfg.RemoveToken(context) |
| 44 | + if !ok { |
| 45 | + log.Fatalf("Context %s does not exist", context) |
| 46 | + } |
| 47 | + |
| 48 | + err = localconfig.ValidateLocalConfig(*localCfg) |
| 49 | + if err != nil { |
| 50 | + log.Fatalf("Error in logging out: %s", err) |
| 51 | + } |
| 52 | + err = localconfig.WriteLocalConfig(*localCfg, globalClientOpts.ConfigPath) |
| 53 | + errors.CheckError(err) |
| 54 | + |
| 55 | + fmt.Printf("Logged out from '%s'\n", context) |
| 56 | + } else { |
| 57 | + log.Infof("Logout from '%s' cancelled", context) |
41 | 58 | }
|
42 |
| - |
43 |
| - err = localconfig.ValidateLocalConfig(*localCfg) |
44 |
| - if err != nil { |
45 |
| - log.Fatalf("Error in logging out: %s", err) |
46 |
| - } |
47 |
| - err = localconfig.WriteLocalConfig(*localCfg, globalClientOpts.ConfigPath) |
48 |
| - errors.CheckError(err) |
49 |
| - |
50 |
| - fmt.Printf("Logged out from '%s'\n", context) |
51 | 59 | },
|
52 | 60 | }
|
53 | 61 | return command
|
|
0 commit comments