(f factory.Factory)
| 61 | } |
| 62 | |
| 63 | func NewCmdCreate(f factory.Factory) *cobra.Command { |
| 64 | createFlags := NewCreateFlags() |
| 65 | |
| 66 | cmd := &cobra.Command{ |
| 67 | Use: "create", |
| 68 | Short: "Create an environment", |
| 69 | Long: "Create a environment in Octopus Deploy", |
| 70 | Example: heredoc.Docf("%s environment create", constants.ExecutableName), |
| 71 | Aliases: []string{"new"}, |
| 72 | RunE: func(c *cobra.Command, _ []string) error { |
| 73 | opts := NewCreateOptions(createFlags, cmd.NewDependencies(f, c)) |
| 74 | |
| 75 | return createRun(opts) |
| 76 | }, |
| 77 | } |
| 78 | |
| 79 | flags := cmd.Flags() |
| 80 | flags.StringVarP(&createFlags.Name.Value, createFlags.Name.Name, "n", "", "Name of the environment") |
| 81 | flags.StringVarP(&createFlags.Description.Value, createFlags.Description.Name, "d", "", "Description of the environment") |
| 82 | flags.BoolVar(&createFlags.GuidedFailureMode.Value, createFlags.GuidedFailureMode.Name, false, "Use guided failure mode by default") |
| 83 | flags.BoolVar(&createFlags.DynamicInfrastructure.Value, createFlags.DynamicInfrastructure.Name, false, "Allow dynamic infrastructure") |
| 84 | flags.StringArrayVarP(&createFlags.Tag.Value, createFlags.Tag.Name, "t", []string{}, "Tag to apply to environment, must use canonical name: <tag_set>/<tag_name>") |
| 85 | |
| 86 | return cmd |
| 87 | } |
| 88 | |
| 89 | func createRun(opts *CreateOptions) error { |
| 90 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected