MCPcopy
hub / github.com/helm/helm / newPullCmd

Function newPullCmd

pkg/cmd/pull.go:46–106  ·  view source on GitHub ↗
(cfg *action.Configuration, out io.Writer)

Source from the content-addressed store, hash-verified

44`
45
46func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
47 client := action.NewPull(action.WithConfig(cfg))
48
49 cmd := &cobra.Command{
50 Use: "pull [chart URL | repo/chartname] [...]",
51 Short: "download a chart from a repository and (optionally) unpack it in local directory",
52 Aliases: []string{"fetch"},
53 Long: pullDesc,
54 Args: require.MinimumNArgs(1),
55 ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
56 if len(args) != 0 {
57 return nil, cobra.ShellCompDirectiveNoFileComp
58 }
59 return compListCharts(toComplete, false)
60 },
61 RunE: func(_ *cobra.Command, args []string) error {
62 client.Settings = settings
63 if client.Version == "" && client.Devel {
64 slog.Debug("setting version to >0.0.0-0")
65 client.Version = ">0.0.0-0"
66 }
67
68 registryClient, err := newRegistryClient(out, client.CertFile, client.KeyFile, client.CaFile,
69 client.InsecureSkipTLSVerify, client.PlainHTTP, client.Username, client.Password)
70 if err != nil {
71 return fmt.Errorf("missing registry client: %w", err)
72 }
73 client.SetRegistryClient(registryClient)
74
75 for i := range args {
76 output, err := client.Run(args[i])
77 if err != nil {
78 return err
79 }
80 fmt.Fprint(out, output)
81 }
82 return nil
83 },
84 }
85
86 f := cmd.Flags()
87 f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.")
88 f.BoolVar(&client.Untar, "untar", false, "if set to true, will untar the chart after downloading it")
89 f.BoolVar(&client.VerifyLater, "prov", false, "fetch the provenance file, but don't perform verification")
90 f.StringVar(&client.UntarDir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded")
91 f.StringVarP(&client.DestDir, "destination", "d", ".", "location to write the chart. If this and untardir are specified, untardir is appended to this")
92 addChartPathOptionsFlags(f, &client.ChartPathOptions)
93
94 err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
95 if len(args) != 1 {
96 return nil, cobra.ShellCompDirectiveNoFileComp
97 }
98 return compVersionFlag(args[0], toComplete)
99 })
100
101 if err != nil {
102 log.Fatal(err)
103 }

Callers 1

newRootCmdWithConfigFunction · 0.85

Calls 10

SetRegistryClientMethod · 0.95
RunMethod · 0.95
NewPullFunction · 0.92
WithConfigFunction · 0.92
MinimumNArgsFunction · 0.92
compListChartsFunction · 0.85
newRegistryClientFunction · 0.85
addChartPathOptionsFlagsFunction · 0.85
compVersionFlagFunction · 0.85
FatalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…