(f factory.Factory)
| 99 | } |
| 100 | |
| 101 | func NewCmdUpdate(f factory.Factory) *cobra.Command { |
| 102 | updateFlags := NewUpdateFlags() |
| 103 | cmd := &cobra.Command{ |
| 104 | Use: "update", |
| 105 | Short: "Update the value of a tenant variable", |
| 106 | Long: "Update the value of a tenant variable in Octopus Deploy", |
| 107 | Example: heredoc.Docf(` |
| 108 | %[1]s tenant variables update |
| 109 | %[1]s tenant variables update --tenant "Bobs Fish Shack" --name "site-name" --value "Bob's Fish Shack" --project "Awesome Web Site" --environment "Test" |
| 110 | %[1]s tenant variables update --tenant "Sally's Tackle Truck" --name dbPassword --value "12345" --library-variable-set "Shared Variables" |
| 111 | `, constants.ExecutableName), |
| 112 | RunE: func(c *cobra.Command, args []string) error { |
| 113 | opts := NewUpdateOptions(updateFlags, cmd.NewDependencies(f, c)) |
| 114 | |
| 115 | toggleValue, _ := opts.FeatureToggleCallback("CommonVariableScopingFeatureToggle") |
| 116 | |
| 117 | if toggleValue { |
| 118 | return updateRun(opts) |
| 119 | } |
| 120 | |
| 121 | return updateRunV1(opts) |
| 122 | }, |
| 123 | } |
| 124 | |
| 125 | flags := cmd.Flags() |
| 126 | flags.StringVarP(&updateFlags.Tenant.Value, updateFlags.Tenant.Name, "t", "", "The tenant") |
| 127 | flags.StringVarP(&updateFlags.Project.Value, updateFlags.Project.Name, "p", "", "The project") |
| 128 | flags.StringSliceVar(&updateFlags.Environments.Value, updateFlags.Environments.Name, []string{}, "Assign environment scopes to the variable. Multiple scopes can be supplied.") |
| 129 | flags.StringVarP(&updateFlags.LibraryVariableSet.Value, updateFlags.LibraryVariableSet.Name, "l", "", "The library variable set") |
| 130 | flags.StringVarP(&updateFlags.Name.Value, updateFlags.Name.Name, "n", "", "The name of the variable") |
| 131 | flags.StringVar(&updateFlags.Value.Value, updateFlags.Value.Name, "", "The value to set on the variable") |
| 132 | |
| 133 | return cmd |
| 134 | } |
| 135 | |
| 136 | func updateRunV1(opts *UpdateOptions) error { |
| 137 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected