(f factory.Factory)
| 53 | } |
| 54 | |
| 55 | func NewCmdView(f factory.Factory) *cobra.Command { |
| 56 | viewFlags := NewViewFlags() |
| 57 | cmd := &cobra.Command{ |
| 58 | Use: "view", |
| 59 | Short: "View all values of a project variable", |
| 60 | Long: "View all values of a project variable in Octopus Deploy", |
| 61 | Example: heredoc.Docf(` |
| 62 | %[1]s project variable view |
| 63 | %[1]s project variable view DatabaseName --project "Vet Clinic" |
| 64 | `, constants.ExecutableName), |
| 65 | Aliases: []string{"ls"}, |
| 66 | RunE: func(cmd *cobra.Command, args []string) error { |
| 67 | if len(args) == 0 { |
| 68 | return fmt.Errorf("must supply variable name") |
| 69 | } |
| 70 | |
| 71 | client, err := f.GetSpacedClient(apiclient.NewRequester(cmd)) |
| 72 | if err != nil { |
| 73 | return err |
| 74 | } |
| 75 | |
| 76 | opts := &ViewOptions{ |
| 77 | client, |
| 78 | f.GetCurrentHost(), |
| 79 | cmd.OutOrStdout(), |
| 80 | args[0], |
| 81 | viewFlags, |
| 82 | cmd, |
| 83 | } |
| 84 | |
| 85 | return viewRun(opts) |
| 86 | }, |
| 87 | } |
| 88 | |
| 89 | flags := cmd.Flags() |
| 90 | flags.StringVarP(&viewFlags.Project.Value, viewFlags.Project.Name, "p", "", "The project containing the variable") |
| 91 | flags.StringVar(&viewFlags.Id.Value, viewFlags.Id.Name, "", "The Id of the specifically scoped variable") |
| 92 | flags.BoolVarP(&viewFlags.Web.Value, viewFlags.Web.Name, "w", false, "Open in web browser") |
| 93 | |
| 94 | return cmd |
| 95 | } |
| 96 | |
| 97 | type VariableValueWithScope struct { |
| 98 | Variable *variables.Variable |
nothing calls this directly
no test coverage detected