(out io.Writer)
| 61 | } |
| 62 | |
| 63 | func newCreateCmd(out io.Writer) *cobra.Command { |
| 64 | o := &createOptions{} |
| 65 | |
| 66 | cmd := &cobra.Command{ |
| 67 | Use: "create NAME", |
| 68 | Short: "create a new chart with the given name", |
| 69 | Long: createDesc, |
| 70 | Args: require.ExactArgs(1), |
| 71 | ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) { |
| 72 | if len(args) == 0 { |
| 73 | // Allow file completion when completing the argument for the name |
| 74 | // which could be a path |
| 75 | return nil, cobra.ShellCompDirectiveDefault |
| 76 | } |
| 77 | // No more completions, so disable file completion |
| 78 | return noMoreArgsComp() |
| 79 | }, |
| 80 | RunE: func(_ *cobra.Command, args []string) error { |
| 81 | o.name = args[0] |
| 82 | o.starterDir = helmpath.DataPath("starters") |
| 83 | return o.run(out) |
| 84 | }, |
| 85 | } |
| 86 | |
| 87 | cmd.Flags().StringVarP(&o.starter, "starter", "p", "", "the name or absolute path to Helm starter scaffold") |
| 88 | cmd.Flags().StringVar(&o.chartAPIVersion, "chart-api-version", chart.APIVersionV2, "chart API version to use (v2 or v3)") |
| 89 | |
| 90 | if !gates.ChartV3.IsEnabled() { |
| 91 | cmd.Flags().MarkHidden("chart-api-version") |
| 92 | } |
| 93 | |
| 94 | return cmd |
| 95 | } |
| 96 | |
| 97 | func (o *createOptions) run(out io.Writer) error { |
| 98 | fmt.Fprintf(out, "Creating %s\n", o.name) |
no test coverage detected
searching dependent graphs…