Added flags to CLI commands

Signed-off-by: Tom Runyon <tom@defenseunicorns.com>
pull/11623/head
Tom Runyon 3 years ago
parent a6a7eb443c
commit cc414577dc
No known key found for this signature in database
GPG Key ID: D1CF51977E0E790F

@ -169,6 +169,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal
f.BoolVar(&client.Atomic, "atomic", false, "if set, the installation process deletes the installation on failure. The --wait flag will be set automatically if --atomic is used")
f.BoolVar(&client.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed. By default, CRDs are installed if not already present")
f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent")
f.BoolVar(&client.PlainHTTP, "plain-http", false, "install charts from http registry")
addValueOptionsFlags(f, valueOpts)
addChartPathOptionsFlags(f, &client.ChartPathOptions)

@ -81,6 +81,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f.BoolVar(&client.VerifyLater, "prov", false, "fetch the provenance file, but don't perform verification")
f.StringVar(&client.UntarDir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded")
f.StringVarP(&client.DestDir, "destination", "d", ".", "location to write the chart. If this and untardir are specified, untardir is appended to this")
f.BoolVar(&client.PlainHTTP, "plain-http", false, "install charts from http registry")
addChartPathOptionsFlags(f, &client.ChartPathOptions)
err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

@ -39,6 +39,7 @@ type registryPushOptions struct {
keyFile string
caFile string
insecureSkipTLSverify bool
plainHTTP bool
}
func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
@ -88,6 +89,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f.StringVar(&o.keyFile, "key-file", "", "identify registry client using this SSL key file")
f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
f.BoolVar(&o.insecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart upload")
f.BoolVar(&o.plainHTTP, "plain-http", false, "push charts to registry over http")
return cmd
}

@ -174,6 +174,7 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) {
f := subCmd.Flags()
f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored")
f.BoolVar(&client.PlainHTTP, "plain-http", false, "use plain http connection instead of https")
if subCmd.Name() == "values" {
f.StringVar(&client.JSONPathTemplate, "jsonpath", "", "supply a JSONPath expression to filter the output")
}

@ -118,6 +118,7 @@ type ChartPathOptions struct {
Username string // --username
Verify bool // --verify
Version string // --version
PlainHTTP bool // --plain-http
// registryClient provides a registry client but is not added with
// options from a flag
@ -678,8 +679,14 @@ func (c *ChartPathOptions) LocateChart(name string, out io.Writer, settings *cli
// an error and a lookup will not occur.
if registry.IsOCI(name) {
if (c.CertFile != "" && c.KeyFile != "") || c.CaFile != "" || c.InsecureSkipTLSverify {
registryClient, err := registry.NewRegistryClientWithTLS(out, c.CertFile, c.KeyFile, c.CaFile,
c.InsecureSkipTLSverify, settings.RegistryConfig, settings.Debug)
var registryClient *registry.Client
var err error
if c.PlainHTTP {
registryClient, err = registry.NewRegistryClientHTTP(out, settings.RegistryConfig, settings.Debug)
} else {
registryClient, err = registry.NewRegistryClientWithTLS(out, c.CertFile, c.KeyFile, c.CaFile,
c.InsecureSkipTLSverify, settings.RegistryConfig, settings.Debug)
}
if err != nil {
return "", err
}

@ -105,8 +105,14 @@ func (p *Pull) Run(chartRef string) (string, error) {
// Provide a tls enabled client for the pull command if the user has
// specified the cert file or key file or ca file.
if (p.ChartPathOptions.CertFile != "" && p.ChartPathOptions.KeyFile != "") || p.ChartPathOptions.CaFile != "" || p.ChartPathOptions.InsecureSkipTLSverify {
registryClient, err := registry.NewRegistryClientWithTLS(p.out, p.ChartPathOptions.CertFile, p.ChartPathOptions.KeyFile, p.ChartPathOptions.CaFile,
p.ChartPathOptions.InsecureSkipTLSverify, p.Settings.RegistryConfig, p.Settings.Debug)
var registryClient *registry.Client
var err error
if p.PlainHTTP {
registryClient, err = registry.NewRegistryClientHTTP(p.out, p.Settings.RegistryConfig, p.Settings.Debug)
} else {
registryClient, err = registry.NewRegistryClientWithTLS(p.out, p.CertFile, p.KeyFile, p.CaFile,
p.InsecureSkipTLSverify, p.Settings.RegistryConfig, p.Settings.Debug)
}
if err != nil {
return out.String(), err
}

@ -36,6 +36,7 @@ type Push struct {
keyFile string
caFile string
insecureSkipTLSverify bool
plainHTTP bool
out io.Writer
}
@ -97,8 +98,15 @@ func (p *Push) Run(chartRef string, remote string) (string, error) {
// Provide a tls enabled client for the pull command if the user has
// specified the cert file or key file or ca file.
if (p.certFile != "" && p.keyFile != "") || p.caFile != "" || p.insecureSkipTLSverify {
registryClient, err := registry.NewRegistryClientWithTLS(p.out, p.certFile, p.keyFile, p.caFile,
p.insecureSkipTLSverify, p.Settings.RegistryConfig, p.Settings.Debug)
var registryClient *registry.Client
var err error
if p.plainHTTP {
registryClient, err = registry.NewRegistryClientHTTP(p.out, p.Settings.RegistryConfig, p.Settings.Debug)
} else {
registryClient, err = registry.NewRegistryClientWithTLS(p.out, p.certFile, p.keyFile, p.caFile,
p.insecureSkipTLSverify, p.Settings.RegistryConfig, p.Settings.Debug)
}
if err != nil {
return out.String(), err
}

Loading…
Cancel
Save