MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / CreateRun

Function CreateRun

pkg/cmd/account/token/create/create.go:102–134  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

100}
101
102func 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
136func PromptMissing(opts *CreateOptions) error {
137 if opts.Name.Value == "" {

Callers 2

NewCmdCreateFunction · 0.70

Calls 6

DimfFunction · 0.92
BluefFunction · 0.92
GenerateAutomationCmdFunction · 0.92
GetSpaceNameOrEmptyMethod · 0.80
PromptMissingFunction · 0.70
GetNameMethod · 0.65

Tested by 1