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

Function CreateRun

pkg/cmd/account/aws/create/create.go:108–139  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

106}
107
108func CreateRun(opts *CreateOptions) error {
109 if !opts.NoPrompt {
110 if err := PromptMissing(opts); err != nil {
111 return err
112 }
113 }
114 awsAccount, err := accounts.NewAmazonWebServicesAccount(opts.Name.Value, opts.AccessKey.Value, core.NewSensitiveValue(opts.SecretKey.Value))
115 if err != nil {
116 return err
117 }
118 awsAccount.Description = opts.Description.Value
119 awsAccount.Region = opts.Region.Value
120 awsAccount.EnvironmentIDs = opts.Environments.Value
121
122 createdAccount, err := opts.Client.Accounts.Add(awsAccount)
123 if err != nil {
124 return err
125 }
126
127 _, err = fmt.Fprintf(opts.Out, "Successfully created AWS account %s %s.\n", createdAccount.GetName(), output.Dimf("(%s)", createdAccount.GetSlug()))
128 if err != nil {
129 return err
130 }
131 link := output.Bluef("%s/app#/%s/infrastructure/accounts/%s", opts.Host, opts.Space.GetID(), createdAccount.GetID())
132 fmt.Fprintf(opts.Out, "\nView this account on Octopus Deploy: %s\n", link)
133 if !opts.NoPrompt {
134 autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.Name, opts.AccessKey, opts.SecretKey, opts.Region, opts.Description, opts.Environments)
135 fmt.Fprintf(opts.Out, "\nAutomation Command: %s\n", autoCmd)
136 }
137
138 return nil
139}
140
141func PromptMissing(opts *CreateOptions) error {
142 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