MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / newAuthDeleteAccountCmd

Function newAuthDeleteAccountCmd

app/cli/cmd/auth_delete_account.go:28–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26)
27
28func newAuthDeleteAccountCmd() *cobra.Command {
29 cmd := &cobra.Command{
30 Use: "delete-account",
31 Short: "delete your account",
32 RunE: func(cmd *cobra.Command, args []string) error {
33 // Get user information to make sure the user knows the account she is deleting
34 contextResp, err := action.NewConfigCurrentContext(ActionOpts).Run()
35 if err != nil {
36 return err
37 }
38
39 fmt.Printf("You are about to delete your account %q\n", contextResp.CurrentUser.Email)
40
41 // Ask for confirmation
42 if err := confirmDeletion(); err != nil {
43 return err
44 }
45
46 // Account deletion
47 if err := action.NewDeleteAccount(ActionOpts).Run(); err != nil {
48 return err
49 }
50
51 // Remove token from config file
52 viper.Set(confOptions.authToken.viperKey, "")
53 if err := viper.WriteConfig(); err != nil {
54 return err
55 }
56
57 logger.Info().Msg("Account deleted :(")
58 return nil
59 },
60 }
61
62 return cmd
63}
64
65// confirmDeletion asks the user to type a random string
66func confirmDeletion() error {

Callers 1

newAuthCmdFunction · 0.85

Calls 6

NewConfigCurrentContextFunction · 0.92
NewDeleteAccountFunction · 0.92
confirmDeletionFunction · 0.85
SetMethod · 0.65
InfoMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected