From 67b8cea50ff24ee6d8c5f81555c1588372b0cc69 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky Date: Thu, 11 Apr 2019 21:21:50 -0500 Subject: [PATCH] login/logout placeholders Signed-off-by: Josh Dolitsky --- cmd/helm/chart.go | 2 ++ cmd/helm/chart_login.go | 43 ++++++++++++++++++++++++++++++++++++++ cmd/helm/chart_logout.go | 43 ++++++++++++++++++++++++++++++++++++++ pkg/action/chart_login.go | 38 +++++++++++++++++++++++++++++++++ pkg/action/chart_logout.go | 38 +++++++++++++++++++++++++++++++++ pkg/engine/funcs.go | 2 +- pkg/registry/cache.go | 2 +- 7 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 cmd/helm/chart_login.go create mode 100644 cmd/helm/chart_logout.go create mode 100644 pkg/action/chart_login.go create mode 100644 pkg/action/chart_logout.go diff --git a/cmd/helm/chart.go b/cmd/helm/chart.go index dd4af9273..b0c59a2d0 100644 --- a/cmd/helm/chart.go +++ b/cmd/helm/chart.go @@ -39,6 +39,8 @@ func newChartCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { Long: chartHelp, } cmd.AddCommand( + newChartLoginCmd(cfg, out), + newChartLogoutCmd(cfg, out), newChartListCmd(cfg, out), newChartExportCmd(cfg, out), newChartPullCmd(cfg, out), diff --git a/cmd/helm/chart_login.go b/cmd/helm/chart_login.go new file mode 100644 index 000000000..6a9ad282d --- /dev/null +++ b/cmd/helm/chart_login.go @@ -0,0 +1,43 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "io" + + "github.com/spf13/cobra" + + "helm.sh/helm/cmd/helm/require" + "helm.sh/helm/pkg/action" +) + +const chartLoginDesc = ` +Authenticate against a remote registry. +` + +func newChartLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { + return &cobra.Command{ + Use: "login [host]", + Short: "login to a registry", + Long: chartLoginDesc, + Args: require.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + host := args[0] + return action.NewChartLogin(cfg).Run(out, host, "myuser", "mypass") + }, + } +} diff --git a/cmd/helm/chart_logout.go b/cmd/helm/chart_logout.go new file mode 100644 index 000000000..ae016dcd7 --- /dev/null +++ b/cmd/helm/chart_logout.go @@ -0,0 +1,43 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "io" + + "github.com/spf13/cobra" + + "helm.sh/helm/cmd/helm/require" + "helm.sh/helm/pkg/action" +) + +const chartLogoutDesc = ` +Remove credentials stored for a remote registry. +` + +func newChartLogoutCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { + return &cobra.Command{ + Use: "logout [host]", + Short: "logout from a registry", + Long: chartLogoutDesc, + Args: require.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + host := args[0] + return action.NewChartLogout(cfg).Run(out, host) + }, + } +} diff --git a/pkg/action/chart_login.go b/pkg/action/chart_login.go new file mode 100644 index 000000000..e4f0a1d0e --- /dev/null +++ b/pkg/action/chart_login.go @@ -0,0 +1,38 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package action + +import ( + "io" +) + +// ChartLogin performs a chart login operation. +type ChartLogin struct { + cfg *Configuration +} + +// NewChartLogin creates a new ChartLogin object with the given configuration. +func NewChartLogin(cfg *Configuration) *ChartLogin { + return &ChartLogin{ + cfg: cfg, + } +} + +// Run executes the chart login operation +func (a *ChartLogin) Run(out io.Writer, host string, username string, password string) error { + return nil +} diff --git a/pkg/action/chart_logout.go b/pkg/action/chart_logout.go new file mode 100644 index 000000000..d666cd9f9 --- /dev/null +++ b/pkg/action/chart_logout.go @@ -0,0 +1,38 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package action + +import ( + "io" +) + +// ChartLogin performs a chart login operation. +type ChartLogout struct { + cfg *Configuration +} + +// NewChartLogin creates a new ChartLogin object with the given configuration. +func NewChartLogout(cfg *Configuration) *ChartLogout { + return &ChartLogout{ + cfg: cfg, + } +} + +// Run executes the chart login operation +func (a *ChartLogout) Run(out io.Writer, host string) error { + return nil +} diff --git a/pkg/engine/funcs.go b/pkg/engine/funcs.go index 2b927872f..936f91d3c 100644 --- a/pkg/engine/funcs.go +++ b/pkg/engine/funcs.go @@ -25,7 +25,7 @@ import ( "github.com/BurntSushi/toml" "github.com/Masterminds/sprig" "github.com/pkg/errors" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" ) // funcMap returns a mapping of all of the functions that Engine has. diff --git a/pkg/registry/cache.go b/pkg/registry/cache.go index 96911c3db..b61b0adee 100644 --- a/pkg/registry/cache.go +++ b/pkg/registry/cache.go @@ -29,7 +29,7 @@ import ( "time" orascontent "github.com/deislabs/oras/pkg/content" - "github.com/docker/go-units" + units "github.com/docker/go-units" checksum "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors"