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

Function NewCmdCreate

pkg/cmd/account/username/create/create.go:61–104  ·  view source on GitHub ↗
(f factory.Factory)

Source from the content-addressed store, hash-verified

59}
60
61func NewCmdCreate(f factory.Factory) *cobra.Command {
62 createFlags := NewCreateFlags()
63 descriptionFilePath := ""
64
65 cmd := &cobra.Command{
66 Use: "create",
67 Short: "Create a Username/Password account",
68 Long: "Create a Username/Password account in Octopus Deploy",
69 Example: heredoc.Docf(`
70 %s account username create"
71 `, constants.ExecutableName),
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.Environments.Value != nil {
85 env, err := helper.ResolveEnvironmentNames(opts.Environments.Value, opts.Client)
86 if err != nil {
87 return err
88 }
89 opts.Environments.Value = env
90 }
91 return CreateRun(opts)
92 },
93 }
94
95 flags := cmd.Flags()
96 flags.StringVarP(&createFlags.Name.Value, createFlags.Name.Name, "n", "", "A short, memorable, unique name for this account.")
97 flags.StringVarP(&createFlags.Description.Value, createFlags.Description.Name, "d", "", "A summary explaining the use of the account to other users.")
98 flags.StringVarP(&createFlags.Username.Value, createFlags.Username.Name, "u", "", "The username to use when authenticating against the remote host.")
99 flags.StringVarP(&createFlags.Password.Value, createFlags.Password.Name, "p", "", "The password to use to when authenticating against the remote host.")
100 flags.StringArrayVarP(&createFlags.Environments.Value, createFlags.Environments.Name, "e", nil, "The environments that are allowed to use this account.")
101 flags.StringVarP(&descriptionFilePath, "description-file", "D", "", "Read the description from `file`.")
102
103 return cmd
104}
105
106func CreateRun(opts *CreateOptions) error {
107 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