Skip to content

Commit 12d8d28

Browse files
committedJun 19, 2024··
Add username/password to package subcommand
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
1 parent 0ad80e3 commit 12d8d28

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
 

‎cmd/helm/package.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If '--keyring' is not specified, Helm usually defaults to the public keyring
4747
unless your environment is otherwise configured.
4848
`
4949

50-
func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
50+
func newPackageCmd(_ *action.Configuration, out io.Writer) *cobra.Command {
5151
client := action.NewPackage()
5252
valueOpts := &values.Options{}
5353

@@ -75,6 +75,12 @@ func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
7575
return err
7676
}
7777

78+
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
79+
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
80+
if err != nil {
81+
return fmt.Errorf("missing registry client: %w", err)
82+
}
83+
7884
for i := 0; i < len(args); i++ {
7985
path, err := filepath.Abs(args[i])
8086
if err != nil {
@@ -91,7 +97,7 @@ func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
9197
Keyring: client.Keyring,
9298
Getters: p,
9399
Debug: settings.Debug,
94-
RegistryClient: cfg.RegistryClient,
100+
RegistryClient: registryClient,
95101
RepositoryConfig: settings.RepositoryConfig,
96102
RepositoryCache: settings.RepositoryCache,
97103
}
@@ -119,6 +125,13 @@ func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
119125
f.StringVar(&client.AppVersion, "app-version", "", "set the appVersion on the chart to this version")
120126
f.StringVarP(&client.Destination, "destination", "d", ".", "location to write the chart.")
121127
f.BoolVarP(&client.DependencyUpdate, "dependency-update", "u", false, `update dependencies from "Chart.yaml" to dir "charts/" before packaging`)
128+
f.StringVar(&client.Username, "username", "", "chart repository username where to locate the requested chart")
129+
f.StringVar(&client.Password, "password", "", "chart repository password where to locate the requested chart")
130+
f.StringVar(&client.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file")
131+
f.StringVar(&client.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file")
132+
f.BoolVar(&client.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download")
133+
f.BoolVar(&client.PlainHTTP, "plain-http", false, "use insecure HTTP connections for the chart download")
134+
f.StringVar(&client.CAFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
122135

123136
return cmd
124137
}

‎pkg/action/package.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ type Package struct {
4444
Destination string
4545
DependencyUpdate bool
4646

47-
RepositoryConfig string
48-
RepositoryCache string
47+
RepositoryConfig string
48+
RepositoryCache string
49+
PlainHTTP bool
50+
Username string
51+
Password string
52+
CertFile string
53+
KeyFile string
54+
CAFile string
55+
InsecureSkipTLSverify bool
4956
}
5057

5158
// NewPackage creates a new Package object with the given configuration.

0 commit comments

Comments
 (0)
Please sign in to comment.