| 113 | } |
| 114 | |
| 115 | func 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 | |
| 149 | func PromptMissing(opts *CreateOptions) error { |
| 150 | if opts.Name.Value == "" { |