MCPcopy Index your code
hub / github.com/helm/helm / newPushCmd

Function newPushCmd

pkg/cmd/push.go:47–108  ·  view source on GitHub ↗
(cfg *action.Configuration, out io.Writer)

Source from the content-addressed store, hash-verified

45}
46
47func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
48 o := &registryPushOptions{}
49
50 cmd := &cobra.Command{
51 Use: "push [chart] [remote]",
52 Short: "push a chart to remote",
53 Long: pushDesc,
54 Args: require.MinimumNArgs(2),
55 ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
56 if len(args) == 0 {
57 // Do file completion for the chart file to push
58 return nil, cobra.ShellCompDirectiveDefault
59 }
60 if len(args) == 1 {
61 providers := []pusher.Provider(pusher.All(settings))
62 var comps []string
63 for _, p := range providers {
64 for _, scheme := range p.Schemes {
65 comps = append(comps, scheme+"://")
66 }
67 }
68 return comps, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveNoSpace
69 }
70 return noMoreArgsComp()
71 },
72 RunE: func(_ *cobra.Command, args []string) error {
73 registryClient, err := newRegistryClient(
74 out, o.certFile, o.keyFile, o.caFile, o.insecureSkipTLSVerify, o.plainHTTP, o.username, o.password,
75 )
76
77 if err != nil {
78 return fmt.Errorf("missing registry client: %w", err)
79 }
80 cfg.RegistryClient = registryClient
81 chartRef := args[0]
82 remote := args[1]
83 client := action.NewPushWithOpts(action.WithPushConfig(cfg),
84 action.WithTLSClientConfig(o.certFile, o.keyFile, o.caFile),
85 action.WithInsecureSkipTLSVerify(o.insecureSkipTLSVerify),
86 action.WithPlainHTTP(o.plainHTTP),
87 action.WithPushOptWriter(out))
88 client.Settings = settings
89 output, err := client.Run(chartRef, remote)
90 if err != nil {
91 return err
92 }
93 fmt.Fprint(out, output)
94 return nil
95 },
96 }
97
98 f := cmd.Flags()
99 f.StringVar(&o.certFile, "cert-file", "", "identify registry client using this SSL certificate file")
100 f.StringVar(&o.keyFile, "key-file", "", "identify registry client using this SSL key file")
101 f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
102 f.BoolVar(&o.insecureSkipTLSVerify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart upload")
103 f.BoolVar(&o.plainHTTP, "plain-http", false, "use insecure HTTP connections for the chart upload")
104 f.StringVar(&o.username, "username", "", "chart repository username where to locate the requested chart")

Callers 1

newRootCmdWithConfigFunction · 0.85

Calls 11

MinimumNArgsFunction · 0.92
AllFunction · 0.92
NewPushWithOptsFunction · 0.92
WithPushConfigFunction · 0.92
WithTLSClientConfigFunction · 0.92
WithPlainHTTPFunction · 0.92
WithPushOptWriterFunction · 0.92
noMoreArgsCompFunction · 0.85
newRegistryClientFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…