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

Function CreateRun

pkg/cmd/account/gcp/create/create.go:115–147  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

113}
114
115func CreateRun(opts *CreateOptions) error {
116 if !opts.NoPrompt {
117 if err := PromptMissing(opts); err != nil {
118 return err
119 }
120 }
121 gcpAccount, err := accounts.NewGoogleCloudPlatformAccount(
122 opts.Name.Value,
123 core.NewSensitiveValue(b64.StdEncoding.EncodeToString(opts.KeyFileData)),
124 )
125 if err != nil {
126 return err
127 }
128 gcpAccount.Description = opts.Description.Value
129 gcpAccount.EnvironmentIDs = opts.Environments.Value
130
131 createdAccount, err := opts.Client.Accounts.Add(gcpAccount)
132 if err != nil {
133 return err
134 }
135
136 _, err = fmt.Fprintf(opts.Out, "Successfully created GCP account %s %s.\n", createdAccount.GetName(), output.Dimf("(%s)", createdAccount.GetSlug()))
137 if err != nil {
138 return err
139 }
140 link := output.Bluef("%s/app#/%s/infrastructure/accounts/%s", opts.Host, opts.Space.GetID(), createdAccount.GetID())
141 _, _ = fmt.Fprintf(opts.Out, "\nView this account on Octopus Deploy: %s\n", link)
142 if !opts.NoPrompt {
143 autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.Name, opts.KeyFilePath, opts.Description, opts.Environments)
144 _, _ = fmt.Fprintf(opts.Out, "\nAutomation Command: %s\n", autoCmd)
145 }
146 return nil
147}
148
149func PromptMissing(opts *CreateOptions) error {
150 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