| 100 | } |
| 101 | |
| 102 | func CreateRun(opts *CreateOptions) error { |
| 103 | if !opts.NoPrompt { |
| 104 | if err := PromptMissing(opts); err != nil { |
| 105 | return err |
| 106 | } |
| 107 | } |
| 108 | tokenAccount, err := accounts.NewTokenAccount( |
| 109 | opts.Name.Value, |
| 110 | core.NewSensitiveValue(opts.Token.Value), |
| 111 | ) |
| 112 | if err != nil { |
| 113 | return err |
| 114 | } |
| 115 | tokenAccount.Description = opts.Description.Value |
| 116 | tokenAccount.EnvironmentIDs = opts.Environments.Value |
| 117 | |
| 118 | createdAccount, err := opts.Client.Accounts.Add(tokenAccount) |
| 119 | if err != nil { |
| 120 | return err |
| 121 | } |
| 122 | |
| 123 | _, err = fmt.Fprintf(opts.Out, "Successfully created Token account %s %s.\n", createdAccount.GetName(), output.Dimf("(%s)", createdAccount.GetSlug())) |
| 124 | if err != nil { |
| 125 | return err |
| 126 | } |
| 127 | link := output.Bluef("%s/app#/%s/infrastructure/accounts/%s", opts.Host, opts.Space.GetID(), createdAccount.GetID()) |
| 128 | _, _ = fmt.Fprintf(opts.Out, "\nView this account on Octopus Deploy: %s\n", link) |
| 129 | if !opts.NoPrompt { |
| 130 | autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.Name, opts.Token, opts.Description, opts.Environments) |
| 131 | _, _ = fmt.Fprintf(opts.Out, "\nAutomation Command: %s\n", autoCmd) |
| 132 | } |
| 133 | return nil |
| 134 | } |
| 135 | |
| 136 | func PromptMissing(opts *CreateOptions) error { |
| 137 | if opts.Name.Value == "" { |