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

Function NewCmdCreate

pkg/cmd/account/gcp/create/create.go:62–113  ·  view source on GitHub ↗
(f factory.Factory)

Source from the content-addressed store, hash-verified

60}
61
62func NewCmdCreate(f factory.Factory) *cobra.Command {
63 createFlags := NewCreateFlags()
64 descriptionFilePath := ""
65
66 cmd := &cobra.Command{
67 Use: "create",
68 Short: "Create a Google Cloud account",
69 Long: "Create a Google Cloud account in Octopus Deploy",
70 Example: heredoc.Docf("%s account gcp create", constants.ExecutableName),
71 Aliases: []string{"new"},
72 RunE: func(c *cobra.Command, _ []string) error {
73 opts := NewCreateOptions(createFlags, cmd.NewDependencies(f, c))
74 if descriptionFilePath != "" {
75 if err := validation.IsExistingFile(descriptionFilePath); err != nil {
76 return err
77 }
78 data, err := os.ReadFile(descriptionFilePath)
79 if err != nil {
80 return err
81 }
82 opts.Description.Value = string(data)
83 }
84 if opts.KeyFilePath.Value != "" {
85 if err := validation.IsExistingFile(opts.KeyFilePath.Value); err != nil {
86 return err
87 }
88 data, err := os.ReadFile(opts.KeyFilePath.Value)
89 if err != nil {
90 return err
91 }
92 opts.KeyFileData = data
93 }
94 if opts.Environments.Value != nil {
95 env, err := helper.ResolveEnvironmentNames(opts.Environments.Value, opts.Client)
96 if err != nil {
97 return err
98 }
99 opts.Environments.Value = env
100 }
101 return CreateRun(opts)
102 },
103 }
104
105 flags := cmd.Flags()
106 flags.StringVarP(&createFlags.Name.Value, createFlags.Name.Name, "n", "", "A short, memorable, unique name for this account.")
107 flags.StringVarP(&createFlags.Description.Value, createFlags.Description.Name, "d", "", "A summary explaining the use of the account to other users.")
108 flags.StringVarP(&createFlags.KeyFilePath.Value, createFlags.KeyFilePath.Name, "K", "", "The json key file to use when authenticating against Google Cloud.")
109 flags.StringArrayVarP(&createFlags.Environments.Value, createFlags.Environments.Name, "e", nil, "The environments that are allowed to use this account")
110 flags.StringVarP(&descriptionFilePath, "description-file", "D", "", "Read the description from `file`")
111
112 return cmd
113}
114
115func CreateRun(opts *CreateOptions) error {
116 if !opts.NoPrompt {

Callers

nothing calls this directly

Calls 5

IsExistingFileFunction · 0.92
ResolveEnvironmentNamesFunction · 0.92
NewCreateFlagsFunction · 0.70
NewCreateOptionsFunction · 0.70
CreateRunFunction · 0.70

Tested by

no test coverage detected