diff --git a/cmd/helm/completion.go b/cmd/helm/completion.go deleted file mode 100644 index 310c915b8..000000000 --- a/cmd/helm/completion.go +++ /dev/null @@ -1,215 +0,0 @@ -/* -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 ( - "fmt" - "io" - "os" - "path/filepath" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" -) - -const completionDesc = ` -Generate autocompletion scripts for Helm for the specified shell. -` -const bashCompDesc = ` -Generate the autocompletion script for Helm for the bash shell. - -To load completions in your current shell session: - - source <(helm completion bash) - -To load completions for every new session, execute once: -- Linux: - - helm completion bash > /etc/bash_completion.d/helm - -- MacOS: - - helm completion bash > /usr/local/etc/bash_completion.d/helm -` - -const zshCompDesc = ` -Generate the autocompletion script for Helm for the zsh shell. - -To load completions in your current shell session: - - source <(helm completion zsh) - -To load completions for every new session, execute once: - - helm completion zsh > "${fpath[1]}/_helm" -` - -const fishCompDesc = ` -Generate the autocompletion script for Helm for the fish shell. - -To load completions in your current shell session: - - helm completion fish | source - -To load completions for every new session, execute once: - - helm completion fish > ~/.config/fish/completions/helm.fish - -You will need to start a new shell for this setup to take effect. -` - -const powershellCompDesc = ` -Generate the autocompletion script for powershell. - -To load completions in your current shell session: -PS C:\> helm completion powershell | Out-String | Invoke-Expression - -To load completions for every new session, add the output of the above command -to your powershell profile. -` - -const ( - noDescFlagName = "no-descriptions" - noDescFlagText = "disable completion descriptions" -) - -var disableCompDescriptions bool - -func newCompletionCmd(out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "completion", - Short: "generate autocompletion scripts for the specified shell", - Long: completionDesc, - Args: require.NoArgs, - } - - bash := &cobra.Command{ - Use: "bash", - Short: "generate autocompletion script for bash", - Long: bashCompDesc, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - return runCompletionBash(out, cmd) - }, - } - bash.Flags().BoolVar(&disableCompDescriptions, noDescFlagName, false, noDescFlagText) - - zsh := &cobra.Command{ - Use: "zsh", - Short: "generate autocompletion script for zsh", - Long: zshCompDesc, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - return runCompletionZsh(out, cmd) - }, - } - zsh.Flags().BoolVar(&disableCompDescriptions, noDescFlagName, false, noDescFlagText) - - fish := &cobra.Command{ - Use: "fish", - Short: "generate autocompletion script for fish", - Long: fishCompDesc, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - return runCompletionFish(out, cmd) - }, - } - fish.Flags().BoolVar(&disableCompDescriptions, noDescFlagName, false, noDescFlagText) - - powershell := &cobra.Command{ - Use: "powershell", - Short: "generate autocompletion script for powershell", - Long: powershellCompDesc, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - return runCompletionPowershell(out, cmd) - }, - } - powershell.Flags().BoolVar(&disableCompDescriptions, noDescFlagName, false, noDescFlagText) - - cmd.AddCommand(bash, zsh, fish, powershell) - - return cmd -} - -func runCompletionBash(out io.Writer, cmd *cobra.Command) error { - err := cmd.Root().GenBashCompletionV2(out, !disableCompDescriptions) - - // In case the user renamed the helm binary (e.g., to be able to run - // both helm2 and helm3), we hook the new binary name to the completion function - if binary := filepath.Base(os.Args[0]); binary != "helm" { - renamedBinaryHook := ` -# Hook the command used to generate the completion script -# to the helm completion function to handle the case where -# the user renamed the helm binary -if [[ $(type -t compopt) = "builtin" ]]; then - complete -o default -F __start_helm %[1]s -else - complete -o default -o nospace -F __start_helm %[1]s -fi -` - fmt.Fprintf(out, renamedBinaryHook, binary) - } - - return err -} - -func runCompletionZsh(out io.Writer, cmd *cobra.Command) error { - var err error - if disableCompDescriptions { - err = cmd.Root().GenZshCompletionNoDesc(out) - } else { - err = cmd.Root().GenZshCompletion(out) - } - - // In case the user renamed the helm binary (e.g., to be able to run - // both helm2 and helm3), we hook the new binary name to the completion function - if binary := filepath.Base(os.Args[0]); binary != "helm" { - renamedBinaryHook := ` -# Hook the command used to generate the completion script -# to the helm completion function to handle the case where -# the user renamed the helm binary -compdef _helm %[1]s -` - fmt.Fprintf(out, renamedBinaryHook, binary) - } - - // Cobra doesn't source zsh completion file, explicitly doing it here - fmt.Fprintf(out, "compdef _helm helm") - - return err -} - -func runCompletionFish(out io.Writer, cmd *cobra.Command) error { - return cmd.Root().GenFishCompletion(out, !disableCompDescriptions) -} - -func runCompletionPowershell(out io.Writer, cmd *cobra.Command) error { - if disableCompDescriptions { - return cmd.Root().GenPowerShellCompletion(out) - } - return cmd.Root().GenPowerShellCompletionWithDesc(out) -} - -// Function to disable file completion -func noCompletions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return nil, cobra.ShellCompDirectiveNoFileComp -} diff --git a/cmd/helm/completion_test.go b/cmd/helm/completion_test.go deleted file mode 100644 index 1143d6445..000000000 --- a/cmd/helm/completion_test.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -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 ( - "fmt" - "strings" - "testing" - - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/release" -) - -// Check if file completion should be performed according to parameter 'shouldBePerformed' -func checkFileCompletion(t *testing.T, cmdName string, shouldBePerformed bool) { - storage := storageFixture() - storage.Create(&release.Release{ - Name: "myrelease", - Info: &release.Info{Status: release.StatusDeployed}, - Chart: &chart.Chart{ - Metadata: &chart.Metadata{ - Name: "Myrelease-Chart", - Version: "1.2.3", - }, - }, - Version: 1, - }) - - testcmd := fmt.Sprintf("__complete %s ''", cmdName) - _, out, err := executeActionCommandC(storage, testcmd) - if err != nil { - t.Errorf("unexpected error, %s", err) - } - if !strings.Contains(out, "ShellCompDirectiveNoFileComp") != shouldBePerformed { - if shouldBePerformed { - t.Errorf("Unexpected directive ShellCompDirectiveNoFileComp when completing '%s'", cmdName) - } else { - - t.Errorf("Did not receive directive ShellCompDirectiveNoFileComp when completing '%s'", cmdName) - } - t.Log(out) - } -} - -func TestCompletionFileCompletion(t *testing.T) { - checkFileCompletion(t, "completion", false) - checkFileCompletion(t, "completion bash", false) - checkFileCompletion(t, "completion zsh", false) - checkFileCompletion(t, "completion fish", false) -} - -func checkReleaseCompletion(t *testing.T, cmdName string, multiReleasesAllowed bool) { - multiReleaseTestGolden := "output/empty_nofile_comp.txt" - if multiReleasesAllowed { - multiReleaseTestGolden = "output/release_list_repeat_comp.txt" - } - tests := []cmdTestCase{{ - name: "completion for uninstall", - cmd: fmt.Sprintf("__complete %s ''", cmdName), - golden: "output/release_list_comp.txt", - rels: []*release.Release{ - release.Mock(&release.MockReleaseOptions{Name: "athos"}), - release.Mock(&release.MockReleaseOptions{Name: "porthos"}), - release.Mock(&release.MockReleaseOptions{Name: "aramis"}), - }, - }, { - name: "completion for uninstall repetition", - cmd: fmt.Sprintf("__complete %s porthos ''", cmdName), - golden: multiReleaseTestGolden, - rels: []*release.Release{ - release.Mock(&release.MockReleaseOptions{Name: "athos"}), - release.Mock(&release.MockReleaseOptions{Name: "porthos"}), - release.Mock(&release.MockReleaseOptions{Name: "aramis"}), - }, - }} - for _, test := range tests { - runTestCmd(t, []cmdTestCase{test}) - } -} diff --git a/cmd/helm/create.go b/cmd/helm/create.go deleted file mode 100644 index fe5cc540a..000000000 --- a/cmd/helm/create.go +++ /dev/null @@ -1,113 +0,0 @@ -/* -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 ( - "fmt" - "io" - "path/filepath" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/helmpath" -) - -const createDesc = ` -This command creates a chart directory along with the common files and -directories used in a chart. - -For example, 'helm create foo' will create a directory structure that looks -something like this: - - foo/ - ├── .helmignore # Contains patterns to ignore when packaging Helm charts. - ├── Chart.yaml # Information about your chart - ├── values.yaml # The default values for your templates - ├── charts/ # Charts that this chart depends on - └── templates/ # The template files - └── tests/ # The test files - -'helm create' takes a path for an argument. If directories in the given path -do not exist, Helm will attempt to create them as it goes. If the given -destination exists and there are files in that directory, conflicting files -will be overwritten, but other files will be left alone. -` - -type createOptions struct { - starter string // --starter - name string - starterDir string -} - -func newCreateCmd(out io.Writer) *cobra.Command { - o := &createOptions{} - - cmd := &cobra.Command{ - Use: "create NAME", - Short: "create a new chart with the given name", - Long: createDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - // Allow file completion when completing the argument for the name - // which could be a path - return nil, cobra.ShellCompDirectiveDefault - } - // No more completions, so disable file completion - return nil, cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - o.name = args[0] - o.starterDir = helmpath.DataPath("starters") - return o.run(out) - }, - } - - cmd.Flags().StringVarP(&o.starter, "starter", "p", "", "the name or absolute path to Helm starter scaffold") - return cmd -} - -func (o *createOptions) run(out io.Writer) error { - fmt.Fprintf(out, "Creating %s\n", o.name) - - chartname := filepath.Base(o.name) - cfile := &chart.Metadata{ - Name: chartname, - Description: "A Helm chart for Kubernetes", - Type: "application", - Version: "0.1.0", - AppVersion: "0.1.0", - APIVersion: chart.APIVersionV2, - } - - if o.starter != "" { - // Create from the starter - lstarter := filepath.Join(o.starterDir, o.starter) - // If path is absolute, we don't want to prefix it with helm starters folder - if filepath.IsAbs(o.starter) { - lstarter = o.starter - } - return chartutil.CreateFrom(cfile, filepath.Dir(o.name), lstarter) - } - - chartutil.Stderr = out - _, err := chartutil.Create(chartname, filepath.Dir(o.name)) - return err -} diff --git a/cmd/helm/create_test.go b/cmd/helm/create_test.go deleted file mode 100644 index 1db6bed52..000000000 --- a/cmd/helm/create_test.go +++ /dev/null @@ -1,199 +0,0 @@ -/* -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 ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chart/loader" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/helmpath" -) - -func TestCreateCmd(t *testing.T) { - defer ensure.HelmHome(t)() - cname := "testchart" - dir := ensure.TempDir(t) - defer testChdir(t, dir)() - - // Run a create - if _, _, err := executeActionCommand("create " + cname); err != nil { - t.Fatalf("Failed to run create: %s", err) - } - - // Test that the chart is there - if fi, err := os.Stat(cname); err != nil { - t.Fatalf("no chart directory: %s", err) - } else if !fi.IsDir() { - t.Fatalf("chart is not directory") - } - - c, err := loader.LoadDir(cname) - if err != nil { - t.Fatal(err) - } - - if c.Name() != cname { - t.Errorf("Expected %q name, got %q", cname, c.Name()) - } - if c.Metadata.APIVersion != chart.APIVersionV2 { - t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) - } -} - -func TestCreateStarterCmd(t *testing.T) { - defer ensure.HelmHome(t)() - cname := "testchart" - defer resetEnv()() - os.MkdirAll(helmpath.CachePath(), 0755) - defer testChdir(t, helmpath.CachePath())() - - // Create a starter. - starterchart := helmpath.DataPath("starters") - os.MkdirAll(starterchart, 0755) - if dest, err := chartutil.Create("starterchart", starterchart); err != nil { - t.Fatalf("Could not create chart: %s", err) - } else { - t.Logf("Created %s", dest) - } - tplpath := filepath.Join(starterchart, "starterchart", "templates", "foo.tpl") - if err := ioutil.WriteFile(tplpath, []byte("test"), 0644); err != nil { - t.Fatalf("Could not write template: %s", err) - } - - // Run a create - if _, _, err := executeActionCommand(fmt.Sprintf("create --starter=starterchart %s", cname)); err != nil { - t.Errorf("Failed to run create: %s", err) - return - } - - // Test that the chart is there - if fi, err := os.Stat(cname); err != nil { - t.Fatalf("no chart directory: %s", err) - } else if !fi.IsDir() { - t.Fatalf("chart is not directory") - } - - c, err := loader.LoadDir(cname) - if err != nil { - t.Fatal(err) - } - - if c.Name() != cname { - t.Errorf("Expected %q name, got %q", cname, c.Name()) - } - if c.Metadata.APIVersion != chart.APIVersionV2 { - t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) - } - - expectedNumberOfTemplates := 9 - if l := len(c.Templates); l != expectedNumberOfTemplates { - t.Errorf("Expected %d templates, got %d", expectedNumberOfTemplates, l) - } - - found := false - for _, tpl := range c.Templates { - if tpl.Name == "templates/foo.tpl" { - found = true - if data := string(tpl.Data); data != "test" { - t.Errorf("Expected template 'test', got %q", data) - } - } - } - if !found { - t.Error("Did not find foo.tpl") - } - -} - -func TestCreateStarterAbsoluteCmd(t *testing.T) { - defer resetEnv()() - defer ensure.HelmHome(t)() - cname := "testchart" - - // Create a starter. - starterchart := helmpath.DataPath("starters") - os.MkdirAll(starterchart, 0755) - if dest, err := chartutil.Create("starterchart", starterchart); err != nil { - t.Fatalf("Could not create chart: %s", err) - } else { - t.Logf("Created %s", dest) - } - tplpath := filepath.Join(starterchart, "starterchart", "templates", "foo.tpl") - if err := ioutil.WriteFile(tplpath, []byte("test"), 0644); err != nil { - t.Fatalf("Could not write template: %s", err) - } - - os.MkdirAll(helmpath.CachePath(), 0755) - defer testChdir(t, helmpath.CachePath())() - - starterChartPath := filepath.Join(starterchart, "starterchart") - - // Run a create - if _, _, err := executeActionCommand(fmt.Sprintf("create --starter=%s %s", starterChartPath, cname)); err != nil { - t.Errorf("Failed to run create: %s", err) - return - } - - // Test that the chart is there - if fi, err := os.Stat(cname); err != nil { - t.Fatalf("no chart directory: %s", err) - } else if !fi.IsDir() { - t.Fatalf("chart is not directory") - } - - c, err := loader.LoadDir(cname) - if err != nil { - t.Fatal(err) - } - - if c.Name() != cname { - t.Errorf("Expected %q name, got %q", cname, c.Name()) - } - if c.Metadata.APIVersion != chart.APIVersionV2 { - t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) - } - - expectedNumberOfTemplates := 9 - if l := len(c.Templates); l != expectedNumberOfTemplates { - t.Errorf("Expected %d templates, got %d", expectedNumberOfTemplates, l) - } - - found := false - for _, tpl := range c.Templates { - if tpl.Name == "templates/foo.tpl" { - found = true - if data := string(tpl.Data); data != "test" { - t.Errorf("Expected template 'test', got %q", data) - } - } - } - if !found { - t.Error("Did not find foo.tpl") - } -} - -func TestCreateFileCompletion(t *testing.T) { - checkFileCompletion(t, "create", true) - checkFileCompletion(t, "create myname", false) -} diff --git a/cmd/helm/dependency.go b/cmd/helm/dependency.go deleted file mode 100644 index 03874742c..000000000 --- a/cmd/helm/dependency.go +++ /dev/null @@ -1,122 +0,0 @@ -/* -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" - "path/filepath" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const dependencyDesc = ` -Manage the dependencies of a chart. - -Helm charts store their dependencies in 'charts/'. For chart developers, it is -often easier to manage dependencies in 'Chart.yaml' which declares all -dependencies. - -The dependency commands operate on that file, making it easy to synchronize -between the desired dependencies and the actual dependencies stored in the -'charts/' directory. - -For example, this Chart.yaml declares two dependencies: - - # Chart.yaml - dependencies: - - name: nginx - version: "1.2.3" - repository: "https://example.com/charts" - - name: memcached - version: "3.2.1" - repository: "https://another.example.com/charts" - - -The 'name' should be the name of a chart, where that name must match the name -in that chart's 'Chart.yaml' file. - -The 'version' field should contain a semantic version or version range. - -The 'repository' URL should point to a Chart Repository. Helm expects that by -appending '/index.yaml' to the URL, it should be able to retrieve the chart -repository's index. Note: 'repository' can be an alias. The alias must start -with 'alias:' or '@'. - -Starting from 2.2.0, repository can be defined as the path to the directory of -the dependency charts stored locally. The path should start with a prefix of -"file://". For example, - - # Chart.yaml - dependencies: - - name: nginx - version: "1.2.3" - repository: "file://../dependency_chart/nginx" - -If the dependency chart is retrieved locally, it is not required to have the -repository added to helm by "helm add repo". Version matching is also supported -for this case. -` - -const dependencyListDesc = ` -List all of the dependencies declared in a chart. - -This can take chart archives and chart directories as input. It will not alter -the contents of a chart. - -This will produce an error if the chart cannot be loaded. -` - -func newDependencyCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "dependency update|build|list", - Aliases: []string{"dep", "dependencies"}, - Short: "manage a chart's dependencies", - Long: dependencyDesc, - Args: require.NoArgs, - } - - cmd.AddCommand(newDependencyListCmd(out)) - cmd.AddCommand(newDependencyUpdateCmd(cfg, out)) - cmd.AddCommand(newDependencyBuildCmd(cfg, out)) - - return cmd -} - -func newDependencyListCmd(out io.Writer) *cobra.Command { - client := action.NewDependency() - cmd := &cobra.Command{ - Use: "list CHART", - Aliases: []string{"ls"}, - Short: "list the dependencies for the given chart", - Long: dependencyListDesc, - Args: require.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - chartpath := "." - if len(args) > 0 { - chartpath = filepath.Clean(args[0]) - } - return client.List(chartpath, out) - }, - } - - f := cmd.Flags() - - f.UintVar(&client.ColumnWidth, "max-col-width", 80, "maximum column width for output table") - return cmd -} diff --git a/cmd/helm/dependency_build.go b/cmd/helm/dependency_build.go deleted file mode 100644 index 1ee46d3d2..000000000 --- a/cmd/helm/dependency_build.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -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 ( - "fmt" - "io" - "os" - "path/filepath" - - "github.com/spf13/cobra" - "k8s.io/client-go/util/homedir" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/downloader" - "helm.sh/helm/v3/pkg/getter" -) - -const dependencyBuildDesc = ` -Build out the charts/ directory from the Chart.lock file. - -Build is used to reconstruct a chart's dependencies to the state specified in -the lock file. This will not re-negotiate dependencies, as 'helm dependency update' -does. - -If no lock file is found, 'helm dependency build' will mirror the behavior -of 'helm dependency update'. -` - -func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewDependency() - - cmd := &cobra.Command{ - Use: "build CHART", - Short: "rebuild the charts/ directory based on the Chart.lock file", - Long: dependencyBuildDesc, - Args: require.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - chartpath := "." - if len(args) > 0 { - chartpath = filepath.Clean(args[0]) - } - man := &downloader.Manager{ - Out: out, - ChartPath: chartpath, - Keyring: client.Keyring, - SkipUpdate: client.SkipRefresh, - Getters: getter.All(settings), - RegistryClient: cfg.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } - if client.Verify { - man.Verify = downloader.VerifyIfPossible - } - err := man.Build() - if e, ok := err.(downloader.ErrRepoNotFound); ok { - return fmt.Errorf("%s. Please add the missing repos via 'helm repo add'", e.Error()) - } - return err - }, - } - - f := cmd.Flags() - f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") - f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") - f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") - - return cmd -} - -// defaultKeyring returns the expanded path to the default keyring. -func defaultKeyring() string { - if v, ok := os.LookupEnv("GNUPGHOME"); ok { - return filepath.Join(v, "pubring.gpg") - } - return filepath.Join(homedir.HomeDir(), ".gnupg", "pubring.gpg") -} diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go deleted file mode 100644 index 37e3242c4..000000000 --- a/cmd/helm/dependency_build_test.go +++ /dev/null @@ -1,164 +0,0 @@ -/* -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 ( - "fmt" - "os" - "path/filepath" - "strings" - "testing" - - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/provenance" - "helm.sh/helm/v3/pkg/repo" - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestDependencyBuildCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") - defer srv.Stop() - if err != nil { - t.Fatal(err) - } - - rootDir := srv.Root() - srv.LinkIndices() - - ociSrv, err := repotest.NewOCIServer(t, srv.Root()) - if err != nil { - t.Fatal(err) - } - - ociChartName := "oci-depending-chart" - c := createTestingMetadataForOCI(ociChartName, ociSrv.RegistryURL) - if _, err := chartutil.Save(c, ociSrv.Dir); err != nil { - t.Fatal(err) - } - ociSrv.Run(t, repotest.WithDependingChart(c)) - - dir := func(p ...string) string { - return filepath.Join(append([]string{srv.Root()}, p...)...) - } - - chartname := "depbuild" - createTestingChart(t, rootDir, chartname, srv.URL()) - repoFile := filepath.Join(rootDir, "repositories.yaml") - - cmd := fmt.Sprintf("dependency build '%s' --repository-config %s --repository-cache %s", filepath.Join(rootDir, chartname), repoFile, rootDir) - _, out, err := executeActionCommand(cmd) - - // In the first pass, we basically want the same results as an update. - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - - if !strings.Contains(out, `update from the "test" chart repository`) { - t.Errorf("Repo did not get updated\n%s", out) - } - - // Make sure the actual file got downloaded. - expect := filepath.Join(rootDir, chartname, "charts/reqtest-0.1.0.tgz") - if _, err := os.Stat(expect); err != nil { - t.Fatal(err) - } - - // In the second pass, we want to remove the chart's request dependency, - // then see if it restores from the lock. - lockfile := filepath.Join(rootDir, chartname, "Chart.lock") - if _, err := os.Stat(lockfile); err != nil { - t.Fatal(err) - } - if err := os.RemoveAll(expect); err != nil { - t.Fatal(err) - } - - _, out, err = executeActionCommand(cmd) - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - - // Now repeat the test that the dependency exists. - if _, err := os.Stat(expect); err != nil { - t.Fatal(err) - } - - // Make sure that build is also fetching the correct version. - hash, err := provenance.DigestFile(expect) - if err != nil { - t.Fatal(err) - } - - i, err := repo.LoadIndexFile(filepath.Join(rootDir, "index.yaml")) - if err != nil { - t.Fatal(err) - } - - reqver := i.Entries["reqtest"][0] - if h := reqver.Digest; h != hash { - t.Errorf("Failed hash match: expected %s, got %s", hash, h) - } - if v := reqver.Version; v != "0.1.0" { - t.Errorf("mismatched versions. Expected %q, got %q", "0.1.0", v) - } - - skipRefreshCmd := fmt.Sprintf("dependency build '%s' --skip-refresh --repository-config %s --repository-cache %s", filepath.Join(rootDir, chartname), repoFile, rootDir) - _, out, err = executeActionCommand(skipRefreshCmd) - - // In this pass, we check --skip-refresh option becomes effective. - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - - if strings.Contains(out, `update from the "test" chart repository`) { - t.Errorf("Repo did get updated\n%s", out) - } - - // OCI dependencies - if err := chartutil.SaveDir(c, dir()); err != nil { - t.Fatal(err) - } - cmd = fmt.Sprintf("dependency build '%s' --repository-config %s --repository-cache %s --registry-config %s/config.json", - dir(ociChartName), - dir("repositories.yaml"), - dir(), - dir()) - _, out, err = executeActionCommand(cmd) - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - expect = dir(ociChartName, "charts/oci-dependent-chart-0.1.0.tgz") - if _, err := os.Stat(expect); err != nil { - t.Fatal(err) - } -} - -func TestDependencyBuildCmdWithHelmV2Hash(t *testing.T) { - chartName := "testdata/testcharts/issue-7233" - - cmd := fmt.Sprintf("dependency build '%s'", chartName) - _, out, err := executeActionCommand(cmd) - - // Want to make sure the build can verify Helm v2 hash - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } -} diff --git a/cmd/helm/dependency_test.go b/cmd/helm/dependency_test.go deleted file mode 100644 index 34c6a25e1..000000000 --- a/cmd/helm/dependency_test.go +++ /dev/null @@ -1,57 +0,0 @@ -/* -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 ( - "runtime" - "testing" -) - -func TestDependencyListCmd(t *testing.T) { - noSuchChart := cmdTestCase{ - name: "No such chart", - cmd: "dependency list /no/such/chart", - golden: "output/dependency-list-no-chart-linux.txt", - wantError: true, - } - - noDependencies := cmdTestCase{ - name: "No dependencies", - cmd: "dependency list testdata/testcharts/alpine", - golden: "output/dependency-list-no-requirements-linux.txt", - } - - if runtime.GOOS == "windows" { - noSuchChart.golden = "output/dependency-list-no-chart-windows.txt" - noDependencies.golden = "output/dependency-list-no-requirements-windows.txt" - } - - tests := []cmdTestCase{noSuchChart, - noDependencies, { - name: "Dependencies in chart dir", - cmd: "dependency list testdata/testcharts/reqtest", - golden: "output/dependency-list.txt", - }, { - name: "Dependencies in chart archive", - cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz", - golden: "output/dependency-list-archive.txt", - }} - runTestCmd(t, tests) -} - -func TestDependencyFileCompletion(t *testing.T) { - checkFileCompletion(t, "dependency", false) -} diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go deleted file mode 100644 index ad0188f17..000000000 --- a/cmd/helm/dependency_update.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -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" - "path/filepath" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/downloader" - "helm.sh/helm/v3/pkg/getter" -) - -const dependencyUpDesc = ` -Update the on-disk dependencies to mirror Chart.yaml. - -This command verifies that the required charts, as expressed in 'Chart.yaml', -are present in 'charts/' and are at an acceptable version. It will pull down -the latest charts that satisfy the dependencies, and clean up old dependencies. - -On successful update, this will generate a lock file that can be used to -rebuild the dependencies to an exact version. - -Dependencies are not required to be represented in 'Chart.yaml'. For that -reason, an update command will not remove charts unless they are (a) present -in the Chart.yaml file, but (b) at the wrong version. -` - -// newDependencyUpdateCmd creates a new dependency update command. -func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewDependency() - - cmd := &cobra.Command{ - Use: "update CHART", - Aliases: []string{"up"}, - Short: "update charts/ based on the contents of Chart.yaml", - Long: dependencyUpDesc, - Args: require.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - chartpath := "." - if len(args) > 0 { - chartpath = filepath.Clean(args[0]) - } - man := &downloader.Manager{ - Out: out, - ChartPath: chartpath, - Keyring: client.Keyring, - SkipUpdate: client.SkipRefresh, - Getters: getter.All(settings), - RegistryClient: cfg.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } - if client.Verify { - man.Verify = downloader.VerifyAlways - } - return man.Update() - }, - } - - f := cmd.Flags() - f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") - f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") - f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") - - return cmd -} diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go deleted file mode 100644 index 491f6a856..000000000 --- a/cmd/helm/dependency_update_test.go +++ /dev/null @@ -1,248 +0,0 @@ -/* -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 ( - "fmt" - "os" - "path/filepath" - "strings" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/provenance" - "helm.sh/helm/v3/pkg/repo" - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestDependencyUpdateCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - t.Logf("Listening on directory %s", srv.Root()) - - ociSrv, err := repotest.NewOCIServer(t, srv.Root()) - if err != nil { - t.Fatal(err) - } - - ociChartName := "oci-depending-chart" - c := createTestingMetadataForOCI(ociChartName, ociSrv.RegistryURL) - if _, err := chartutil.Save(c, ociSrv.Dir); err != nil { - t.Fatal(err) - } - ociSrv.Run(t, repotest.WithDependingChart(c)) - - if err := srv.LinkIndices(); err != nil { - t.Fatal(err) - } - - dir := func(p ...string) string { - return filepath.Join(append([]string{srv.Root()}, p...)...) - } - - chartname := "depup" - ch := createTestingMetadata(chartname, srv.URL()) - md := ch.Metadata - if err := chartutil.SaveDir(ch, dir()); err != nil { - t.Fatal(err) - } - - _, out, err := executeActionCommand( - fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir()), - ) - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - - // This is written directly to stdout, so we have to capture as is. - if !strings.Contains(out, `update from the "test" chart repository`) { - t.Errorf("Repo did not get updated\n%s", out) - } - - // Make sure the actual file got downloaded. - expect := dir(chartname, "charts/reqtest-0.1.0.tgz") - if _, err := os.Stat(expect); err != nil { - t.Fatal(err) - } - - hash, err := provenance.DigestFile(expect) - if err != nil { - t.Fatal(err) - } - - i, err := repo.LoadIndexFile(dir(helmpath.CacheIndexFile("test"))) - if err != nil { - t.Fatal(err) - } - - reqver := i.Entries["reqtest"][0] - if h := reqver.Digest; h != hash { - t.Errorf("Failed hash match: expected %s, got %s", hash, h) - } - - // Now change the dependencies and update. This verifies that on update, - // old dependencies are cleansed and new dependencies are added. - md.Dependencies = []*chart.Dependency{ - {Name: "reqtest", Version: "0.1.0", Repository: srv.URL()}, - {Name: "compressedchart", Version: "0.3.0", Repository: srv.URL()}, - } - if err := chartutil.SaveChartfile(dir(chartname, "Chart.yaml"), md); err != nil { - t.Fatal(err) - } - - _, out, err = executeActionCommand(fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir())) - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - - // In this second run, we should see compressedchart-0.3.0.tgz, and not - // the 0.1.0 version. - expect = dir(chartname, "charts/compressedchart-0.3.0.tgz") - if _, err := os.Stat(expect); err != nil { - t.Fatalf("Expected %q: %s", expect, err) - } - unexpected := dir(chartname, "charts/compressedchart-0.1.0.tgz") - if _, err := os.Stat(unexpected); err == nil { - t.Fatalf("Unexpected %q", unexpected) - } - - // test for OCI charts - if err := chartutil.SaveDir(c, dir()); err != nil { - t.Fatal(err) - } - cmd := fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --registry-config %s/config.json", - dir(ociChartName), - dir("repositories.yaml"), - dir(), - dir()) - _, out, err = executeActionCommand(cmd) - if err != nil { - t.Logf("Output: %s", out) - t.Fatal(err) - } - expect = dir(ociChartName, "charts/oci-dependent-chart-0.1.0.tgz") - if _, err := os.Stat(expect); err != nil { - t.Fatal(err) - } -} - -func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { - defer resetEnv()() - defer ensure.HelmHome(t)() - - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - t.Logf("Listening on directory %s", srv.Root()) - - if err := srv.LinkIndices(); err != nil { - t.Fatal(err) - } - - chartname := "depupdelete" - - dir := func(p ...string) string { - return filepath.Join(append([]string{srv.Root()}, p...)...) - } - createTestingChart(t, dir(), chartname, srv.URL()) - - _, output, err := executeActionCommand(fmt.Sprintf("dependency update %s --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir())) - if err != nil { - t.Logf("Output: %s", output) - t.Fatal(err) - } - - // Chart repo is down - srv.Stop() - - _, output, err = executeActionCommand(fmt.Sprintf("dependency update %s --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir())) - if err == nil { - t.Logf("Output: %s", output) - t.Fatal("Expected error, got nil") - } - - // Make sure charts dir still has dependencies - files, err := os.ReadDir(filepath.Join(dir(chartname), "charts")) - if err != nil { - t.Fatal(err) - } - dependencies := []string{"compressedchart-0.1.0.tgz", "reqtest-0.1.0.tgz"} - - if len(dependencies) != len(files) { - t.Fatalf("Expected %d chart dependencies, got %d", len(dependencies), len(files)) - } - for index, file := range files { - if dependencies[index] != file.Name() { - t.Fatalf("Chart dependency %s not matching %s", dependencies[index], file.Name()) - } - } - - // Make sure tmpcharts is deleted - if _, err := os.Stat(filepath.Join(dir(chartname), "tmpcharts")); !os.IsNotExist(err) { - t.Fatalf("tmpcharts dir still exists") - } -} - -// createTestingMetadata creates a basic chart that depends on reqtest-0.1.0 -// -// The baseURL can be used to point to a particular repository server. -func createTestingMetadata(name, baseURL string) *chart.Chart { - return &chart.Chart{ - Metadata: &chart.Metadata{ - APIVersion: chart.APIVersionV2, - Name: name, - Version: "1.2.3", - Dependencies: []*chart.Dependency{ - {Name: "reqtest", Version: "0.1.0", Repository: baseURL}, - {Name: "compressedchart", Version: "0.1.0", Repository: baseURL}, - }, - }, - } -} - -func createTestingMetadataForOCI(name, registryURL string) *chart.Chart { - return &chart.Chart{ - Metadata: &chart.Metadata{ - APIVersion: chart.APIVersionV2, - Name: name, - Version: "1.2.3", - Dependencies: []*chart.Dependency{ - {Name: "oci-dependent-chart", Version: "0.1.0", Repository: fmt.Sprintf("oci://%s/u/ocitestuser", registryURL)}, - }, - }, - } -} - -// createTestingChart creates a basic chart that depends on reqtest-0.1.0 -// -// The baseURL can be used to point to a particular repository server. -func createTestingChart(t *testing.T, dest, name, baseURL string) { - t.Helper() - cfile := createTestingMetadata(name, baseURL) - if err := chartutil.SaveDir(cfile, dest); err != nil { - t.Fatal(err) - } -} diff --git a/cmd/helm/docs.go b/cmd/helm/docs.go deleted file mode 100644 index 523a96022..000000000 --- a/cmd/helm/docs.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -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 ( - "fmt" - "io" - "path" - "path/filepath" - "strings" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - "github.com/spf13/cobra/doc" - "golang.org/x/text/cases" - "golang.org/x/text/language" - - "helm.sh/helm/v3/cmd/helm/require" -) - -const docsDesc = ` -Generate documentation files for Helm. - -This command can generate documentation for Helm in the following formats: - -- Markdown -- Man pages - -It can also generate bash autocompletions. -` - -type docsOptions struct { - dest string - docTypeString string - topCmd *cobra.Command - generateHeaders bool -} - -func newDocsCmd(out io.Writer) *cobra.Command { - o := &docsOptions{} - - cmd := &cobra.Command{ - Use: "docs", - Short: "generate documentation as markdown or man pages", - Long: docsDesc, - Hidden: true, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - o.topCmd = cmd.Root() - return o.run(out) - }, - } - - f := cmd.Flags() - f.StringVar(&o.dest, "dir", "./", "directory to which documentation is written") - f.StringVar(&o.docTypeString, "type", "markdown", "the type of documentation to generate (markdown, man, bash)") - f.BoolVar(&o.generateHeaders, "generate-headers", false, "generate standard headers for markdown files") - - cmd.RegisterFlagCompletionFunc("type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return []string{"bash", "man", "markdown"}, cobra.ShellCompDirectiveNoFileComp - }) - - return cmd -} - -func (o *docsOptions) run(out io.Writer) error { - switch o.docTypeString { - case "markdown", "mdown", "md": - if o.generateHeaders { - standardLinks := func(s string) string { return s } - - hdrFunc := func(filename string) string { - base := filepath.Base(filename) - name := strings.TrimSuffix(base, path.Ext(base)) - title := cases.Title(language.Und, cases.NoLower).String(strings.Replace(name, "_", " ", -1)) - return fmt.Sprintf("---\ntitle: \"%s\"\n---\n\n", title) - } - - return doc.GenMarkdownTreeCustom(o.topCmd, o.dest, hdrFunc, standardLinks) - } - return doc.GenMarkdownTree(o.topCmd, o.dest) - case "man": - manHdr := &doc.GenManHeader{Title: "HELM", Section: "1"} - return doc.GenManTree(o.topCmd, manHdr, o.dest) - case "bash": - return o.topCmd.GenBashCompletionFile(filepath.Join(o.dest, "completions.bash")) - default: - return errors.Errorf("unknown doc type %q. Try 'markdown' or 'man'", o.docTypeString) - } -} diff --git a/cmd/helm/docs_test.go b/cmd/helm/docs_test.go deleted file mode 100644 index fe5864d5e..000000000 --- a/cmd/helm/docs_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -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 ( - "testing" -) - -func TestDocsTypeFlagCompletion(t *testing.T) { - tests := []cmdTestCase{{ - name: "completion for docs --type", - cmd: "__complete docs --type ''", - golden: "output/docs-type-comp.txt", - }, { - name: "completion for docs --type, no filter", - cmd: "__complete docs --type mar", - golden: "output/docs-type-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestDocsFileCompletion(t *testing.T) { - checkFileCompletion(t, "docs", false) -} diff --git a/cmd/helm/env.go b/cmd/helm/env.go deleted file mode 100644 index 3754b748d..000000000 --- a/cmd/helm/env.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -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 ( - "fmt" - "io" - "sort" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" -) - -var envHelp = ` -Env prints out all the environment information in use by Helm. -` - -func newEnvCmd(out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "env", - Short: "helm client environment information", - Long: envHelp, - Args: require.MaximumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - keys := getSortedEnvVarKeys() - return keys, cobra.ShellCompDirectiveNoFileComp - } - - return nil, cobra.ShellCompDirectiveNoFileComp - }, - Run: func(cmd *cobra.Command, args []string) { - envVars := settings.EnvVars() - - if len(args) == 0 { - // Sort the variables by alphabetical order. - // This allows for a constant output across calls to 'helm env'. - keys := getSortedEnvVarKeys() - - for _, k := range keys { - fmt.Fprintf(out, "%s=\"%s\"\n", k, envVars[k]) - } - } else { - fmt.Fprintf(out, "%s\n", envVars[args[0]]) - } - }, - } - return cmd -} - -func getSortedEnvVarKeys() []string { - envVars := settings.EnvVars() - - var keys []string - for k := range envVars { - keys = append(keys, k) - } - sort.Strings(keys) - - return keys -} diff --git a/cmd/helm/env_test.go b/cmd/helm/env_test.go deleted file mode 100644 index 01ef25933..000000000 --- a/cmd/helm/env_test.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -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 ( - "testing" -) - -func TestEnv(t *testing.T) { - tests := []cmdTestCase{{ - name: "completion for env", - cmd: "__complete env ''", - golden: "output/env-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestEnvFileCompletion(t *testing.T) { - checkFileCompletion(t, "env", false) - checkFileCompletion(t, "env HELM_BIN", false) -} diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go deleted file mode 100644 index 76d6e0476..000000000 --- a/cmd/helm/flags.go +++ /dev/null @@ -1,250 +0,0 @@ -/* -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 ( - "flag" - "fmt" - "log" - "path/filepath" - "sort" - "strings" - - "github.com/spf13/cobra" - "github.com/spf13/pflag" - "k8s.io/klog/v2" - - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/cli/values" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/postrender" - "helm.sh/helm/v3/pkg/repo" -) - -const ( - outputFlag = "output" - postRenderFlag = "post-renderer" - postRenderArgsFlag = "post-renderer-args" -) - -func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { - f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL (can specify multiple)") - f.StringArrayVar(&v.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") - f.StringArrayVar(&v.StringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") - f.StringArrayVar(&v.FileValues, "set-file", []string{}, "set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)") - f.StringArrayVar(&v.JSONValues, "set-json", []string{}, "set JSON values on the command line (can specify multiple or separate values with commas: key1=jsonval1,key2=jsonval2)") -} - -func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) { - f.StringVar(&c.Version, "version", "", "specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used") - f.BoolVar(&c.Verify, "verify", false, "verify the package before using it") - f.StringVar(&c.Keyring, "keyring", defaultKeyring(), "location of public keys used for verification") - f.StringVar(&c.RepoURL, "repo", "", "chart repository url where to locate the requested chart") - f.StringVar(&c.Username, "username", "", "chart repository username where to locate the requested chart") - f.StringVar(&c.Password, "password", "", "chart repository password where to locate the requested chart") - f.StringVar(&c.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") - f.StringVar(&c.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file") - f.BoolVar(&c.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") - f.StringVar(&c.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") - f.BoolVar(&c.PassCredentialsAll, "pass-credentials", false, "pass credentials to all domains") -} - -// bindOutputFlag will add the output flag to the given command and bind the -// value to the given format pointer -func bindOutputFlag(cmd *cobra.Command, varRef *output.Format) { - cmd.Flags().VarP(newOutputValue(output.Table, varRef), outputFlag, "o", - fmt.Sprintf("prints the output in the specified format. Allowed values: %s", strings.Join(output.Formats(), ", "))) - - err := cmd.RegisterFlagCompletionFunc(outputFlag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - var formatNames []string - for format, desc := range output.FormatsWithDesc() { - formatNames = append(formatNames, fmt.Sprintf("%s\t%s", format, desc)) - } - - // Sort the results to get a deterministic order for the tests - sort.Strings(formatNames) - return formatNames, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } -} - -type outputValue output.Format - -func newOutputValue(defaultValue output.Format, p *output.Format) *outputValue { - *p = defaultValue - return (*outputValue)(p) -} - -func (o *outputValue) String() string { - // It is much cleaner looking (and technically less allocations) to just - // convert to a string rather than type asserting to the underlying - // output.Format - return string(*o) -} - -func (o *outputValue) Type() string { - return "format" -} - -func (o *outputValue) Set(s string) error { - outfmt, err := output.ParseFormat(s) - if err != nil { - return err - } - *o = outputValue(outfmt) - return nil -} - -func bindPostRenderFlag(cmd *cobra.Command, varRef *postrender.PostRenderer) { - p := &postRendererOptions{varRef, "", []string{}} - cmd.Flags().Var(&postRendererString{p}, postRenderFlag, "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path") - cmd.Flags().Var(&postRendererArgsSlice{p}, postRenderArgsFlag, "an argument to the post-renderer (can specify multiple)") -} - -type postRendererOptions struct { - renderer *postrender.PostRenderer - binaryPath string - args []string -} - -type postRendererString struct { - options *postRendererOptions -} - -func (p *postRendererString) String() string { - return p.options.binaryPath -} - -func (p *postRendererString) Type() string { - return "postRendererString" -} - -func (p *postRendererString) Set(val string) error { - if val == "" { - return nil - } - p.options.binaryPath = val - pr, err := postrender.NewExec(p.options.binaryPath, p.options.args...) - if err != nil { - return err - } - *p.options.renderer = pr - return nil -} - -type postRendererArgsSlice struct { - options *postRendererOptions -} - -func (p *postRendererArgsSlice) String() string { - return "[" + strings.Join(p.options.args, ",") + "]" -} - -func (p *postRendererArgsSlice) Type() string { - return "postRendererArgsSlice" -} - -func (p *postRendererArgsSlice) Set(val string) error { - - // a post-renderer defined by a user may accept empty arguments - p.options.args = append(p.options.args, val) - - if p.options.binaryPath == "" { - return nil - } - // overwrite if already create PostRenderer by `post-renderer` flags - pr, err := postrender.NewExec(p.options.binaryPath, p.options.args...) - if err != nil { - return err - } - *p.options.renderer = pr - return nil -} - -func (p *postRendererArgsSlice) Append(val string) error { - p.options.args = append(p.options.args, val) - return nil -} - -func (p *postRendererArgsSlice) Replace(val []string) error { - p.options.args = val - return nil -} - -func (p *postRendererArgsSlice) GetSlice() []string { - return p.options.args -} - -func compVersionFlag(chartRef string, toComplete string) ([]string, cobra.ShellCompDirective) { - chartInfo := strings.Split(chartRef, "/") - if len(chartInfo) != 2 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - - repoName := chartInfo[0] - chartName := chartInfo[1] - - path := filepath.Join(settings.RepositoryCache, helmpath.CacheIndexFile(repoName)) - - var versions []string - if indexFile, err := repo.LoadIndexFile(path); err == nil { - for _, details := range indexFile.Entries[chartName] { - appVersion := details.Metadata.AppVersion - appVersionDesc := "" - if appVersion != "" { - appVersionDesc = fmt.Sprintf("App: %s, ", appVersion) - } - created := details.Created.Format("January 2, 2006") - createdDesc := "" - if created != "" { - createdDesc = fmt.Sprintf("Created: %s ", created) - } - deprecated := "" - if details.Metadata.Deprecated { - deprecated = "(deprecated)" - } - versions = append(versions, fmt.Sprintf("%s\t%s%s%s", details.Metadata.Version, appVersionDesc, createdDesc, deprecated)) - } - } - - return versions, cobra.ShellCompDirectiveNoFileComp -} - -// addKlogFlags adds flags from k8s.io/klog -// marks the flags as hidden to avoid polluting the help text -func addKlogFlags(fs *pflag.FlagSet) { - local := flag.NewFlagSet("klog", flag.ExitOnError) - klog.InitFlags(local) - local.VisitAll(func(fl *flag.Flag) { - fl.Name = normalize(fl.Name) - if fs.Lookup(fl.Name) != nil { - return - } - newflag := pflag.PFlagFromGoFlag(fl) - newflag.Hidden = true - fs.AddFlag(newflag) - }) -} - -// normalize replaces underscores with hyphens -func normalize(s string) string { - return strings.ReplaceAll(s, "_", "-") -} diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go deleted file mode 100644 index 07d28c460..000000000 --- a/cmd/helm/flags_test.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -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 ( - "fmt" - "testing" - - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/release" - helmtime "helm.sh/helm/v3/pkg/time" -) - -func outputFlagCompletionTest(t *testing.T, cmdName string) { - releasesMockWithStatus := func(info *release.Info, hooks ...*release.Hook) []*release.Release { - info.LastDeployed = helmtime.Unix(1452902400, 0).UTC() - return []*release.Release{{ - Name: "athos", - Namespace: "default", - Info: info, - Chart: &chart.Chart{}, - Hooks: hooks, - }, { - Name: "porthos", - Namespace: "default", - Info: info, - Chart: &chart.Chart{}, - Hooks: hooks, - }, { - Name: "aramis", - Namespace: "default", - Info: info, - Chart: &chart.Chart{}, - Hooks: hooks, - }, { - Name: "dartagnan", - Namespace: "gascony", - Info: info, - Chart: &chart.Chart{}, - Hooks: hooks, - }} - } - - tests := []cmdTestCase{{ - name: "completion for output flag long and before arg", - cmd: fmt.Sprintf("__complete %s --output ''", cmdName), - golden: "output/output-comp.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - }), - }, { - name: "completion for output flag long and after arg", - cmd: fmt.Sprintf("__complete %s aramis --output ''", cmdName), - golden: "output/output-comp.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - }), - }, { - name: "completion for output flag short and before arg", - cmd: fmt.Sprintf("__complete %s -o ''", cmdName), - golden: "output/output-comp.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - }), - }, { - name: "completion for output flag short and after arg", - cmd: fmt.Sprintf("__complete %s aramis -o ''", cmdName), - golden: "output/output-comp.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - }), - }, { - name: "completion for output flag, no filter", - cmd: fmt.Sprintf("__complete %s --output jso", cmdName), - golden: "output/output-comp.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - }), - }} - runTestCmd(t, tests) -} diff --git a/cmd/helm/get.go b/cmd/helm/get.go deleted file mode 100644 index 7c4854b59..000000000 --- a/cmd/helm/get.go +++ /dev/null @@ -1,53 +0,0 @@ -/* -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/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -var getHelp = ` -This command consists of multiple subcommands which can be used to -get extended information about the release, including: - -- The values used to generate the release -- The generated manifest file -- The notes provided by the chart of the release -- The hooks associated with the release -` - -func newGetCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "get", - Short: "download extended information of a named release", - Long: getHelp, - Args: require.NoArgs, - } - - cmd.AddCommand(newGetAllCmd(cfg, out)) - cmd.AddCommand(newGetValuesCmd(cfg, out)) - cmd.AddCommand(newGetManifestCmd(cfg, out)) - cmd.AddCommand(newGetHooksCmd(cfg, out)) - cmd.AddCommand(newGetNotesCmd(cfg, out)) - - return cmd -} diff --git a/cmd/helm/get_all.go b/cmd/helm/get_all.go deleted file mode 100644 index bf367da7f..000000000 --- a/cmd/helm/get_all.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -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" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/output" -) - -var getAllHelp = ` -This command prints a human readable collection of information about the -notes, hooks, supplied values, and generated manifest file of the given release. -` - -func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - var template string - client := action.NewGet(cfg) - - cmd := &cobra.Command{ - Use: "all RELEASE_NAME", - Short: "download all information for a named release", - Long: getAllHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - res, err := client.Run(args[0]) - if err != nil { - return err - } - if template != "" { - data := map[string]interface{}{ - "Release": res, - } - return tpl(template, data, out) - } - - return output.Table.Write(out, &statusPrinter{res, true, false}) - }, - } - - f := cmd.Flags() - f.IntVar(&client.Version, "revision", 0, "get the named release with revision") - err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - f.StringVar(&template, "template", "", "go template for formatting the output, eg: {{.Release.Name}}") - - return cmd -} diff --git a/cmd/helm/get_all_test.go b/cmd/helm/get_all_test.go deleted file mode 100644 index 948f0aa71..000000000 --- a/cmd/helm/get_all_test.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestGetCmd(t *testing.T) { - tests := []cmdTestCase{{ - name: "get all with a release", - cmd: "get all thomas-guide", - golden: "output/get-release.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})}, - }, { - name: "get all with a formatted release", - cmd: "get all elevated-turkey --template {{.Release.Chart.Metadata.Version}}", - golden: "output/get-release-template.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "elevated-turkey"})}, - }, { - name: "get all requires release name arg", - cmd: "get all", - golden: "output/get-all-no-args.txt", - wantError: true, - }} - runTestCmd(t, tests) -} - -func TestGetAllCompletion(t *testing.T) { - checkReleaseCompletion(t, "get all", false) -} - -func TestGetAllRevisionCompletion(t *testing.T) { - revisionFlagCompletionTest(t, "get all") -} - -func TestGetAllFileCompletion(t *testing.T) { - checkFileCompletion(t, "get all", false) - checkFileCompletion(t, "get all myrelease", false) -} diff --git a/cmd/helm/get_hooks.go b/cmd/helm/get_hooks.go deleted file mode 100644 index 913e2c58a..000000000 --- a/cmd/helm/get_hooks.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const getHooksHelp = ` -This command downloads hooks for a given release. - -Hooks are formatted in YAML and separated by the YAML '---\n' separator. -` - -func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewGet(cfg) - - cmd := &cobra.Command{ - Use: "hooks RELEASE_NAME", - Short: "download all hooks for a named release", - Long: getHooksHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - res, err := client.Run(args[0]) - if err != nil { - return err - } - for _, hook := range res.Hooks { - fmt.Fprintf(out, "---\n# Source: %s\n%s\n", hook.Path, hook.Manifest) - } - return nil - }, - } - - cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") - err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - return cmd -} diff --git a/cmd/helm/get_hooks_test.go b/cmd/helm/get_hooks_test.go deleted file mode 100644 index 251d5c731..000000000 --- a/cmd/helm/get_hooks_test.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestGetHooks(t *testing.T) { - tests := []cmdTestCase{{ - name: "get hooks with release", - cmd: "get hooks aeneas", - golden: "output/get-hooks.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, - }, { - name: "get hooks without args", - cmd: "get hooks", - golden: "output/get-hooks-no-args.txt", - wantError: true, - }} - runTestCmd(t, tests) -} - -func TestGetHooksCompletion(t *testing.T) { - checkReleaseCompletion(t, "get hooks", false) -} - -func TestGetHooksRevisionCompletion(t *testing.T) { - revisionFlagCompletionTest(t, "get hooks") -} - -func TestGetHooksFileCompletion(t *testing.T) { - checkFileCompletion(t, "get hooks", false) - checkFileCompletion(t, "get hooks myrelease", false) -} diff --git a/cmd/helm/get_manifest.go b/cmd/helm/get_manifest.go deleted file mode 100644 index baeaf8d72..000000000 --- a/cmd/helm/get_manifest.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -var getManifestHelp = ` -This command fetches the generated manifest for a given release. - -A manifest is a YAML-encoded representation of the Kubernetes resources that -were generated from this release's chart(s). If a chart is dependent on other -charts, those resources will also be included in the manifest. -` - -func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewGet(cfg) - - cmd := &cobra.Command{ - Use: "manifest RELEASE_NAME", - Short: "download the manifest for a named release", - Long: getManifestHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - res, err := client.Run(args[0]) - if err != nil { - return err - } - fmt.Fprintln(out, res.Manifest) - return nil - }, - } - - cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") - err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - return cmd -} diff --git a/cmd/helm/get_manifest_test.go b/cmd/helm/get_manifest_test.go deleted file mode 100644 index 2f27476b6..000000000 --- a/cmd/helm/get_manifest_test.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestGetManifest(t *testing.T) { - tests := []cmdTestCase{{ - name: "get manifest with release", - cmd: "get manifest juno", - golden: "output/get-manifest.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "juno"})}, - }, { - name: "get manifest without args", - cmd: "get manifest", - golden: "output/get-manifest-no-args.txt", - wantError: true, - }} - runTestCmd(t, tests) -} - -func TestGetManifestCompletion(t *testing.T) { - checkReleaseCompletion(t, "get manifest", false) -} - -func TestGetManifestRevisionCompletion(t *testing.T) { - revisionFlagCompletionTest(t, "get manifest") -} - -func TestGetManifestFileCompletion(t *testing.T) { - checkFileCompletion(t, "get manifest", false) - checkFileCompletion(t, "get manifest myrelease", false) -} diff --git a/cmd/helm/get_notes.go b/cmd/helm/get_notes.go deleted file mode 100644 index b71bcbdf6..000000000 --- a/cmd/helm/get_notes.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -var getNotesHelp = ` -This command shows notes provided by the chart of a named release. -` - -func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewGet(cfg) - - cmd := &cobra.Command{ - Use: "notes RELEASE_NAME", - Short: "download the notes for a named release", - Long: getNotesHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - res, err := client.Run(args[0]) - if err != nil { - return err - } - if len(res.Info.Notes) > 0 { - fmt.Fprintf(out, "NOTES:\n%s\n", res.Info.Notes) - } - return nil - }, - } - - f := cmd.Flags() - f.IntVar(&client.Version, "revision", 0, "get the named release with revision") - err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - return cmd -} diff --git a/cmd/helm/get_notes_test.go b/cmd/helm/get_notes_test.go deleted file mode 100644 index 8be9a3f7c..000000000 --- a/cmd/helm/get_notes_test.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestGetNotesCmd(t *testing.T) { - tests := []cmdTestCase{{ - name: "get notes of a deployed release", - cmd: "get notes the-limerick", - golden: "output/get-notes.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "the-limerick"})}, - }, { - name: "get notes without args", - cmd: "get notes", - golden: "output/get-notes-no-args.txt", - wantError: true, - }} - runTestCmd(t, tests) -} - -func TestGetNotesCompletion(t *testing.T) { - checkReleaseCompletion(t, "get notes", false) -} - -func TestGetNotesRevisionCompletion(t *testing.T) { - revisionFlagCompletionTest(t, "get notes") -} - -func TestGetNotesFileCompletion(t *testing.T) { - checkFileCompletion(t, "get notes", false) - checkFileCompletion(t, "get notes myrelease", false) -} diff --git a/cmd/helm/get_test.go b/cmd/helm/get_test.go deleted file mode 100644 index 79f914bea..000000000 --- a/cmd/helm/get_test.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -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 ( - "testing" -) - -func TestGetFileCompletion(t *testing.T) { - checkFileCompletion(t, "get", false) -} diff --git a/cmd/helm/get_values.go b/cmd/helm/get_values.go deleted file mode 100644 index 6124e1b33..000000000 --- a/cmd/helm/get_values.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/output" -) - -var getValuesHelp = ` -This command downloads a values file for a given release. -` - -type valuesWriter struct { - vals map[string]interface{} - allValues bool -} - -func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - var outfmt output.Format - client := action.NewGetValues(cfg) - - cmd := &cobra.Command{ - Use: "values RELEASE_NAME", - Short: "download the values file for a named release", - Long: getValuesHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - vals, err := client.Run(args[0]) - if err != nil { - return err - } - return outfmt.Write(out, &valuesWriter{vals, client.AllValues}) - }, - } - - f := cmd.Flags() - f.IntVar(&client.Version, "revision", 0, "get the named release with revision") - err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - f.BoolVarP(&client.AllValues, "all", "a", false, "dump all (computed) values") - bindOutputFlag(cmd, &outfmt) - - return cmd -} - -func (v valuesWriter) WriteTable(out io.Writer) error { - if v.allValues { - fmt.Fprintln(out, "COMPUTED VALUES:") - } else { - fmt.Fprintln(out, "USER-SUPPLIED VALUES:") - } - return output.EncodeYAML(out, v.vals) -} - -func (v valuesWriter) WriteJSON(out io.Writer) error { - return output.EncodeJSON(out, v.vals) -} - -func (v valuesWriter) WriteYAML(out io.Writer) error { - return output.EncodeYAML(out, v.vals) -} diff --git a/cmd/helm/get_values_test.go b/cmd/helm/get_values_test.go deleted file mode 100644 index 423c32859..000000000 --- a/cmd/helm/get_values_test.go +++ /dev/null @@ -1,71 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestGetValuesCmd(t *testing.T) { - tests := []cmdTestCase{{ - name: "get values with a release", - cmd: "get values thomas-guide", - golden: "output/get-values.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})}, - }, { - name: "get values requires release name arg", - cmd: "get values", - golden: "output/get-values-args.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})}, - wantError: true, - }, { - name: "get values thomas-guide (all)", - cmd: "get values thomas-guide --all", - golden: "output/get-values-all.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})}, - }, { - name: "get values to json", - cmd: "get values thomas-guide --output json", - golden: "output/values.json", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})}, - }, { - name: "get values to yaml", - cmd: "get values thomas-guide --output yaml", - golden: "output/values.yaml", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})}, - }} - runTestCmd(t, tests) -} - -func TestGetValuesCompletion(t *testing.T) { - checkReleaseCompletion(t, "get values", false) -} - -func TestGetValuesRevisionCompletion(t *testing.T) { - revisionFlagCompletionTest(t, "get values") -} - -func TestGetValuesOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "get values") -} - -func TestGetValuesFileCompletion(t *testing.T) { - checkFileCompletion(t, "get values", false) - checkFileCompletion(t, "get values myrelease", false) -} diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go deleted file mode 100644 index 15b0d5c76..000000000 --- a/cmd/helm/helm.go +++ /dev/null @@ -1,130 +0,0 @@ -/* -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 "helm.sh/helm/v3/cmd/helm" - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "strings" - - "github.com/spf13/cobra" - "sigs.k8s.io/yaml" - - // Import to initialize client auth plugins. - _ "k8s.io/client-go/plugin/pkg/client/auth" - - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli" - "helm.sh/helm/v3/pkg/kube" - kubefake "helm.sh/helm/v3/pkg/kube/fake" - "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/storage/driver" -) - -var settings = cli.New() - -func init() { - log.SetFlags(log.Lshortfile) -} - -func debug(format string, v ...interface{}) { - if settings.Debug { - format = fmt.Sprintf("[debug] %s\n", format) - log.Output(2, fmt.Sprintf(format, v...)) - } -} - -func warning(format string, v ...interface{}) { - format = fmt.Sprintf("WARNING: %s\n", format) - fmt.Fprintf(os.Stderr, format, v...) -} - -func main() { - // Setting the name of the app for managedFields in the Kubernetes client. - // It is set here to the full name of "helm" so that renaming of helm to - // another name (e.g., helm2 or helm3) does not change the name of the - // manager as picked up by the automated name detection. - kube.ManagedFieldsManager = "helm" - - actionConfig := new(action.Configuration) - cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) - if err != nil { - warning("%+v", err) - os.Exit(1) - } - - // run when each command's execute method is called - cobra.OnInitialize(func() { - helmDriver := os.Getenv("HELM_DRIVER") - if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, debug); err != nil { - log.Fatal(err) - } - if helmDriver == "memory" { - loadReleasesInMemory(actionConfig) - } - }) - - if err := cmd.Execute(); err != nil { - debug("%+v", err) - switch e := err.(type) { - case pluginError: - os.Exit(e.code) - default: - os.Exit(1) - } - } -} - -// This function loads releases into the memory storage if the -// environment variable is properly set. -func loadReleasesInMemory(actionConfig *action.Configuration) { - filePaths := strings.Split(os.Getenv("HELM_MEMORY_DRIVER_DATA"), ":") - if len(filePaths) == 0 { - return - } - - store := actionConfig.Releases - mem, ok := store.Driver.(*driver.Memory) - if !ok { - // For an unexpected reason we are not dealing with the memory storage driver. - return - } - - actionConfig.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard} - - for _, path := range filePaths { - b, err := ioutil.ReadFile(path) - if err != nil { - log.Fatal("Unable to read memory driver data", err) - } - - releases := []*release.Release{} - if err := yaml.Unmarshal(b, &releases); err != nil { - log.Fatal("Unable to unmarshal memory driver data: ", err) - } - - for _, rel := range releases { - if err := store.Create(rel); err != nil { - log.Fatal(err) - } - } - } - // Must reset namespace to the proper one - mem.SetNamespace(settings.Namespace()) -} diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go deleted file mode 100644 index 1adcf016f..000000000 --- a/cmd/helm/helm_test.go +++ /dev/null @@ -1,222 +0,0 @@ -/* -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 ( - "bytes" - "io/ioutil" - "os" - "os/exec" - "runtime" - "strings" - "testing" - - shellwords "github.com/mattn/go-shellwords" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/internal/test" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/cli" - kubefake "helm.sh/helm/v3/pkg/kube/fake" - "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/storage" - "helm.sh/helm/v3/pkg/storage/driver" - "helm.sh/helm/v3/pkg/time" -) - -func testTimestamper() time.Time { return time.Unix(242085845, 0).UTC() } - -func init() { - action.Timestamper = testTimestamper -} - -func runTestCmd(t *testing.T, tests []cmdTestCase) { - t.Helper() - for _, tt := range tests { - for i := 0; i <= tt.repeat; i++ { - t.Run(tt.name, func(t *testing.T) { - defer resetEnv()() - - storage := storageFixture() - for _, rel := range tt.rels { - if err := storage.Create(rel); err != nil { - t.Fatal(err) - } - } - t.Logf("running cmd (attempt %d): %s", i+1, tt.cmd) - _, out, err := executeActionCommandC(storage, tt.cmd) - if tt.wantError && err == nil { - t.Errorf("expected error, got success with the following output:\n%s", out) - } - if !tt.wantError && err != nil { - t.Errorf("expected no error, got: '%v'", err) - } - if tt.golden != "" { - test.AssertGoldenString(t, out, tt.golden) - } - }) - } - } -} - -func storageFixture() *storage.Storage { - return storage.Init(driver.NewMemory()) -} - -func executeActionCommandC(store *storage.Storage, cmd string) (*cobra.Command, string, error) { - return executeActionCommandStdinC(store, nil, cmd) -} - -func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) (*cobra.Command, string, error) { - args, err := shellwords.Parse(cmd) - if err != nil { - return nil, "", err - } - - buf := new(bytes.Buffer) - - actionConfig := &action.Configuration{ - Releases: store, - KubeClient: &kubefake.PrintingKubeClient{Out: ioutil.Discard}, - Capabilities: chartutil.DefaultCapabilities, - Log: func(format string, v ...interface{}) {}, - } - - root, err := newRootCmd(actionConfig, buf, args) - if err != nil { - return nil, "", err - } - - root.SetOut(buf) - root.SetErr(buf) - root.SetArgs(args) - - oldStdin := os.Stdin - if in != nil { - root.SetIn(in) - os.Stdin = in - } - - if mem, ok := store.Driver.(*driver.Memory); ok { - mem.SetNamespace(settings.Namespace()) - } - c, err := root.ExecuteC() - - result := buf.String() - - os.Stdin = oldStdin - - return c, result, err -} - -// cmdTestCase describes a test case that works with releases. -type cmdTestCase struct { - name string - cmd string - golden string - wantError bool - // Rels are the available releases at the start of the test. - rels []*release.Release - // Number of repeats (in case a feature was previously flaky and the test checks - // it's now stably producing identical results). 0 means test is run exactly once. - repeat int -} - -func executeActionCommand(cmd string) (*cobra.Command, string, error) { - return executeActionCommandC(storageFixture(), cmd) -} - -func resetEnv() func() { - origEnv := os.Environ() - return func() { - os.Clearenv() - for _, pair := range origEnv { - kv := strings.SplitN(pair, "=", 2) - os.Setenv(kv[0], kv[1]) - } - settings = cli.New() - } -} - -func testChdir(t *testing.T, dir string) func() { - t.Helper() - old, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - if err := os.Chdir(dir); err != nil { - t.Fatal(err) - } - return func() { os.Chdir(old) } -} - -func TestPluginExitCode(t *testing.T) { - if os.Getenv("RUN_MAIN_FOR_TESTING") == "1" { - os.Args = []string{"helm", "exitwith", "2"} - - // We DO call helm's main() here. So this looks like a normal `helm` process. - main() - - // As main calls os.Exit, we never reach this line. - // But the test called this block of code catches and verifies the exit code. - return - } - - // Currently, plugins assume a Linux subsystem. Skip the execution - // tests until this is fixed - if runtime.GOOS != "windows" { - // Do a second run of this specific test(TestPluginExitCode) with RUN_MAIN_FOR_TESTING=1 set, - // So that the second run is able to run main() and this first run can verify the exit status returned by that. - // - // This technique originates from https://talks.golang.org/2014/testing.slide#23. - cmd := exec.Command(os.Args[0], "-test.run=TestPluginExitCode") - cmd.Env = append( - os.Environ(), - "RUN_MAIN_FOR_TESTING=1", - // See pkg/cli/environment.go for which envvars can be used for configuring these passes - // and also see plugin_test.go for how a plugin env can be set up. - // We just does the same setup as plugin_test.go via envvars - "HELM_PLUGINS=testdata/helmhome/helm/plugins", - "HELM_REPOSITORY_CONFIG=testdata/helmhome/helm/repositories.yaml", - "HELM_REPOSITORY_CACHE=testdata/helmhome/helm/repository", - ) - stdout := &bytes.Buffer{} - stderr := &bytes.Buffer{} - cmd.Stdout = stdout - cmd.Stderr = stderr - err := cmd.Run() - exiterr, ok := err.(*exec.ExitError) - - if !ok { - t.Fatalf("Unexpected error returned by os.Exit: %T", err) - } - - if stdout.String() != "" { - t.Errorf("Expected no write to stdout: Got %q", stdout.String()) - } - - expectedStderr := "Error: plugin \"exitwith\" exited with error\n" - if stderr.String() != expectedStderr { - t.Errorf("Expected %q written to stderr: Got %q", expectedStderr, stderr.String()) - } - - if exiterr.ExitCode() != 2 { - t.Errorf("Expected exit code 2: Got %d", exiterr.ExitCode()) - } - } -} diff --git a/cmd/helm/history.go b/cmd/helm/history.go deleted file mode 100644 index ee6f391e4..000000000 --- a/cmd/helm/history.go +++ /dev/null @@ -1,200 +0,0 @@ -/* -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 ( - "fmt" - "io" - "strconv" - "time" - - "github.com/gosuri/uitable" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/releaseutil" - helmtime "helm.sh/helm/v3/pkg/time" -) - -var historyHelp = ` -History prints historical revisions for a given release. - -A default maximum of 256 revisions will be returned. Setting '--max' -configures the maximum length of the revision list returned. - -The historical release set is printed as a formatted table, e.g: - - $ helm history angry-bird - REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION - 1 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Initial install - 2 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Upgraded successfully - 3 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Rolled back to 2 - 4 Mon Oct 3 10:15:13 2016 deployed alpine-0.1.0 1.0 Upgraded successfully -` - -func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewHistory(cfg) - var outfmt output.Format - - cmd := &cobra.Command{ - Use: "history RELEASE_NAME", - Long: historyHelp, - Short: "fetch release history", - Aliases: []string{"hist"}, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - history, err := getHistory(client, args[0]) - if err != nil { - return err - } - - return outfmt.Write(out, history) - }, - } - - f := cmd.Flags() - f.IntVar(&client.Max, "max", 256, "maximum number of revision to include in history") - bindOutputFlag(cmd, &outfmt) - - return cmd -} - -type releaseInfo struct { - Revision int `json:"revision"` - Updated helmtime.Time `json:"updated"` - Status string `json:"status"` - Chart string `json:"chart"` - AppVersion string `json:"app_version"` - Description string `json:"description"` -} - -type releaseHistory []releaseInfo - -func (r releaseHistory) WriteJSON(out io.Writer) error { - return output.EncodeJSON(out, r) -} - -func (r releaseHistory) WriteYAML(out io.Writer) error { - return output.EncodeYAML(out, r) -} - -func (r releaseHistory) WriteTable(out io.Writer) error { - tbl := uitable.New() - tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART", "APP VERSION", "DESCRIPTION") - for _, item := range r { - tbl.AddRow(item.Revision, item.Updated.Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) - } - return output.EncodeTable(out, tbl) -} - -func getHistory(client *action.History, name string) (releaseHistory, error) { - hist, err := client.Run(name) - if err != nil { - return nil, err - } - - releaseutil.Reverse(hist, releaseutil.SortByRevision) - - var rels []*release.Release - for i := 0; i < min(len(hist), client.Max); i++ { - rels = append(rels, hist[i]) - } - - if len(rels) == 0 { - return releaseHistory{}, nil - } - - releaseHistory := getReleaseHistory(rels) - - return releaseHistory, nil -} - -func getReleaseHistory(rls []*release.Release) (history releaseHistory) { - for i := len(rls) - 1; i >= 0; i-- { - r := rls[i] - c := formatChartname(r.Chart) - s := r.Info.Status.String() - v := r.Version - d := r.Info.Description - a := formatAppVersion(r.Chart) - - rInfo := releaseInfo{ - Revision: v, - Status: s, - Chart: c, - AppVersion: a, - Description: d, - } - if !r.Info.LastDeployed.IsZero() { - rInfo.Updated = r.Info.LastDeployed - - } - history = append(history, rInfo) - } - - return history -} - -func formatChartname(c *chart.Chart) string { - if c == nil || c.Metadata == nil { - // This is an edge case that has happened in prod, though we don't - // know how: https://github.com/helm/helm/issues/1347 - return "MISSING" - } - return fmt.Sprintf("%s-%s", c.Name(), c.Metadata.Version) -} - -func formatAppVersion(c *chart.Chart) string { - if c == nil || c.Metadata == nil { - // This is an edge case that has happened in prod, though we don't - // know how: https://github.com/helm/helm/issues/1347 - return "MISSING" - } - return c.AppVersion() -} - -func min(x, y int) int { - if x < y { - return x - } - return y -} - -func compListRevisions(toComplete string, cfg *action.Configuration, releaseName string) ([]string, cobra.ShellCompDirective) { - client := action.NewHistory(cfg) - - var revisions []string - if hist, err := client.Run(releaseName); err == nil { - for _, release := range hist { - appVersion := fmt.Sprintf("App: %s", release.Chart.Metadata.AppVersion) - chartDesc := fmt.Sprintf("Chart: %s-%s", release.Chart.Metadata.Name, release.Chart.Metadata.Version) - revisions = append(revisions, fmt.Sprintf("%s\t%s, %s", strconv.Itoa(release.Version), appVersion, chartDesc)) - } - return revisions, cobra.ShellCompDirectiveNoFileComp - } - return nil, cobra.ShellCompDirectiveError -} diff --git a/cmd/helm/history_test.go b/cmd/helm/history_test.go deleted file mode 100644 index 07f2d85df..000000000 --- a/cmd/helm/history_test.go +++ /dev/null @@ -1,124 +0,0 @@ -/* -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 ( - "fmt" - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestHistoryCmd(t *testing.T) { - mk := func(name string, vers int, status release.Status) *release.Release { - return release.Mock(&release.MockReleaseOptions{ - Name: name, - Version: vers, - Status: status, - }) - } - - tests := []cmdTestCase{{ - name: "get history for release", - cmd: "history angry-bird", - rels: []*release.Release{ - mk("angry-bird", 4, release.StatusDeployed), - mk("angry-bird", 3, release.StatusSuperseded), - mk("angry-bird", 2, release.StatusSuperseded), - mk("angry-bird", 1, release.StatusSuperseded), - }, - golden: "output/history.txt", - }, { - name: "get history with max limit set", - cmd: "history angry-bird --max 2", - rels: []*release.Release{ - mk("angry-bird", 4, release.StatusDeployed), - mk("angry-bird", 3, release.StatusSuperseded), - }, - golden: "output/history-limit.txt", - }, { - name: "get history with yaml output format", - cmd: "history angry-bird --output yaml", - rels: []*release.Release{ - mk("angry-bird", 4, release.StatusDeployed), - mk("angry-bird", 3, release.StatusSuperseded), - }, - golden: "output/history.yaml", - }, { - name: "get history with json output format", - cmd: "history angry-bird --output json", - rels: []*release.Release{ - mk("angry-bird", 4, release.StatusDeployed), - mk("angry-bird", 3, release.StatusSuperseded), - }, - golden: "output/history.json", - }} - runTestCmd(t, tests) -} - -func TestHistoryOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "history") -} - -func revisionFlagCompletionTest(t *testing.T, cmdName string) { - mk := func(name string, vers int, status release.Status) *release.Release { - return release.Mock(&release.MockReleaseOptions{ - Name: name, - Version: vers, - Status: status, - }) - } - - releases := []*release.Release{ - mk("musketeers", 11, release.StatusDeployed), - mk("musketeers", 10, release.StatusSuperseded), - mk("musketeers", 9, release.StatusSuperseded), - mk("musketeers", 8, release.StatusSuperseded), - } - - tests := []cmdTestCase{{ - name: "completion for revision flag", - cmd: fmt.Sprintf("__complete %s musketeers --revision ''", cmdName), - rels: releases, - golden: "output/revision-comp.txt", - }, { - name: "completion for revision flag, no filter", - cmd: fmt.Sprintf("__complete %s musketeers --revision 1", cmdName), - rels: releases, - golden: "output/revision-comp.txt", - }, { - name: "completion for revision flag with too few args", - cmd: fmt.Sprintf("__complete %s --revision ''", cmdName), - rels: releases, - golden: "output/revision-wrong-args-comp.txt", - }, { - name: "completion for revision flag with too many args", - cmd: fmt.Sprintf("__complete %s three musketeers --revision ''", cmdName), - rels: releases, - golden: "output/revision-wrong-args-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestHistoryCompletion(t *testing.T) { - checkReleaseCompletion(t, "history", false) -} - -func TestHistoryFileCompletion(t *testing.T) { - checkFileCompletion(t, "history", false) - checkFileCompletion(t, "history myrelease", false) -} diff --git a/cmd/helm/install.go b/cmd/helm/install.go deleted file mode 100644 index 794fef52c..000000000 --- a/cmd/helm/install.go +++ /dev/null @@ -1,302 +0,0 @@ -/* -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 ( - "context" - "fmt" - "io" - "log" - "os" - "os/signal" - "syscall" - "time" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - "github.com/spf13/pflag" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chart/loader" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/cli/values" - "helm.sh/helm/v3/pkg/downloader" - "helm.sh/helm/v3/pkg/getter" - "helm.sh/helm/v3/pkg/release" -) - -const installDesc = ` -This command installs a chart archive. - -The install argument must be a chart reference, a path to a packaged chart, -a path to an unpacked chart directory or a URL. - -To override values in a chart, use either the '--values' flag and pass in a file -or use the '--set' flag and pass configuration from the command line, to force -a string value use '--set-string'. You can use '--set-file' to set individual -values from a file when the value itself is too long for the command line -or is dynamically generated. You can also use '--set-json' to set json values -(scalars/objects/arrays) from the command line. - - $ helm install -f myvalues.yaml myredis ./redis - -or - - $ helm install --set name=prod myredis ./redis - -or - - $ helm install --set-string long_int=1234567890 myredis ./redis - -or - - $ helm install --set-file my_script=dothings.sh myredis ./redis - -or - - $ helm install --set-json 'master.sidecars=[{"name":"sidecar","image":"myImage","imagePullPolicy":"Always","ports":[{"name":"portname","containerPort":1234}]}]' myredis ./redis - - -You can specify the '--values'/'-f' flag multiple times. The priority will be given to the -last (right-most) file specified. For example, if both myvalues.yaml and override.yaml -contained a key called 'Test', the value set in override.yaml would take precedence: - - $ helm install -f myvalues.yaml -f override.yaml myredis ./redis - -You can specify the '--set' flag multiple times. The priority will be given to the -last (right-most) set specified. For example, if both 'bar' and 'newbar' values are -set for a key called 'foo', the 'newbar' value would take precedence: - - $ helm install --set foo=bar --set foo=newbar myredis ./redis - -Similarly, in the following example 'foo' is set to '["four"]': - - $ helm install --set-json='foo=["one", "two", "three"]' --set-json='foo=["four"]' myredis ./redis - -And in the following example, 'foo' is set to '{"key1":"value1","key2":"bar"}': - - $ helm install --set-json='foo={"key1":"value1","key2":"value2"}' --set-json='foo.key2="bar"' myredis ./redis - -To check the generated manifests of a release without installing the chart, -the '--debug' and '--dry-run' flags can be combined. - -If --verify is set, the chart MUST have a provenance file, and the provenance -file MUST pass all verification steps. - -There are six different ways you can express the chart you want to install: - -1. By chart reference: helm install mymaria example/mariadb -2. By path to a packaged chart: helm install mynginx ./nginx-1.2.3.tgz -3. By path to an unpacked chart directory: helm install mynginx ./nginx -4. By absolute URL: helm install mynginx https://example.com/charts/nginx-1.2.3.tgz -5. By chart reference and repo url: helm install --repo https://example.com/charts/ mynginx nginx -6. By OCI registries: helm install mynginx --version 1.2.3 oci://example.com/charts/nginx - -CHART REFERENCES - -A chart reference is a convenient way of referencing a chart in a chart repository. - -When you use a chart reference with a repo prefix ('example/mariadb'), Helm will look in the local -configuration for a chart repository named 'example', and will then look for a -chart in that repository whose name is 'mariadb'. It will install the latest stable version of that chart -until you specify '--devel' flag to also include development version (alpha, beta, and release candidate releases), or -supply a version number with the '--version' flag. - -To see the list of chart repositories, use 'helm repo list'. To search for -charts in a repository, use 'helm search'. -` - -func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewInstall(cfg) - valueOpts := &values.Options{} - var outfmt output.Format - - cmd := &cobra.Command{ - Use: "install [NAME] [CHART]", - Short: "install a chart", - Long: installDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compInstall(args, toComplete, client) - }, - RunE: func(_ *cobra.Command, args []string) error { - rel, err := runInstall(args, client, valueOpts, out) - if err != nil { - return errors.Wrap(err, "INSTALLATION FAILED") - } - - return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false}) - }, - } - - addInstallFlags(cmd, cmd.Flags(), client, valueOpts) - bindOutputFlag(cmd, &outfmt) - bindPostRenderFlag(cmd, &client.PostRenderer) - - return cmd -} - -func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Install, valueOpts *values.Options) { - f.BoolVar(&client.CreateNamespace, "create-namespace", false, "create the release namespace if not present") - f.BoolVar(&client.DryRun, "dry-run", false, "simulate an install") - f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") - f.BoolVar(&client.Replace, "replace", false, "re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production") - f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") - f.BoolVar(&client.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout") - f.BoolVarP(&client.GenerateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)") - f.StringVar(&client.NameTemplate, "name-template", "", "specify template used to name the release") - f.StringVar(&client.Description, "description", "", "add a custom description") - 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.DependencyUpdate, "dependency-update", false, "update dependencies if they are missing before installing the chart") - f.BoolVar(&client.DisableOpenAPIValidation, "disable-openapi-validation", false, "if set, the installation process will not validate rendered templates against the Kubernetes OpenAPI Schema") - 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") - addValueOptionsFlags(f, valueOpts) - addChartPathOptionsFlags(f, &client.ChartPathOptions) - - err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - requiredArgs := 2 - if client.GenerateName { - requiredArgs = 1 - } - if len(args) != requiredArgs { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compVersionFlag(args[requiredArgs-1], toComplete) - }) - - if err != nil { - log.Fatal(err) - } -} - -func runInstall(args []string, client *action.Install, valueOpts *values.Options, out io.Writer) (*release.Release, error) { - debug("Original chart version: %q", client.Version) - if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") - client.Version = ">0.0.0-0" - } - - name, chart, err := client.NameAndChart(args) - if err != nil { - return nil, err - } - client.ReleaseName = name - - cp, err := client.ChartPathOptions.LocateChart(chart, settings) - if err != nil { - return nil, err - } - - debug("CHART PATH: %s\n", cp) - - p := getter.All(settings) - vals, err := valueOpts.MergeValues(p) - if err != nil { - return nil, err - } - - // Check chart dependencies to make sure all are present in /charts - chartRequested, err := loader.Load(cp) - if err != nil { - return nil, err - } - - if err := checkIfInstallable(chartRequested); err != nil { - return nil, err - } - - if chartRequested.Metadata.Deprecated { - warning("This chart is deprecated") - } - - if req := chartRequested.Metadata.Dependencies; req != nil { - // If CheckDependencies returns an error, we have unfulfilled dependencies. - // As of Helm 2.4.0, this is treated as a stopping condition: - // https://github.com/helm/helm/issues/2209 - if err := action.CheckDependencies(chartRequested, req); err != nil { - err = errors.Wrap(err, "An error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies") - if client.DependencyUpdate { - man := &downloader.Manager{ - Out: out, - ChartPath: cp, - Keyring: client.ChartPathOptions.Keyring, - SkipUpdate: false, - Getters: p, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } - if err := man.Update(); err != nil { - return nil, err - } - // Reload the chart with the updated Chart.lock file. - if chartRequested, err = loader.Load(cp); err != nil { - return nil, errors.Wrap(err, "failed reloading chart after repo update") - } - } else { - return nil, err - } - } - } - - client.Namespace = settings.Namespace() - - // Create context and prepare the handle of SIGTERM - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - - // Set up channel on which to send signal notifications. - // We must use a buffered channel or risk missing the signal - // if we're not ready to receive when the signal is sent. - cSignal := make(chan os.Signal, 2) - signal.Notify(cSignal, os.Interrupt, syscall.SIGTERM) - go func() { - <-cSignal - fmt.Fprintf(out, "Release %s has been cancelled.\n", args[0]) - cancel() - }() - - return client.RunWithContext(ctx, chartRequested, vals) -} - -// checkIfInstallable validates if a chart can be installed -// -// Application chart type is only installable -func checkIfInstallable(ch *chart.Chart) error { - switch ch.Metadata.Type { - case "", "application": - return nil - } - return errors.Errorf("%s charts are not installable", ch.Metadata.Type) -} - -// Provide dynamic auto-completion for the install and template commands -func compInstall(args []string, toComplete string, client *action.Install) ([]string, cobra.ShellCompDirective) { - requiredArgs := 1 - if client.GenerateName { - requiredArgs = 0 - } - if len(args) == requiredArgs { - return compListCharts(toComplete, true) - } - return nil, cobra.ShellCompDirectiveNoFileComp -} diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go deleted file mode 100644 index b34d1455c..000000000 --- a/cmd/helm/install_test.go +++ /dev/null @@ -1,303 +0,0 @@ -/* -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 ( - "fmt" - "net/http" - "net/http/httptest" - "path/filepath" - "testing" - - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestInstall(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - - srv.WithMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - username, password, ok := r.BasicAuth() - if !ok || username != "username" || password != "password" { - t.Errorf("Expected request to use basic auth and for username == 'username' and password == 'password', got '%v', '%s', '%s'", ok, username, password) - } - })) - - srv2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.FileServer(http.Dir(srv.Root())).ServeHTTP(w, r) - })) - defer srv2.Close() - - if err := srv.LinkIndices(); err != nil { - t.Fatal(err) - } - - repoFile := filepath.Join(srv.Root(), "repositories.yaml") - - tests := []cmdTestCase{ - // Install, base case - { - name: "basic install", - cmd: "install aeneas testdata/testcharts/empty --namespace default", - golden: "output/install.txt", - }, - - // Install, values from cli - { - name: "install with values", - cmd: "install virgil testdata/testcharts/alpine --set test.Name=bar", - golden: "output/install-with-values.txt", - }, - // Install, values from cli via multiple --set - { - name: "install with multiple values", - cmd: "install virgil testdata/testcharts/alpine --set test.Color=yellow --set test.Name=banana", - golden: "output/install-with-multiple-values.txt", - }, - // Install, values from yaml - { - name: "install with values file", - cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml", - golden: "output/install-with-values-file.txt", - }, - // Install, no hooks - { - name: "install without hooks", - cmd: "install aeneas testdata/testcharts/alpine --no-hooks --set test.Name=hello", - golden: "output/install-no-hooks.txt", - }, - // Install, values from multiple yaml - { - name: "install with values", - cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml -f testdata/testcharts/alpine/more_values.yaml", - golden: "output/install-with-multiple-values-files.txt", - }, - // Install, no charts - { - name: "install with no chart specified", - cmd: "install", - golden: "output/install-no-args.txt", - wantError: true, - }, - // Install, re-use name - { - name: "install and replace release", - cmd: "install aeneas testdata/testcharts/empty --replace", - golden: "output/install-and-replace.txt", - }, - // Install, with timeout - { - name: "install with a timeout", - cmd: "install foobar testdata/testcharts/empty --timeout 120s", - golden: "output/install-with-timeout.txt", - }, - // Install, with wait - { - name: "install with a wait", - cmd: "install apollo testdata/testcharts/empty --wait", - golden: "output/install-with-wait.txt", - }, - // Install, with wait-for-jobs - { - name: "install with wait-for-jobs", - cmd: "install apollo testdata/testcharts/empty --wait --wait-for-jobs", - golden: "output/install-with-wait-for-jobs.txt", - }, - // Install, using the name-template - { - name: "install with name-template", - cmd: "install testdata/testcharts/empty --name-template '{{ \"foobar\"}}'", - golden: "output/install-name-template.txt", - }, - // Install, perform chart verification along the way. - { - name: "install with verification, missing provenance", - cmd: "install bogus testdata/testcharts/compressedchart-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub", - wantError: true, - }, - { - name: "install with verification, directory instead of file", - cmd: "install bogus testdata/testcharts/signtest --verify --keyring testdata/helm-test-key.pub", - wantError: true, - }, - { - name: "install with verification, valid", - cmd: "install signtest testdata/testcharts/signtest-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub", - }, - // Install, chart with missing dependencies in /charts - { - name: "install chart with missing dependencies", - cmd: "install nodeps testdata/testcharts/chart-missing-deps", - wantError: true, - }, - // Install chart with update-dependency - { - name: "install chart with missing dependencies", - cmd: "install --dependency-update updeps testdata/testcharts/chart-with-subchart-update", - golden: "output/chart-with-subchart-update.txt", - }, - // Install, chart with bad dependencies in Chart.yaml in /charts - { - name: "install chart with bad dependencies in Chart.yaml", - cmd: "install badreq testdata/testcharts/chart-bad-requirements", - wantError: true, - }, - // Install, chart with library chart dependency - { - name: "install chart with library chart dependency", - cmd: "install withlibchartp testdata/testcharts/chart-with-lib-dep", - }, - // Install, library chart - { - name: "install library chart", - cmd: "install libchart testdata/testcharts/lib-chart", - wantError: true, - golden: "output/install-lib-chart.txt", - }, - // Install, chart with bad type - { - name: "install chart with bad type", - cmd: "install badtype testdata/testcharts/chart-bad-type", - wantError: true, - golden: "output/install-chart-bad-type.txt", - }, - // Install, values from yaml, schematized - { - name: "install with schema file", - cmd: "install schema testdata/testcharts/chart-with-schema", - golden: "output/schema.txt", - }, - // Install, values from yaml, schematized with errors - { - name: "install with schema file, with errors", - cmd: "install schema testdata/testcharts/chart-with-schema-negative", - wantError: true, - golden: "output/schema-negative.txt", - }, - // Install, values from yaml, extra values from yaml, schematized with errors - { - name: "install with schema file, extra values from yaml, with errors", - cmd: "install schema testdata/testcharts/chart-with-schema -f testdata/testcharts/chart-with-schema/extra-values.yaml", - wantError: true, - golden: "output/schema-negative.txt", - }, - // Install, values from yaml, extra values from cli, schematized with errors - { - name: "install with schema file, extra values from cli, with errors", - cmd: "install schema testdata/testcharts/chart-with-schema --set age=-5", - wantError: true, - golden: "output/schema-negative-cli.txt", - }, - // Install with subchart, values from yaml, schematized with errors - { - name: "install with schema file and schematized subchart, with errors", - cmd: "install schema testdata/testcharts/chart-with-schema-and-subchart", - wantError: true, - golden: "output/subchart-schema-negative.txt", - }, - // Install with subchart, values from yaml, extra values from cli, schematized with errors - { - name: "install with schema file and schematized subchart, extra values from cli", - cmd: "install schema testdata/testcharts/chart-with-schema-and-subchart --set lastname=doe --set subchart-with-schema.age=25", - golden: "output/subchart-schema-cli.txt", - }, - // Install with subchart, values from yaml, extra values from cli, schematized with errors - { - name: "install with schema file and schematized subchart, extra values from cli, with errors", - cmd: "install schema testdata/testcharts/chart-with-schema-and-subchart --set lastname=doe --set subchart-with-schema.age=-25", - wantError: true, - golden: "output/subchart-schema-cli-negative.txt", - }, - // Install deprecated chart - { - name: "install with warning about deprecated chart", - cmd: "install aeneas testdata/testcharts/deprecated --namespace default", - golden: "output/deprecated-chart.txt", - }, - // Install chart with only crds - { - name: "install chart with only crds", - cmd: "install crd-test testdata/testcharts/chart-with-only-crds --namespace default", - }, - // Verify the user/pass works - { - name: "basic install with credentials", - cmd: "install aeneas reqtest --namespace default --repo " + srv.URL() + " --username username --password password", - golden: "output/install.txt", - }, - { - name: "basic install with credentials", - cmd: "install aeneas reqtest --namespace default --repo " + srv2.URL + " --username username --password password --pass-credentials", - golden: "output/install.txt", - }, - { - name: "basic install with credentials and no repo", - cmd: fmt.Sprintf("install aeneas test/reqtest --username username --password password --repository-config %s --repository-cache %s", repoFile, srv.Root()), - golden: "output/install.txt", - }, - } - - runTestCmd(t, tests) -} - -func TestInstallOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "install") -} - -func TestInstallVersionCompletion(t *testing.T) { - repoFile := "testdata/helmhome/helm/repositories.yaml" - repoCache := "testdata/helmhome/helm/repository" - - repoSetup := fmt.Sprintf("--repository-config %s --repository-cache %s", repoFile, repoCache) - - tests := []cmdTestCase{{ - name: "completion for install version flag with release name", - cmd: fmt.Sprintf("%s __complete install releasename testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for install version flag with generate-name", - cmd: fmt.Sprintf("%s __complete install --generate-name testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for install version flag, no filter", - cmd: fmt.Sprintf("%s __complete install releasename testing/alpine --version 0.3", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for install version flag too few args", - cmd: fmt.Sprintf("%s __complete install testing/alpine --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for install version flag too many args", - cmd: fmt.Sprintf("%s __complete install releasename testing/alpine badarg --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for install version flag invalid chart", - cmd: fmt.Sprintf("%s __complete install releasename invalid/invalid --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestInstallFileCompletion(t *testing.T) { - checkFileCompletion(t, "install", false) - checkFileCompletion(t, "install --generate-name", true) - checkFileCompletion(t, "install myname", true) - checkFileCompletion(t, "install myname mychart", false) -} diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go deleted file mode 100644 index 73a37b6fe..000000000 --- a/cmd/helm/lint.go +++ /dev/null @@ -1,143 +0,0 @@ -/* -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 ( - "fmt" - "io" - "os" - "path/filepath" - "strings" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/values" - "helm.sh/helm/v3/pkg/getter" - "helm.sh/helm/v3/pkg/lint/support" -) - -var longLintHelp = ` -This command takes a path to a chart and runs a series of tests to verify that -the chart is well-formed. - -If the linter encounters things that will cause the chart to fail installation, -it will emit [ERROR] messages. If it encounters issues that break with convention -or recommendation, it will emit [WARNING] messages. -` - -func newLintCmd(out io.Writer) *cobra.Command { - client := action.NewLint() - valueOpts := &values.Options{} - - cmd := &cobra.Command{ - Use: "lint PATH", - Short: "examine a chart for possible issues", - Long: longLintHelp, - RunE: func(cmd *cobra.Command, args []string) error { - paths := []string{"."} - if len(args) > 0 { - paths = args - } - if client.WithSubcharts { - for _, p := range paths { - filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, err error) error { - if info != nil { - if info.Name() == "Chart.yaml" { - paths = append(paths, filepath.Dir(path)) - } else if strings.HasSuffix(path, ".tgz") || strings.HasSuffix(path, ".tar.gz") { - paths = append(paths, path) - } - } - return nil - }) - } - } - - client.Namespace = settings.Namespace() - vals, err := valueOpts.MergeValues(getter.All(settings)) - if err != nil { - return err - } - - var message strings.Builder - failed := 0 - errorsOrWarnings := 0 - - for _, path := range paths { - result := client.Run([]string{path}, vals) - - // If there is no errors/warnings and quiet flag is set - // go to the next chart - hasWarningsOrErrors := action.HasWarningsOrErrors(result) - if hasWarningsOrErrors { - errorsOrWarnings++ - } - if client.Quiet && !hasWarningsOrErrors { - continue - } - - fmt.Fprintf(&message, "==> Linting %s\n", path) - - // All the Errors that are generated by a chart - // that failed a lint will be included in the - // results.Messages so we only need to print - // the Errors if there are no Messages. - if len(result.Messages) == 0 { - for _, err := range result.Errors { - fmt.Fprintf(&message, "Error %s\n", err) - } - } - - for _, msg := range result.Messages { - if !client.Quiet || msg.Severity > support.InfoSev { - fmt.Fprintf(&message, "%s\n", msg) - } - } - - if len(result.Errors) != 0 { - failed++ - } - - // Adding extra new line here to break up the - // results, stops this from being a big wall of - // text and makes it easier to follow. - fmt.Fprint(&message, "\n") - } - - fmt.Fprint(out, message.String()) - - summary := fmt.Sprintf("%d chart(s) linted, %d chart(s) failed", len(paths), failed) - if failed > 0 { - return errors.New(summary) - } - if !client.Quiet || errorsOrWarnings > 0 { - fmt.Fprintln(out, summary) - } - return nil - }, - } - - f := cmd.Flags() - f.BoolVar(&client.Strict, "strict", false, "fail on lint warnings") - f.BoolVar(&client.WithSubcharts, "with-subcharts", false, "lint dependent charts") - f.BoolVar(&client.Quiet, "quiet", false, "print only warnings and errors") - addValueOptionsFlags(f, valueOpts) - - return cmd -} diff --git a/cmd/helm/lint_test.go b/cmd/helm/lint_test.go deleted file mode 100644 index ebea09bf0..000000000 --- a/cmd/helm/lint_test.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -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 ( - "fmt" - "testing" -) - -func TestLintCmdWithSubchartsFlag(t *testing.T) { - testChart := "testdata/testcharts/chart-with-bad-subcharts" - tests := []cmdTestCase{{ - name: "lint good chart with bad subcharts", - cmd: fmt.Sprintf("lint %s", testChart), - golden: "output/lint-chart-with-bad-subcharts.txt", - wantError: true, - }, { - name: "lint good chart with bad subcharts using --with-subcharts flag", - cmd: fmt.Sprintf("lint --with-subcharts %s", testChart), - golden: "output/lint-chart-with-bad-subcharts-with-subcharts.txt", - wantError: true, - }} - runTestCmd(t, tests) -} - -func TestLintCmdWithQuietFlag(t *testing.T) { - testChart1 := "testdata/testcharts/alpine" - testChart2 := "testdata/testcharts/chart-bad-requirements" - tests := []cmdTestCase{{ - name: "lint good chart using --quiet flag", - cmd: fmt.Sprintf("lint --quiet %s", testChart1), - golden: "output/lint-quiet.txt", - }, { - name: "lint two charts, one with error using --quiet flag", - cmd: fmt.Sprintf("lint --quiet %s %s", testChart1, testChart2), - golden: "output/lint-quiet-with-error.txt", - wantError: true, - }, { - name: "lint chart with warning using --quiet flag", - cmd: "lint --quiet testdata/testcharts/chart-with-only-crds", - golden: "output/lint-quiet-with-warning.txt", - }} - runTestCmd(t, tests) - -} - -func TestLintFileCompletion(t *testing.T) { - checkFileCompletion(t, "lint", true) - checkFileCompletion(t, "lint mypath", true) // Multiple paths can be given -} diff --git a/cmd/helm/list.go b/cmd/helm/list.go deleted file mode 100644 index 5ca3de18e..000000000 --- a/cmd/helm/list.go +++ /dev/null @@ -1,251 +0,0 @@ -/* -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 ( - "fmt" - "io" - "os" - "strconv" - - "github.com/gosuri/uitable" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/release" -) - -var listHelp = ` -This command lists all of the releases for a specified namespace (uses current namespace context if namespace not specified). - -By default, it lists only releases that are deployed or failed. Flags like -'--uninstalled' and '--all' will alter this behavior. Such flags can be combined: -'--uninstalled --failed'. - -By default, items are sorted alphabetically. Use the '-d' flag to sort by -release date. - -If the --filter flag is provided, it will be treated as a filter. Filters are -regular expressions (Perl compatible) that are applied to the list of releases. -Only items that match the filter will be returned. - - $ helm list --filter 'ara[a-z]+' - NAME UPDATED CHART - maudlin-arachnid 2020-06-18 14:17:46.125134977 +0000 UTC alpine-0.1.0 - -If no results are found, 'helm list' will exit 0, but with no output (or in -the case of no '-q' flag, only headers). - -By default, up to 256 items may be returned. To limit this, use the '--max' flag. -Setting '--max' to 0 will not return all results. Rather, it will return the -server's default, which may be much higher than 256. Pairing the '--max' -flag with the '--offset' flag allows you to page through results. -` - -func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewList(cfg) - var outfmt output.Format - - cmd := &cobra.Command{ - Use: "list", - Short: "list releases", - Long: listHelp, - Aliases: []string{"ls"}, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil { - return err - } - } - client.SetStateMask() - - results, err := client.Run() - if err != nil { - return err - } - - if client.Short { - names := make([]string, 0, len(results)) - for _, res := range results { - names = append(names, res.Name) - } - - outputFlag := cmd.Flag("output") - - switch outputFlag.Value.String() { - case "json": - output.EncodeJSON(out, names) - return nil - case "yaml": - output.EncodeYAML(out, names) - return nil - case "table": - for _, res := range results { - fmt.Fprintln(out, res.Name) - } - return nil - } - } - - return outfmt.Write(out, newReleaseListWriter(results, client.TimeFormat, client.NoHeaders)) - }, - } - - f := cmd.Flags() - f.BoolVarP(&client.Short, "short", "q", false, "output short (quiet) listing format") - f.BoolVarP(&client.NoHeaders, "no-headers", "", false, "don't print headers when using the default output format") - f.StringVar(&client.TimeFormat, "time-format", "", `format time using golang time formatter. Example: --time-format "2006-01-02 15:04:05Z0700"`) - f.BoolVarP(&client.ByDate, "date", "d", false, "sort by release date") - f.BoolVarP(&client.SortReverse, "reverse", "r", false, "reverse the sort order") - f.BoolVarP(&client.All, "all", "a", false, "show all releases without any filter applied") - f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases (if 'helm uninstall --keep-history' was used)") - f.BoolVar(&client.Superseded, "superseded", false, "show superseded releases") - f.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") - f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") - f.BoolVar(&client.Failed, "failed", false, "show failed releases") - f.BoolVar(&client.Pending, "pending", false, "show pending releases") - f.BoolVarP(&client.AllNamespaces, "all-namespaces", "A", false, "list releases across all namespaces") - f.IntVarP(&client.Limit, "max", "m", 256, "maximum number of releases to fetch") - f.IntVar(&client.Offset, "offset", 0, "next release index in the list, used to offset from start value") - f.StringVarP(&client.Filter, "filter", "f", "", "a regular expression (Perl compatible). Any releases that match the expression will be included in the results") - f.StringVarP(&client.Selector, "selector", "l", "", "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Works only for secret(default) and configmap storage backends.") - bindOutputFlag(cmd, &outfmt) - - return cmd -} - -type releaseElement struct { - Name string `json:"name"` - Namespace string `json:"namespace"` - Revision string `json:"revision"` - Updated string `json:"updated"` - Status string `json:"status"` - Chart string `json:"chart"` - AppVersion string `json:"app_version"` -} - -type releaseListWriter struct { - releases []releaseElement - noHeaders bool -} - -func newReleaseListWriter(releases []*release.Release, timeFormat string, noHeaders bool) *releaseListWriter { - // Initialize the array so no results returns an empty array instead of null - elements := make([]releaseElement, 0, len(releases)) - for _, r := range releases { - element := releaseElement{ - Name: r.Name, - Namespace: r.Namespace, - Revision: strconv.Itoa(r.Version), - Status: r.Info.Status.String(), - Chart: formatChartname(r.Chart), - AppVersion: formatAppVersion(r.Chart), - } - - t := "-" - if tspb := r.Info.LastDeployed; !tspb.IsZero() { - if timeFormat != "" { - t = tspb.Format(timeFormat) - } else { - t = tspb.String() - } - } - element.Updated = t - - elements = append(elements, element) - } - return &releaseListWriter{elements, noHeaders} -} - -func (r *releaseListWriter) WriteTable(out io.Writer) error { - table := uitable.New() - if !r.noHeaders { - table.AddRow("NAME", "NAMESPACE", "REVISION", "UPDATED", "STATUS", "CHART", "APP VERSION") - } - for _, r := range r.releases { - table.AddRow(r.Name, r.Namespace, r.Revision, r.Updated, r.Status, r.Chart, r.AppVersion) - } - return output.EncodeTable(out, table) -} - -func (r *releaseListWriter) WriteJSON(out io.Writer) error { - return output.EncodeJSON(out, r.releases) -} - -func (r *releaseListWriter) WriteYAML(out io.Writer) error { - return output.EncodeYAML(out, r.releases) -} - -// Returns all releases from 'releases', except those with names matching 'ignoredReleases' -func filterReleases(releases []*release.Release, ignoredReleaseNames []string) []*release.Release { - // if ignoredReleaseNames is nil, just return releases - if ignoredReleaseNames == nil { - return releases - } - - var filteredReleases []*release.Release - for _, rel := range releases { - found := false - for _, ignoredName := range ignoredReleaseNames { - if rel.Name == ignoredName { - found = true - break - } - } - if !found { - filteredReleases = append(filteredReleases, rel) - } - } - - return filteredReleases -} - -// Provide dynamic auto-completion for release names -func compListReleases(toComplete string, ignoredReleaseNames []string, cfg *action.Configuration) ([]string, cobra.ShellCompDirective) { - cobra.CompDebugln(fmt.Sprintf("compListReleases with toComplete %s", toComplete), settings.Debug) - - client := action.NewList(cfg) - client.All = true - client.Limit = 0 - // Do not filter so as to get the entire list of releases. - // This will allow zsh and fish to match completion choices - // on other criteria then prefix. For example: - // helm status ingress - // can match - // helm status nginx-ingress - // - // client.Filter = fmt.Sprintf("^%s", toComplete) - - client.SetStateMask() - releases, err := client.Run() - if err != nil { - return nil, cobra.ShellCompDirectiveDefault - } - - var choices []string - filteredReleases := filterReleases(releases, ignoredReleaseNames) - for _, rel := range filteredReleases { - choices = append(choices, - fmt.Sprintf("%s\t%s-%s -> %s", rel.Name, rel.Chart.Metadata.Name, rel.Chart.Metadata.Version, rel.Info.Status.String())) - } - - return choices, cobra.ShellCompDirectiveNoFileComp -} diff --git a/cmd/helm/list_test.go b/cmd/helm/list_test.go deleted file mode 100644 index 97a1e284f..000000000 --- a/cmd/helm/list_test.go +++ /dev/null @@ -1,246 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/time" -) - -func TestListCmd(t *testing.T) { - defaultNamespace := "default" - - sampleTimeSeconds := int64(1452902400) - timestamp1 := time.Unix(sampleTimeSeconds+1, 0).UTC() - timestamp2 := time.Unix(sampleTimeSeconds+2, 0).UTC() - timestamp3 := time.Unix(sampleTimeSeconds+3, 0).UTC() - timestamp4 := time.Unix(sampleTimeSeconds+4, 0).UTC() - chartInfo := &chart.Chart{ - Metadata: &chart.Metadata{ - Name: "chickadee", - Version: "1.0.0", - AppVersion: "0.0.1", - }, - } - - releaseFixture := []*release.Release{ - { - Name: "starlord", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusSuperseded, - }, - Chart: chartInfo, - }, - { - Name: "starlord", - Version: 2, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusDeployed, - }, - Chart: chartInfo, - }, - { - Name: "groot", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusUninstalled, - }, - Chart: chartInfo, - }, - { - Name: "gamora", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusSuperseded, - }, - Chart: chartInfo, - }, - { - Name: "rocket", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp2, - Status: release.StatusFailed, - }, - Chart: chartInfo, - }, - { - Name: "drax", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusUninstalling, - }, - Chart: chartInfo, - }, - { - Name: "thanos", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusPendingInstall, - }, - Chart: chartInfo, - }, - { - Name: "hummingbird", - Version: 1, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp3, - Status: release.StatusDeployed, - }, - Chart: chartInfo, - }, - { - Name: "iguana", - Version: 2, - Namespace: defaultNamespace, - Info: &release.Info{ - LastDeployed: timestamp4, - Status: release.StatusDeployed, - }, - Chart: chartInfo, - }, - { - Name: "starlord", - Version: 2, - Namespace: "milano", - Info: &release.Info{ - LastDeployed: timestamp1, - Status: release.StatusDeployed, - }, - Chart: chartInfo, - }, - } - - tests := []cmdTestCase{{ - name: "list releases", - cmd: "list", - golden: "output/list.txt", - rels: releaseFixture, - }, { - name: "list without headers", - cmd: "list --no-headers", - golden: "output/list-no-headers.txt", - rels: releaseFixture, - }, { - name: "list all releases", - cmd: "list --all", - golden: "output/list-all.txt", - rels: releaseFixture, - }, { - name: "list releases sorted by release date", - cmd: "list --date", - golden: "output/list-date.txt", - rels: releaseFixture, - }, { - name: "list failed releases", - cmd: "list --failed", - golden: "output/list-failed.txt", - rels: releaseFixture, - }, { - name: "list filtered releases", - cmd: "list --filter='.*'", - golden: "output/list-filter.txt", - rels: releaseFixture, - }, { - name: "list releases, limited to one release", - cmd: "list --max 1", - golden: "output/list-max.txt", - rels: releaseFixture, - }, { - name: "list releases, offset by one", - cmd: "list --offset 1", - golden: "output/list-offset.txt", - rels: releaseFixture, - }, { - name: "list pending releases", - cmd: "list --pending", - golden: "output/list-pending.txt", - rels: releaseFixture, - }, { - name: "list releases in reverse order", - cmd: "list --reverse", - golden: "output/list-reverse.txt", - rels: releaseFixture, - }, { - name: "list releases sorted by reversed release date", - cmd: "list --date --reverse", - golden: "output/list-date-reversed.txt", - rels: releaseFixture, - }, { - name: "list releases in short output format", - cmd: "list --short", - golden: "output/list-short.txt", - rels: releaseFixture, - }, { - name: "list releases in short output format", - cmd: "list --short --output yaml", - golden: "output/list-short-yaml.txt", - rels: releaseFixture, - }, { - name: "list releases in short output format", - cmd: "list --short --output json", - golden: "output/list-short-json.txt", - rels: releaseFixture, - }, { - name: "list superseded releases", - cmd: "list --superseded", - golden: "output/list-superseded.txt", - rels: releaseFixture, - }, { - name: "list uninstalled releases", - cmd: "list --uninstalled", - golden: "output/list-uninstalled.txt", - rels: releaseFixture, - }, { - name: "list releases currently uninstalling", - cmd: "list --uninstalling", - golden: "output/list-uninstalling.txt", - rels: releaseFixture, - }, { - name: "list releases in another namespace", - cmd: "list -n milano", - golden: "output/list-namespace.txt", - rels: releaseFixture, - }} - runTestCmd(t, tests) -} - -func TestListOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "list") -} - -func TestListFileCompletion(t *testing.T) { - checkFileCompletion(t, "list", false) -} diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go deleted file mode 100644 index 6b67ac28f..000000000 --- a/cmd/helm/load_plugins.go +++ /dev/null @@ -1,377 +0,0 @@ -/* -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 ( - "bytes" - "fmt" - "io" - "io/ioutil" - "log" - "os" - "os/exec" - "path/filepath" - "strconv" - "strings" - "syscall" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - "sigs.k8s.io/yaml" - - "helm.sh/helm/v3/pkg/plugin" -) - -const ( - pluginStaticCompletionFile = "completion.yaml" - pluginDynamicCompletionExecutable = "plugin.complete" -) - -type pluginError struct { - error - code int -} - -// loadPlugins loads plugins into the command list. -// -// This follows a different pattern than the other commands because it has -// to inspect its environment and then add commands to the base command -// as it finds them. -func loadPlugins(baseCmd *cobra.Command, out io.Writer) { - - // If HELM_NO_PLUGINS is set to 1, do not load plugins. - if os.Getenv("HELM_NO_PLUGINS") == "1" { - return - } - - found, err := plugin.FindPlugins(settings.PluginsDirectory) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to load plugins: %s\n", err) - return - } - - // Now we create commands for all of these. - for _, plug := range found { - plug := plug - md := plug.Metadata - if md.Usage == "" { - md.Usage = fmt.Sprintf("the %q plugin", md.Name) - } - - c := &cobra.Command{ - Use: md.Name, - Short: md.Usage, - Long: md.Description, - RunE: func(cmd *cobra.Command, args []string) error { - u, err := processParent(cmd, args) - if err != nil { - return err - } - - // Call setupEnv before PrepareCommand because - // PrepareCommand uses os.ExpandEnv and expects the - // setupEnv vars. - plugin.SetupPluginEnv(settings, md.Name, plug.Dir) - main, argv, prepCmdErr := plug.PrepareCommand(u) - if prepCmdErr != nil { - os.Stderr.WriteString(prepCmdErr.Error()) - return errors.Errorf("plugin %q exited with error", md.Name) - } - - return callPluginExecutable(md.Name, main, argv, out) - }, - // This passes all the flags to the subcommand. - DisableFlagParsing: true, - } - - // TODO: Make sure a command with this name does not already exist. - baseCmd.AddCommand(c) - - // For completion, we try to load more details about the plugins so as to allow for command and - // flag completion of the plugin itself. - // We only do this when necessary (for the "completion" and "__complete" commands) to avoid the - // risk of a rogue plugin affecting Helm's normal behavior. - subCmd, _, err := baseCmd.Find(os.Args[1:]) - if (err == nil && - ((subCmd.HasParent() && subCmd.Parent().Name() == "completion") || subCmd.Name() == cobra.ShellCompRequestCmd)) || - /* for the tests */ subCmd == baseCmd.Root() { - loadCompletionForPlugin(c, plug) - } - } -} - -func processParent(cmd *cobra.Command, args []string) ([]string, error) { - k, u := manuallyProcessArgs(args) - if err := cmd.Parent().ParseFlags(k); err != nil { - return nil, err - } - return u, nil -} - -// This function is used to setup the environment for the plugin and then -// call the executable specified by the parameter 'main' -func callPluginExecutable(pluginName string, main string, argv []string, out io.Writer) error { - env := os.Environ() - for k, v := range settings.EnvVars() { - env = append(env, fmt.Sprintf("%s=%s", k, v)) - } - - prog := exec.Command(main, argv...) - prog.Env = env - prog.Stdin = os.Stdin - prog.Stdout = out - prog.Stderr = os.Stderr - if err := prog.Run(); err != nil { - if eerr, ok := err.(*exec.ExitError); ok { - os.Stderr.Write(eerr.Stderr) - status := eerr.Sys().(syscall.WaitStatus) - return pluginError{ - error: errors.Errorf("plugin %q exited with error", pluginName), - code: status.ExitStatus(), - } - } - return err - } - return nil -} - -// manuallyProcessArgs processes an arg array, removing special args. -// -// Returns two sets of args: known and unknown (in that order) -func manuallyProcessArgs(args []string) ([]string, []string) { - known := []string{} - unknown := []string{} - kvargs := []string{"--kube-context", "--namespace", "-n", "--kubeconfig", "--kube-apiserver", "--kube-token", "--kube-as-user", "--kube-as-group", "--kube-ca-file", "--registry-config", "--repository-cache", "--repository-config", "--insecure-skip-tls-verify", "--tls-server-name"} - knownArg := func(a string) bool { - for _, pre := range kvargs { - if strings.HasPrefix(a, pre+"=") { - return true - } - } - return false - } - - isKnown := func(v string) string { - for _, i := range kvargs { - if i == v { - return v - } - } - return "" - } - - for i := 0; i < len(args); i++ { - switch a := args[i]; a { - case "--debug": - known = append(known, a) - case isKnown(a): - known = append(known, a) - i++ - if i < len(args) { - known = append(known, args[i]) - } - default: - if knownArg(a) { - known = append(known, a) - continue - } - unknown = append(unknown, a) - } - } - return known, unknown -} - -// pluginCommand represents the optional completion.yaml file of a plugin -type pluginCommand struct { - Name string `json:"name"` - ValidArgs []string `json:"validArgs"` - Flags []string `json:"flags"` - Commands []pluginCommand `json:"commands"` -} - -// loadCompletionForPlugin will load and parse any completion.yaml provided by the plugin -// and add the dynamic completion hook to call the optional plugin.complete -func loadCompletionForPlugin(pluginCmd *cobra.Command, plugin *plugin.Plugin) { - // Parse the yaml file providing the plugin's sub-commands and flags - cmds, err := loadFile(strings.Join( - []string{plugin.Dir, pluginStaticCompletionFile}, string(filepath.Separator))) - - if err != nil { - // The file could be missing or invalid. No static completion for this plugin. - if settings.Debug { - log.Output(2, fmt.Sprintf("[info] %s\n", err.Error())) - } - // Continue to setup dynamic completion. - cmds = &pluginCommand{} - } - - // Preserve the Usage string specified for the plugin - cmds.Name = pluginCmd.Use - - addPluginCommands(plugin, pluginCmd, cmds) -} - -// addPluginCommands is a recursive method that adds each different level -// of sub-commands and flags for the plugins that have provided such information -func addPluginCommands(plugin *plugin.Plugin, baseCmd *cobra.Command, cmds *pluginCommand) { - if cmds == nil { - return - } - - if len(cmds.Name) == 0 { - // Missing name for a command - if settings.Debug { - log.Output(2, fmt.Sprintf("[info] sub-command name field missing for %s", baseCmd.CommandPath())) - } - return - } - - baseCmd.Use = cmds.Name - baseCmd.ValidArgs = cmds.ValidArgs - // Setup the same dynamic completion for each plugin sub-command. - // This is because if dynamic completion is triggered, there is a single executable - // to call (plugin.complete), so every sub-commands calls it in the same fashion. - if cmds.Commands == nil { - // Only setup dynamic completion if there are no sub-commands. This avoids - // calling plugin.complete at every completion, which greatly simplifies - // development of plugin.complete for plugin developers. - baseCmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return pluginDynamicComp(plugin, cmd, args, toComplete) - } - } - - // Create fake flags. - if len(cmds.Flags) > 0 { - // The flags can be created with any type, since we only need them for completion. - // pflag does not allow to create short flags without a corresponding long form - // so we look for all short flags and match them to any long flag. This will allow - // plugins to provide short flags without a long form. - // If there are more short-flags than long ones, we'll create an extra long flag with - // the same single letter as the short form. - shorts := []string{} - longs := []string{} - for _, flag := range cmds.Flags { - if len(flag) == 1 { - shorts = append(shorts, flag) - } else { - longs = append(longs, flag) - } - } - - f := baseCmd.Flags() - if len(longs) >= len(shorts) { - for i := range longs { - if i < len(shorts) { - f.BoolP(longs[i], shorts[i], false, "") - } else { - f.Bool(longs[i], false, "") - } - } - } else { - for i := range shorts { - if i < len(longs) { - f.BoolP(longs[i], shorts[i], false, "") - } else { - // Create a long flag with the same name as the short flag. - // Not a perfect solution, but its better than ignoring the extra short flags. - f.BoolP(shorts[i], shorts[i], false, "") - } - } - } - } - - // Recursively add any sub-commands - for _, cmd := range cmds.Commands { - // Create a fake command so that completion can be done for the sub-commands of the plugin - subCmd := &cobra.Command{ - // This prevents Cobra from removing the flags. We want to keep the flags to pass them - // to the dynamic completion script of the plugin. - DisableFlagParsing: true, - // A Run is required for it to be a valid command without subcommands - Run: func(cmd *cobra.Command, args []string) {}, - } - baseCmd.AddCommand(subCmd) - addPluginCommands(plugin, subCmd, &cmd) - } -} - -// loadFile takes a yaml file at the given path, parses it and returns a pluginCommand object -func loadFile(path string) (*pluginCommand, error) { - cmds := new(pluginCommand) - b, err := ioutil.ReadFile(path) - if err != nil { - return cmds, fmt.Errorf("file (%s) not provided by plugin. No plugin auto-completion possible", path) - } - - err = yaml.Unmarshal(b, cmds) - return cmds, err -} - -// pluginDynamicComp call the plugin.complete script of the plugin (if available) -// to obtain the dynamic completion choices. It must pass all the flags and sub-commands -// specified in the command-line to the plugin.complete executable (except helm's global flags) -func pluginDynamicComp(plug *plugin.Plugin, cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - md := plug.Metadata - - u, err := processParent(cmd, args) - if err != nil { - return nil, cobra.ShellCompDirectiveError - } - - // We will call the dynamic completion script of the plugin - main := strings.Join([]string{plug.Dir, pluginDynamicCompletionExecutable}, string(filepath.Separator)) - - // We must include all sub-commands passed on the command-line. - // To do that, we pass-in the entire CommandPath, except the first two elements - // which are 'helm' and 'pluginName'. - argv := strings.Split(cmd.CommandPath(), " ")[2:] - if !md.IgnoreFlags { - argv = append(argv, u...) - argv = append(argv, toComplete) - } - plugin.SetupPluginEnv(settings, md.Name, plug.Dir) - - cobra.CompDebugln(fmt.Sprintf("calling %s with args %v", main, argv), settings.Debug) - buf := new(bytes.Buffer) - if err := callPluginExecutable(md.Name, main, argv, buf); err != nil { - // The dynamic completion file is optional for a plugin, so this error is ok. - cobra.CompDebugln(fmt.Sprintf("Unable to call %s: %v", main, err.Error()), settings.Debug) - return nil, cobra.ShellCompDirectiveDefault - } - - var completions []string - for _, comp := range strings.Split(buf.String(), "\n") { - // Remove any empty lines - if len(comp) > 0 { - completions = append(completions, comp) - } - } - - // Check if the last line of output is of the form :, which - // indicates the BashCompletionDirective. - directive := cobra.ShellCompDirectiveDefault - if len(completions) > 0 { - lastLine := completions[len(completions)-1] - if len(lastLine) > 1 && lastLine[0] == ':' { - if strInt, err := strconv.Atoi(lastLine[1:]); err == nil { - directive = cobra.ShellCompDirective(strInt) - completions = completions[:len(completions)-1] - } - } - } - - return completions, directive -} diff --git a/cmd/helm/package.go b/cmd/helm/package.go deleted file mode 100644 index ce965b729..000000000 --- a/cmd/helm/package.go +++ /dev/null @@ -1,125 +0,0 @@ -/* -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 ( - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/values" - "helm.sh/helm/v3/pkg/downloader" - "helm.sh/helm/v3/pkg/getter" -) - -const packageDesc = ` -This command packages a chart into a versioned chart archive file. If a path -is given, this will look at that path for a chart (which must contain a -Chart.yaml file) and then package that directory. - -Versioned chart archives are used by Helm package repositories. - -To sign a chart, use the '--sign' flag. In most cases, you should also -provide '--keyring path/to/secret/keys' and '--key keyname'. - - $ helm package --sign ./mychart --key mykey --keyring ~/.gnupg/secring.gpg - -If '--keyring' is not specified, Helm usually defaults to the public keyring -unless your environment is otherwise configured. -` - -func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewPackage() - valueOpts := &values.Options{} - - cmd := &cobra.Command{ - Use: "package [CHART_PATH] [...]", - Short: "package a chart directory into a chart archive", - Long: packageDesc, - RunE: func(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return errors.Errorf("need at least one argument, the path to the chart") - } - if client.Sign { - if client.Key == "" { - return errors.New("--key is required for signing a package") - } - if client.Keyring == "" { - return errors.New("--keyring is required for signing a package") - } - } - client.RepositoryConfig = settings.RepositoryConfig - client.RepositoryCache = settings.RepositoryCache - p := getter.All(settings) - vals, err := valueOpts.MergeValues(p) - if err != nil { - return err - } - - for i := 0; i < len(args); i++ { - path, err := filepath.Abs(args[i]) - if err != nil { - return err - } - if _, err := os.Stat(args[i]); err != nil { - return err - } - - if client.DependencyUpdate { - downloadManager := &downloader.Manager{ - Out: ioutil.Discard, - ChartPath: path, - Keyring: client.Keyring, - Getters: p, - Debug: settings.Debug, - RegistryClient: cfg.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - } - - if err := downloadManager.Update(); err != nil { - return err - } - } - p, err := client.Run(path, vals) - if err != nil { - return err - } - fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", p) - } - return nil - }, - } - - f := cmd.Flags() - f.BoolVar(&client.Sign, "sign", false, "use a PGP private key to sign this package") - f.StringVar(&client.Key, "key", "", "name of the key to use when signing. Used if --sign is true") - f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "location of a public keyring") - f.StringVar(&client.PassphraseFile, "passphrase-file", "", `location of a file which contains the passphrase for the signing key. Use "-" in order to read from stdin.`) - f.StringVar(&client.Version, "version", "", "set the version on the chart to this semver version") - f.StringVar(&client.AppVersion, "app-version", "", "set the appVersion on the chart to this version") - f.StringVarP(&client.Destination, "destination", "d", ".", "location to write the chart.") - f.BoolVarP(&client.DependencyUpdate, "dependency-update", "u", false, `update dependencies from "Chart.yaml" to dir "charts/" before packaging`) - - return cmd -} diff --git a/cmd/helm/package_test.go b/cmd/helm/package_test.go deleted file mode 100644 index d7e01fb75..000000000 --- a/cmd/helm/package_test.go +++ /dev/null @@ -1,198 +0,0 @@ -/* -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 ( - "fmt" - "os" - "path/filepath" - "regexp" - "strings" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chart/loader" -) - -func TestPackage(t *testing.T) { - tests := []struct { - name string - flags map[string]string - args []string - expect string - hasfile string - err bool - }{ - { - name: "package without chart path", - args: []string{}, - flags: map[string]string{}, - expect: "need at least one argument, the path to the chart", - err: true, - }, - { - name: "package --sign, no --key", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"sign": "1"}, - expect: "key is required for signing a package", - err: true, - }, - { - name: "package --sign, no --keyring", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"sign": "1", "key": "nosuchkey", "keyring": ""}, - expect: "keyring is required for signing a package", - err: true, - }, - { - name: "package testdata/testcharts/alpine, no save", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"save": "0"}, - expect: "", - hasfile: "alpine-0.1.0.tgz", - }, - { - name: "package testdata/testcharts/alpine", - args: []string{"testdata/testcharts/alpine"}, - expect: "", - hasfile: "alpine-0.1.0.tgz", - }, - { - name: "package testdata/testcharts/issue1979", - args: []string{"testdata/testcharts/issue1979"}, - expect: "", - hasfile: "alpine-0.1.0.tgz", - }, - { - name: "package --destination toot", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"destination": "toot"}, - expect: "", - hasfile: "toot/alpine-0.1.0.tgz", - }, - { - name: "package --sign --key=KEY --keyring=KEYRING testdata/testcharts/alpine", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"sign": "1", "keyring": "testdata/helm-test-key.secret", "key": "helm-test"}, - expect: "", - hasfile: "alpine-0.1.0.tgz", - }, - { - name: "package testdata/testcharts/chart-missing-deps", - args: []string{"testdata/testcharts/chart-missing-deps"}, - hasfile: "chart-missing-deps-0.1.0.tgz", - err: true, - }, - { - name: "package testdata/testcharts/chart-bad-type", - args: []string{"testdata/testcharts/chart-bad-type"}, - err: true, - }, - } - - origDir, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cachePath := ensure.TempDir(t) - defer testChdir(t, cachePath)() - - if err := os.MkdirAll("toot", 0777); err != nil { - t.Fatal(err) - } - - // This is an unfortunate byproduct of the tmpdir - if v, ok := tt.flags["keyring"]; ok && len(v) > 0 { - tt.flags["keyring"] = filepath.Join(origDir, v) - } - - re := regexp.MustCompile(tt.expect) - - adjustedArgs := make([]string, len(tt.args)) - for i, f := range tt.args { - adjustedArgs[i] = filepath.Join(origDir, f) - } - - cmd := []string{"package"} - if len(adjustedArgs) > 0 { - cmd = append(cmd, adjustedArgs...) - } - for k, v := range tt.flags { - if v != "0" { - cmd = append(cmd, fmt.Sprintf("--%s=%s", k, v)) - } - } - _, _, err = executeActionCommand(strings.Join(cmd, " ")) - if err != nil { - if tt.err && re.MatchString(err.Error()) { - return - } - t.Fatalf("%q: expected error %q, got %q", tt.name, tt.expect, err) - } - - if len(tt.hasfile) > 0 { - if fi, err := os.Stat(tt.hasfile); err != nil { - t.Errorf("%q: expected file %q, got err %q", tt.name, tt.hasfile, err) - } else if fi.Size() == 0 { - t.Errorf("%q: file %q has zero bytes.", tt.name, tt.hasfile) - } - } - - if v, ok := tt.flags["sign"]; ok && v == "1" { - if fi, err := os.Stat(tt.hasfile + ".prov"); err != nil { - t.Errorf("%q: expected provenance file", tt.name) - } else if fi.Size() == 0 { - t.Errorf("%q: provenance file is empty", tt.name) - } - } - }) - } -} - -func TestSetAppVersion(t *testing.T) { - var ch *chart.Chart - expectedAppVersion := "app-version-foo" - chartToPackage := "testdata/testcharts/alpine" - dir := ensure.TempDir(t) - cmd := fmt.Sprintf("package %s --destination=%s --app-version=%s", chartToPackage, dir, expectedAppVersion) - _, output, err := executeActionCommand(cmd) - if err != nil { - t.Logf("Output: %s", output) - t.Fatal(err) - } - chartPath := filepath.Join(dir, "alpine-0.1.0.tgz") - if fi, err := os.Stat(chartPath); err != nil { - t.Errorf("expected file %q, got err %q", chartPath, err) - } else if fi.Size() == 0 { - t.Errorf("file %q has zero bytes.", chartPath) - } - ch, err = loader.Load(chartPath) - if err != nil { - t.Fatalf("unexpected error loading packaged chart: %v", err) - } - if ch.Metadata.AppVersion != expectedAppVersion { - t.Errorf("expected app-version %q, found %q", expectedAppVersion, ch.Metadata.AppVersion) - } -} - -func TestPackageFileCompletion(t *testing.T) { - checkFileCompletion(t, "package", true) - checkFileCompletion(t, "package mypath", true) // Multiple paths can be given -} diff --git a/cmd/helm/plugin.go b/cmd/helm/plugin.go deleted file mode 100644 index 8e1044f54..000000000 --- a/cmd/helm/plugin.go +++ /dev/null @@ -1,72 +0,0 @@ -/* -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" - "os" - "os/exec" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/pkg/plugin" -) - -const pluginHelp = ` -Manage client-side Helm plugins. -` - -func newPluginCmd(out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "plugin", - Short: "install, list, or uninstall Helm plugins", - Long: pluginHelp, - } - cmd.AddCommand( - newPluginInstallCmd(out), - newPluginListCmd(out), - newPluginUninstallCmd(out), - newPluginUpdateCmd(out), - ) - return cmd -} - -// runHook will execute a plugin hook. -func runHook(p *plugin.Plugin, event string) error { - hook := p.Metadata.Hooks[event] - if hook == "" { - return nil - } - - prog := exec.Command("sh", "-c", hook) - // TODO make this work on windows - // I think its ... ¯\_(ツ)_/¯ - // prog := exec.Command("cmd", "/C", p.Metadata.Hooks.Install()) - - debug("running %s hook: %s", event, prog) - - plugin.SetupPluginEnv(settings, p.Metadata.Name, p.Dir) - prog.Stdout, prog.Stderr = os.Stdout, os.Stderr - if err := prog.Run(); err != nil { - if eerr, ok := err.(*exec.ExitError); ok { - os.Stderr.Write(eerr.Stderr) - return errors.Errorf("plugin %s hook for %q exited with error", event, p.Metadata.Name) - } - return err - } - return nil -} diff --git a/cmd/helm/plugin_install.go b/cmd/helm/plugin_install.go deleted file mode 100644 index 4e8ee327b..000000000 --- a/cmd/helm/plugin_install.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -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 ( - "fmt" - "io" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/plugin" - "helm.sh/helm/v3/pkg/plugin/installer" -) - -type pluginInstallOptions struct { - source string - version string -} - -const pluginInstallDesc = ` -This command allows you to install a plugin from a url to a VCS repo or a local path. -` - -func newPluginInstallCmd(out io.Writer) *cobra.Command { - o := &pluginInstallOptions{} - cmd := &cobra.Command{ - Use: "install [options] ...", - Short: "install one or more Helm plugins", - Long: pluginInstallDesc, - Aliases: []string{"add"}, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - // We do file completion, in case the plugin is local - return nil, cobra.ShellCompDirectiveDefault - } - // No more completion once the plugin path has been specified - return nil, cobra.ShellCompDirectiveNoFileComp - }, - PreRunE: func(cmd *cobra.Command, args []string) error { - return o.complete(args) - }, - RunE: func(cmd *cobra.Command, args []string) error { - return o.run(out) - }, - } - cmd.Flags().StringVar(&o.version, "version", "", "specify a version constraint. If this is not specified, the latest version is installed") - return cmd -} - -func (o *pluginInstallOptions) complete(args []string) error { - o.source = args[0] - return nil -} - -func (o *pluginInstallOptions) run(out io.Writer) error { - installer.Debug = settings.Debug - - i, err := installer.NewForSource(o.source, o.version) - if err != nil { - return err - } - if err := installer.Install(i); err != nil { - return err - } - - debug("loading plugin from %s", i.Path()) - p, err := plugin.LoadDir(i.Path()) - if err != nil { - return errors.Wrap(err, "plugin is installed but unusable") - } - - if err := runHook(p, plugin.Install); err != nil { - return err - } - - fmt.Fprintf(out, "Installed plugin: %s\n", p.Metadata.Name) - return nil -} diff --git a/cmd/helm/plugin_list.go b/cmd/helm/plugin_list.go deleted file mode 100644 index ddf01f6f2..000000000 --- a/cmd/helm/plugin_list.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -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 ( - "fmt" - "io" - - "github.com/gosuri/uitable" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/pkg/plugin" -) - -func newPluginListCmd(out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "list", - Aliases: []string{"ls"}, - Short: "list installed Helm plugins", - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - debug("pluginDirs: %s", settings.PluginsDirectory) - plugins, err := plugin.FindPlugins(settings.PluginsDirectory) - if err != nil { - return err - } - - table := uitable.New() - table.AddRow("NAME", "VERSION", "DESCRIPTION") - for _, p := range plugins { - table.AddRow(p.Metadata.Name, p.Metadata.Version, p.Metadata.Description) - } - fmt.Fprintln(out, table) - return nil - }, - } - return cmd -} - -// Returns all plugins from plugins, except those with names matching ignoredPluginNames -func filterPlugins(plugins []*plugin.Plugin, ignoredPluginNames []string) []*plugin.Plugin { - // if ignoredPluginNames is nil, just return plugins - if ignoredPluginNames == nil { - return plugins - } - - var filteredPlugins []*plugin.Plugin - for _, plugin := range plugins { - found := false - for _, ignoredName := range ignoredPluginNames { - if plugin.Metadata.Name == ignoredName { - found = true - break - } - } - if !found { - filteredPlugins = append(filteredPlugins, plugin) - } - } - - return filteredPlugins -} - -// Provide dynamic auto-completion for plugin names -func compListPlugins(toComplete string, ignoredPluginNames []string) []string { - var pNames []string - plugins, err := plugin.FindPlugins(settings.PluginsDirectory) - if err == nil && len(plugins) > 0 { - filteredPlugins := filterPlugins(plugins, ignoredPluginNames) - for _, p := range filteredPlugins { - pNames = append(pNames, fmt.Sprintf("%s\t%s", p.Metadata.Name, p.Metadata.Usage)) - } - } - return pNames -} diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go deleted file mode 100644 index 33de33522..000000000 --- a/cmd/helm/plugin_test.go +++ /dev/null @@ -1,378 +0,0 @@ -/* -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 ( - "bytes" - "os" - "runtime" - "sort" - "strings" - "testing" - - "github.com/spf13/cobra" - "github.com/spf13/pflag" - - "helm.sh/helm/v3/pkg/release" -) - -func TestManuallyProcessArgs(t *testing.T) { - input := []string{ - "--debug", - "--foo", "bar", - "--kubeconfig=/home/foo", - "--kubeconfig", "/home/foo", - "--kube-context=test1", - "--kube-context", "test1", - "--kube-as-user", "pikachu", - "--kube-as-group", "teatime", - "--kube-as-group", "admins", - "-n=test2", - "-n", "test2", - "--namespace=test2", - "--namespace", "test2", - "--home=/tmp", - "command", - } - - expectKnown := []string{ - "--debug", - "--kubeconfig=/home/foo", - "--kubeconfig", "/home/foo", - "--kube-context=test1", - "--kube-context", "test1", - "--kube-as-user", "pikachu", - "--kube-as-group", "teatime", - "--kube-as-group", "admins", - "-n=test2", - "-n", "test2", - "--namespace=test2", - "--namespace", "test2", - } - - expectUnknown := []string{ - "--foo", "bar", "--home=/tmp", "command", - } - - known, unknown := manuallyProcessArgs(input) - - for i, k := range known { - if k != expectKnown[i] { - t.Errorf("expected known flag %d to be %q, got %q", i, expectKnown[i], k) - } - } - for i, k := range unknown { - if k != expectUnknown[i] { - t.Errorf("expected unknown flag %d to be %q, got %q", i, expectUnknown[i], k) - } - } - -} - -func TestLoadPlugins(t *testing.T) { - settings.PluginsDirectory = "testdata/helmhome/helm/plugins" - settings.RepositoryConfig = "testdata/helmhome/helm/repositories.yaml" - settings.RepositoryCache = "testdata/helmhome/helm/repository" - - var ( - out bytes.Buffer - cmd cobra.Command - ) - loadPlugins(&cmd, &out) - - envs := strings.Join([]string{ - "fullenv", - "testdata/helmhome/helm/plugins/fullenv", - "testdata/helmhome/helm/plugins", - "testdata/helmhome/helm/repositories.yaml", - "testdata/helmhome/helm/repository", - os.Args[0], - }, "\n") - - // Test that the YAML file was correctly converted to a command. - tests := []struct { - use string - short string - long string - expect string - args []string - code int - }{ - {"args", "echo args", "This echos args", "-a -b -c\n", []string{"-a", "-b", "-c"}, 0}, - {"echo", "echo stuff", "This echos stuff", "hello\n", []string{}, 0}, - {"env", "env stuff", "show the env", "env\n", []string{}, 0}, - {"exitwith", "exitwith code", "This exits with the specified exit code", "", []string{"2"}, 2}, - {"fullenv", "show env vars", "show all env vars", envs + "\n", []string{}, 0}, - } - - plugins := cmd.Commands() - - if len(plugins) != len(tests) { - t.Fatalf("Expected %d plugins, got %d", len(tests), len(plugins)) - } - - for i := 0; i < len(plugins); i++ { - out.Reset() - tt := tests[i] - pp := plugins[i] - if pp.Use != tt.use { - t.Errorf("%d: Expected Use=%q, got %q", i, tt.use, pp.Use) - } - if pp.Short != tt.short { - t.Errorf("%d: Expected Use=%q, got %q", i, tt.short, pp.Short) - } - if pp.Long != tt.long { - t.Errorf("%d: Expected Use=%q, got %q", i, tt.long, pp.Long) - } - - // Currently, plugins assume a Linux subsystem. Skip the execution - // tests until this is fixed - if runtime.GOOS != "windows" { - if err := pp.RunE(pp, tt.args); err != nil { - if tt.code > 0 { - perr, ok := err.(pluginError) - if !ok { - t.Errorf("Expected %s to return pluginError: got %v(%T)", tt.use, err, err) - } - if perr.code != tt.code { - t.Errorf("Expected %s to return %d: got %d", tt.use, tt.code, perr.code) - } - } else { - t.Errorf("Error running %s: %+v", tt.use, err) - } - } - if out.String() != tt.expect { - t.Errorf("Expected %s to output:\n%s\ngot\n%s", tt.use, tt.expect, out.String()) - } - } - } -} - -type staticCompletionDetails struct { - use string - validArgs []string - flags []string - next []staticCompletionDetails -} - -func TestLoadPluginsForCompletion(t *testing.T) { - settings.PluginsDirectory = "testdata/helmhome/helm/plugins" - - var out bytes.Buffer - - cmd := &cobra.Command{ - Use: "completion", - } - - loadPlugins(cmd, &out) - - tests := []staticCompletionDetails{ - {"args", []string{}, []string{}, []staticCompletionDetails{}}, - {"echo", []string{}, []string{}, []staticCompletionDetails{}}, - {"env", []string{}, []string{"global"}, []staticCompletionDetails{ - {"list", []string{}, []string{"a", "all", "log"}, []staticCompletionDetails{}}, - {"remove", []string{"all", "one"}, []string{}, []staticCompletionDetails{}}, - }}, - {"exitwith", []string{}, []string{}, []staticCompletionDetails{ - {"code", []string{}, []string{"a", "b"}, []staticCompletionDetails{}}, - }}, - {"fullenv", []string{}, []string{"q", "z"}, []staticCompletionDetails{ - {"empty", []string{}, []string{}, []staticCompletionDetails{}}, - {"full", []string{}, []string{}, []staticCompletionDetails{ - {"less", []string{}, []string{"a", "all"}, []staticCompletionDetails{}}, - {"more", []string{"one", "two"}, []string{"b", "ball"}, []staticCompletionDetails{}}, - }}, - }}, - } - checkCommand(t, cmd.Commands(), tests) -} - -func checkCommand(t *testing.T, plugins []*cobra.Command, tests []staticCompletionDetails) { - if len(plugins) != len(tests) { - t.Fatalf("Expected commands %v, got %v", tests, plugins) - } - - for i := 0; i < len(plugins); i++ { - pp := plugins[i] - tt := tests[i] - if pp.Use != tt.use { - t.Errorf("%s: Expected Use=%q, got %q", pp.Name(), tt.use, pp.Use) - } - - targs := tt.validArgs - pargs := pp.ValidArgs - if len(targs) != len(pargs) { - t.Fatalf("%s: expected args %v, got %v", pp.Name(), targs, pargs) - } - - sort.Strings(targs) - sort.Strings(pargs) - for j := range targs { - if targs[j] != pargs[j] { - t.Errorf("%s: expected validArg=%q, got %q", pp.Name(), targs[j], pargs[j]) - } - } - - tflags := tt.flags - var pflags []string - pp.LocalFlags().VisitAll(func(flag *pflag.Flag) { - pflags = append(pflags, flag.Name) - if len(flag.Shorthand) > 0 && flag.Shorthand != flag.Name { - pflags = append(pflags, flag.Shorthand) - } - }) - if len(tflags) != len(pflags) { - t.Fatalf("%s: expected flags %v, got %v", pp.Name(), tflags, pflags) - } - - sort.Strings(tflags) - sort.Strings(pflags) - for j := range tflags { - if tflags[j] != pflags[j] { - t.Errorf("%s: expected flag=%q, got %q", pp.Name(), tflags[j], pflags[j]) - } - } - // Check the next level - checkCommand(t, pp.Commands(), tt.next) - } -} - -func TestPluginDynamicCompletion(t *testing.T) { - - tests := []cmdTestCase{{ - name: "completion for plugin", - cmd: "__complete args ''", - golden: "output/plugin_args_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin with flag", - cmd: "__complete args --myflag ''", - golden: "output/plugin_args_flag_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin with global flag", - cmd: "__complete args --namespace mynamespace ''", - golden: "output/plugin_args_ns_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin with multiple args", - cmd: "__complete args --myflag --namespace mynamespace start", - golden: "output/plugin_args_many_args_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin no directive", - cmd: "__complete echo -n mynamespace ''", - golden: "output/plugin_echo_no_directive.txt", - rels: []*release.Release{}, - }} - for _, test := range tests { - settings.PluginsDirectory = "testdata/helmhome/helm/plugins" - runTestCmd(t, []cmdTestCase{test}) - } -} - -func TestLoadPlugins_HelmNoPlugins(t *testing.T) { - settings.PluginsDirectory = "testdata/helmhome/helm/plugins" - settings.RepositoryConfig = "testdata/helmhome/helm/repository" - - os.Setenv("HELM_NO_PLUGINS", "1") - - out := bytes.NewBuffer(nil) - cmd := &cobra.Command{} - loadPlugins(cmd, out) - plugins := cmd.Commands() - - if len(plugins) != 0 { - t.Fatalf("Expected 0 plugins, got %d", len(plugins)) - } -} - -func TestPluginCmdsCompletion(t *testing.T) { - - tests := []cmdTestCase{{ - name: "completion for plugin update", - cmd: "__complete plugin update ''", - golden: "output/plugin_list_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin update, no filter", - cmd: "__complete plugin update full", - golden: "output/plugin_list_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin update repetition", - cmd: "__complete plugin update args ''", - golden: "output/plugin_repeat_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin uninstall", - cmd: "__complete plugin uninstall ''", - golden: "output/plugin_list_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin uninstall, no filter", - cmd: "__complete plugin uninstall full", - golden: "output/plugin_list_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin uninstall repetition", - cmd: "__complete plugin uninstall args ''", - golden: "output/plugin_repeat_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin list", - cmd: "__complete plugin list ''", - golden: "output/empty_nofile_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin install no args", - cmd: "__complete plugin install ''", - golden: "output/empty_default_comp.txt", - rels: []*release.Release{}, - }, { - name: "completion for plugin install one arg", - cmd: "__complete plugin list /tmp ''", - golden: "output/empty_nofile_comp.txt", - rels: []*release.Release{}, - }, {}} - for _, test := range tests { - settings.PluginsDirectory = "testdata/helmhome/helm/plugins" - runTestCmd(t, []cmdTestCase{test}) - } -} - -func TestPluginFileCompletion(t *testing.T) { - checkFileCompletion(t, "plugin", false) -} - -func TestPluginInstallFileCompletion(t *testing.T) { - checkFileCompletion(t, "plugin install", true) - checkFileCompletion(t, "plugin install mypath", false) -} - -func TestPluginListFileCompletion(t *testing.T) { - checkFileCompletion(t, "plugin list", false) -} - -func TestPluginUninstallFileCompletion(t *testing.T) { - checkFileCompletion(t, "plugin uninstall", false) - checkFileCompletion(t, "plugin uninstall myplugin", false) -} - -func TestPluginUpdateFileCompletion(t *testing.T) { - checkFileCompletion(t, "plugin update", false) - checkFileCompletion(t, "plugin update myplugin", false) -} diff --git a/cmd/helm/plugin_uninstall.go b/cmd/helm/plugin_uninstall.go deleted file mode 100644 index ee4a47beb..000000000 --- a/cmd/helm/plugin_uninstall.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 ( - "fmt" - "io" - "os" - "strings" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/pkg/plugin" -) - -type pluginUninstallOptions struct { - names []string -} - -func newPluginUninstallCmd(out io.Writer) *cobra.Command { - o := &pluginUninstallOptions{} - - cmd := &cobra.Command{ - Use: "uninstall ...", - Aliases: []string{"rm", "remove"}, - Short: "uninstall one or more Helm plugins", - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compListPlugins(toComplete, args), cobra.ShellCompDirectiveNoFileComp - }, - PreRunE: func(cmd *cobra.Command, args []string) error { - return o.complete(args) - }, - RunE: func(cmd *cobra.Command, args []string) error { - return o.run(out) - }, - } - return cmd -} - -func (o *pluginUninstallOptions) complete(args []string) error { - if len(args) == 0 { - return errors.New("please provide plugin name to uninstall") - } - o.names = args - return nil -} - -func (o *pluginUninstallOptions) run(out io.Writer) error { - debug("loading installed plugins from %s", settings.PluginsDirectory) - plugins, err := plugin.FindPlugins(settings.PluginsDirectory) - if err != nil { - return err - } - var errorPlugins []string - for _, name := range o.names { - if found := findPlugin(plugins, name); found != nil { - if err := uninstallPlugin(found); err != nil { - errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to uninstall plugin %s, got error (%v)", name, err)) - } else { - fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) - } - } else { - errorPlugins = append(errorPlugins, fmt.Sprintf("Plugin: %s not found", name)) - } - } - if len(errorPlugins) > 0 { - return errors.Errorf(strings.Join(errorPlugins, "\n")) - } - return nil -} - -func uninstallPlugin(p *plugin.Plugin) error { - if err := os.RemoveAll(p.Dir); err != nil { - return err - } - return runHook(p, plugin.Delete) -} - -func findPlugin(plugins []*plugin.Plugin, name string) *plugin.Plugin { - for _, p := range plugins { - if p.Metadata.Name == name { - return p - } - } - return nil -} diff --git a/cmd/helm/plugin_update.go b/cmd/helm/plugin_update.go deleted file mode 100644 index 4515acdbb..000000000 --- a/cmd/helm/plugin_update.go +++ /dev/null @@ -1,114 +0,0 @@ -/* -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 ( - "fmt" - "io" - "path/filepath" - "strings" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/pkg/plugin" - "helm.sh/helm/v3/pkg/plugin/installer" -) - -type pluginUpdateOptions struct { - names []string -} - -func newPluginUpdateCmd(out io.Writer) *cobra.Command { - o := &pluginUpdateOptions{} - - cmd := &cobra.Command{ - Use: "update ...", - Aliases: []string{"up"}, - Short: "update one or more Helm plugins", - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compListPlugins(toComplete, args), cobra.ShellCompDirectiveNoFileComp - }, - PreRunE: func(cmd *cobra.Command, args []string) error { - return o.complete(args) - }, - RunE: func(cmd *cobra.Command, args []string) error { - return o.run(out) - }, - } - return cmd -} - -func (o *pluginUpdateOptions) complete(args []string) error { - if len(args) == 0 { - return errors.New("please provide plugin name to update") - } - o.names = args - return nil -} - -func (o *pluginUpdateOptions) run(out io.Writer) error { - installer.Debug = settings.Debug - debug("loading installed plugins from %s", settings.PluginsDirectory) - plugins, err := plugin.FindPlugins(settings.PluginsDirectory) - if err != nil { - return err - } - var errorPlugins []string - - for _, name := range o.names { - if found := findPlugin(plugins, name); found != nil { - if err := updatePlugin(found); err != nil { - errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to update plugin %s, got error (%v)", name, err)) - } else { - fmt.Fprintf(out, "Updated plugin: %s\n", name) - } - } else { - errorPlugins = append(errorPlugins, fmt.Sprintf("Plugin: %s not found", name)) - } - } - if len(errorPlugins) > 0 { - return errors.Errorf(strings.Join(errorPlugins, "\n")) - } - return nil -} - -func updatePlugin(p *plugin.Plugin) error { - exactLocation, err := filepath.EvalSymlinks(p.Dir) - if err != nil { - return err - } - absExactLocation, err := filepath.Abs(exactLocation) - if err != nil { - return err - } - - i, err := installer.FindSource(absExactLocation) - if err != nil { - return err - } - if err := installer.Update(i); err != nil { - return err - } - - debug("loading plugin from %s", i.Path()) - updatedPlugin, err := plugin.LoadDir(i.Path()) - if err != nil { - return err - } - - return runHook(updatedPlugin, plugin.Update) -} diff --git a/cmd/helm/printer.go b/cmd/helm/printer.go deleted file mode 100644 index 7cf7bf994..000000000 --- a/cmd/helm/printer.go +++ /dev/null @@ -1,30 +0,0 @@ -/* -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" - "text/template" -) - -func tpl(t string, vals map[string]interface{}, out io.Writer) error { - tt, err := template.New("_").Parse(t) - if err != nil { - return err - } - return tt.Execute(out, vals) -} diff --git a/cmd/helm/pull.go b/cmd/helm/pull.go deleted file mode 100644 index 378301196..000000000 --- a/cmd/helm/pull.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const pullDesc = ` -Retrieve a package from a package repository, and download it locally. - -This is useful for fetching packages to inspect, modify, or repackage. It can -also be used to perform cryptographic verification of a chart without installing -the chart. - -There are options for unpacking the chart after download. This will create a -directory for the chart and uncompress into that directory. - -If the --verify flag is specified, the requested chart MUST have a provenance -file, and MUST pass the verification process. Failure in any part of this will -result in an error, and the chart will not be saved locally. -` - -func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewPullWithOpts(action.WithConfig(cfg)) - - cmd := &cobra.Command{ - Use: "pull [chart URL | repo/chartname] [...]", - Short: "download a chart from a repository and (optionally) unpack it in local directory", - Aliases: []string{"fetch"}, - Long: pullDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListCharts(toComplete, false) - }, - RunE: func(cmd *cobra.Command, args []string) error { - client.Settings = settings - if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") - client.Version = ">0.0.0-0" - } - - for i := 0; i < len(args); i++ { - output, err := client.Run(args[i]) - if err != nil { - return err - } - fmt.Fprint(out, output) - } - return nil - }, - } - - f := cmd.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.Untar, "untar", false, "if set to true, will untar the chart after downloading it") - 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") - addChartPathOptionsFlags(f, &client.ChartPathOptions) - - err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 1 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compVersionFlag(args[0], toComplete) - }) - - if err != nil { - log.Fatal(err) - } - - return cmd -} diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go deleted file mode 100644 index 41ac237f4..000000000 --- a/cmd/helm/pull_test.go +++ /dev/null @@ -1,396 +0,0 @@ -/* -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 ( - "fmt" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "testing" - - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestPullCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - - ociSrv, err := repotest.NewOCIServer(t, srv.Root()) - if err != nil { - t.Fatal(err) - } - ociSrv.Run(t) - - if err := srv.LinkIndices(); err != nil { - t.Fatal(err) - } - - helmTestKeyOut := "Signed by: Helm Testing (This key should only be used for testing. DO NOT TRUST.) \n" + - "Using Key With Fingerprint: 5E615389B53CA37F0EE60BD3843BBF981FC18762\n" + - "Chart Hash Verified: " - - // all flags will get "-d outdir" appended. - tests := []struct { - name string - args string - existFile string - existDir string - wantError bool - wantErrorMsg string - failExpect string - expectFile string - expectDir bool - expectVerify bool - expectSha string - }{ - { - name: "Basic chart fetch", - args: "test/signtest", - expectFile: "./signtest-0.1.0.tgz", - }, - { - name: "Chart fetch with version", - args: "test/signtest --version=0.1.0", - expectFile: "./signtest-0.1.0.tgz", - }, - { - name: "Fail chart fetch with non-existent version", - args: "test/signtest --version=99.1.0", - wantError: true, - failExpect: "no such chart", - }, - { - name: "Fail fetching non-existent chart", - args: "test/nosuchthing", - failExpect: "Failed to fetch", - wantError: true, - }, - { - name: "Fetch and verify", - args: "test/signtest --verify --keyring testdata/helm-test-key.pub", - expectFile: "./signtest-0.1.0.tgz", - expectVerify: true, - expectSha: "sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55", - }, - { - name: "Fetch and fail verify", - args: "test/reqtest --verify --keyring testdata/helm-test-key.pub", - failExpect: "Failed to fetch provenance", - wantError: true, - }, - { - name: "Fetch and untar", - args: "test/signtest --untar --untardir signtest", - expectFile: "./signtest", - expectDir: true, - }, - { - name: "Fetch untar when file with same name existed", - args: "test/test1 --untar --untardir test1", - existFile: "test1", - wantError: true, - wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "test1")), - }, - { - name: "Fetch untar when dir with same name existed", - args: "test/test2 --untar --untardir test2", - existDir: "test2", - wantError: true, - wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "test2")), - }, - { - name: "Fetch, verify, untar", - args: "test/signtest --verify --keyring=testdata/helm-test-key.pub --untar --untardir signtest2", - expectFile: "./signtest2", - expectDir: true, - expectVerify: true, - expectSha: "sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55", - }, - { - name: "Chart fetch using repo URL", - expectFile: "./signtest-0.1.0.tgz", - args: "signtest --repo " + srv.URL(), - }, - { - name: "Fail fetching non-existent chart on repo URL", - args: "someChart --repo " + srv.URL(), - failExpect: "Failed to fetch chart", - wantError: true, - }, - { - name: "Specific version chart fetch using repo URL", - expectFile: "./signtest-0.1.0.tgz", - args: "signtest --version=0.1.0 --repo " + srv.URL(), - }, - { - name: "Specific version chart fetch using repo URL", - args: "signtest --version=0.2.0 --repo " + srv.URL(), - failExpect: "Failed to fetch chart version", - wantError: true, - }, - { - name: "Fetch OCI Chart", - args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart --version 0.1.0", ociSrv.RegistryURL), - expectFile: "./oci-dependent-chart-0.1.0.tgz", - }, - { - name: "Fetch OCI Chart with untar", - args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart --version 0.1.0 --untar", ociSrv.RegistryURL), - expectFile: "./oci-dependent-chart", - expectDir: true, - }, - { - name: "Fetch OCI Chart with untar and untardir", - args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart --version 0.1.0 --untar --untardir ocitest2", ociSrv.RegistryURL), - expectFile: "./ocitest2", - expectDir: true, - }, - { - name: "OCI Fetch untar when dir with same name existed", - args: fmt.Sprintf("oci-test-chart oci://%s/u/ocitestuser/oci-dependent-chart --version 0.1.0 --untar --untardir ocitest2 --untar --untardir ocitest2", ociSrv.RegistryURL), - wantError: true, - wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "ocitest2")), - }, - { - name: "Fail fetching non-existent OCI chart", - args: fmt.Sprintf("oci://%s/u/ocitestuser/nosuchthing --version 0.1.0", ociSrv.RegistryURL), - failExpect: "Failed to fetch", - wantError: true, - }, - { - name: "Fail fetching OCI chart without version specified", - args: fmt.Sprintf("oci://%s/u/ocitestuser/nosuchthing", ociSrv.RegistryURL), - wantErrorMsg: "Error: --version flag is explicitly required for OCI registries", - wantError: true, - }, - { - name: "Fail fetching OCI chart without version specified", - args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart:0.1.0", ociSrv.RegistryURL), - wantErrorMsg: "Error: --version flag is explicitly required for OCI registries", - wantError: true, - }, - { - name: "Fail fetching OCI chart without version specified", - args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart:0.1.0 --version 0.1.0", ociSrv.RegistryURL), - wantError: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - outdir := srv.Root() - cmd := fmt.Sprintf("fetch %s -d '%s' --repository-config %s --repository-cache %s --registry-config %s", - tt.args, - outdir, - filepath.Join(outdir, "repositories.yaml"), - outdir, - filepath.Join(outdir, "config.json"), - ) - // Create file or Dir before helm pull --untar, see: https://github.com/helm/helm/issues/7182 - if tt.existFile != "" { - file := filepath.Join(outdir, tt.existFile) - _, err := os.Create(file) - if err != nil { - t.Fatal(err) - } - } - if tt.existDir != "" { - file := filepath.Join(outdir, tt.existDir) - err := os.Mkdir(file, 0755) - if err != nil { - t.Fatal(err) - } - } - _, out, err := executeActionCommand(cmd) - if err != nil { - if tt.wantError { - if tt.wantErrorMsg != "" && tt.wantErrorMsg == err.Error() { - t.Fatalf("Actual error %s, not equal to expected error %s", err, tt.wantErrorMsg) - } - return - } - t.Fatalf("%q reported error: %s", tt.name, err) - } - - if tt.expectVerify { - outString := helmTestKeyOut + tt.expectSha + "\n" - if out != outString { - t.Errorf("%q: expected verification output %q, got %q", tt.name, outString, out) - } - - } - - ef := filepath.Join(outdir, tt.expectFile) - fi, err := os.Stat(ef) - if err != nil { - t.Errorf("%q: expected a file at %s. %s", tt.name, ef, err) - } - if fi.IsDir() != tt.expectDir { - t.Errorf("%q: expected directory=%t, but it's not.", tt.name, tt.expectDir) - } - }) - } -} - -func TestPullWithCredentialsCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - - srv.WithMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - username, password, ok := r.BasicAuth() - if !ok || username != "username" || password != "password" { - t.Errorf("Expected request to use basic auth and for username == 'username' and password == 'password', got '%v', '%s', '%s'", ok, username, password) - } - })) - - srv2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.FileServer(http.Dir(srv.Root())).ServeHTTP(w, r) - })) - defer srv2.Close() - - if err := srv.LinkIndices(); err != nil { - t.Fatal(err) - } - - // all flags will get "-d outdir" appended. - tests := []struct { - name string - args string - existFile string - existDir string - wantError bool - wantErrorMsg string - expectFile string - expectDir bool - }{ - { - name: "Chart fetch using repo URL", - expectFile: "./signtest-0.1.0.tgz", - args: "signtest --repo " + srv.URL() + " --username username --password password", - }, - { - name: "Fail fetching non-existent chart on repo URL", - args: "someChart --repo " + srv.URL() + " --username username --password password", - wantError: true, - }, - { - name: "Specific version chart fetch using repo URL", - expectFile: "./signtest-0.1.0.tgz", - args: "signtest --version=0.1.0 --repo " + srv.URL() + " --username username --password password", - }, - { - name: "Specific version chart fetch using repo URL", - args: "signtest --version=0.2.0 --repo " + srv.URL() + " --username username --password password", - wantError: true, - }, - { - name: "Chart located on different domain with credentials passed", - args: "reqtest --repo " + srv2.URL + " --username username --password password --pass-credentials", - expectFile: "./reqtest-0.1.0.tgz", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - outdir := srv.Root() - cmd := fmt.Sprintf("pull %s -d '%s' --repository-config %s --repository-cache %s --registry-config %s", - tt.args, - outdir, - filepath.Join(outdir, "repositories.yaml"), - outdir, - filepath.Join(outdir, "config.json"), - ) - // Create file or Dir before helm pull --untar, see: https://github.com/helm/helm/issues/7182 - if tt.existFile != "" { - file := filepath.Join(outdir, tt.existFile) - _, err := os.Create(file) - if err != nil { - t.Fatal(err) - } - } - if tt.existDir != "" { - file := filepath.Join(outdir, tt.existDir) - err := os.Mkdir(file, 0755) - if err != nil { - t.Fatal(err) - } - } - _, _, err := executeActionCommand(cmd) - if err != nil { - if tt.wantError { - if tt.wantErrorMsg != "" && tt.wantErrorMsg == err.Error() { - t.Fatalf("Actual error %s, not equal to expected error %s", err, tt.wantErrorMsg) - } - return - } - t.Fatalf("%q reported error: %s", tt.name, err) - } - - ef := filepath.Join(outdir, tt.expectFile) - fi, err := os.Stat(ef) - if err != nil { - t.Errorf("%q: expected a file at %s. %s", tt.name, ef, err) - } - if fi.IsDir() != tt.expectDir { - t.Errorf("%q: expected directory=%t, but it's not.", tt.name, tt.expectDir) - } - }) - } -} - -func TestPullVersionCompletion(t *testing.T) { - repoFile := "testdata/helmhome/helm/repositories.yaml" - repoCache := "testdata/helmhome/helm/repository" - - repoSetup := fmt.Sprintf("--repository-config %s --repository-cache %s", repoFile, repoCache) - - tests := []cmdTestCase{{ - name: "completion for pull version flag", - cmd: fmt.Sprintf("%s __complete pull testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for pull version flag, no filter", - cmd: fmt.Sprintf("%s __complete pull testing/alpine --version 0.3", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for pull version flag too few args", - cmd: fmt.Sprintf("%s __complete pull --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for pull version flag too many args", - cmd: fmt.Sprintf("%s __complete pull testing/alpine badarg --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for pull version flag invalid chart", - cmd: fmt.Sprintf("%s __complete pull invalid/invalid --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestPullFileCompletion(t *testing.T) { - checkFileCompletion(t, "pull", false) - checkFileCompletion(t, "pull repo/chart", false) -} diff --git a/cmd/helm/push.go b/cmd/helm/push.go deleted file mode 100644 index d2cf2693e..000000000 --- a/cmd/helm/push.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -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 ( - "fmt" - "io" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/pusher" -) - -const pushDesc = ` -Upload a chart to a registry. - -If the chart has an associated provenance file, -it will also be uploaded. -` - -func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewPushWithOpts(action.WithPushConfig(cfg)) - - cmd := &cobra.Command{ - Use: "push [chart] [remote]", - Short: "push a chart to remote", - Long: pushDesc, - Args: require.MinimumNArgs(2), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - // Do file completion for the chart file to push - return nil, cobra.ShellCompDirectiveDefault - } - if len(args) == 1 { - providers := []pusher.Provider(pusher.All(settings)) - var comps []string - for _, p := range providers { - for _, scheme := range p.Schemes { - comps = append(comps, fmt.Sprintf("%s://", scheme)) - } - } - return comps, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveNoSpace - } - return nil, cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - chartRef := args[0] - remote := args[1] - client.Settings = settings - output, err := client.Run(chartRef, remote) - if err != nil { - return err - } - fmt.Fprint(out, output) - return nil - }, - } - - return cmd -} diff --git a/cmd/helm/push_test.go b/cmd/helm/push_test.go deleted file mode 100644 index 8e56d99dc..000000000 --- a/cmd/helm/push_test.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -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 ( - "testing" -) - -func TestPushFileCompletion(t *testing.T) { - checkFileCompletion(t, "push", true) - checkFileCompletion(t, "push package.tgz", false) - checkFileCompletion(t, "push package.tgz oci://localhost:5000", false) -} diff --git a/cmd/helm/registry.go b/cmd/helm/registry.go deleted file mode 100644 index b2b24cd14..000000000 --- a/cmd/helm/registry.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -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/v3/pkg/action" -) - -const registryHelp = ` -This command consists of multiple subcommands to interact with registries. -` - -func newRegistryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "registry", - Short: "login to or logout from a registry", - Long: registryHelp, - } - cmd.AddCommand( - newRegistryLoginCmd(cfg, out), - newRegistryLogoutCmd(cfg, out), - ) - return cmd -} diff --git a/cmd/helm/registry_login.go b/cmd/helm/registry_login.go deleted file mode 100644 index 6b1fed589..000000000 --- a/cmd/helm/registry_login.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -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 ( - "bufio" - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "strings" - - "github.com/moby/term" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const registryLoginDesc = ` -Authenticate to a remote registry. -` - -func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - var usernameOpt, passwordOpt string - var passwordFromStdinOpt, insecureOpt bool - - cmd := &cobra.Command{ - Use: "login [host]", - Short: "login to a registry", - Long: registryLoginDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - hostname := args[0] - - username, password, err := getUsernamePassword(usernameOpt, passwordOpt, passwordFromStdinOpt) - if err != nil { - return err - } - - return action.NewRegistryLogin(cfg).Run(out, hostname, username, password, insecureOpt) - }, - } - - f := cmd.Flags() - f.StringVarP(&usernameOpt, "username", "u", "", "registry username") - f.StringVarP(&passwordOpt, "password", "p", "", "registry password or identity token") - f.BoolVarP(&passwordFromStdinOpt, "password-stdin", "", false, "read password or identity token from stdin") - f.BoolVarP(&insecureOpt, "insecure", "", false, "allow connections to TLS registry without certs") - - return cmd -} - -// Adapted from https://github.com/oras-project/oras -func getUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStdinOpt bool) (string, string, error) { - var err error - username := usernameOpt - password := passwordOpt - - if passwordFromStdinOpt { - passwordFromStdin, err := ioutil.ReadAll(os.Stdin) - if err != nil { - return "", "", err - } - password = strings.TrimSuffix(string(passwordFromStdin), "\n") - password = strings.TrimSuffix(password, "\r") - } else if password == "" { - if username == "" { - username, err = readLine("Username: ", false) - if err != nil { - return "", "", err - } - username = strings.TrimSpace(username) - } - if username == "" { - password, err = readLine("Token: ", true) - if err != nil { - return "", "", err - } else if password == "" { - return "", "", errors.New("token required") - } - } else { - password, err = readLine("Password: ", true) - if err != nil { - return "", "", err - } else if password == "" { - return "", "", errors.New("password required") - } - } - } else { - warning("Using --password via the CLI is insecure. Use --password-stdin.") - } - - return username, password, nil -} - -// Copied/adapted from https://github.com/oras-project/oras -func readLine(prompt string, silent bool) (string, error) { - fmt.Print(prompt) - if silent { - fd := os.Stdin.Fd() - state, err := term.SaveState(fd) - if err != nil { - return "", err - } - term.DisableEcho(fd, state) - defer term.RestoreTerminal(fd, state) - } - - reader := bufio.NewReader(os.Stdin) - line, _, err := reader.ReadLine() - if err != nil { - return "", err - } - if silent { - fmt.Println() - } - - return string(line), nil -} diff --git a/cmd/helm/registry_login_test.go b/cmd/helm/registry_login_test.go deleted file mode 100644 index 517fe08e1..000000000 --- a/cmd/helm/registry_login_test.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -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 ( - "testing" -) - -func TestRegistryLoginFileCompletion(t *testing.T) { - checkFileCompletion(t, "registry login", false) -} diff --git a/cmd/helm/registry_logout.go b/cmd/helm/registry_logout.go deleted file mode 100644 index 0084f8c09..000000000 --- a/cmd/helm/registry_logout.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -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/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const registryLogoutDesc = ` -Remove credentials stored for a remote registry. -` - -func newRegistryLogoutCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - return &cobra.Command{ - Use: "logout [host]", - Short: "logout from a registry", - Long: registryLogoutDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - hostname := args[0] - return action.NewRegistryLogout(cfg).Run(out, hostname) - }, - } -} diff --git a/cmd/helm/registry_logout_test.go b/cmd/helm/registry_logout_test.go deleted file mode 100644 index 31f716725..000000000 --- a/cmd/helm/registry_logout_test.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -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 ( - "testing" -) - -func TestRegistryLogoutFileCompletion(t *testing.T) { - checkFileCompletion(t, "registry logout", false) -} diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go deleted file mode 100644 index 2637cbb9f..000000000 --- a/cmd/helm/release_testing.go +++ /dev/null @@ -1,97 +0,0 @@ -/* -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 ( - "fmt" - "io" - "regexp" - "strings" - "time" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/output" -) - -const releaseTestHelp = ` -The test command runs the tests for a release. - -The argument this command takes is the name of a deployed release. -The tests to be run are defined in the chart that was installed. -` - -func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewReleaseTesting(cfg) - var outfmt = output.Table - var outputLogs bool - var filter []string - - cmd := &cobra.Command{ - Use: "test [RELEASE]", - Short: "run tests for a release", - Long: releaseTestHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - client.Namespace = settings.Namespace() - notName := regexp.MustCompile(`^!\s?name=`) - for _, f := range filter { - if strings.HasPrefix(f, "name=") { - client.Filters["name"] = append(client.Filters["name"], strings.TrimPrefix(f, "name=")) - } else if notName.MatchString(f) { - client.Filters["!name"] = append(client.Filters["!name"], notName.ReplaceAllLiteralString(f, "")) - } - } - rel, runErr := client.Run(args[0]) - // We only return an error if we weren't even able to get the - // release, otherwise we keep going so we can print status and logs - // if requested - if runErr != nil && rel == nil { - return runErr - } - - if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug, false}); err != nil { - return err - } - - if outputLogs { - // Print a newline to stdout to separate the output - fmt.Fprintln(out) - if err := client.GetPodLogs(out, rel); err != nil { - return err - } - } - - return runErr - }, - } - - f := cmd.Flags() - f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&outputLogs, "logs", false, "dump the logs from test pods (this runs after all tests are complete, but before any cleanup)") - f.StringSliceVar(&filter, "filter", []string{}, "specify tests by attribute (currently \"name\") using attribute=value syntax or '!attribute=value' to exclude a test (can specify multiple or separate values with commas: name=test1,name=test2)") - - return cmd -} diff --git a/cmd/helm/release_testing_test.go b/cmd/helm/release_testing_test.go deleted file mode 100644 index 680a9bd3e..000000000 --- a/cmd/helm/release_testing_test.go +++ /dev/null @@ -1,30 +0,0 @@ -/* -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 ( - "testing" -) - -func TestReleaseTestingCompletion(t *testing.T) { - checkReleaseCompletion(t, "test", false) -} - -func TestReleaseTestingFileCompletion(t *testing.T) { - checkFileCompletion(t, "test", false) - checkFileCompletion(t, "test myrelease", false) -} diff --git a/cmd/helm/repo.go b/cmd/helm/repo.go deleted file mode 100644 index ad6ceaa8f..000000000 --- a/cmd/helm/repo.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -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" - "os" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" -) - -var repoHelm = ` -This command consists of multiple subcommands to interact with chart repositories. - -It can be used to add, remove, list, and index chart repositories. -` - -func newRepoCmd(out io.Writer) *cobra.Command { - cmd := &cobra.Command{ - Use: "repo add|remove|list|index|update [ARGS]", - Short: "add, list, remove, update, and index chart repositories", - Long: repoHelm, - Args: require.NoArgs, - } - - cmd.AddCommand(newRepoAddCmd(out)) - cmd.AddCommand(newRepoListCmd(out)) - cmd.AddCommand(newRepoRemoveCmd(out)) - cmd.AddCommand(newRepoIndexCmd(out)) - cmd.AddCommand(newRepoUpdateCmd(out)) - - return cmd -} - -func isNotExist(err error) bool { - return os.IsNotExist(errors.Cause(err)) -} diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go deleted file mode 100644 index e13df7ad8..000000000 --- a/cmd/helm/repo_add.go +++ /dev/null @@ -1,221 +0,0 @@ -/* -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 ( - "context" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - "time" - - "github.com/gofrs/flock" - "github.com/pkg/errors" - "github.com/spf13/cobra" - "golang.org/x/term" - "sigs.k8s.io/yaml" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/getter" - "helm.sh/helm/v3/pkg/repo" -) - -// Repositories that have been permanently deleted and no longer work -var deprecatedRepos = map[string]string{ - "//kubernetes-charts.storage.googleapis.com": "https://charts.helm.sh/stable", - "//kubernetes-charts-incubator.storage.googleapis.com": "https://charts.helm.sh/incubator", -} - -type repoAddOptions struct { - name string - url string - username string - password string - passwordFromStdinOpt bool - passCredentialsAll bool - forceUpdate bool - allowDeprecatedRepos bool - - certFile string - keyFile string - caFile string - insecureSkipTLSverify bool - - repoFile string - repoCache string - - // Deprecated, but cannot be removed until Helm 4 - deprecatedNoUpdate bool -} - -func newRepoAddCmd(out io.Writer) *cobra.Command { - o := &repoAddOptions{} - - cmd := &cobra.Command{ - Use: "add [NAME] [URL]", - Short: "add a chart repository", - Args: require.ExactArgs(2), - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - o.name = args[0] - o.url = args[1] - o.repoFile = settings.RepositoryConfig - o.repoCache = settings.RepositoryCache - - return o.run(out) - }, - } - - f := cmd.Flags() - f.StringVar(&o.username, "username", "", "chart repository username") - f.StringVar(&o.password, "password", "", "chart repository password") - f.BoolVarP(&o.passwordFromStdinOpt, "password-stdin", "", false, "read chart repository password from stdin") - f.BoolVar(&o.forceUpdate, "force-update", false, "replace (overwrite) the repo if it already exists") - f.BoolVar(&o.deprecatedNoUpdate, "no-update", false, "Ignored. Formerly, it would disabled forced updates. It is deprecated by force-update.") - f.StringVar(&o.certFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") - f.StringVar(&o.keyFile, "key-file", "", "identify HTTPS 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 repository") - f.BoolVar(&o.allowDeprecatedRepos, "allow-deprecated-repos", false, "by default, this command will not allow adding official repos that have been permanently deleted. This disables that behavior") - f.BoolVar(&o.passCredentialsAll, "pass-credentials", false, "pass credentials to all domains") - - return cmd -} - -func (o *repoAddOptions) run(out io.Writer) error { - // Block deprecated repos - if !o.allowDeprecatedRepos { - for oldURL, newURL := range deprecatedRepos { - if strings.Contains(o.url, oldURL) { - return fmt.Errorf("repo %q is no longer available; try %q instead", o.url, newURL) - } - } - } - - // Ensure the file directory exists as it is required for file locking - err := os.MkdirAll(filepath.Dir(o.repoFile), os.ModePerm) - if err != nil && !os.IsExist(err) { - return err - } - - // Acquire a file lock for process synchronization - repoFileExt := filepath.Ext(o.repoFile) - var lockPath string - if len(repoFileExt) > 0 && len(repoFileExt) < len(o.repoFile) { - lockPath = strings.TrimSuffix(o.repoFile, repoFileExt) + ".lock" - } else { - lockPath = o.repoFile + ".lock" - } - fileLock := flock.New(lockPath) - lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) - defer cancel() - locked, err := fileLock.TryLockContext(lockCtx, time.Second) - if err == nil && locked { - defer fileLock.Unlock() - } - if err != nil { - return err - } - - b, err := ioutil.ReadFile(o.repoFile) - if err != nil && !os.IsNotExist(err) { - return err - } - - var f repo.File - if err := yaml.Unmarshal(b, &f); err != nil { - return err - } - - if o.username != "" && o.password == "" { - if o.passwordFromStdinOpt { - passwordFromStdin, err := io.ReadAll(os.Stdin) - if err != nil { - return err - } - password := strings.TrimSuffix(string(passwordFromStdin), "\n") - password = strings.TrimSuffix(password, "\r") - o.password = password - } else { - fd := int(os.Stdin.Fd()) - fmt.Fprint(out, "Password: ") - password, err := term.ReadPassword(fd) - fmt.Fprintln(out) - if err != nil { - return err - } - o.password = string(password) - } - } - - c := repo.Entry{ - Name: o.name, - URL: o.url, - Username: o.username, - Password: o.password, - PassCredentialsAll: o.passCredentialsAll, - CertFile: o.certFile, - KeyFile: o.keyFile, - CAFile: o.caFile, - InsecureSkipTLSverify: o.insecureSkipTLSverify, - } - - // Check if the repo name is legal - if strings.Contains(o.name, "/") { - return errors.Errorf("repository name (%s) contains '/', please specify a different name without '/'", o.name) - } - - // If the repo exists do one of two things: - // 1. If the configuration for the name is the same continue without error - // 2. When the config is different require --force-update - if !o.forceUpdate && f.Has(o.name) { - existing := f.Get(o.name) - if c != *existing { - - // The input coming in for the name is different from what is already - // configured. Return an error. - return errors.Errorf("repository name (%s) already exists, please specify a different name", o.name) - } - - // The add is idempotent so do nothing - fmt.Fprintf(out, "%q already exists with the same configuration, skipping\n", o.name) - return nil - } - - r, err := repo.NewChartRepository(&c, getter.All(settings)) - if err != nil { - return err - } - - if o.repoCache != "" { - r.CachePath = o.repoCache - } - if _, err := r.DownloadIndexFile(); err != nil { - return errors.Wrapf(err, "looks like %q is not a valid chart repository or cannot be reached", o.url) - } - - f.Update(&c) - - if err := f.WriteFile(o.repoFile, 0644); err != nil { - return err - } - fmt.Fprintf(out, "%q has been added to your repositories\n", o.name) - return nil -} diff --git a/cmd/helm/repo_add_test.go b/cmd/helm/repo_add_test.go deleted file mode 100644 index f9b0cab00..000000000 --- a/cmd/helm/repo_add_test.go +++ /dev/null @@ -1,274 +0,0 @@ -/* -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 ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - "sync" - "testing" - - "sigs.k8s.io/yaml" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/helmpath/xdg" - "helm.sh/helm/v3/pkg/repo" - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestRepoAddCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - - // A second test server is setup to verify URL changing - srv2, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer srv2.Stop() - - tmpdir := filepath.Join(ensure.TempDir(t), "path-component.yaml/data") - err = os.MkdirAll(tmpdir, 0777) - if err != nil { - t.Fatal(err) - } - repoFile := filepath.Join(tmpdir, "repositories.yaml") - - tests := []cmdTestCase{ - { - name: "add a repository", - cmd: fmt.Sprintf("repo add test-name %s --repository-config %s --repository-cache %s", srv.URL(), repoFile, tmpdir), - golden: "output/repo-add.txt", - }, - { - name: "add repository second time", - cmd: fmt.Sprintf("repo add test-name %s --repository-config %s --repository-cache %s", srv.URL(), repoFile, tmpdir), - golden: "output/repo-add2.txt", - }, - { - name: "add repository different url", - cmd: fmt.Sprintf("repo add test-name %s --repository-config %s --repository-cache %s", srv2.URL(), repoFile, tmpdir), - wantError: true, - }, - { - name: "add repository second time", - cmd: fmt.Sprintf("repo add test-name %s --repository-config %s --repository-cache %s --force-update", srv2.URL(), repoFile, tmpdir), - golden: "output/repo-add.txt", - }, - } - - runTestCmd(t, tests) -} - -func TestRepoAdd(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - rootDir := ensure.TempDir(t) - repoFile := filepath.Join(rootDir, "repositories.yaml") - - const testRepoName = "test-name" - - o := &repoAddOptions{ - name: testRepoName, - url: ts.URL(), - forceUpdate: false, - deprecatedNoUpdate: true, - repoFile: repoFile, - } - os.Setenv(xdg.CacheHomeEnvVar, rootDir) - - if err := o.run(ioutil.Discard); err != nil { - t.Error(err) - } - - f, err := repo.LoadFile(repoFile) - if err != nil { - t.Fatal(err) - } - - if !f.Has(testRepoName) { - t.Errorf("%s was not successfully inserted into %s", testRepoName, repoFile) - } - - idx := filepath.Join(helmpath.CachePath("repository"), helmpath.CacheIndexFile(testRepoName)) - if _, err := os.Stat(idx); os.IsNotExist(err) { - t.Errorf("Error cache index file was not created for repository %s", testRepoName) - } - idx = filepath.Join(helmpath.CachePath("repository"), helmpath.CacheChartsFile(testRepoName)) - if _, err := os.Stat(idx); os.IsNotExist(err) { - t.Errorf("Error cache charts file was not created for repository %s", testRepoName) - } - - o.forceUpdate = true - - if err := o.run(ioutil.Discard); err != nil { - t.Errorf("Repository was not updated: %s", err) - } - - if err := o.run(ioutil.Discard); err != nil { - t.Errorf("Duplicate repository name was added") - } -} - -func TestRepoAddCheckLegalName(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - defer resetEnv()() - - const testRepoName = "test-hub/test-name" - - rootDir := ensure.TempDir(t) - repoFile := filepath.Join(ensure.TempDir(t), "repositories.yaml") - - o := &repoAddOptions{ - name: testRepoName, - url: ts.URL(), - forceUpdate: false, - deprecatedNoUpdate: true, - repoFile: repoFile, - } - os.Setenv(xdg.CacheHomeEnvVar, rootDir) - - wantErrorMsg := fmt.Sprintf("repository name (%s) contains '/', please specify a different name without '/'", testRepoName) - - if err := o.run(ioutil.Discard); err != nil { - if wantErrorMsg != err.Error() { - t.Fatalf("Actual error %s, not equal to expected error %s", err, wantErrorMsg) - } - } else { - t.Fatalf("expect reported an error.") - } -} - -func TestRepoAddConcurrentGoRoutines(t *testing.T) { - const testName = "test-name" - repoFile := filepath.Join(ensure.TempDir(t), "repositories.yaml") - repoAddConcurrent(t, testName, repoFile) -} - -func TestRepoAddConcurrentDirNotExist(t *testing.T) { - const testName = "test-name-2" - repoFile := filepath.Join(ensure.TempDir(t), "foo", "repositories.yaml") - repoAddConcurrent(t, testName, repoFile) -} - -func TestRepoAddConcurrentNoFileExtension(t *testing.T) { - const testName = "test-name-3" - repoFile := filepath.Join(ensure.TempDir(t), "repositories") - repoAddConcurrent(t, testName, repoFile) -} - -func TestRepoAddConcurrentHiddenFile(t *testing.T) { - const testName = "test-name-4" - repoFile := filepath.Join(ensure.TempDir(t), ".repositories") - repoAddConcurrent(t, testName, repoFile) -} - -func repoAddConcurrent(t *testing.T, testName, repoFile string) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - var wg sync.WaitGroup - wg.Add(3) - for i := 0; i < 3; i++ { - go func(name string) { - defer wg.Done() - o := &repoAddOptions{ - name: name, - url: ts.URL(), - deprecatedNoUpdate: true, - forceUpdate: false, - repoFile: repoFile, - } - if err := o.run(ioutil.Discard); err != nil { - t.Error(err) - } - }(fmt.Sprintf("%s-%d", testName, i)) - } - wg.Wait() - - b, err := ioutil.ReadFile(repoFile) - if err != nil { - t.Error(err) - } - - var f repo.File - if err := yaml.Unmarshal(b, &f); err != nil { - t.Error(err) - } - - var name string - for i := 0; i < 3; i++ { - name = fmt.Sprintf("%s-%d", testName, i) - if !f.Has(name) { - t.Errorf("%s was not successfully inserted into %s: %s", name, repoFile, f.Repositories[0]) - } - } -} - -func TestRepoAddFileCompletion(t *testing.T) { - checkFileCompletion(t, "repo add", false) - checkFileCompletion(t, "repo add reponame", false) - checkFileCompletion(t, "repo add reponame https://example.com", false) -} - -func TestRepoAddWithPasswordFromStdin(t *testing.T) { - srv := repotest.NewTempServerWithCleanupAndBasicAuth(t, "testdata/testserver/*.*") - defer srv.Stop() - - defer resetEnv()() - - in, err := os.Open("testdata/password") - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - tmpdir := ensure.TempDir(t) - repoFile := filepath.Join(tmpdir, "repositories.yaml") - - store := storageFixture() - - const testName = "test-name" - const username = "username" - cmd := fmt.Sprintf("repo add %s %s --repository-config %s --repository-cache %s --username %s --password-stdin", testName, srv.URL(), repoFile, tmpdir, username) - var result string - _, result, err = executeActionCommandStdinC(store, in, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(result, fmt.Sprintf("\"%s\" has been added to your repositories", testName)) { - t.Errorf("Repo was not successfully added. Output: %s", result) - } -} diff --git a/cmd/helm/repo_index.go b/cmd/helm/repo_index.go deleted file mode 100644 index 917acd442..000000000 --- a/cmd/helm/repo_index.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -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" - "os" - "path/filepath" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/repo" -) - -const repoIndexDesc = ` -Read the current directory and generate an index file based on the charts found. - -This tool is used for creating an 'index.yaml' file for a chart repository. To -set an absolute URL to the charts, use '--url' flag. - -To merge the generated index with an existing index file, use the '--merge' -flag. In this case, the charts found in the current directory will be merged -into the existing index, with local charts taking priority over existing charts. -` - -type repoIndexOptions struct { - dir string - url string - merge string -} - -func newRepoIndexCmd(out io.Writer) *cobra.Command { - o := &repoIndexOptions{} - - cmd := &cobra.Command{ - Use: "index [DIR]", - Short: "generate an index file given a directory containing packaged charts", - Long: repoIndexDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - // Allow file completion when completing the argument for the directory - return nil, cobra.ShellCompDirectiveDefault - } - // No more completions, so disable file completion - return nil, cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - o.dir = args[0] - return o.run(out) - }, - } - - f := cmd.Flags() - f.StringVar(&o.url, "url", "", "url of chart repository") - f.StringVar(&o.merge, "merge", "", "merge the generated index into the given index") - - return cmd -} - -func (i *repoIndexOptions) run(out io.Writer) error { - path, err := filepath.Abs(i.dir) - if err != nil { - return err - } - - return index(path, i.url, i.merge) -} - -func index(dir, url, mergeTo string) error { - out := filepath.Join(dir, "index.yaml") - - i, err := repo.IndexDirectory(dir, url) - if err != nil { - return err - } - if mergeTo != "" { - // if index.yaml is missing then create an empty one to merge into - var i2 *repo.IndexFile - if _, err := os.Stat(mergeTo); os.IsNotExist(err) { - i2 = repo.NewIndexFile() - i2.WriteFile(mergeTo, 0644) - } else { - i2, err = repo.LoadIndexFile(mergeTo) - if err != nil { - return errors.Wrap(err, "merge failed") - } - } - i.Merge(i2) - } - i.SortEntries() - return i.WriteFile(out, 0644) -} diff --git a/cmd/helm/repo_index_test.go b/cmd/helm/repo_index_test.go deleted file mode 100644 index ae3390154..000000000 --- a/cmd/helm/repo_index_test.go +++ /dev/null @@ -1,172 +0,0 @@ -/* -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 ( - "bytes" - "io" - "os" - "path/filepath" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/repo" -) - -func TestRepoIndexCmd(t *testing.T) { - - dir := ensure.TempDir(t) - - comp := filepath.Join(dir, "compressedchart-0.1.0.tgz") - if err := linkOrCopy("testdata/testcharts/compressedchart-0.1.0.tgz", comp); err != nil { - t.Fatal(err) - } - comp2 := filepath.Join(dir, "compressedchart-0.2.0.tgz") - if err := linkOrCopy("testdata/testcharts/compressedchart-0.2.0.tgz", comp2); err != nil { - t.Fatal(err) - } - - buf := bytes.NewBuffer(nil) - c := newRepoIndexCmd(buf) - - if err := c.RunE(c, []string{dir}); err != nil { - t.Error(err) - } - - destIndex := filepath.Join(dir, "index.yaml") - - index, err := repo.LoadIndexFile(destIndex) - if err != nil { - t.Fatal(err) - } - - if len(index.Entries) != 1 { - t.Errorf("expected 1 entry, got %d: %#v", len(index.Entries), index.Entries) - } - - vs := index.Entries["compressedchart"] - if len(vs) != 2 { - t.Errorf("expected 2 versions, got %d: %#v", len(vs), vs) - } - - expectedVersion := "0.2.0" - if vs[0].Version != expectedVersion { - t.Errorf("expected %q, got %q", expectedVersion, vs[0].Version) - } - - // Test with `--merge` - - // Remove first two charts. - if err := os.Remove(comp); err != nil { - t.Fatal(err) - } - if err := os.Remove(comp2); err != nil { - t.Fatal(err) - } - // Add a new chart and a new version of an existing chart - if err := linkOrCopy("testdata/testcharts/reqtest-0.1.0.tgz", filepath.Join(dir, "reqtest-0.1.0.tgz")); err != nil { - t.Fatal(err) - } - if err := linkOrCopy("testdata/testcharts/compressedchart-0.3.0.tgz", filepath.Join(dir, "compressedchart-0.3.0.tgz")); err != nil { - t.Fatal(err) - } - - c.ParseFlags([]string{"--merge", destIndex}) - if err := c.RunE(c, []string{dir}); err != nil { - t.Error(err) - } - - index, err = repo.LoadIndexFile(destIndex) - if err != nil { - t.Fatal(err) - } - - if len(index.Entries) != 2 { - t.Errorf("expected 2 entries, got %d: %#v", len(index.Entries), index.Entries) - } - - vs = index.Entries["compressedchart"] - if len(vs) != 3 { - t.Errorf("expected 3 versions, got %d: %#v", len(vs), vs) - } - - expectedVersion = "0.3.0" - if vs[0].Version != expectedVersion { - t.Errorf("expected %q, got %q", expectedVersion, vs[0].Version) - } - - // test that index.yaml gets generated on merge even when it doesn't exist - if err := os.Remove(destIndex); err != nil { - t.Fatal(err) - } - - c.ParseFlags([]string{"--merge", destIndex}) - if err := c.RunE(c, []string{dir}); err != nil { - t.Error(err) - } - - index, err = repo.LoadIndexFile(destIndex) - if err != nil { - t.Fatal(err) - } - - // verify it didn't create an empty index.yaml and the merged happened - if len(index.Entries) != 2 { - t.Errorf("expected 2 entries, got %d: %#v", len(index.Entries), index.Entries) - } - - vs = index.Entries["compressedchart"] - if len(vs) != 1 { - t.Errorf("expected 1 versions, got %d: %#v", len(vs), vs) - } - - expectedVersion = "0.3.0" - if vs[0].Version != expectedVersion { - t.Errorf("expected %q, got %q", expectedVersion, vs[0].Version) - } -} - -func linkOrCopy(old, new string) error { - if err := os.Link(old, new); err != nil { - return copyFile(old, new) - } - - return nil -} - -func copyFile(dst, src string) error { - i, err := os.Open(dst) - if err != nil { - return err - } - defer i.Close() - - o, err := os.Create(src) - if err != nil { - return err - } - defer o.Close() - - _, err = io.Copy(o, i) - - return err -} - -func TestRepoIndexFileCompletion(t *testing.T) { - checkFileCompletion(t, "repo index", true) - checkFileCompletion(t, "repo index mydir", false) -} diff --git a/cmd/helm/repo_list.go b/cmd/helm/repo_list.go deleted file mode 100644 index c9b952fee..000000000 --- a/cmd/helm/repo_list.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -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 ( - "fmt" - "io" - - "github.com/gosuri/uitable" - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/repo" -) - -func newRepoListCmd(out io.Writer) *cobra.Command { - var outfmt output.Format - cmd := &cobra.Command{ - Use: "list", - Aliases: []string{"ls"}, - Short: "list chart repositories", - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - f, _ := repo.LoadFile(settings.RepositoryConfig) - if len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML) { - return errors.New("no repositories to show") - } - - return outfmt.Write(out, &repoListWriter{f.Repositories}) - }, - } - - bindOutputFlag(cmd, &outfmt) - - return cmd -} - -type repositoryElement struct { - Name string `json:"name"` - URL string `json:"url"` -} - -type repoListWriter struct { - repos []*repo.Entry -} - -func (r *repoListWriter) WriteTable(out io.Writer) error { - table := uitable.New() - table.AddRow("NAME", "URL") - for _, re := range r.repos { - table.AddRow(re.Name, re.URL) - } - return output.EncodeTable(out, table) -} - -func (r *repoListWriter) WriteJSON(out io.Writer) error { - return r.encodeByFormat(out, output.JSON) -} - -func (r *repoListWriter) WriteYAML(out io.Writer) error { - return r.encodeByFormat(out, output.YAML) -} - -func (r *repoListWriter) encodeByFormat(out io.Writer, format output.Format) error { - // Initialize the array so no results returns an empty array instead of null - repolist := make([]repositoryElement, 0, len(r.repos)) - - for _, re := range r.repos { - repolist = append(repolist, repositoryElement{Name: re.Name, URL: re.URL}) - } - - switch format { - case output.JSON: - return output.EncodeJSON(out, repolist) - case output.YAML: - return output.EncodeYAML(out, repolist) - } - - // Because this is a non-exported function and only called internally by - // WriteJSON and WriteYAML, we shouldn't get invalid types - return nil -} - -// Returns all repos from repos, except those with names matching ignoredRepoNames -// Inspired by https://stackoverflow.com/a/28701031/893211 -func filterRepos(repos []*repo.Entry, ignoredRepoNames []string) []*repo.Entry { - // if ignoredRepoNames is nil, just return repo - if ignoredRepoNames == nil { - return repos - } - - filteredRepos := make([]*repo.Entry, 0) - - ignored := make(map[string]bool, len(ignoredRepoNames)) - for _, repoName := range ignoredRepoNames { - ignored[repoName] = true - } - - for _, repo := range repos { - if _, removed := ignored[repo.Name]; !removed { - filteredRepos = append(filteredRepos, repo) - } - } - - return filteredRepos -} - -// Provide dynamic auto-completion for repo names -func compListRepos(prefix string, ignoredRepoNames []string) []string { - var rNames []string - - f, err := repo.LoadFile(settings.RepositoryConfig) - if err == nil && len(f.Repositories) > 0 { - filteredRepos := filterRepos(f.Repositories, ignoredRepoNames) - for _, repo := range filteredRepos { - rNames = append(rNames, fmt.Sprintf("%s\t%s", repo.Name, repo.URL)) - } - } - return rNames -} diff --git a/cmd/helm/repo_list_test.go b/cmd/helm/repo_list_test.go deleted file mode 100644 index 90149ebda..000000000 --- a/cmd/helm/repo_list_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -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 ( - "testing" -) - -func TestRepoListOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "repo list") -} - -func TestRepoListFileCompletion(t *testing.T) { - checkFileCompletion(t, "repo list", false) -} diff --git a/cmd/helm/repo_remove.go b/cmd/helm/repo_remove.go deleted file mode 100644 index e6e9cb681..000000000 --- a/cmd/helm/repo_remove.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -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 ( - "fmt" - "io" - "os" - "path/filepath" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/repo" -) - -type repoRemoveOptions struct { - names []string - repoFile string - repoCache string -} - -func newRepoRemoveCmd(out io.Writer) *cobra.Command { - o := &repoRemoveOptions{} - - cmd := &cobra.Command{ - Use: "remove [REPO1 [REPO2 ...]]", - Aliases: []string{"rm"}, - Short: "remove one or more chart repositories", - Args: require.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compListRepos(toComplete, args), cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - o.repoFile = settings.RepositoryConfig - o.repoCache = settings.RepositoryCache - o.names = args - return o.run(out) - }, - } - return cmd -} - -func (o *repoRemoveOptions) run(out io.Writer) error { - r, err := repo.LoadFile(o.repoFile) - if isNotExist(err) || len(r.Repositories) == 0 { - return errors.New("no repositories configured") - } - - for _, name := range o.names { - if !r.Remove(name) { - return errors.Errorf("no repo named %q found", name) - } - if err := r.WriteFile(o.repoFile, 0644); err != nil { - return err - } - - if err := removeRepoCache(o.repoCache, name); err != nil { - return err - } - fmt.Fprintf(out, "%q has been removed from your repositories\n", name) - } - - return nil -} - -func removeRepoCache(root, name string) error { - idx := filepath.Join(root, helmpath.CacheChartsFile(name)) - if _, err := os.Stat(idx); err == nil { - os.Remove(idx) - } - - idx = filepath.Join(root, helmpath.CacheIndexFile(name)) - if _, err := os.Stat(idx); os.IsNotExist(err) { - return nil - } else if err != nil { - return errors.Wrapf(err, "can't remove index file %s", idx) - } - return os.Remove(idx) -} diff --git a/cmd/helm/repo_remove_test.go b/cmd/helm/repo_remove_test.go deleted file mode 100644 index 768295655..000000000 --- a/cmd/helm/repo_remove_test.go +++ /dev/null @@ -1,217 +0,0 @@ -/* -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 ( - "bytes" - "fmt" - "os" - "path/filepath" - "strings" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/repo" - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestRepoRemove(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - rootDir := ensure.TempDir(t) - repoFile := filepath.Join(rootDir, "repositories.yaml") - - const testRepoName = "test-name" - - b := bytes.NewBuffer(nil) - - rmOpts := repoRemoveOptions{ - names: []string{testRepoName}, - repoFile: repoFile, - repoCache: rootDir, - } - - if err := rmOpts.run(os.Stderr); err == nil { - t.Errorf("Expected error removing %s, but did not get one.", testRepoName) - } - o := &repoAddOptions{ - name: testRepoName, - url: ts.URL(), - repoFile: repoFile, - } - - if err := o.run(os.Stderr); err != nil { - t.Error(err) - } - - cacheIndexFile, cacheChartsFile := createCacheFiles(rootDir, testRepoName) - - // Reset the buffer before running repo remove - b.Reset() - - if err := rmOpts.run(b); err != nil { - t.Errorf("Error removing %s from repositories", testRepoName) - } - if !strings.Contains(b.String(), "has been removed") { - t.Errorf("Unexpected output: %s", b.String()) - } - - testCacheFiles(t, cacheIndexFile, cacheChartsFile, testRepoName) - - f, err := repo.LoadFile(repoFile) - if err != nil { - t.Error(err) - } - - if f.Has(testRepoName) { - t.Errorf("%s was not successfully removed from repositories list", testRepoName) - } - - // Test removal of multiple repos in one go - var testRepoNames = []string{"foo", "bar", "baz"} - cacheFiles := make(map[string][]string, len(testRepoNames)) - - // Add test repos - for _, repoName := range testRepoNames { - o := &repoAddOptions{ - name: repoName, - url: ts.URL(), - repoFile: repoFile, - } - - if err := o.run(os.Stderr); err != nil { - t.Error(err) - } - - cacheIndex, cacheChart := createCacheFiles(rootDir, repoName) - cacheFiles[repoName] = []string{cacheIndex, cacheChart} - - } - - // Create repo remove command - multiRmOpts := repoRemoveOptions{ - names: testRepoNames, - repoFile: repoFile, - repoCache: rootDir, - } - - // Reset the buffer before running repo remove - b.Reset() - - // Run repo remove command - if err := multiRmOpts.run(b); err != nil { - t.Errorf("Error removing list of repos from repositories: %q", testRepoNames) - } - - // Check that stuff were removed - if !strings.Contains(b.String(), "has been removed") { - t.Errorf("Unexpected output: %s", b.String()) - } - - for _, repoName := range testRepoNames { - f, err := repo.LoadFile(repoFile) - if err != nil { - t.Error(err) - } - if f.Has(repoName) { - t.Errorf("%s was not successfully removed from repositories list", repoName) - } - cacheIndex := cacheFiles[repoName][0] - cacheChart := cacheFiles[repoName][1] - testCacheFiles(t, cacheIndex, cacheChart, repoName) - } -} - -func createCacheFiles(rootDir string, repoName string) (cacheIndexFile string, cacheChartsFile string) { - cacheIndexFile = filepath.Join(rootDir, helmpath.CacheIndexFile(repoName)) - mf, _ := os.Create(cacheIndexFile) - mf.Close() - - cacheChartsFile = filepath.Join(rootDir, helmpath.CacheChartsFile(repoName)) - mf, _ = os.Create(cacheChartsFile) - mf.Close() - - return cacheIndexFile, cacheChartsFile -} - -func testCacheFiles(t *testing.T, cacheIndexFile string, cacheChartsFile string, repoName string) { - if _, err := os.Stat(cacheIndexFile); err == nil { - t.Errorf("Error cache index file was not removed for repository %s", repoName) - } - if _, err := os.Stat(cacheChartsFile); err == nil { - t.Errorf("Error cache chart file was not removed for repository %s", repoName) - } -} - -func TestRepoRemoveCompletion(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - rootDir := ensure.TempDir(t) - repoFile := filepath.Join(rootDir, "repositories.yaml") - repoCache := filepath.Join(rootDir, "cache/") - - var testRepoNames = []string{"foo", "bar", "baz"} - - // Add test repos - for _, repoName := range testRepoNames { - o := &repoAddOptions{ - name: repoName, - url: ts.URL(), - repoFile: repoFile, - } - - if err := o.run(os.Stderr); err != nil { - t.Error(err) - } - } - - repoSetup := fmt.Sprintf("--repository-config %s --repository-cache %s", repoFile, repoCache) - - // In the following tests, we turn off descriptions for completions by using __completeNoDesc. - // We have to do this because the description will contain the port used by the webserver, - // and that port changes each time we run the test. - tests := []cmdTestCase{{ - name: "completion for repo remove", - cmd: fmt.Sprintf("%s __completeNoDesc repo remove ''", repoSetup), - golden: "output/repo_list_comp.txt", - }, { - name: "completion for repo remove, no filter", - cmd: fmt.Sprintf("%s __completeNoDesc repo remove fo", repoSetup), - golden: "output/repo_list_comp.txt", - }, { - name: "completion for repo remove repetition", - cmd: fmt.Sprintf("%s __completeNoDesc repo remove foo ''", repoSetup), - golden: "output/repo_repeat_comp.txt", - }} - for _, test := range tests { - runTestCmd(t, []cmdTestCase{test}) - } -} - -func TestRepoRemoveFileCompletion(t *testing.T) { - checkFileCompletion(t, "repo remove", false) - checkFileCompletion(t, "repo remove repo1", false) -} diff --git a/cmd/helm/repo_test.go b/cmd/helm/repo_test.go deleted file mode 100644 index 2b0df7c4c..000000000 --- a/cmd/helm/repo_test.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -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 ( - "testing" -) - -func TestRepoFileCompletion(t *testing.T) { - checkFileCompletion(t, "repo", false) -} diff --git a/cmd/helm/repo_update.go b/cmd/helm/repo_update.go deleted file mode 100644 index 27661674c..000000000 --- a/cmd/helm/repo_update.go +++ /dev/null @@ -1,167 +0,0 @@ -/* -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 ( - "fmt" - "io" - "sync" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/getter" - "helm.sh/helm/v3/pkg/repo" -) - -const updateDesc = ` -Update gets the latest information about charts from the respective chart repositories. -Information is cached locally, where it is used by commands like 'helm search'. - -You can optionally specify a list of repositories you want to update. - $ helm repo update ... -To update all the repositories, use 'helm repo update'. -` - -var errNoRepositories = errors.New("no repositories found. You must add one before updating") - -type repoUpdateOptions struct { - update func([]*repo.ChartRepository, io.Writer, bool) error - repoFile string - repoCache string - names []string - failOnRepoUpdateFail bool -} - -func newRepoUpdateCmd(out io.Writer) *cobra.Command { - o := &repoUpdateOptions{update: updateCharts} - - cmd := &cobra.Command{ - Use: "update [REPO1 [REPO2 ...]]", - Aliases: []string{"up"}, - Short: "update information of available charts locally from chart repositories", - Long: updateDesc, - Args: require.MinimumNArgs(0), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compListRepos(toComplete, args), cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - o.repoFile = settings.RepositoryConfig - o.repoCache = settings.RepositoryCache - o.names = args - return o.run(out) - }, - } - - f := cmd.Flags() - - // Adding this flag for Helm 3 as stop gap functionality for https://github.com/helm/helm/issues/10016. - // This should be deprecated in Helm 4 by update to the behaviour of `helm repo update` command. - f.BoolVar(&o.failOnRepoUpdateFail, "fail-on-repo-update-fail", false, "update fails if any of the repository updates fail") - - return cmd -} - -func (o *repoUpdateOptions) run(out io.Writer) error { - f, err := repo.LoadFile(o.repoFile) - switch { - case isNotExist(err): - return errNoRepositories - case err != nil: - return errors.Wrapf(err, "failed loading file: %s", o.repoFile) - case len(f.Repositories) == 0: - return errNoRepositories - } - - var repos []*repo.ChartRepository - updateAllRepos := len(o.names) == 0 - - if !updateAllRepos { - // Fail early if the user specified an invalid repo to update - if err := checkRequestedRepos(o.names, f.Repositories); err != nil { - return err - } - } - - for _, cfg := range f.Repositories { - if updateAllRepos || isRepoRequested(cfg.Name, o.names) { - r, err := repo.NewChartRepository(cfg, getter.All(settings)) - if err != nil { - return err - } - if o.repoCache != "" { - r.CachePath = o.repoCache - } - repos = append(repos, r) - } - } - - return o.update(repos, out, o.failOnRepoUpdateFail) -} - -func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { - fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") - var wg sync.WaitGroup - var repoFailList []string - for _, re := range repos { - wg.Add(1) - go func(re *repo.ChartRepository) { - defer wg.Done() - if _, err := re.DownloadIndexFile(); err != nil { - fmt.Fprintf(out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", re.Config.Name, re.Config.URL, err) - repoFailList = append(repoFailList, re.Config.URL) - } else { - fmt.Fprintf(out, "...Successfully got an update from the %q chart repository\n", re.Config.Name) - } - }(re) - } - wg.Wait() - - if len(repoFailList) > 0 && failOnRepoUpdateFail { - return fmt.Errorf("Failed to update the following repositories: %s", - repoFailList) - } - - fmt.Fprintln(out, "Update Complete. ⎈Happy Helming!⎈") - return nil -} - -func checkRequestedRepos(requestedRepos []string, validRepos []*repo.Entry) error { - for _, requestedRepo := range requestedRepos { - found := false - for _, repo := range validRepos { - if requestedRepo == repo.Name { - found = true - break - } - } - if !found { - return errors.Errorf("no repositories found matching '%s'. Nothing will be updated", requestedRepo) - } - } - return nil -} - -func isRepoRequested(repoName string, requestedRepos []string) bool { - for _, requestedRepo := range requestedRepos { - if repoName == requestedRepo { - return true - } - } - return false -} diff --git a/cmd/helm/repo_update_test.go b/cmd/helm/repo_update_test.go deleted file mode 100644 index cf2136ff0..000000000 --- a/cmd/helm/repo_update_test.go +++ /dev/null @@ -1,240 +0,0 @@ -/* -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 ( - "bytes" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/getter" - "helm.sh/helm/v3/pkg/repo" - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestUpdateCmd(t *testing.T) { - var out bytes.Buffer - // Instead of using the HTTP updater, we provide our own for this test. - // The TestUpdateCharts test verifies the HTTP behavior independently. - updater := func(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { - for _, re := range repos { - fmt.Fprintln(out, re.Config.Name) - } - return nil - } - o := &repoUpdateOptions{ - update: updater, - repoFile: "testdata/repositories.yaml", - } - if err := o.run(&out); err != nil { - t.Fatal(err) - } - - if got := out.String(); !strings.Contains(got, "charts") || - !strings.Contains(got, "firstexample") || - !strings.Contains(got, "secondexample") { - t.Errorf("Expected 'charts', 'firstexample' and 'secondexample' but got %q", got) - } -} - -func TestUpdateCmdMultiple(t *testing.T) { - var out bytes.Buffer - // Instead of using the HTTP updater, we provide our own for this test. - // The TestUpdateCharts test verifies the HTTP behavior independently. - updater := func(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { - for _, re := range repos { - fmt.Fprintln(out, re.Config.Name) - } - return nil - } - o := &repoUpdateOptions{ - update: updater, - repoFile: "testdata/repositories.yaml", - names: []string{"firstexample", "charts"}, - } - if err := o.run(&out); err != nil { - t.Fatal(err) - } - - if got := out.String(); !strings.Contains(got, "charts") || - !strings.Contains(got, "firstexample") || - strings.Contains(got, "secondexample") { - t.Errorf("Expected 'charts' and 'firstexample' but not 'secondexample' but got %q", got) - } -} - -func TestUpdateCmdInvalid(t *testing.T) { - var out bytes.Buffer - // Instead of using the HTTP updater, we provide our own for this test. - // The TestUpdateCharts test verifies the HTTP behavior independently. - updater := func(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { - for _, re := range repos { - fmt.Fprintln(out, re.Config.Name) - } - return nil - } - o := &repoUpdateOptions{ - update: updater, - repoFile: "testdata/repositories.yaml", - names: []string{"firstexample", "invalid"}, - } - if err := o.run(&out); err == nil { - t.Fatal("expected error but did not get one") - } -} - -func TestUpdateCustomCacheCmd(t *testing.T) { - rootDir := ensure.TempDir(t) - cachePath := filepath.Join(rootDir, "updcustomcache") - os.Mkdir(cachePath, os.ModePerm) - defer os.RemoveAll(cachePath) - - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - o := &repoUpdateOptions{ - update: updateCharts, - repoFile: filepath.Join(ts.Root(), "repositories.yaml"), - repoCache: cachePath, - } - b := ioutil.Discard - if err := o.run(b); err != nil { - t.Fatal(err) - } - if _, err := os.Stat(filepath.Join(cachePath, "test-index.yaml")); err != nil { - t.Fatalf("error finding created index file in custom cache: %v", err) - } -} - -func TestUpdateCharts(t *testing.T) { - defer resetEnv()() - defer ensure.HelmHome(t)() - - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - r, err := repo.NewChartRepository(&repo.Entry{ - Name: "charts", - URL: ts.URL(), - }, getter.All(settings)) - if err != nil { - t.Error(err) - } - - b := bytes.NewBuffer(nil) - updateCharts([]*repo.ChartRepository{r}, b, false) - - got := b.String() - if strings.Contains(got, "Unable to get an update") { - t.Errorf("Failed to get a repo: %q", got) - } - if !strings.Contains(got, "Update Complete.") { - t.Error("Update was not successful") - } -} - -func TestRepoUpdateFileCompletion(t *testing.T) { - checkFileCompletion(t, "repo update", false) - checkFileCompletion(t, "repo update repo1", false) -} - -func TestUpdateChartsFail(t *testing.T) { - defer resetEnv()() - defer ensure.HelmHome(t)() - - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - var invalidURL = ts.URL() + "55" - r, err := repo.NewChartRepository(&repo.Entry{ - Name: "charts", - URL: invalidURL, - }, getter.All(settings)) - if err != nil { - t.Error(err) - } - - b := bytes.NewBuffer(nil) - if err := updateCharts([]*repo.ChartRepository{r}, b, false); err != nil { - t.Error("Repo update should not return error if update of repository fails") - } - - got := b.String() - if !strings.Contains(got, "Unable to get an update") { - t.Errorf("Repo should have failed update but instead got: %q", got) - } - if !strings.Contains(got, "Update Complete.") { - t.Error("Update was not successful") - } -} - -func TestUpdateChartsFailWithError(t *testing.T) { - defer resetEnv()() - defer ensure.HelmHome(t)() - - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - var invalidURL = ts.URL() + "55" - r, err := repo.NewChartRepository(&repo.Entry{ - Name: "charts", - URL: invalidURL, - }, getter.All(settings)) - if err != nil { - t.Error(err) - } - - b := bytes.NewBuffer(nil) - err = updateCharts([]*repo.ChartRepository{r}, b, true) - if err == nil { - t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set") - return - } - var expectedErr = "Failed to update the following repositories" - var receivedErr = err.Error() - if !strings.Contains(receivedErr, expectedErr) { - t.Errorf("Expected error (%s) but got (%s) instead", expectedErr, receivedErr) - } - if !strings.Contains(receivedErr, invalidURL) { - t.Errorf("Expected invalid URL (%s) in error message but got (%s) instead", invalidURL, receivedErr) - } - - got := b.String() - if !strings.Contains(got, "Unable to get an update") { - t.Errorf("Repo should have failed update but instead got: %q", got) - } - if strings.Contains(got, "Update Complete.") { - t.Error("Update was not successful and should return error message because 'fail-on-repo-update-fail' flag set") - } -} diff --git a/cmd/helm/require/args.go b/cmd/helm/require/args.go deleted file mode 100644 index cfa8a0169..000000000 --- a/cmd/helm/require/args.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -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 require - -import ( - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -// NoArgs returns an error if any args are included. -func NoArgs(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - return errors.Errorf( - "%q accepts no arguments\n\nUsage: %s", - cmd.CommandPath(), - cmd.UseLine(), - ) - } - return nil -} - -// ExactArgs returns an error if there are not exactly n args. -func ExactArgs(n int) cobra.PositionalArgs { - return func(cmd *cobra.Command, args []string) error { - if len(args) != n { - return errors.Errorf( - "%q requires %d %s\n\nUsage: %s", - cmd.CommandPath(), - n, - pluralize("argument", n), - cmd.UseLine(), - ) - } - return nil - } -} - -// MaximumNArgs returns an error if there are more than N args. -func MaximumNArgs(n int) cobra.PositionalArgs { - return func(cmd *cobra.Command, args []string) error { - if len(args) > n { - return errors.Errorf( - "%q accepts at most %d %s\n\nUsage: %s", - cmd.CommandPath(), - n, - pluralize("argument", n), - cmd.UseLine(), - ) - } - return nil - } -} - -// MinimumNArgs returns an error if there is not at least N args. -func MinimumNArgs(n int) cobra.PositionalArgs { - return func(cmd *cobra.Command, args []string) error { - if len(args) < n { - return errors.Errorf( - "%q requires at least %d %s\n\nUsage: %s", - cmd.CommandPath(), - n, - pluralize("argument", n), - cmd.UseLine(), - ) - } - return nil - } -} - -func pluralize(word string, n int) string { - if n == 1 { - return word - } - return word + "s" -} diff --git a/cmd/helm/require/args_test.go b/cmd/helm/require/args_test.go deleted file mode 100644 index c8d5c3110..000000000 --- a/cmd/helm/require/args_test.go +++ /dev/null @@ -1,91 +0,0 @@ -/* -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 require - -import ( - "fmt" - "io/ioutil" - "strings" - "testing" - - "github.com/spf13/cobra" -) - -func TestArgs(t *testing.T) { - runTestCases(t, []testCase{{ - validateFunc: NoArgs, - }, { - args: []string{"one"}, - validateFunc: NoArgs, - wantError: `"root" accepts no arguments`, - }, { - args: []string{"one"}, - validateFunc: ExactArgs(1), - }, { - validateFunc: ExactArgs(1), - wantError: `"root" requires 1 argument`, - }, { - validateFunc: ExactArgs(2), - wantError: `"root" requires 2 arguments`, - }, { - args: []string{"one"}, - validateFunc: MaximumNArgs(1), - }, { - args: []string{"one", "two"}, - validateFunc: MaximumNArgs(1), - wantError: `"root" accepts at most 1 argument`, - }, { - validateFunc: MinimumNArgs(1), - wantError: `"root" requires at least 1 argument`, - }, { - args: []string{"one", "two"}, - validateFunc: MinimumNArgs(1), - }}) -} - -type testCase struct { - args []string - validateFunc cobra.PositionalArgs - wantError string -} - -func runTestCases(t *testing.T, testCases []testCase) { - for i, tc := range testCases { - t.Run(fmt.Sprint(i), func(t *testing.T) { - cmd := &cobra.Command{ - Use: "root", - Run: func(*cobra.Command, []string) {}, - Args: tc.validateFunc, - } - cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) - - err := cmd.Execute() - if tc.wantError == "" { - if err != nil { - t.Fatalf("unexpected error, got '%v'", err) - } - return - } - if !strings.Contains(err.Error(), tc.wantError) { - t.Fatalf("unexpected error \n\nWANT:\n%q\n\nGOT:\n%q\n", tc.wantError, err) - } - if !strings.Contains(err.Error(), "Usage:") { - t.Fatalf("unexpected error: want Usage string\n\nGOT:\n%q\n", err) - } - }) - } -} diff --git a/cmd/helm/rollback.go b/cmd/helm/rollback.go deleted file mode 100644 index ea4b75cb1..000000000 --- a/cmd/helm/rollback.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -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 ( - "fmt" - "io" - "strconv" - "time" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const rollbackDesc = ` -This command rolls back a release to a previous revision. - -The first argument of the rollback command is the name of a release, and the -second is a revision (version) number. If this argument is omitted, it will -roll back to the previous release. - -To see revision numbers, run 'helm history RELEASE'. -` - -func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewRollback(cfg) - - cmd := &cobra.Command{ - Use: "rollback [REVISION]", - Short: "roll back a release to a previous revision", - Long: rollbackDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - return compListReleases(toComplete, args, cfg) - } - - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - - return nil, cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - ver, err := strconv.Atoi(args[1]) - if err != nil { - return fmt.Errorf("could not convert revision to a number: %v", err) - } - client.Version = ver - } - - if err := client.Run(args[0]); err != nil { - return err - } - - fmt.Fprintf(out, "Rollback was a success! Happy Helming!\n") - return nil - }, - } - - f := cmd.Flags() - f.BoolVar(&client.DryRun, "dry-run", false, "simulate a rollback") - f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") - f.BoolVar(&client.Force, "force", false, "force resource update through delete/recreate if needed") - f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during rollback") - f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") - f.BoolVar(&client.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout") - f.BoolVar(&client.CleanupOnFail, "cleanup-on-fail", false, "allow deletion of new resources created in this rollback when rollback fails") - f.IntVar(&client.MaxHistory, "history-max", settings.MaxHistory, "limit the maximum number of revisions saved per release. Use 0 for no limit") - - return cmd -} diff --git a/cmd/helm/rollback_test.go b/cmd/helm/rollback_test.go deleted file mode 100644 index 9ca921557..000000000 --- a/cmd/helm/rollback_test.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/release" -) - -func TestRollbackCmd(t *testing.T) { - rels := []*release.Release{ - { - Name: "funny-honey", - Info: &release.Info{Status: release.StatusSuperseded}, - Chart: &chart.Chart{}, - Version: 1, - }, - { - Name: "funny-honey", - Info: &release.Info{Status: release.StatusDeployed}, - Chart: &chart.Chart{}, - Version: 2, - }, - } - - tests := []cmdTestCase{{ - name: "rollback a release", - cmd: "rollback funny-honey 1", - golden: "output/rollback.txt", - rels: rels, - }, { - name: "rollback a release with timeout", - cmd: "rollback funny-honey 1 --timeout 120s", - golden: "output/rollback-timeout.txt", - rels: rels, - }, { - name: "rollback a release with wait", - cmd: "rollback funny-honey 1 --wait", - golden: "output/rollback-wait.txt", - rels: rels, - }, { - name: "rollback a release with wait-for-jobs", - cmd: "rollback funny-honey 1 --wait --wait-for-jobs", - golden: "output/rollback-wait-for-jobs.txt", - rels: rels, - }, { - name: "rollback a release without revision", - cmd: "rollback funny-honey", - golden: "output/rollback-no-revision.txt", - rels: rels, - }, { - name: "rollback a release without release name", - cmd: "rollback", - golden: "output/rollback-no-args.txt", - rels: rels, - wantError: true, - }} - runTestCmd(t, tests) -} - -func TestRollbackRevisionCompletion(t *testing.T) { - mk := func(name string, vers int, status release.Status) *release.Release { - return release.Mock(&release.MockReleaseOptions{ - Name: name, - Version: vers, - Status: status, - }) - } - - releases := []*release.Release{ - mk("musketeers", 11, release.StatusDeployed), - mk("musketeers", 10, release.StatusSuperseded), - mk("musketeers", 9, release.StatusSuperseded), - mk("musketeers", 8, release.StatusSuperseded), - mk("carabins", 1, release.StatusSuperseded), - } - - tests := []cmdTestCase{{ - name: "completion for release parameter", - cmd: "__complete rollback ''", - rels: releases, - golden: "output/rollback-comp.txt", - }, { - name: "completion for revision parameter", - cmd: "__complete rollback musketeers ''", - rels: releases, - golden: "output/revision-comp.txt", - }, { - name: "completion for with too many args", - cmd: "__complete rollback musketeers 11 ''", - rels: releases, - golden: "output/rollback-wrong-args-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestRollbackFileCompletion(t *testing.T) { - checkFileCompletion(t, "rollback", false) - checkFileCompletion(t, "rollback myrelease", false) - checkFileCompletion(t, "rollback myrelease 1", false) -} diff --git a/cmd/helm/root.go b/cmd/helm/root.go deleted file mode 100644 index ef92fea92..000000000 --- a/cmd/helm/root.go +++ /dev/null @@ -1,263 +0,0 @@ -/* -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 "helm.sh/helm/v3/cmd/helm" - -import ( - "context" - "fmt" - "io" - "log" - "os" - "strings" - - "github.com/spf13/cobra" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/tools/clientcmd" - - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/registry" - "helm.sh/helm/v3/pkg/repo" -) - -var globalUsage = `The Kubernetes package manager - -Common actions for Helm: - -- helm search: search for charts -- helm pull: download a chart to your local directory to view -- helm install: upload the chart to Kubernetes -- helm list: list releases of charts - -Environment variables: - -| Name | Description | -|------------------------------------|---------------------------------------------------------------------------------------------------| -| $HELM_CACHE_HOME | set an alternative location for storing cached files. | -| $HELM_CONFIG_HOME | set an alternative location for storing Helm configuration. | -| $HELM_DATA_HOME | set an alternative location for storing Helm data. | -| $HELM_DEBUG | indicate whether or not Helm is running in Debug mode | -| $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, sql. | -| $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. | -| $HELM_MAX_HISTORY | set the maximum number of helm release history. | -| $HELM_NAMESPACE | set the namespace used for the helm operations. | -| $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. | -| $HELM_PLUGINS | set the path to the plugins directory | -| $HELM_REGISTRY_CONFIG | set the path to the registry config file. | -| $HELM_REPOSITORY_CACHE | set the path to the repository cache directory | -| $HELM_REPOSITORY_CONFIG | set the path to the repositories file. | -| $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") | -| $HELM_KUBEAPISERVER | set the Kubernetes API Server Endpoint for authentication | -| $HELM_KUBECAFILE | set the Kubernetes certificate authority file. | -| $HELM_KUBEASGROUPS | set the Groups to use for impersonation using a comma-separated list. | -| $HELM_KUBEASUSER | set the Username to impersonate for the operation. | -| $HELM_KUBECONTEXT | set the name of the kubeconfig context. | -| $HELM_KUBETOKEN | set the Bearer KubeToken used for authentication. | -| $HELM_KUBEINSECURE_SKIP_TLS_VERIFY | indicate if the Kubernetes API server's certificate validation should be skipped (insecure) | -| $HELM_KUBETLS_SERVER_NAME | set the server name used to validate the Kubernetes API server certificate | -| $HELM_BURST_LIMIT | set the default burst limit in the case the server contains many CRDs (default 100, -1 to disable)| - -Helm stores cache, configuration, and data based on the following configuration order: - -- If a HELM_*_HOME environment variable is set, it will be used -- Otherwise, on systems supporting the XDG base directory specification, the XDG variables will be used -- When no other location is set a default location will be used based on the operating system - -By default, the default directories depend on the Operating System. The defaults are listed below: - -| Operating System | Cache Path | Configuration Path | Data Path | -|------------------|---------------------------|--------------------------------|-------------------------| -| Linux | $HOME/.cache/helm | $HOME/.config/helm | $HOME/.local/share/helm | -| macOS | $HOME/Library/Caches/helm | $HOME/Library/Preferences/helm | $HOME/Library/helm | -| Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm | -` - -func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) { - cmd := &cobra.Command{ - Use: "helm", - Short: "The Helm package manager for Kubernetes.", - Long: globalUsage, - SilenceUsage: true, - } - flags := cmd.PersistentFlags() - - settings.AddFlags(flags) - addKlogFlags(flags) - - // Setup shell completion for the namespace flag - err := cmd.RegisterFlagCompletionFunc("namespace", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if client, err := actionConfig.KubernetesClientSet(); err == nil { - // Choose a long enough timeout that the user notices something is not working - // but short enough that the user is not made to wait very long - to := int64(3) - cobra.CompDebugln(fmt.Sprintf("About to call kube client for namespaces with timeout of: %d", to), settings.Debug) - - nsNames := []string{} - if namespaces, err := client.CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{TimeoutSeconds: &to}); err == nil { - for _, ns := range namespaces.Items { - nsNames = append(nsNames, ns.Name) - } - return nsNames, cobra.ShellCompDirectiveNoFileComp - } - } - return nil, cobra.ShellCompDirectiveDefault - }) - - if err != nil { - log.Fatal(err) - } - - // Setup shell completion for the kube-context flag - err = cmd.RegisterFlagCompletionFunc("kube-context", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - cobra.CompDebugln("About to get the different kube-contexts", settings.Debug) - - loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() - if len(settings.KubeConfig) > 0 { - loadingRules = &clientcmd.ClientConfigLoadingRules{ExplicitPath: settings.KubeConfig} - } - if config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( - loadingRules, - &clientcmd.ConfigOverrides{}).RawConfig(); err == nil { - comps := []string{} - for name, context := range config.Contexts { - comps = append(comps, fmt.Sprintf("%s\t%s", name, context.Cluster)) - } - return comps, cobra.ShellCompDirectiveNoFileComp - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - // We can safely ignore any errors that flags.Parse encounters since - // those errors will be caught later during the call to cmd.Execution. - // This call is required to gather configuration information prior to - // execution. - flags.ParseErrorsWhitelist.UnknownFlags = true - flags.Parse(args) - - registryClient, err := registry.NewClient( - registry.ClientOptDebug(settings.Debug), - registry.ClientOptEnableCache(true), - registry.ClientOptWriter(out), - registry.ClientOptCredentialsFile(settings.RegistryConfig), - ) - if err != nil { - return nil, err - } - actionConfig.RegistryClient = registryClient - - // Add subcommands - cmd.AddCommand( - // chart commands - newCreateCmd(out), - newDependencyCmd(actionConfig, out), - newPullCmd(actionConfig, out), - newShowCmd(actionConfig, out), - newLintCmd(out), - newPackageCmd(actionConfig, out), - newRepoCmd(out), - newSearchCmd(out), - newVerifyCmd(out), - - // release commands - newGetCmd(actionConfig, out), - newHistoryCmd(actionConfig, out), - newInstallCmd(actionConfig, out), - newListCmd(actionConfig, out), - newReleaseTestCmd(actionConfig, out), - newRollbackCmd(actionConfig, out), - newStatusCmd(actionConfig, out), - newTemplateCmd(actionConfig, out), - newUninstallCmd(actionConfig, out), - newUpgradeCmd(actionConfig, out), - - newCompletionCmd(out), - newEnvCmd(out), - newPluginCmd(out), - newVersionCmd(out), - - // Hidden documentation generator command: 'helm docs' - newDocsCmd(out), - ) - - cmd.AddCommand( - newRegistryCmd(actionConfig, out), - newPushCmd(actionConfig, out), - ) - - // Find and add plugins - loadPlugins(cmd, out) - - // Check permissions on critical files - checkPerms() - - // Check for expired repositories - checkForExpiredRepos(settings.RepositoryConfig) - - return cmd, nil -} - -func checkForExpiredRepos(repofile string) { - - expiredRepos := []struct { - name string - old string - new string - }{ - { - name: "stable", - old: "kubernetes-charts.storage.googleapis.com", - new: "https://charts.helm.sh/stable", - }, - { - name: "incubator", - old: "kubernetes-charts-incubator.storage.googleapis.com", - new: "https://charts.helm.sh/incubator", - }, - } - - // parse repo file. - // Ignore the error because it is okay for a repo file to be unparseable at this - // stage. Later checks will trap the error and respond accordingly. - repoFile, err := repo.LoadFile(repofile) - if err != nil { - return - } - - for _, exp := range expiredRepos { - r := repoFile.Get(exp.name) - if r == nil { - return - } - - if url := r.URL; strings.Contains(url, exp.old) { - fmt.Fprintf( - os.Stderr, - "WARNING: %q is deprecated for %q and will be deleted Nov. 13, 2020.\nWARNING: You should switch to %q via:\nWARNING: helm repo add %q %q --force-update\n", - exp.old, - exp.name, - exp.new, - exp.name, - exp.new, - ) - } - } - -} diff --git a/cmd/helm/root_test.go b/cmd/helm/root_test.go deleted file mode 100644 index 075544971..000000000 --- a/cmd/helm/root_test.go +++ /dev/null @@ -1,131 +0,0 @@ -/* -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 ( - "os" - "path/filepath" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/helmpath/xdg" -) - -func TestRootCmd(t *testing.T) { - defer resetEnv()() - - tests := []struct { - name, args, cachePath, configPath, dataPath string - envvars map[string]string - }{ - { - name: "defaults", - args: "env", - }, - { - name: "with $XDG_CACHE_HOME set", - args: "env", - envvars: map[string]string{xdg.CacheHomeEnvVar: "/bar"}, - cachePath: "/bar/helm", - }, - { - name: "with $XDG_CONFIG_HOME set", - args: "env", - envvars: map[string]string{xdg.ConfigHomeEnvVar: "/bar"}, - configPath: "/bar/helm", - }, - { - name: "with $XDG_DATA_HOME set", - args: "env", - envvars: map[string]string{xdg.DataHomeEnvVar: "/bar"}, - dataPath: "/bar/helm", - }, - { - name: "with $HELM_CACHE_HOME set", - args: "env", - envvars: map[string]string{helmpath.CacheHomeEnvVar: "/foo/helm"}, - cachePath: "/foo/helm", - }, - { - name: "with $HELM_CONFIG_HOME set", - args: "env", - envvars: map[string]string{helmpath.ConfigHomeEnvVar: "/foo/helm"}, - configPath: "/foo/helm", - }, - { - name: "with $HELM_DATA_HOME set", - args: "env", - envvars: map[string]string{helmpath.DataHomeEnvVar: "/foo/helm"}, - dataPath: "/foo/helm", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer ensure.HelmHome(t)() - - for k, v := range tt.envvars { - os.Setenv(k, v) - } - - if _, _, err := executeActionCommand(tt.args); err != nil { - t.Fatalf("unexpected error: %s", err) - } - - // NOTE(bacongobbler): we need to check here after calling ensure.HelmHome so we - // load the proper paths after XDG_*_HOME is set - if tt.cachePath == "" { - tt.cachePath = filepath.Join(os.Getenv(xdg.CacheHomeEnvVar), "helm") - } - - if tt.configPath == "" { - tt.configPath = filepath.Join(os.Getenv(xdg.ConfigHomeEnvVar), "helm") - } - - if tt.dataPath == "" { - tt.dataPath = filepath.Join(os.Getenv(xdg.DataHomeEnvVar), "helm") - } - - if helmpath.CachePath() != tt.cachePath { - t.Errorf("expected cache path %q, got %q", tt.cachePath, helmpath.CachePath()) - } - if helmpath.ConfigPath() != tt.configPath { - t.Errorf("expected config path %q, got %q", tt.configPath, helmpath.ConfigPath()) - } - if helmpath.DataPath() != tt.dataPath { - t.Errorf("expected data path %q, got %q", tt.dataPath, helmpath.DataPath()) - } - }) - } -} - -func TestUnknownSubCmd(t *testing.T) { - _, _, err := executeActionCommand("foobar") - - if err == nil || err.Error() != `unknown command "foobar" for "helm"` { - t.Errorf("Expect unknown command error, got %q", err) - } -} - -// Need the release of Cobra following 1.0 to be able to disable -// file completion on the root command. Until then, we cannot -// because it would break 'helm help ' -// -// func TestRootFileCompletion(t *testing.T) { -// checkFileCompletion(t, "", false) -// } diff --git a/cmd/helm/root_unix.go b/cmd/helm/root_unix.go deleted file mode 100644 index 92fa1b59d..000000000 --- a/cmd/helm/root_unix.go +++ /dev/null @@ -1,58 +0,0 @@ -//go:build !windows - -/* -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 ( - "os" - "os/user" - "path/filepath" -) - -func checkPerms() { - // This function MUST NOT FAIL, as it is just a check for a common permissions problem. - // If for some reason the function hits a stopping condition, it may panic. But only if - // we can be sure that it is panicking because Helm cannot proceed. - - kc := settings.KubeConfig - if kc == "" { - kc = os.Getenv("KUBECONFIG") - } - if kc == "" { - u, err := user.Current() - if err != nil { - // No idea where to find KubeConfig, so return silently. Many helm commands - // can proceed happily without a KUBECONFIG, so this is not a fatal error. - return - } - kc = filepath.Join(u.HomeDir, ".kube", "config") - } - fi, err := os.Stat(kc) - if err != nil { - // DO NOT error if no KubeConfig is found. Not all commands require one. - return - } - - perm := fi.Mode().Perm() - if perm&0040 > 0 { - warning("Kubernetes configuration file is group-readable. This is insecure. Location: %s", kc) - } - if perm&0004 > 0 { - warning("Kubernetes configuration file is world-readable. This is insecure. Location: %s", kc) - } -} diff --git a/cmd/helm/root_unix_test.go b/cmd/helm/root_unix_test.go deleted file mode 100644 index f7466a93d..000000000 --- a/cmd/helm/root_unix_test.go +++ /dev/null @@ -1,82 +0,0 @@ -//go:build !windows - -/* -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 ( - "bytes" - "io" - "os" - "path/filepath" - "strings" - "testing" -) - -func checkPermsStderr() (string, error) { - r, w, err := os.Pipe() - if err != nil { - return "", err - } - - stderr := os.Stderr - os.Stderr = w - defer func() { - os.Stderr = stderr - }() - - checkPerms() - w.Close() - - var text bytes.Buffer - io.Copy(&text, r) - return text.String(), nil -} - -func TestCheckPerms(t *testing.T) { - tdir := t.TempDir() - tfile := filepath.Join(tdir, "testconfig") - fh, err := os.OpenFile(tfile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0440) - if err != nil { - t.Errorf("Failed to create temp file: %s", err) - } - - tconfig := settings.KubeConfig - settings.KubeConfig = tfile - defer func() { settings.KubeConfig = tconfig }() - - text, err := checkPermsStderr() - if err != nil { - t.Fatalf("could not read from stderr: %s", err) - } - expectPrefix := "WARNING: Kubernetes configuration file is group-readable. This is insecure. Location:" - if !strings.HasPrefix(text, expectPrefix) { - t.Errorf("Expected to get a warning for group perms. Got %q", text) - } - - if err := fh.Chmod(0404); err != nil { - t.Errorf("Could not change mode on file: %s", err) - } - text, err = checkPermsStderr() - if err != nil { - t.Fatalf("could not read from stderr: %s", err) - } - expectPrefix = "WARNING: Kubernetes configuration file is world-readable. This is insecure. Location:" - if !strings.HasPrefix(text, expectPrefix) { - t.Errorf("Expected to get a warning for world perms. Got %q", text) - } -} diff --git a/cmd/helm/root_windows.go b/cmd/helm/root_windows.go deleted file mode 100644 index 7b5000f4f..000000000 --- a/cmd/helm/root_windows.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -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 - -func checkPerms() { - // Not yet implemented on Windows. If you know how to do a comprehensive perms - // check on Windows, contributions welcomed! -} diff --git a/cmd/helm/search.go b/cmd/helm/search.go deleted file mode 100644 index 6c62d5d2e..000000000 --- a/cmd/helm/search.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -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" -) - -const searchDesc = ` -Search provides the ability to search for Helm charts in the various places -they can be stored including the Artifact Hub and repositories you have added. -Use search subcommands to search different locations for charts. -` - -func newSearchCmd(out io.Writer) *cobra.Command { - - cmd := &cobra.Command{ - Use: "search [keyword]", - Short: "search for a keyword in charts", - Long: searchDesc, - } - - cmd.AddCommand(newSearchHubCmd(out)) - cmd.AddCommand(newSearchRepoCmd(out)) - - return cmd -} diff --git a/cmd/helm/search/search.go b/cmd/helm/search/search.go deleted file mode 100644 index fc7f30596..000000000 --- a/cmd/helm/search/search.go +++ /dev/null @@ -1,227 +0,0 @@ -/* -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 search provides client-side repository searching. - -This supports building an in-memory search index based on the contents of -multiple repositories, and then using string matching or regular expressions -to find matches. -*/ -package search - -import ( - "path" - "regexp" - "sort" - "strings" - - "github.com/Masterminds/semver/v3" - - "helm.sh/helm/v3/pkg/repo" -) - -// Result is a search result. -// -// Score indicates how close it is to match. The higher the score, the longer -// the distance. -type Result struct { - Name string - Score int - Chart *repo.ChartVersion -} - -// Index is a searchable index of chart information. -type Index struct { - lines map[string]string - charts map[string]*repo.ChartVersion -} - -const sep = "\v" - -// NewIndex creates a new Index. -func NewIndex() *Index { - return &Index{lines: map[string]string{}, charts: map[string]*repo.ChartVersion{}} -} - -// verSep is a separator for version fields in map keys. -const verSep = "$$" - -// AddRepo adds a repository index to the search index. -func (i *Index) AddRepo(rname string, ind *repo.IndexFile, all bool) { - ind.SortEntries() - for name, ref := range ind.Entries { - if len(ref) == 0 { - // Skip chart names that have zero releases. - continue - } - // By convention, an index file is supposed to have the newest at the - // 0 slot, so our best bet is to grab the 0 entry and build the index - // entry off of that. - // Note: Do not use filePath.Join since on Windows it will return \ - // which results in a repo name that cannot be understood. - fname := path.Join(rname, name) - if !all { - i.lines[fname] = indstr(rname, ref[0]) - i.charts[fname] = ref[0] - continue - } - - // If 'all' is set, then we go through all of the refs, and add them all - // to the index. This will generate a lot of near-duplicate entries. - for _, rr := range ref { - versionedName := fname + verSep + rr.Version - i.lines[versionedName] = indstr(rname, rr) - i.charts[versionedName] = rr - } - } -} - -// All returns all charts in the index as if they were search results. -// -// Each will be given a score of 0. -func (i *Index) All() []*Result { - res := make([]*Result, len(i.charts)) - j := 0 - for name, ch := range i.charts { - parts := strings.Split(name, verSep) - res[j] = &Result{ - Name: parts[0], - Chart: ch, - } - j++ - } - return res -} - -// Search searches an index for the given term. -// -// Threshold indicates the maximum score a term may have before being marked -// irrelevant. (Low score means higher relevance. Golf, not bowling.) -// -// If regexp is true, the term is treated as a regular expression. Otherwise, -// term is treated as a literal string. -func (i *Index) Search(term string, threshold int, regexp bool) ([]*Result, error) { - if regexp { - return i.SearchRegexp(term, threshold) - } - return i.SearchLiteral(term, threshold), nil -} - -// calcScore calculates a score for a match. -func (i *Index) calcScore(index int, matchline string) int { - - // This is currently tied to the fact that sep is a single char. - splits := []int{} - s := rune(sep[0]) - for i, ch := range matchline { - if ch == s { - splits = append(splits, i) - } - } - - for i, pos := range splits { - if index > pos { - continue - } - return i - } - return len(splits) -} - -// SearchLiteral does a literal string search (no regexp). -func (i *Index) SearchLiteral(term string, threshold int) []*Result { - term = strings.ToLower(term) - buf := []*Result{} - for k, v := range i.lines { - lk := strings.ToLower(k) - lv := strings.ToLower(v) - res := strings.Index(lv, term) - if score := i.calcScore(res, lv); res != -1 && score < threshold { - parts := strings.Split(lk, verSep) // Remove version, if it is there. - buf = append(buf, &Result{Name: parts[0], Score: score, Chart: i.charts[k]}) - } - } - return buf -} - -// SearchRegexp searches using a regular expression. -func (i *Index) SearchRegexp(re string, threshold int) ([]*Result, error) { - matcher, err := regexp.Compile(re) - if err != nil { - return []*Result{}, err - } - buf := []*Result{} - for k, v := range i.lines { - ind := matcher.FindStringIndex(v) - if len(ind) == 0 { - continue - } - if score := i.calcScore(ind[0], v); ind[0] >= 0 && score < threshold { - parts := strings.Split(k, verSep) // Remove version, if it is there. - buf = append(buf, &Result{Name: parts[0], Score: score, Chart: i.charts[k]}) - } - } - return buf, nil -} - -// SortScore does an in-place sort of the results. -// -// Lowest scores are highest on the list. Matching scores are subsorted alphabetically. -func SortScore(r []*Result) { - sort.Sort(scoreSorter(r)) -} - -// scoreSorter sorts results by score, and subsorts by alpha Name. -type scoreSorter []*Result - -// Len returns the length of this scoreSorter. -func (s scoreSorter) Len() int { return len(s) } - -// Swap performs an in-place swap. -func (s scoreSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Less compares a to b, and returns true if a is less than b. -func (s scoreSorter) Less(a, b int) bool { - first := s[a] - second := s[b] - - if first.Score > second.Score { - return false - } - if first.Score < second.Score { - return true - } - if first.Name == second.Name { - v1, err := semver.NewVersion(first.Chart.Version) - if err != nil { - return true - } - v2, err := semver.NewVersion(second.Chart.Version) - if err != nil { - return true - } - // Sort so that the newest chart is higher than the oldest chart. This is - // the opposite of what you'd expect in a function called Less. - return v1.GreaterThan(v2) - } - return first.Name < second.Name -} - -func indstr(name string, ref *repo.ChartVersion) string { - i := ref.Name + sep + name + "/" + ref.Name + sep + - ref.Description + sep + strings.Join(ref.Keywords, " ") - return i -} diff --git a/cmd/helm/search/search_test.go b/cmd/helm/search/search_test.go deleted file mode 100644 index 9c1859d77..000000000 --- a/cmd/helm/search/search_test.go +++ /dev/null @@ -1,303 +0,0 @@ -/* -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 search - -import ( - "strings" - "testing" - - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/repo" -) - -func TestSortScore(t *testing.T) { - in := []*Result{ - {Name: "bbb", Score: 0, Chart: &repo.ChartVersion{Metadata: &chart.Metadata{Version: "1.2.3"}}}, - {Name: "aaa", Score: 5}, - {Name: "abb", Score: 5}, - {Name: "aab", Score: 0}, - {Name: "bab", Score: 5}, - {Name: "ver", Score: 5, Chart: &repo.ChartVersion{Metadata: &chart.Metadata{Version: "1.2.4"}}}, - {Name: "ver", Score: 5, Chart: &repo.ChartVersion{Metadata: &chart.Metadata{Version: "1.2.3"}}}, - } - expect := []string{"aab", "bbb", "aaa", "abb", "bab", "ver", "ver"} - expectScore := []int{0, 0, 5, 5, 5, 5, 5} - SortScore(in) - - // Test Score - for i := 0; i < len(expectScore); i++ { - if expectScore[i] != in[i].Score { - t.Errorf("Sort error on index %d: expected %d, got %d", i, expectScore[i], in[i].Score) - } - } - // Test Name - for i := 0; i < len(expect); i++ { - if expect[i] != in[i].Name { - t.Errorf("Sort error: expected %s, got %s", expect[i], in[i].Name) - } - } - - // Test version of last two items - if in[5].Chart.Version != "1.2.4" { - t.Errorf("Expected 1.2.4, got %s", in[5].Chart.Version) - } - if in[6].Chart.Version != "1.2.3" { - t.Error("Expected 1.2.3 to be last") - } -} - -var indexfileEntries = map[string]repo.ChartVersions{ - "niña": { - { - URLs: []string{"http://example.com/charts/nina-0.1.0.tgz"}, - Metadata: &chart.Metadata{ - Name: "niña", - Version: "0.1.0", - Description: "One boat", - }, - }, - }, - "pinta": { - { - URLs: []string{"http://example.com/charts/pinta-0.1.0.tgz"}, - Metadata: &chart.Metadata{ - Name: "pinta", - Version: "0.1.0", - Description: "Two ship", - }, - }, - }, - "santa-maria": { - { - URLs: []string{"http://example.com/charts/santa-maria-1.2.3.tgz"}, - Metadata: &chart.Metadata{ - Name: "santa-maria", - Version: "1.2.3", - Description: "Three boat", - }, - }, - { - URLs: []string{"http://example.com/charts/santa-maria-1.2.2-rc-1.tgz"}, - Metadata: &chart.Metadata{ - Name: "santa-maria", - Version: "1.2.2-RC-1", - Description: "Three boat", - }, - }, - }, -} - -func loadTestIndex(t *testing.T, all bool) *Index { - i := NewIndex() - i.AddRepo("testing", &repo.IndexFile{Entries: indexfileEntries}, all) - i.AddRepo("ztesting", &repo.IndexFile{Entries: map[string]repo.ChartVersions{ - "pinta": { - { - URLs: []string{"http://example.com/charts/pinta-2.0.0.tgz"}, - Metadata: &chart.Metadata{ - Name: "pinta", - Version: "2.0.0", - Description: "Two ship, version two", - }, - }, - }, - }}, all) - return i -} - -func TestAll(t *testing.T) { - i := loadTestIndex(t, false) - all := i.All() - if len(all) != 4 { - t.Errorf("Expected 4 entries, got %d", len(all)) - } - - i = loadTestIndex(t, true) - all = i.All() - if len(all) != 5 { - t.Errorf("Expected 5 entries, got %d", len(all)) - } -} - -func TestAddRepo_Sort(t *testing.T) { - i := loadTestIndex(t, true) - sr, err := i.Search("TESTING/SANTA-MARIA", 100, false) - if err != nil { - t.Fatal(err) - } - SortScore(sr) - - ch := sr[0] - expect := "1.2.3" - if ch.Chart.Version != expect { - t.Errorf("Expected %q, got %q", expect, ch.Chart.Version) - } -} - -func TestSearchByName(t *testing.T) { - - tests := []struct { - name string - query string - expect []*Result - regexp bool - fail bool - failMsg string - }{ - { - name: "basic search for one result", - query: "santa-maria", - expect: []*Result{ - {Name: "testing/santa-maria"}, - }, - }, - { - name: "basic search for two results", - query: "pinta", - expect: []*Result{ - {Name: "testing/pinta"}, - {Name: "ztesting/pinta"}, - }, - }, - { - name: "repo-specific search for one result", - query: "ztesting/pinta", - expect: []*Result{ - {Name: "ztesting/pinta"}, - }, - }, - { - name: "partial name search", - query: "santa", - expect: []*Result{ - {Name: "testing/santa-maria"}, - }, - }, - { - name: "description search, one result", - query: "Three", - expect: []*Result{ - {Name: "testing/santa-maria"}, - }, - }, - { - name: "description search, two results", - query: "two", - expect: []*Result{ - {Name: "testing/pinta"}, - {Name: "ztesting/pinta"}, - }, - }, - { - name: "description upper search, two results", - query: "TWO", - expect: []*Result{ - {Name: "testing/pinta"}, - {Name: "ztesting/pinta"}, - }, - }, - { - name: "nothing found", - query: "mayflower", - expect: []*Result{}, - }, - { - name: "regexp, one result", - query: "Th[ref]*", - expect: []*Result{ - {Name: "testing/santa-maria"}, - }, - regexp: true, - }, - { - name: "regexp, fail compile", - query: "th[", - expect: []*Result{}, - regexp: true, - fail: true, - failMsg: "error parsing regexp:", - }, - } - - i := loadTestIndex(t, false) - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - - charts, err := i.Search(tt.query, 100, tt.regexp) - if err != nil { - if tt.fail { - if !strings.Contains(err.Error(), tt.failMsg) { - t.Fatalf("Unexpected error message: %s", err) - } - return - } - t.Fatalf("%s: %s", tt.name, err) - } - // Give us predictably ordered results. - SortScore(charts) - - l := len(charts) - if l != len(tt.expect) { - t.Fatalf("Expected %d result, got %d", len(tt.expect), l) - } - // For empty result sets, just keep going. - if l == 0 { - return - } - - for i, got := range charts { - ex := tt.expect[i] - if got.Name != ex.Name { - t.Errorf("[%d]: Expected name %q, got %q", i, ex.Name, got.Name) - } - } - - }) - } -} - -func TestSearchByNameAll(t *testing.T) { - // Test with the All bit turned on. - i := loadTestIndex(t, true) - cs, err := i.Search("santa-maria", 100, false) - if err != nil { - t.Fatal(err) - } - if len(cs) != 2 { - t.Errorf("expected 2 charts, got %d", len(cs)) - } -} - -func TestCalcScore(t *testing.T) { - i := NewIndex() - - fields := []string{"aaa", "bbb", "ccc", "ddd"} - matchline := strings.Join(fields, sep) - if r := i.calcScore(2, matchline); r != 0 { - t.Errorf("Expected 0, got %d", r) - } - if r := i.calcScore(5, matchline); r != 1 { - t.Errorf("Expected 1, got %d", r) - } - if r := i.calcScore(10, matchline); r != 2 { - t.Errorf("Expected 2, got %d", r) - } - if r := i.calcScore(14, matchline); r != 3 { - t.Errorf("Expected 3, got %d", r) - } -} diff --git a/cmd/helm/search_hub.go b/cmd/helm/search_hub.go deleted file mode 100644 index b8887efd5..000000000 --- a/cmd/helm/search_hub.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -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 ( - "fmt" - "io" - "strings" - - "github.com/gosuri/uitable" - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/internal/monocular" - "helm.sh/helm/v3/pkg/cli/output" -) - -const searchHubDesc = ` -Search for Helm charts in the Artifact Hub or your own hub instance. - -Artifact Hub is a web-based application that enables finding, installing, and -publishing packages and configurations for CNCF projects, including publicly -available distributed charts Helm charts. It is a Cloud Native Computing -Foundation sandbox project. You can browse the hub at https://artifacthub.io/ - -The [KEYWORD] argument accepts either a keyword string, or quoted string of rich -query options. For rich query options documentation, see -https://artifacthub.github.io/hub/api/?urls.primaryName=Monocular%20compatible%20search%20API#/Monocular/get_api_chartsvc_v1_charts_search - -Previous versions of Helm used an instance of Monocular as the default -'endpoint', so for backwards compatibility Artifact Hub is compatible with the -Monocular search API. Similarly, when setting the 'endpoint' flag, the specified -endpoint must also be implement a Monocular compatible search API endpoint. -Note that when specifying a Monocular instance as the 'endpoint', rich queries -are not supported. For API details, see https://github.com/helm/monocular -` - -type searchHubOptions struct { - searchEndpoint string - maxColWidth uint - outputFormat output.Format - listRepoURL bool -} - -func newSearchHubCmd(out io.Writer) *cobra.Command { - o := &searchHubOptions{} - - cmd := &cobra.Command{ - Use: "hub [KEYWORD]", - Short: "search for charts in the Artifact Hub or your own hub instance", - Long: searchHubDesc, - RunE: func(cmd *cobra.Command, args []string) error { - return o.run(out, args) - }, - } - - f := cmd.Flags() - f.StringVar(&o.searchEndpoint, "endpoint", "https://hub.helm.sh", "Hub instance to query for charts") - f.UintVar(&o.maxColWidth, "max-col-width", 50, "maximum column width for output table") - f.BoolVar(&o.listRepoURL, "list-repo-url", false, "print charts repository URL") - - bindOutputFlag(cmd, &o.outputFormat) - - return cmd -} - -func (o *searchHubOptions) run(out io.Writer, args []string) error { - c, err := monocular.New(o.searchEndpoint) - if err != nil { - return errors.Wrap(err, fmt.Sprintf("unable to create connection to %q", o.searchEndpoint)) - } - - q := strings.Join(args, " ") - results, err := c.Search(q) - if err != nil { - debug("%s", err) - return fmt.Errorf("unable to perform search against %q", o.searchEndpoint) - } - - return o.outputFormat.Write(out, newHubSearchWriter(results, o.searchEndpoint, o.maxColWidth, o.listRepoURL)) -} - -type hubChartRepo struct { - URL string `json:"url"` - Name string `json:"name"` -} - -type hubChartElement struct { - URL string `json:"url"` - Version string `json:"version"` - AppVersion string `json:"app_version"` - Description string `json:"description"` - Repository hubChartRepo `json:"repository"` -} - -type hubSearchWriter struct { - elements []hubChartElement - columnWidth uint - listRepoURL bool -} - -func newHubSearchWriter(results []monocular.SearchResult, endpoint string, columnWidth uint, listRepoURL bool) *hubSearchWriter { - var elements []hubChartElement - for _, r := range results { - // Backwards compatibility for Monocular - url := endpoint + "/charts/" + r.ID - - // Check for artifactHub compatibility - if r.ArtifactHub.PackageURL != "" { - url = r.ArtifactHub.PackageURL - } - - elements = append(elements, hubChartElement{url, r.Relationships.LatestChartVersion.Data.Version, r.Relationships.LatestChartVersion.Data.AppVersion, r.Attributes.Description, hubChartRepo{URL: r.Attributes.Repo.URL, Name: r.Attributes.Repo.Name}}) - } - return &hubSearchWriter{elements, columnWidth, listRepoURL} -} - -func (h *hubSearchWriter) WriteTable(out io.Writer) error { - if len(h.elements) == 0 { - _, err := out.Write([]byte("No results found\n")) - if err != nil { - return fmt.Errorf("unable to write results: %s", err) - } - return nil - } - table := uitable.New() - table.MaxColWidth = h.columnWidth - - if h.listRepoURL { - table.AddRow("URL", "CHART VERSION", "APP VERSION", "DESCRIPTION", "REPO URL") - } else { - table.AddRow("URL", "CHART VERSION", "APP VERSION", "DESCRIPTION") - } - - for _, r := range h.elements { - if h.listRepoURL { - table.AddRow(r.URL, r.Version, r.AppVersion, r.Description, r.Repository.URL) - } else { - table.AddRow(r.URL, r.Version, r.AppVersion, r.Description) - } - } - return output.EncodeTable(out, table) -} - -func (h *hubSearchWriter) WriteJSON(out io.Writer) error { - return h.encodeByFormat(out, output.JSON) -} - -func (h *hubSearchWriter) WriteYAML(out io.Writer) error { - return h.encodeByFormat(out, output.YAML) -} - -func (h *hubSearchWriter) encodeByFormat(out io.Writer, format output.Format) error { - // Initialize the array so no results returns an empty array instead of null - chartList := make([]hubChartElement, 0, len(h.elements)) - - for _, r := range h.elements { - chartList = append(chartList, hubChartElement{r.URL, r.Version, r.AppVersion, r.Description, r.Repository}) - } - - switch format { - case output.JSON: - return output.EncodeJSON(out, chartList) - case output.YAML: - return output.EncodeYAML(out, chartList) - } - - // Because this is a non-exported function and only called internally by - // WriteJSON and WriteYAML, we shouldn't get invalid types - return nil -} diff --git a/cmd/helm/search_hub_test.go b/cmd/helm/search_hub_test.go deleted file mode 100644 index 7df54ea8f..000000000 --- a/cmd/helm/search_hub_test.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -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 ( - "fmt" - "net/http" - "net/http/httptest" - "testing" -) - -func TestSearchHubCmd(t *testing.T) { - - // Setup a mock search service - var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"stable","url":"https://charts.helm.sh/stable"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/stable/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T17:57:31.38Z","digest":"119c499251bffd4b06ff0cd5ac98c2ce32231f84899fb4825be6c2d90971c742","urls":["https://charts.helm.sh/stable/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/stable/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/stable/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/stable/phpmyadmin/versions/3.0.0"}}}},{"id":"bitnami/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"bitnami","url":"https://charts.bitnami.com"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/bitnami/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T18:34:13.341Z","digest":"66d77cf6d8c2b52c488d0a294cd4996bd5bad8dc41d3829c394498fb401c008a","urls":["https://charts.bitnami.com/bitnami/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/bitnami/phpmyadmin/versions/3.0.0"}}}}]}` - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintln(w, searchResult) - })) - defer ts.Close() - - // The expected output has the URL to the mocked search service in it - // Trailing spaces are necessary to preserve in "expected" as the uitable package adds - // them during printing. - var expected = fmt.Sprintf(`URL CHART VERSION APP VERSION DESCRIPTION -%s/charts/stable/phpmyadmin 3.0.0 4.9.0-1 phpMyAdmin is an mysql administration frontend -%s/charts/bitnami/phpmyadmin 3.0.0 4.9.0-1 phpMyAdmin is an mysql administration frontend -`, ts.URL, ts.URL) - - testcmd := "search hub --endpoint " + ts.URL + " maria" - storage := storageFixture() - _, out, err := executeActionCommandC(storage, testcmd) - if err != nil { - t.Errorf("unexpected error, %s", err) - } - if out != expected { - t.Error("expected and actual output did not match") - t.Log(out) - t.Log(expected) - } -} - -func TestSearchHubListRepoCmd(t *testing.T) { - - // Setup a mock search service - var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"stable","url":"https://charts.helm.sh/stable"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/stable/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T17:57:31.38Z","digest":"119c499251bffd4b06ff0cd5ac98c2ce32231f84899fb4825be6c2d90971c742","urls":["https://charts.helm.sh/stable/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/stable/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/stable/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/stable/phpmyadmin/versions/3.0.0"}}}},{"id":"bitnami/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"bitnami","url":"https://charts.bitnami.com"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/bitnami/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T18:34:13.341Z","digest":"66d77cf6d8c2b52c488d0a294cd4996bd5bad8dc41d3829c394498fb401c008a","urls":["https://charts.bitnami.com/bitnami/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/bitnami/phpmyadmin/versions/3.0.0"}}}}]}` - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintln(w, searchResult) - })) - defer ts.Close() - - // The expected output has the URL to the mocked search service in it - // Trailing spaces are necessary to preserve in "expected" as the uitable package adds - // them during printing. - var expected = fmt.Sprintf(`URL CHART VERSION APP VERSION DESCRIPTION REPO URL -%s/charts/stable/phpmyadmin 3.0.0 4.9.0-1 phpMyAdmin is an mysql administration frontend https://charts.helm.sh/stable -%s/charts/bitnami/phpmyadmin 3.0.0 4.9.0-1 phpMyAdmin is an mysql administration frontend https://charts.bitnami.com -`, ts.URL, ts.URL) - - testcmd := "search hub --list-repo-url --endpoint " + ts.URL + " maria" - storage := storageFixture() - _, out, err := executeActionCommandC(storage, testcmd) - if err != nil { - t.Errorf("unexpected error, %s", err) - } - if out != expected { - t.Error("expected and actual output did not match") - t.Log(out) - t.Log(expected) - } -} - -func TestSearchHubOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "search hub") -} - -func TestSearchHubFileCompletion(t *testing.T) { - checkFileCompletion(t, "search hub", true) // File completion may be useful when inputting a keyword -} diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go deleted file mode 100644 index f794f6bca..000000000 --- a/cmd/helm/search_repo.go +++ /dev/null @@ -1,383 +0,0 @@ -/* -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 ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/Masterminds/semver/v3" - "github.com/gosuri/uitable" - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/search" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/helmpath" - "helm.sh/helm/v3/pkg/repo" -) - -const searchRepoDesc = ` -Search reads through all of the repositories configured on the system, and -looks for matches. Search of these repositories uses the metadata stored on -the system. - -It will display the latest stable versions of the charts found. If you -specify the --devel flag, the output will include pre-release versions. -If you want to search using a version constraint, use --version. - -Examples: - - # Search for stable release versions matching the keyword "nginx" - $ helm search repo nginx - - # Search for release versions matching the keyword "nginx", including pre-release versions - $ helm search repo nginx --devel - - # Search for the latest stable release for nginx-ingress with a major version of 1 - $ helm search repo nginx-ingress --version ^1.0.0 - -Repositories are managed with 'helm repo' commands. -` - -// searchMaxScore suggests that any score higher than this is not considered a match. -const searchMaxScore = 25 - -type searchRepoOptions struct { - versions bool - regexp bool - devel bool - version string - maxColWidth uint - repoFile string - repoCacheDir string - outputFormat output.Format -} - -func newSearchRepoCmd(out io.Writer) *cobra.Command { - o := &searchRepoOptions{} - - cmd := &cobra.Command{ - Use: "repo [keyword]", - Short: "search repositories for a keyword in charts", - Long: searchRepoDesc, - RunE: func(cmd *cobra.Command, args []string) error { - o.repoFile = settings.RepositoryConfig - o.repoCacheDir = settings.RepositoryCache - return o.run(out, args) - }, - } - - f := cmd.Flags() - f.BoolVarP(&o.regexp, "regexp", "r", false, "use regular expressions for searching repositories you have added") - f.BoolVarP(&o.versions, "versions", "l", false, "show the long listing, with each version of each chart on its own line, for repositories you have added") - f.BoolVar(&o.devel, "devel", false, "use development versions (alpha, beta, and release candidate releases), too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") - f.StringVar(&o.version, "version", "", "search using semantic versioning constraints on repositories you have added") - f.UintVar(&o.maxColWidth, "max-col-width", 50, "maximum column width for output table") - bindOutputFlag(cmd, &o.outputFormat) - - return cmd -} - -func (o *searchRepoOptions) run(out io.Writer, args []string) error { - o.setupSearchedVersion() - - index, err := o.buildIndex() - if err != nil { - return err - } - - var res []*search.Result - if len(args) == 0 { - res = index.All() - } else { - q := strings.Join(args, " ") - res, err = index.Search(q, searchMaxScore, o.regexp) - if err != nil { - return err - } - } - - search.SortScore(res) - data, err := o.applyConstraint(res) - if err != nil { - return err - } - - return o.outputFormat.Write(out, &repoSearchWriter{data, o.maxColWidth}) -} - -func (o *searchRepoOptions) setupSearchedVersion() { - debug("Original chart version: %q", o.version) - - if o.version != "" { - return - } - - if o.devel { // search for releases and prereleases (alpha, beta, and release candidate releases). - debug("setting version to >0.0.0-0") - o.version = ">0.0.0-0" - } else { // search only for stable releases, prerelease versions will be skip - debug("setting version to >0.0.0") - o.version = ">0.0.0" - } -} - -func (o *searchRepoOptions) applyConstraint(res []*search.Result) ([]*search.Result, error) { - if o.version == "" { - return res, nil - } - - constraint, err := semver.NewConstraint(o.version) - if err != nil { - return res, errors.Wrap(err, "an invalid version/constraint format") - } - - data := res[:0] - foundNames := map[string]bool{} - for _, r := range res { - // if not returning all versions and already have found a result, - // you're done! - if !o.versions && foundNames[r.Name] { - continue - } - v, err := semver.NewVersion(r.Chart.Version) - if err != nil { - continue - } - if constraint.Check(v) { - data = append(data, r) - foundNames[r.Name] = true - } - } - - return data, nil -} - -func (o *searchRepoOptions) buildIndex() (*search.Index, error) { - // Load the repositories.yaml - rf, err := repo.LoadFile(o.repoFile) - if isNotExist(err) || len(rf.Repositories) == 0 { - return nil, errors.New("no repositories configured") - } - - i := search.NewIndex() - for _, re := range rf.Repositories { - n := re.Name - f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n)) - ind, err := repo.LoadIndexFile(f) - if err != nil { - warning("Repo %q is corrupt or missing. Try 'helm repo update'.", n) - warning("%s", err) - continue - } - - i.AddRepo(n, ind, o.versions || len(o.version) > 0) - } - return i, nil -} - -type repoChartElement struct { - Name string `json:"name"` - Version string `json:"version"` - AppVersion string `json:"app_version"` - Description string `json:"description"` -} - -type repoSearchWriter struct { - results []*search.Result - columnWidth uint -} - -func (r *repoSearchWriter) WriteTable(out io.Writer) error { - if len(r.results) == 0 { - _, err := out.Write([]byte("No results found\n")) - if err != nil { - return fmt.Errorf("unable to write results: %s", err) - } - return nil - } - table := uitable.New() - table.MaxColWidth = r.columnWidth - table.AddRow("NAME", "CHART VERSION", "APP VERSION", "DESCRIPTION") - for _, r := range r.results { - table.AddRow(r.Name, r.Chart.Version, r.Chart.AppVersion, r.Chart.Description) - } - return output.EncodeTable(out, table) -} - -func (r *repoSearchWriter) WriteJSON(out io.Writer) error { - return r.encodeByFormat(out, output.JSON) -} - -func (r *repoSearchWriter) WriteYAML(out io.Writer) error { - return r.encodeByFormat(out, output.YAML) -} - -func (r *repoSearchWriter) encodeByFormat(out io.Writer, format output.Format) error { - // Initialize the array so no results returns an empty array instead of null - chartList := make([]repoChartElement, 0, len(r.results)) - - for _, r := range r.results { - chartList = append(chartList, repoChartElement{r.Name, r.Chart.Version, r.Chart.AppVersion, r.Chart.Description}) - } - - switch format { - case output.JSON: - return output.EncodeJSON(out, chartList) - case output.YAML: - return output.EncodeYAML(out, chartList) - } - - // Because this is a non-exported function and only called internally by - // WriteJSON and WriteYAML, we shouldn't get invalid types - return nil -} - -// Provides the list of charts that are part of the specified repo, and that starts with 'prefix'. -func compListChartsOfRepo(repoName string, prefix string) []string { - var charts []string - - path := filepath.Join(settings.RepositoryCache, helmpath.CacheChartsFile(repoName)) - content, err := ioutil.ReadFile(path) - if err == nil { - scanner := bufio.NewScanner(bytes.NewReader(content)) - for scanner.Scan() { - fullName := fmt.Sprintf("%s/%s", repoName, scanner.Text()) - if strings.HasPrefix(fullName, prefix) { - charts = append(charts, fullName) - } - } - return charts - } - - if isNotExist(err) { - // If there is no cached charts file, fallback to the full index file. - // This is much slower but can happen after the caching feature is first - // installed but before the user does a 'helm repo update' to generate the - // first cached charts file. - path = filepath.Join(settings.RepositoryCache, helmpath.CacheIndexFile(repoName)) - if indexFile, err := repo.LoadIndexFile(path); err == nil { - for name := range indexFile.Entries { - fullName := fmt.Sprintf("%s/%s", repoName, name) - if strings.HasPrefix(fullName, prefix) { - charts = append(charts, fullName) - } - } - return charts - } - } - - return []string{} -} - -// Provide dynamic auto-completion for commands that operate on charts (e.g., helm show) -// When true, the includeFiles argument indicates that completion should include local files (e.g., local charts) -func compListCharts(toComplete string, includeFiles bool) ([]string, cobra.ShellCompDirective) { - cobra.CompDebugln(fmt.Sprintf("compListCharts with toComplete %s", toComplete), settings.Debug) - - noSpace := false - noFile := false - var completions []string - - // First check completions for repos - repos := compListRepos("", nil) - for _, repoInfo := range repos { - // Split name from description - repoInfo := strings.Split(repoInfo, "\t") - repo := repoInfo[0] - repoDesc := "" - if len(repoInfo) > 1 { - repoDesc = repoInfo[1] - } - repoWithSlash := fmt.Sprintf("%s/", repo) - if strings.HasPrefix(toComplete, repoWithSlash) { - // Must complete with charts within the specified repo. - // Don't filter on toComplete to allow for shell fuzzy matching - completions = append(completions, compListChartsOfRepo(repo, "")...) - noSpace = false - break - } else if strings.HasPrefix(repo, toComplete) { - // Must complete the repo name with the slash, followed by the description - completions = append(completions, fmt.Sprintf("%s\t%s", repoWithSlash, repoDesc)) - noSpace = true - } - } - cobra.CompDebugln(fmt.Sprintf("Completions after repos: %v", completions), settings.Debug) - - // Now handle completions for url prefixes - for _, url := range []string{"oci://\tChart OCI prefix", "https://\tChart URL prefix", "http://\tChart URL prefix", "file://\tChart local URL prefix"} { - if strings.HasPrefix(toComplete, url) { - // The user already put in the full url prefix; we don't have - // anything to add, but make sure the shell does not default - // to file completion since we could be returning an empty array. - noFile = true - noSpace = true - } else if strings.HasPrefix(url, toComplete) { - // We are completing a url prefix - completions = append(completions, url) - noSpace = true - } - } - cobra.CompDebugln(fmt.Sprintf("Completions after urls: %v", completions), settings.Debug) - - // Finally, provide file completion if we need to. - // We only do this if: - // 1- There are other completions found (if there are no completions, - // the shell will do file completion itself) - // 2- If there is some input from the user (or else we will end up - // listing the entire content of the current directory which will - // be too many choices for the user to find the real repos) - if includeFiles && len(completions) > 0 && len(toComplete) > 0 { - if files, err := os.ReadDir("."); err == nil { - for _, file := range files { - if strings.HasPrefix(file.Name(), toComplete) { - // We are completing a file prefix - completions = append(completions, file.Name()) - } - } - } - } - cobra.CompDebugln(fmt.Sprintf("Completions after files: %v", completions), settings.Debug) - - // If the user didn't provide any input to completion, - // we provide a hint that a path can also be used - if includeFiles && len(toComplete) == 0 { - completions = append(completions, "./\tRelative path prefix to local chart", "/\tAbsolute path prefix to local chart") - } - cobra.CompDebugln(fmt.Sprintf("Completions after checking empty input: %v", completions), settings.Debug) - - directive := cobra.ShellCompDirectiveDefault - if noFile { - directive = directive | cobra.ShellCompDirectiveNoFileComp - } - if noSpace { - directive = directive | cobra.ShellCompDirectiveNoSpace - } - if !includeFiles { - // If we should not include files in the completions, - // we should disable file completion - directive = directive | cobra.ShellCompDirectiveNoFileComp - } - return completions, directive -} diff --git a/cmd/helm/search_repo_test.go b/cmd/helm/search_repo_test.go deleted file mode 100644 index 58ba3a715..000000000 --- a/cmd/helm/search_repo_test.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -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 ( - "testing" -) - -func TestSearchRepositoriesCmd(t *testing.T) { - repoFile := "testdata/helmhome/helm/repositories.yaml" - repoCache := "testdata/helmhome/helm/repository" - - tests := []cmdTestCase{{ - name: "search for 'alpine', expect one match with latest stable version", - cmd: "search repo alpine", - golden: "output/search-multiple-stable-release.txt", - }, { - name: "search for 'alpine', expect one match with newest development version", - cmd: "search repo alpine --devel", - golden: "output/search-multiple-devel-release.txt", - }, { - name: "search for 'alpine' with versions, expect three matches", - cmd: "search repo alpine --versions", - golden: "output/search-multiple-versions.txt", - }, { - name: "search for 'alpine' with version constraint, expect one match with version 0.1.0", - cmd: "search repo alpine --version '>= 0.1, < 0.2'", - golden: "output/search-constraint.txt", - }, { - name: "search for 'alpine' with version constraint, expect one match with version 0.1.0", - cmd: "search repo alpine --versions --version '>= 0.1, < 0.2'", - golden: "output/search-versions-constraint.txt", - }, { - name: "search for 'alpine' with version constraint, expect one match with version 0.2.0", - cmd: "search repo alpine --version '>= 0.1'", - golden: "output/search-constraint-single.txt", - }, { - name: "search for 'alpine' with version constraint and --versions, expect two matches", - cmd: "search repo alpine --versions --version '>= 0.1'", - golden: "output/search-multiple-versions-constraints.txt", - }, { - name: "search for 'syzygy', expect no matches", - cmd: "search repo syzygy", - golden: "output/search-not-found.txt", - }, { - name: "search for 'alp[a-z]+', expect two matches", - cmd: "search repo alp[a-z]+ --regexp", - golden: "output/search-regex.txt", - }, { - name: "search for 'alp[', expect failure to compile regexp", - cmd: "search repo alp[ --regexp", - wantError: true, - }, { - name: "search for 'maria', expect valid json output", - cmd: "search repo maria --output json", - golden: "output/search-output-json.txt", - }, { - name: "search for 'alpine', expect valid yaml output", - cmd: "search repo alpine --output yaml", - golden: "output/search-output-yaml.txt", - }} - - settings.Debug = true - defer func() { settings.Debug = false }() - - for i := range tests { - tests[i].cmd += " --repository-config " + repoFile - tests[i].cmd += " --repository-cache " + repoCache - } - runTestCmd(t, tests) -} - -func TestSearchRepoOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "search repo") -} - -func TestSearchRepoFileCompletion(t *testing.T) { - checkFileCompletion(t, "search repo", true) // File completion may be useful when inputting a keyword -} diff --git a/cmd/helm/search_test.go b/cmd/helm/search_test.go deleted file mode 100644 index 6cf845b06..000000000 --- a/cmd/helm/search_test.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -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 "testing" - -func TestSearchFileCompletion(t *testing.T) { - checkFileCompletion(t, "search", false) -} diff --git a/cmd/helm/show.go b/cmd/helm/show.go deleted file mode 100644 index 718d716a0..000000000 --- a/cmd/helm/show.go +++ /dev/null @@ -1,206 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const showDesc = ` -This command consists of multiple subcommands to display information about a chart -` - -const showAllDesc = ` -This command inspects a chart (directory, file, or URL) and displays all its content -(values.yaml, Chart.yaml, README) -` - -const showValuesDesc = ` -This command inspects a chart (directory, file, or URL) and displays the contents -of the values.yaml file -` - -const showChartDesc = ` -This command inspects a chart (directory, file, or URL) and displays the contents -of the Chart.yaml file -` - -const readmeChartDesc = ` -This command inspects a chart (directory, file, or URL) and displays the contents -of the README file -` - -const showCRDsDesc = ` -This command inspects a chart (directory, file, or URL) and displays the contents -of the CustomResourceDefinition files -` - -func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewShowWithConfig(action.ShowAll, cfg) - - showCommand := &cobra.Command{ - Use: "show", - Short: "show information of a chart", - Aliases: []string{"inspect"}, - Long: showDesc, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, // Disable file completion - } - - // Function providing dynamic auto-completion - validArgsFunc := func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListCharts(toComplete, true) - } - - all := &cobra.Command{ - Use: "all [CHART]", - Short: "show all information of the chart", - Long: showAllDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: validArgsFunc, - RunE: func(cmd *cobra.Command, args []string) error { - client.OutputFormat = action.ShowAll - output, err := runShow(args, client) - if err != nil { - return err - } - fmt.Fprint(out, output) - return nil - }, - } - - valuesSubCmd := &cobra.Command{ - Use: "values [CHART]", - Short: "show the chart's values", - Long: showValuesDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: validArgsFunc, - RunE: func(cmd *cobra.Command, args []string) error { - client.OutputFormat = action.ShowValues - output, err := runShow(args, client) - if err != nil { - return err - } - fmt.Fprint(out, output) - return nil - }, - } - - chartSubCmd := &cobra.Command{ - Use: "chart [CHART]", - Short: "show the chart's definition", - Long: showChartDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: validArgsFunc, - RunE: func(cmd *cobra.Command, args []string) error { - client.OutputFormat = action.ShowChart - output, err := runShow(args, client) - if err != nil { - return err - } - fmt.Fprint(out, output) - return nil - }, - } - - readmeSubCmd := &cobra.Command{ - Use: "readme [CHART]", - Short: "show the chart's README", - Long: readmeChartDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: validArgsFunc, - RunE: func(cmd *cobra.Command, args []string) error { - client.OutputFormat = action.ShowReadme - output, err := runShow(args, client) - if err != nil { - return err - } - fmt.Fprint(out, output) - return nil - }, - } - - crdsSubCmd := &cobra.Command{ - Use: "crds [CHART]", - Short: "show the chart's CRDs", - Long: showCRDsDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: validArgsFunc, - RunE: func(cmd *cobra.Command, args []string) error { - client.OutputFormat = action.ShowCRDs - output, err := runShow(args, client) - if err != nil { - return err - } - fmt.Fprint(out, output) - return nil - }, - } - - cmds := []*cobra.Command{all, readmeSubCmd, valuesSubCmd, chartSubCmd, crdsSubCmd} - for _, subCmd := range cmds { - addShowFlags(subCmd, client) - showCommand.AddCommand(subCmd) - } - - return showCommand -} - -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") - if subCmd.Name() == "values" { - f.StringVar(&client.JSONPathTemplate, "jsonpath", "", "supply a JSONPath expression to filter the output") - } - addChartPathOptionsFlags(f, &client.ChartPathOptions) - - err := subCmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 1 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compVersionFlag(args[0], toComplete) - }) - - if err != nil { - log.Fatal(err) - } -} - -func runShow(args []string, client *action.Show) (string, error) { - debug("Original chart version: %q", client.Version) - if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") - client.Version = ">0.0.0-0" - } - - cp, err := client.ChartPathOptions.LocateChart(args[0], settings) - if err != nil { - return "", err - } - return client.Run(cp) -} diff --git a/cmd/helm/show_test.go b/cmd/helm/show_test.go deleted file mode 100644 index 93ec08d0f..000000000 --- a/cmd/helm/show_test.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -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 ( - "fmt" - "path/filepath" - "strings" - "testing" - - "helm.sh/helm/v3/pkg/repo/repotest" -) - -func TestShowPreReleaseChart(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } - defer srv.Stop() - - if err := srv.LinkIndices(); err != nil { - t.Fatal(err) - } - - tests := []struct { - name string - args string - flags string - fail bool - expectedErr string - }{ - { - name: "show pre-release chart", - args: "test/pre-release-chart", - fail: true, - expectedErr: "chart \"pre-release-chart\" matching not found in test index. (try 'helm repo update'): no chart version found for pre-release-chart-", - }, - { - name: "show pre-release chart", - args: "test/pre-release-chart", - fail: true, - flags: "--version 1.0.0", - expectedErr: "chart \"pre-release-chart\" matching 1.0.0 not found in test index. (try 'helm repo update'): no chart version found for pre-release-chart-1.0.0", - }, - { - name: "show pre-release chart with 'devel' flag", - args: "test/pre-release-chart", - flags: "--devel", - fail: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - outdir := srv.Root() - cmd := fmt.Sprintf("show all '%s' %s --repository-config %s --repository-cache %s", - tt.args, - tt.flags, - filepath.Join(outdir, "repositories.yaml"), - outdir, - ) - //_, out, err := executeActionCommand(cmd) - _, _, err := executeActionCommand(cmd) - if err != nil { - if tt.fail { - if !strings.Contains(err.Error(), tt.expectedErr) { - t.Errorf("%q expected error: %s, got: %s", tt.name, tt.expectedErr, err.Error()) - } - return - } - t.Errorf("%q reported error: %s", tt.name, err) - } - }) - } -} - -func TestShowVersionCompletion(t *testing.T) { - repoFile := "testdata/helmhome/helm/repositories.yaml" - repoCache := "testdata/helmhome/helm/repository" - - repoSetup := fmt.Sprintf("--repository-config %s --repository-cache %s", repoFile, repoCache) - - tests := []cmdTestCase{{ - name: "completion for show version flag", - cmd: fmt.Sprintf("%s __complete show chart testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for show version flag, no filter", - cmd: fmt.Sprintf("%s __complete show chart testing/alpine --version 0.3", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for show version flag too few args", - cmd: fmt.Sprintf("%s __complete show chart --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for show version flag too many args", - cmd: fmt.Sprintf("%s __complete show chart testing/alpine badarg --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for show version flag invalid chart", - cmd: fmt.Sprintf("%s __complete show chart invalid/invalid --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for show version flag with all", - cmd: fmt.Sprintf("%s __complete show all testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for show version flag with readme", - cmd: fmt.Sprintf("%s __complete show readme testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for show version flag with values", - cmd: fmt.Sprintf("%s __complete show values testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestShowFileCompletion(t *testing.T) { - checkFileCompletion(t, "show", false) -} - -func TestShowAllFileCompletion(t *testing.T) { - checkFileCompletion(t, "show all", true) -} - -func TestShowChartFileCompletion(t *testing.T) { - checkFileCompletion(t, "show chart", true) -} - -func TestShowReadmeFileCompletion(t *testing.T) { - checkFileCompletion(t, "show readme", true) -} - -func TestShowValuesFileCompletion(t *testing.T) { - checkFileCompletion(t, "show values", true) -} - -func TestShowCRDsFileCompletion(t *testing.T) { - checkFileCompletion(t, "show crds", true) -} diff --git a/cmd/helm/status.go b/cmd/helm/status.go deleted file mode 100644 index 6085251d5..000000000 --- a/cmd/helm/status.go +++ /dev/null @@ -1,194 +0,0 @@ -/* -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 ( - "fmt" - "io" - "log" - "strings" - "time" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/release" -) - -// NOTE: Keep the list of statuses up-to-date with pkg/release/status.go. -var statusHelp = ` -This command shows the status of a named release. -The status consists of: -- last deployment time -- k8s namespace in which the release lives -- state of the release (can be: unknown, deployed, uninstalled, superseded, failed, uninstalling, pending-install, pending-upgrade or pending-rollback) -- revision of the release -- description of the release (can be completion message or error message, need to enable --show-desc) -- list of resources that this release consists of, sorted by kind -- details on last test suite run, if applicable -- additional notes provided by the chart -` - -func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewStatus(cfg) - var outfmt output.Format - - cmd := &cobra.Command{ - Use: "status RELEASE_NAME", - Short: "display the status of the named release", - Long: statusHelp, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 0 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - rel, err := client.Run(args[0]) - if err != nil { - return err - } - - // strip chart metadata from the output - rel.Chart = nil - - return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription}) - }, - } - - f := cmd.Flags() - - f.IntVar(&client.Version, "revision", 0, "if set, display the status of the named release with revision") - - err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 1 { - return compListRevisions(toComplete, cfg, args[0]) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }) - - if err != nil { - log.Fatal(err) - } - - bindOutputFlag(cmd, &outfmt) - f.BoolVar(&client.ShowDescription, "show-desc", false, "if set, display the description message of the named release") - - return cmd -} - -type statusPrinter struct { - release *release.Release - debug bool - showDescription bool -} - -func (s statusPrinter) WriteJSON(out io.Writer) error { - return output.EncodeJSON(out, s.release) -} - -func (s statusPrinter) WriteYAML(out io.Writer) error { - return output.EncodeYAML(out, s.release) -} - -func (s statusPrinter) WriteTable(out io.Writer) error { - if s.release == nil { - return nil - } - fmt.Fprintf(out, "NAME: %s\n", s.release.Name) - if !s.release.Info.LastDeployed.IsZero() { - fmt.Fprintf(out, "LAST DEPLOYED: %s\n", s.release.Info.LastDeployed.Format(time.ANSIC)) - } - fmt.Fprintf(out, "NAMESPACE: %s\n", s.release.Namespace) - fmt.Fprintf(out, "STATUS: %s\n", s.release.Info.Status.String()) - fmt.Fprintf(out, "REVISION: %d\n", s.release.Version) - if s.showDescription { - fmt.Fprintf(out, "DESCRIPTION: %s\n", s.release.Info.Description) - } - - executions := executionsByHookEvent(s.release) - if tests, ok := executions[release.HookTest]; !ok || len(tests) == 0 { - fmt.Fprintln(out, "TEST SUITE: None") - } else { - for _, h := range tests { - // Don't print anything if hook has not been initiated - if h.LastRun.StartedAt.IsZero() { - continue - } - fmt.Fprintf(out, "TEST SUITE: %s\n%s\n%s\n%s\n", - h.Name, - fmt.Sprintf("Last Started: %s", h.LastRun.StartedAt.Format(time.ANSIC)), - fmt.Sprintf("Last Completed: %s", h.LastRun.CompletedAt.Format(time.ANSIC)), - fmt.Sprintf("Phase: %s", h.LastRun.Phase), - ) - } - } - - if s.debug { - fmt.Fprintln(out, "USER-SUPPLIED VALUES:") - err := output.EncodeYAML(out, s.release.Config) - if err != nil { - return err - } - // Print an extra newline - fmt.Fprintln(out) - - cfg, err := chartutil.CoalesceValues(s.release.Chart, s.release.Config) - if err != nil { - return err - } - - fmt.Fprintln(out, "COMPUTED VALUES:") - err = output.EncodeYAML(out, cfg.AsMap()) - if err != nil { - return err - } - // Print an extra newline - fmt.Fprintln(out) - } - - if strings.EqualFold(s.release.Info.Description, "Dry run complete") || s.debug { - fmt.Fprintln(out, "HOOKS:") - for _, h := range s.release.Hooks { - fmt.Fprintf(out, "---\n# Source: %s\n%s\n", h.Path, h.Manifest) - } - fmt.Fprintf(out, "MANIFEST:\n%s\n", s.release.Manifest) - } - - if len(s.release.Info.Notes) > 0 { - fmt.Fprintf(out, "NOTES:\n%s\n", strings.TrimSpace(s.release.Info.Notes)) - } - return nil -} - -func executionsByHookEvent(rel *release.Release) map[release.HookEvent][]*release.Hook { - result := make(map[release.HookEvent][]*release.Hook) - for _, h := range rel.Hooks { - for _, e := range h.Events { - executions, ok := result[e] - if !ok { - executions = []*release.Hook{} - } - result[e] = append(executions, h) - } - } - return result -} diff --git a/cmd/helm/status_test.go b/cmd/helm/status_test.go deleted file mode 100644 index 7f305d56b..000000000 --- a/cmd/helm/status_test.go +++ /dev/null @@ -1,202 +0,0 @@ -/* -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 ( - "testing" - "time" - - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/release" - helmtime "helm.sh/helm/v3/pkg/time" -) - -func TestStatusCmd(t *testing.T) { - releasesMockWithStatus := func(info *release.Info, hooks ...*release.Hook) []*release.Release { - info.LastDeployed = helmtime.Unix(1452902400, 0).UTC() - return []*release.Release{{ - Name: "flummoxed-chickadee", - Namespace: "default", - Info: info, - Chart: &chart.Chart{}, - Hooks: hooks, - }} - } - - tests := []cmdTestCase{{ - name: "get status of a deployed release", - cmd: "status flummoxed-chickadee", - golden: "output/status.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - }), - }, { - name: "get status of a deployed release, with desc", - cmd: "status --show-desc flummoxed-chickadee", - golden: "output/status-with-desc.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - Description: "Mock description", - }), - }, { - name: "get status of a deployed release with notes", - cmd: "status flummoxed-chickadee", - golden: "output/status-with-notes.txt", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - Notes: "release notes", - }), - }, { - name: "get status of a deployed release with notes in json", - cmd: "status flummoxed-chickadee -o json", - golden: "output/status.json", - rels: releasesMockWithStatus(&release.Info{ - Status: release.StatusDeployed, - Notes: "release notes", - }), - }, { - name: "get status of a deployed release with test suite", - cmd: "status flummoxed-chickadee", - golden: "output/status-with-test-suite.txt", - rels: releasesMockWithStatus( - &release.Info{ - Status: release.StatusDeployed, - }, - &release.Hook{ - Name: "never-run-test", - Events: []release.HookEvent{release.HookTest}, - }, - &release.Hook{ - Name: "passing-test", - Events: []release.HookEvent{release.HookTest}, - LastRun: release.HookExecution{ - StartedAt: mustParseTime("2006-01-02T15:04:05Z"), - CompletedAt: mustParseTime("2006-01-02T15:04:07Z"), - Phase: release.HookPhaseSucceeded, - }, - }, - &release.Hook{ - Name: "failing-test", - Events: []release.HookEvent{release.HookTest}, - LastRun: release.HookExecution{ - StartedAt: mustParseTime("2006-01-02T15:10:05Z"), - CompletedAt: mustParseTime("2006-01-02T15:10:07Z"), - Phase: release.HookPhaseFailed, - }, - }, - &release.Hook{ - Name: "passing-pre-install", - Events: []release.HookEvent{release.HookPreInstall}, - LastRun: release.HookExecution{ - StartedAt: mustParseTime("2006-01-02T15:00:05Z"), - CompletedAt: mustParseTime("2006-01-02T15:00:07Z"), - Phase: release.HookPhaseSucceeded, - }, - }, - ), - }} - runTestCmd(t, tests) -} - -func mustParseTime(t string) helmtime.Time { - res, _ := helmtime.Parse(time.RFC3339, t) - return res -} - -func TestStatusCompletion(t *testing.T) { - rels := []*release.Release{ - { - Name: "athos", - Namespace: "default", - Info: &release.Info{ - Status: release.StatusDeployed, - }, - Chart: &chart.Chart{ - Metadata: &chart.Metadata{ - Name: "Athos-chart", - Version: "1.2.3", - }, - }, - }, { - Name: "porthos", - Namespace: "default", - Info: &release.Info{ - Status: release.StatusFailed, - }, - Chart: &chart.Chart{ - Metadata: &chart.Metadata{ - Name: "Porthos-chart", - Version: "111.222.333", - }, - }, - }, { - Name: "aramis", - Namespace: "default", - Info: &release.Info{ - Status: release.StatusUninstalled, - }, - Chart: &chart.Chart{ - Metadata: &chart.Metadata{ - Name: "Aramis-chart", - Version: "0.0.0", - }, - }, - }, { - Name: "dartagnan", - Namespace: "gascony", - Info: &release.Info{ - Status: release.StatusUnknown, - }, - Chart: &chart.Chart{ - Metadata: &chart.Metadata{ - Name: "Dartagnan-chart", - Version: "1.2.3-prerelease", - }, - }, - }} - - tests := []cmdTestCase{{ - name: "completion for status", - cmd: "__complete status a", - golden: "output/status-comp.txt", - rels: rels, - }, { - name: "completion for status with too many arguments", - cmd: "__complete status dartagnan ''", - golden: "output/status-wrong-args-comp.txt", - rels: rels, - }, { - name: "completion for status with global flag", - cmd: "__complete status --debug a", - golden: "output/status-comp.txt", - rels: rels, - }} - runTestCmd(t, tests) -} - -func TestStatusRevisionCompletion(t *testing.T) { - revisionFlagCompletionTest(t, "status") -} - -func TestStatusOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "status") -} - -func TestStatusFileCompletion(t *testing.T) { - checkFileCompletion(t, "status", false) - checkFileCompletion(t, "status myrelease", false) -} diff --git a/cmd/helm/template.go b/cmd/helm/template.go deleted file mode 100644 index f9c51542a..000000000 --- a/cmd/helm/template.go +++ /dev/null @@ -1,245 +0,0 @@ -/* -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 ( - "bytes" - "fmt" - "io" - "os" - "path" - "path/filepath" - "regexp" - "sort" - "strings" - - "helm.sh/helm/v3/pkg/release" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/cli/values" - "helm.sh/helm/v3/pkg/releaseutil" -) - -const templateDesc = ` -Render chart templates locally and display the output. - -Any values that would normally be looked up or retrieved in-cluster will be -faked locally. Additionally, none of the server-side testing of chart validity -(e.g. whether an API is supported) is done. -` - -func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - var validate bool - var includeCrds bool - var skipTests bool - client := action.NewInstall(cfg) - valueOpts := &values.Options{} - var kubeVersion string - var extraAPIs []string - var showFiles []string - - cmd := &cobra.Command{ - Use: "template [NAME] [CHART]", - Short: "locally render templates", - Long: templateDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compInstall(args, toComplete, client) - }, - RunE: func(_ *cobra.Command, args []string) error { - if kubeVersion != "" { - parsedKubeVersion, err := chartutil.ParseKubeVersion(kubeVersion) - if err != nil { - return fmt.Errorf("invalid kube version '%s': %s", kubeVersion, err) - } - client.KubeVersion = parsedKubeVersion - } - - client.DryRun = true - client.ReleaseName = "release-name" - client.Replace = true // Skip the name check - client.ClientOnly = !validate - client.APIVersions = chartutil.VersionSet(extraAPIs) - client.IncludeCRDs = includeCrds - rel, err := runInstall(args, client, valueOpts, out) - - if err != nil && !settings.Debug { - if rel != nil { - return fmt.Errorf("%w\n\nUse --debug flag to render out invalid YAML", err) - } - return err - } - - // We ignore a potential error here because, when the --debug flag was specified, - // we always want to print the YAML, even if it is not valid. The error is still returned afterwards. - if rel != nil { - var manifests bytes.Buffer - fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) - if !client.DisableHooks { - fileWritten := make(map[string]bool) - for _, m := range rel.Hooks { - if skipTests && isTestHook(m) { - continue - } - if client.OutputDir == "" { - fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) - } else { - newDir := client.OutputDir - if client.UseReleaseName { - newDir = filepath.Join(client.OutputDir, client.ReleaseName) - } - err = writeToFile(newDir, m.Path, m.Manifest, fileWritten[m.Path]) - if err != nil { - return err - } - fileWritten[m.Path] = true - } - - } - } - - // if we have a list of files to render, then check that each of the - // provided files exists in the chart. - if len(showFiles) > 0 { - // This is necessary to ensure consistent manifest ordering when using --show-only - // with globs or directory names. - splitManifests := releaseutil.SplitManifests(manifests.String()) - manifestsKeys := make([]string, 0, len(splitManifests)) - for k := range splitManifests { - manifestsKeys = append(manifestsKeys, k) - } - sort.Sort(releaseutil.BySplitManifestsOrder(manifestsKeys)) - - manifestNameRegex := regexp.MustCompile("# Source: [^/]+/(.+)") - var manifestsToRender []string - for _, f := range showFiles { - missing := true - // Use linux-style filepath separators to unify user's input path - f = filepath.ToSlash(f) - for _, manifestKey := range manifestsKeys { - manifest := splitManifests[manifestKey] - submatch := manifestNameRegex.FindStringSubmatch(manifest) - if len(submatch) == 0 { - continue - } - manifestName := submatch[1] - // manifest.Name is rendered using linux-style filepath separators on Windows as - // well as macOS/linux. - manifestPathSplit := strings.Split(manifestName, "/") - // manifest.Path is connected using linux-style filepath separators on Windows as - // well as macOS/linux - manifestPath := strings.Join(manifestPathSplit, "/") - - // if the filepath provided matches a manifest path in the - // chart, render that manifest - if matched, _ := filepath.Match(f, manifestPath); !matched { - continue - } - manifestsToRender = append(manifestsToRender, manifest) - missing = false - } - if missing { - return fmt.Errorf("could not find template %s in chart", f) - } - } - for _, m := range manifestsToRender { - fmt.Fprintf(out, "---\n%s\n", m) - } - } else { - fmt.Fprintf(out, "%s", manifests.String()) - } - } - - return err - }, - } - - f := cmd.Flags() - addInstallFlags(cmd, f, client, valueOpts) - f.StringArrayVarP(&showFiles, "show-only", "s", []string{}, "only show manifests rendered from the given templates") - f.StringVar(&client.OutputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") - f.BoolVar(&validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. This is the same validation performed on an install") - f.BoolVar(&includeCrds, "include-crds", false, "include CRDs in the templated output") - f.BoolVar(&skipTests, "skip-tests", false, "skip tests from templated output") - f.BoolVar(&client.IsUpgrade, "is-upgrade", false, "set .Release.IsUpgrade instead of .Release.IsInstall") - f.StringVar(&kubeVersion, "kube-version", "", "Kubernetes version used for Capabilities.KubeVersion") - f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") - f.BoolVar(&client.UseReleaseName, "release-name", false, "use release name in the output-dir path.") - bindPostRenderFlag(cmd, &client.PostRenderer) - - return cmd -} - -func isTestHook(h *release.Hook) bool { - for _, e := range h.Events { - if e == release.HookTest { - return true - } - } - return false -} - -// The following functions (writeToFile, createOrOpenFile, and ensureDirectoryForFile) -// are copied from the actions package. This is part of a change to correct a -// bug introduced by #8156. As part of the todo to refactor renderResources -// this duplicate code should be removed. It is added here so that the API -// surface area is as minimally impacted as possible in fixing the issue. -func writeToFile(outputDir string, name string, data string, append bool) error { - outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator)) - - err := ensureDirectoryForFile(outfileName) - if err != nil { - return err - } - - f, err := createOrOpenFile(outfileName, append) - if err != nil { - return err - } - - defer f.Close() - - _, err = f.WriteString(fmt.Sprintf("---\n# Source: %s\n%s\n", name, data)) - - if err != nil { - return err - } - - fmt.Printf("wrote %s\n", outfileName) - return nil -} - -func createOrOpenFile(filename string, append bool) (*os.File, error) { - if append { - return os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0600) - } - return os.Create(filename) -} - -func ensureDirectoryForFile(file string) error { - baseDir := path.Dir(file) - _, err := os.Stat(baseDir) - if err != nil && !os.IsNotExist(err) { - return err - } - - return os.MkdirAll(baseDir, 0755) -} diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go deleted file mode 100644 index d1f17fe98..000000000 --- a/cmd/helm/template_test.go +++ /dev/null @@ -1,173 +0,0 @@ -/* -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 ( - "fmt" - "path/filepath" - "testing" -) - -var chartPath = "testdata/testcharts/subchart" - -func TestTemplateCmd(t *testing.T) { - tests := []cmdTestCase{ - { - name: "check name", - cmd: fmt.Sprintf("template '%s'", chartPath), - golden: "output/template.txt", - }, - { - name: "check set name", - cmd: fmt.Sprintf("template '%s' --set service.name=apache", chartPath), - golden: "output/template-set.txt", - }, - { - name: "check values files", - cmd: fmt.Sprintf("template '%s' --values '%s'", chartPath, filepath.Join(chartPath, "/charts/subchartA/values.yaml")), - golden: "output/template-values-files.txt", - }, - { - name: "check name template", - cmd: fmt.Sprintf(`template '%s' --name-template='foobar-{{ b64enc "abc" | lower }}-baz'`, chartPath), - golden: "output/template-name-template.txt", - }, - { - name: "check no args", - cmd: "template", - wantError: true, - golden: "output/template-no-args.txt", - }, - { - name: "check library chart", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/lib-chart"), - wantError: true, - golden: "output/template-lib-chart.txt", - }, - { - name: "check chart bad type", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/chart-bad-type"), - wantError: true, - golden: "output/template-chart-bad-type.txt", - }, - { - name: "check chart with dependency which is an app chart acting as a library chart", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/chart-with-template-lib-dep"), - golden: "output/template-chart-with-template-lib-dep.txt", - }, - { - name: "check chart with dependency which is an app chart archive acting as a library chart", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/chart-with-template-lib-archive-dep"), - golden: "output/template-chart-with-template-lib-archive-dep.txt", - }, - { - name: "check kube version", - cmd: fmt.Sprintf("template --kube-version 1.16.0 '%s'", chartPath), - golden: "output/template-with-kube-version.txt", - }, - { - name: "check kube api versions", - cmd: fmt.Sprintf("template --api-versions helm.k8s.io/test '%s'", chartPath), - golden: "output/template-with-api-version.txt", - }, - { - name: "template with CRDs", - cmd: fmt.Sprintf("template '%s' --include-crds", chartPath), - golden: "output/template-with-crds.txt", - }, - { - name: "template with show-only one", - cmd: fmt.Sprintf("template '%s' --show-only templates/service.yaml", chartPath), - golden: "output/template-show-only-one.txt", - }, - { - name: "template with show-only multiple", - cmd: fmt.Sprintf("template '%s' --show-only templates/service.yaml --show-only charts/subcharta/templates/service.yaml", chartPath), - golden: "output/template-show-only-multiple.txt", - }, - { - name: "template with show-only glob", - cmd: fmt.Sprintf("template '%s' --show-only templates/subdir/role*", chartPath), - golden: "output/template-show-only-glob.txt", - // Repeat to ensure manifest ordering regressions are caught - repeat: 10, - }, - { - name: "sorted output of manifests (order of filenames, then order of objects within each YAML file)", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/object-order"), - golden: "output/object-order.txt", - // Helm previously used random file order. Repeat the test so we - // don't accidentally get the expected result. - repeat: 10, - }, - { - name: "chart with template with invalid yaml", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/chart-with-template-with-invalid-yaml"), - wantError: true, - golden: "output/template-with-invalid-yaml.txt", - }, - { - name: "chart with template with invalid yaml (--debug)", - cmd: fmt.Sprintf("template '%s' --debug", "testdata/testcharts/chart-with-template-with-invalid-yaml"), - wantError: true, - golden: "output/template-with-invalid-yaml-debug.txt", - }, - { - name: "template skip-tests", - cmd: fmt.Sprintf(`template '%s' --skip-tests`, chartPath), - golden: "output/template-skip-tests.txt", - }, - } - runTestCmd(t, tests) -} - -func TestTemplateVersionCompletion(t *testing.T) { - repoFile := "testdata/helmhome/helm/repositories.yaml" - repoCache := "testdata/helmhome/helm/repository" - - repoSetup := fmt.Sprintf("--repository-config %s --repository-cache %s", repoFile, repoCache) - - tests := []cmdTestCase{{ - name: "completion for template version flag with release name", - cmd: fmt.Sprintf("%s __complete template releasename testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for template version flag with generate-name", - cmd: fmt.Sprintf("%s __complete template --generate-name testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for template version flag too few args", - cmd: fmt.Sprintf("%s __complete template testing/alpine --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for template version flag too many args", - cmd: fmt.Sprintf("%s __complete template releasename testing/alpine badarg --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for template version flag invalid chart", - cmd: fmt.Sprintf("%s __complete template releasename invalid/invalid --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestTemplateFileCompletion(t *testing.T) { - checkFileCompletion(t, "template", false) - checkFileCompletion(t, "template --generate-name", true) - checkFileCompletion(t, "template myname", true) - checkFileCompletion(t, "template myname mychart", false) -} diff --git a/cmd/helm/testdata/helm-test-key.pub b/cmd/helm/testdata/helm-test-key.pub deleted file mode 100644 index 38714f25a..000000000 Binary files a/cmd/helm/testdata/helm-test-key.pub and /dev/null differ diff --git a/cmd/helm/testdata/helm-test-key.secret b/cmd/helm/testdata/helm-test-key.secret deleted file mode 100644 index a966aef93..000000000 Binary files a/cmd/helm/testdata/helm-test-key.secret and /dev/null differ diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/args.sh b/cmd/helm/testdata/helmhome/helm/plugins/args/args.sh deleted file mode 100755 index 678b4eff5..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/args/args.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo $* diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete b/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete deleted file mode 100755 index 2b00c2281..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh - -echo "plugin.complete was called" -echo "Namespace: ${HELM_NAMESPACE:-NO_NS}" -echo "Num args received: ${#}" -echo "Args received: ${@}" - -# Final printout is the optional completion directive of the form : -if [ "$HELM_NAMESPACE" = "default" ]; then - echo ":4" -else - echo ":2" -fi diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.yaml b/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.yaml deleted file mode 100644 index 21e28a7c2..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: args -usage: "echo args" -description: "This echos args" -command: "$HELM_PLUGIN_DIR/args.sh" diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete b/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete deleted file mode 100755 index 63569aada..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh - -echo "echo plugin.complete was called" -echo "Namespace: ${HELM_NAMESPACE:-NO_NS}" -echo "Num args received: ${#}" -echo "Args received: ${@}" - -# Final printout is the optional completion directive of the form : -if [ "$HELM_NAMESPACE" = "default" ]; then - echo ":0" -# else - # Don't include the directive, to test it is really optional -fi diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.yaml b/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.yaml deleted file mode 100644 index 7b9362a08..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: echo -usage: "echo stuff" -description: "This echos stuff" -command: "echo hello" diff --git a/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml deleted file mode 100644 index e479a0503..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: env -commands: - - name: list - flags: - - a - - all - - log - - name: remove - validArgs: - - all - - one -flags: -- global diff --git a/cmd/helm/testdata/helmhome/helm/plugins/env/plugin.yaml b/cmd/helm/testdata/helmhome/helm/plugins/env/plugin.yaml deleted file mode 100644 index 52cb7a848..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/env/plugin.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: env -usage: "env stuff" -description: "show the env" -command: "echo $HELM_PLUGIN_NAME" diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml deleted file mode 100644 index e5bf440f6..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml +++ /dev/null @@ -1,5 +0,0 @@ -commands: - - name: code - flags: - - a - - b diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh deleted file mode 100755 index ec8469657..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -exit $* diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml deleted file mode 100644 index 5691d1712..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: exitwith -usage: "exitwith code" -description: "This exits with the specified exit code" -command: "$HELM_PLUGIN_DIR/exitwith.sh" diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml deleted file mode 100644 index e0b161c69..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: wrongname -commands: - - name: empty - - name: full - commands: - - name: more - validArgs: - - one - - two - flags: - - b - - ball - - name: less - flags: - - a - - all -flags: -- z -- q diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh deleted file mode 100755 index 2efad9b3c..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -echo $HELM_PLUGIN_NAME -echo $HELM_PLUGIN_DIR -echo $HELM_PLUGINS -echo $HELM_REPOSITORY_CONFIG -echo $HELM_REPOSITORY_CACHE -echo $HELM_BIN diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/plugin.yaml b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/plugin.yaml deleted file mode 100644 index 63f2f12db..000000000 --- a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/plugin.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: fullenv -usage: "show env vars" -description: "show all env vars" -command: "$HELM_PLUGIN_DIR/fullenv.sh" diff --git a/cmd/helm/testdata/helmhome/helm/repositories.yaml b/cmd/helm/testdata/helmhome/helm/repositories.yaml deleted file mode 100644 index 3835aaa5a..000000000 --- a/cmd/helm/testdata/helmhome/helm/repositories.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -generated: 2016-10-03T16:03:10.640376913-06:00 -repositories: -- cache: testing-index.yaml - name: testing - url: http://example.com/charts diff --git a/cmd/helm/testdata/helmhome/helm/repository/test-name-charts.txt b/cmd/helm/testdata/helmhome/helm/repository/test-name-charts.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/helmhome/helm/repository/test-name-index.yaml b/cmd/helm/testdata/helmhome/helm/repository/test-name-index.yaml deleted file mode 100644 index d5ab620ad..000000000 --- a/cmd/helm/testdata/helmhome/helm/repository/test-name-index.yaml +++ /dev/null @@ -1,3 +0,0 @@ -apiVersion: v1 -entries: {} -generated: "2020-09-09T19:50:50.198347916-04:00" diff --git a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml b/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml deleted file mode 100644 index 91e4d463f..000000000 --- a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml +++ /dev/null @@ -1,66 +0,0 @@ -apiVersion: v1 -entries: - alpine: - - name: alpine - url: https://charts.helm.sh/stable/alpine-0.1.0.tgz - checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d - created: "2018-06-27T10:00:18.230700509Z" - deprecated: true - home: https://helm.sh/helm - sources: - - https://github.com/helm/helm - version: 0.1.0 - appVersion: 1.2.3 - description: Deploy a basic Alpine Linux pod - keywords: [] - maintainers: [] - icon: "" - apiVersion: v2 - - name: alpine - url: https://charts.helm.sh/stable/alpine-0.2.0.tgz - checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d - created: "2018-07-09T11:34:37.797864902Z" - home: https://helm.sh/helm - sources: - - https://github.com/helm/helm - version: 0.2.0 - appVersion: 2.3.4 - description: Deploy a basic Alpine Linux pod - keywords: [] - maintainers: [] - icon: "" - apiVersion: v2 - - name: alpine - url: https://charts.helm.sh/stable/alpine-0.3.0-rc.1.tgz - checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d - created: "2020-11-12T08:44:58.872726222Z" - home: https://helm.sh/helm - sources: - - https://github.com/helm/helm - version: 0.3.0-rc.1 - appVersion: 3.0.0 - description: Deploy a basic Alpine Linux pod - keywords: [] - maintainers: [] - icon: "" - apiVersion: v2 - mariadb: - - name: mariadb - url: https://charts.helm.sh/stable/mariadb-0.3.0.tgz - checksum: 65229f6de44a2be9f215d11dbff311673fc8ba56 - created: "2018-04-23T08:20:27.160959131Z" - home: https://mariadb.org - sources: - - https://github.com/bitnami/bitnami-docker-mariadb - version: 0.3.0 - description: Chart for MariaDB - keywords: - - mariadb - - mysql - - database - - sql - maintainers: - - name: Bitnami - email: containers@bitnami.com - icon: "" - apiVersion: v2 diff --git a/cmd/helm/testdata/output/chart-with-subchart-update.txt b/cmd/helm/testdata/output/chart-with-subchart-update.txt deleted file mode 100644 index a4135c782..000000000 --- a/cmd/helm/testdata/output/chart-with-subchart-update.txt +++ /dev/null @@ -1,8 +0,0 @@ -NAME: updeps -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None -NOTES: -PARENT NOTES diff --git a/cmd/helm/testdata/output/dependency-list-archive.txt b/cmd/helm/testdata/output/dependency-list-archive.txt deleted file mode 100644 index ffd4542b0..000000000 --- a/cmd/helm/testdata/output/dependency-list-archive.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME VERSION REPOSITORY STATUS -reqsubchart 0.1.0 https://example.com/charts unpacked -reqsubchart2 0.2.0 https://example.com/charts unpacked -reqsubchart3 >=0.1.0 https://example.com/charts unpacked - diff --git a/cmd/helm/testdata/output/dependency-list-no-chart-linux.txt b/cmd/helm/testdata/output/dependency-list-no-chart-linux.txt deleted file mode 100644 index 8fab8f8eb..000000000 --- a/cmd/helm/testdata/output/dependency-list-no-chart-linux.txt +++ /dev/null @@ -1 +0,0 @@ -Error: stat /no/such/chart: no such file or directory diff --git a/cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt b/cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt deleted file mode 100644 index 35fe1d2e3..000000000 --- a/cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt +++ /dev/null @@ -1 +0,0 @@ -WARNING: no dependencies at testdata/testcharts/alpine/charts diff --git a/cmd/helm/testdata/output/dependency-list.txt b/cmd/helm/testdata/output/dependency-list.txt deleted file mode 100644 index b57c21a21..000000000 --- a/cmd/helm/testdata/output/dependency-list.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME VERSION REPOSITORY STATUS -reqsubchart 0.1.0 https://example.com/charts unpacked -reqsubchart2 0.2.0 https://example.com/charts unpacked -reqsubchart3 >=0.1.0 https://example.com/charts ok - diff --git a/cmd/helm/testdata/output/deprecated-chart.txt b/cmd/helm/testdata/output/deprecated-chart.txt deleted file mode 100644 index 039d6aef6..000000000 --- a/cmd/helm/testdata/output/deprecated-chart.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: aeneas -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/docs-type-comp.txt b/cmd/helm/testdata/output/docs-type-comp.txt deleted file mode 100644 index 69494f87d..000000000 --- a/cmd/helm/testdata/output/docs-type-comp.txt +++ /dev/null @@ -1,5 +0,0 @@ -bash -man -markdown -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/empty_default_comp.txt b/cmd/helm/testdata/output/empty_default_comp.txt deleted file mode 100644 index 879d50d0e..000000000 --- a/cmd/helm/testdata/output/empty_default_comp.txt +++ /dev/null @@ -1,2 +0,0 @@ -:0 -Completion ended with directive: ShellCompDirectiveDefault diff --git a/cmd/helm/testdata/output/empty_nofile_comp.txt b/cmd/helm/testdata/output/empty_nofile_comp.txt deleted file mode 100644 index 8d9fad576..000000000 --- a/cmd/helm/testdata/output/empty_nofile_comp.txt +++ /dev/null @@ -1,2 +0,0 @@ -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/env-comp.txt b/cmd/helm/testdata/output/env-comp.txt deleted file mode 100644 index b7d93c12e..000000000 --- a/cmd/helm/testdata/output/env-comp.txt +++ /dev/null @@ -1,22 +0,0 @@ -HELM_BIN -HELM_BURST_LIMIT -HELM_CACHE_HOME -HELM_CONFIG_HOME -HELM_DATA_HOME -HELM_DEBUG -HELM_KUBEAPISERVER -HELM_KUBEASGROUPS -HELM_KUBEASUSER -HELM_KUBECAFILE -HELM_KUBECONTEXT -HELM_KUBEINSECURE_SKIP_TLS_VERIFY -HELM_KUBETLS_SERVER_NAME -HELM_KUBETOKEN -HELM_MAX_HISTORY -HELM_NAMESPACE -HELM_PLUGINS -HELM_REGISTRY_CONFIG -HELM_REPOSITORY_CACHE -HELM_REPOSITORY_CONFIG -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/get-all-no-args.txt b/cmd/helm/testdata/output/get-all-no-args.txt deleted file mode 100644 index cc3fc2ad1..000000000 --- a/cmd/helm/testdata/output/get-all-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm get all" requires 1 argument - -Usage: helm get all RELEASE_NAME [flags] diff --git a/cmd/helm/testdata/output/get-hooks-no-args.txt b/cmd/helm/testdata/output/get-hooks-no-args.txt deleted file mode 100644 index 2911fdb88..000000000 --- a/cmd/helm/testdata/output/get-hooks-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm get hooks" requires 1 argument - -Usage: helm get hooks RELEASE_NAME [flags] diff --git a/cmd/helm/testdata/output/get-hooks.txt b/cmd/helm/testdata/output/get-hooks.txt deleted file mode 100644 index 81e87b1f1..000000000 --- a/cmd/helm/testdata/output/get-hooks.txt +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Source: pre-install-hook.yaml -apiVersion: v1 -kind: Job -metadata: - annotations: - "helm.sh/hook": pre-install - diff --git a/cmd/helm/testdata/output/get-manifest-no-args.txt b/cmd/helm/testdata/output/get-manifest-no-args.txt deleted file mode 100644 index df7aa5b04..000000000 --- a/cmd/helm/testdata/output/get-manifest-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm get manifest" requires 1 argument - -Usage: helm get manifest RELEASE_NAME [flags] diff --git a/cmd/helm/testdata/output/get-manifest.txt b/cmd/helm/testdata/output/get-manifest.txt deleted file mode 100644 index 88937e089..000000000 --- a/cmd/helm/testdata/output/get-manifest.txt +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: fixture - diff --git a/cmd/helm/testdata/output/get-notes-no-args.txt b/cmd/helm/testdata/output/get-notes-no-args.txt deleted file mode 100644 index 1a0c20caa..000000000 --- a/cmd/helm/testdata/output/get-notes-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm get notes" requires 1 argument - -Usage: helm get notes RELEASE_NAME [flags] diff --git a/cmd/helm/testdata/output/get-notes.txt b/cmd/helm/testdata/output/get-notes.txt deleted file mode 100644 index e710c7801..000000000 --- a/cmd/helm/testdata/output/get-notes.txt +++ /dev/null @@ -1,2 +0,0 @@ -NOTES: -Some mock release notes! diff --git a/cmd/helm/testdata/output/get-release-template.txt b/cmd/helm/testdata/output/get-release-template.txt deleted file mode 100644 index 02d44fb01..000000000 --- a/cmd/helm/testdata/output/get-release-template.txt +++ /dev/null @@ -1 +0,0 @@ -0.1.0-beta.1 \ No newline at end of file diff --git a/cmd/helm/testdata/output/get-release.txt b/cmd/helm/testdata/output/get-release.txt deleted file mode 100644 index f6c3b57eb..000000000 --- a/cmd/helm/testdata/output/get-release.txt +++ /dev/null @@ -1,29 +0,0 @@ -NAME: thomas-guide -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None -USER-SUPPLIED VALUES: -name: value - -COMPUTED VALUES: -name: value - -HOOKS: ---- -# Source: pre-install-hook.yaml -apiVersion: v1 -kind: Job -metadata: - annotations: - "helm.sh/hook": pre-install - -MANIFEST: -apiVersion: v1 -kind: Secret -metadata: - name: fixture - -NOTES: -Some mock release notes! diff --git a/cmd/helm/testdata/output/get-values-all.txt b/cmd/helm/testdata/output/get-values-all.txt deleted file mode 100644 index b7e9696bc..000000000 --- a/cmd/helm/testdata/output/get-values-all.txt +++ /dev/null @@ -1,2 +0,0 @@ -COMPUTED VALUES: -name: value diff --git a/cmd/helm/testdata/output/get-values-args.txt b/cmd/helm/testdata/output/get-values-args.txt deleted file mode 100644 index c8a65e7f3..000000000 --- a/cmd/helm/testdata/output/get-values-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm get values" requires 1 argument - -Usage: helm get values RELEASE_NAME [flags] diff --git a/cmd/helm/testdata/output/get-values.txt b/cmd/helm/testdata/output/get-values.txt deleted file mode 100644 index b7d146b15..000000000 --- a/cmd/helm/testdata/output/get-values.txt +++ /dev/null @@ -1,2 +0,0 @@ -USER-SUPPLIED VALUES: -name: value diff --git a/cmd/helm/testdata/output/history-limit.txt b/cmd/helm/testdata/output/history-limit.txt deleted file mode 100644 index aee0fadb2..000000000 --- a/cmd/helm/testdata/output/history-limit.txt +++ /dev/null @@ -1,3 +0,0 @@ -REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION -3 Fri Sep 2 22:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock -4 Fri Sep 2 22:04:05 1977 deployed foo-0.1.0-beta.1 1.0 Release mock diff --git a/cmd/helm/testdata/output/history.json b/cmd/helm/testdata/output/history.json deleted file mode 100644 index 35311d3ce..000000000 --- a/cmd/helm/testdata/output/history.json +++ /dev/null @@ -1 +0,0 @@ -[{"revision":3,"updated":"1977-09-02T22:04:05Z","status":"superseded","chart":"foo-0.1.0-beta.1","app_version":"1.0","description":"Release mock"},{"revision":4,"updated":"1977-09-02T22:04:05Z","status":"deployed","chart":"foo-0.1.0-beta.1","app_version":"1.0","description":"Release mock"}] diff --git a/cmd/helm/testdata/output/history.txt b/cmd/helm/testdata/output/history.txt deleted file mode 100644 index 2a5d69c11..000000000 --- a/cmd/helm/testdata/output/history.txt +++ /dev/null @@ -1,5 +0,0 @@ -REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION -1 Fri Sep 2 22:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock -2 Fri Sep 2 22:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock -3 Fri Sep 2 22:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Release mock -4 Fri Sep 2 22:04:05 1977 deployed foo-0.1.0-beta.1 1.0 Release mock diff --git a/cmd/helm/testdata/output/history.yaml b/cmd/helm/testdata/output/history.yaml deleted file mode 100644 index b7ae03be7..000000000 --- a/cmd/helm/testdata/output/history.yaml +++ /dev/null @@ -1,12 +0,0 @@ -- app_version: "1.0" - chart: foo-0.1.0-beta.1 - description: Release mock - revision: 3 - status: superseded - updated: "1977-09-02T22:04:05Z" -- app_version: "1.0" - chart: foo-0.1.0-beta.1 - description: Release mock - revision: 4 - status: deployed - updated: "1977-09-02T22:04:05Z" diff --git a/cmd/helm/testdata/output/install-and-replace.txt b/cmd/helm/testdata/output/install-and-replace.txt deleted file mode 100644 index 039d6aef6..000000000 --- a/cmd/helm/testdata/output/install-and-replace.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: aeneas -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-chart-bad-type.txt b/cmd/helm/testdata/output/install-chart-bad-type.txt deleted file mode 100644 index c482a793d..000000000 --- a/cmd/helm/testdata/output/install-chart-bad-type.txt +++ /dev/null @@ -1 +0,0 @@ -Error: INSTALLATION FAILED: validation: chart.metadata.type must be application or library diff --git a/cmd/helm/testdata/output/install-lib-chart.txt b/cmd/helm/testdata/output/install-lib-chart.txt deleted file mode 100644 index c482a793d..000000000 --- a/cmd/helm/testdata/output/install-lib-chart.txt +++ /dev/null @@ -1 +0,0 @@ -Error: INSTALLATION FAILED: validation: chart.metadata.type must be application or library diff --git a/cmd/helm/testdata/output/install-name-template.txt b/cmd/helm/testdata/output/install-name-template.txt deleted file mode 100644 index 19952e3c2..000000000 --- a/cmd/helm/testdata/output/install-name-template.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: foobar -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-no-args.txt b/cmd/helm/testdata/output/install-no-args.txt deleted file mode 100644 index 47f010ab8..000000000 --- a/cmd/helm/testdata/output/install-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm install" requires at least 1 argument - -Usage: helm install [NAME] [CHART] [flags] diff --git a/cmd/helm/testdata/output/install-no-hooks.txt b/cmd/helm/testdata/output/install-no-hooks.txt deleted file mode 100644 index 039d6aef6..000000000 --- a/cmd/helm/testdata/output/install-no-hooks.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: aeneas -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-multiple-values-files.txt b/cmd/helm/testdata/output/install-with-multiple-values-files.txt deleted file mode 100644 index 406e522a9..000000000 --- a/cmd/helm/testdata/output/install-with-multiple-values-files.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: virgil -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-multiple-values.txt b/cmd/helm/testdata/output/install-with-multiple-values.txt deleted file mode 100644 index 406e522a9..000000000 --- a/cmd/helm/testdata/output/install-with-multiple-values.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: virgil -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-timeout.txt b/cmd/helm/testdata/output/install-with-timeout.txt deleted file mode 100644 index 19952e3c2..000000000 --- a/cmd/helm/testdata/output/install-with-timeout.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: foobar -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-values-file.txt b/cmd/helm/testdata/output/install-with-values-file.txt deleted file mode 100644 index 406e522a9..000000000 --- a/cmd/helm/testdata/output/install-with-values-file.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: virgil -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-values.txt b/cmd/helm/testdata/output/install-with-values.txt deleted file mode 100644 index 406e522a9..000000000 --- a/cmd/helm/testdata/output/install-with-values.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: virgil -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-wait-for-jobs.txt b/cmd/helm/testdata/output/install-with-wait-for-jobs.txt deleted file mode 100644 index 7ce22d4ec..000000000 --- a/cmd/helm/testdata/output/install-with-wait-for-jobs.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: apollo -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install-with-wait.txt b/cmd/helm/testdata/output/install-with-wait.txt deleted file mode 100644 index 7ce22d4ec..000000000 --- a/cmd/helm/testdata/output/install-with-wait.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: apollo -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/install.txt b/cmd/helm/testdata/output/install.txt deleted file mode 100644 index 039d6aef6..000000000 --- a/cmd/helm/testdata/output/install.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: aeneas -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt b/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt deleted file mode 100644 index e77aa387f..000000000 --- a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt +++ /dev/null @@ -1,20 +0,0 @@ -==> Linting testdata/testcharts/chart-with-bad-subcharts -[INFO] Chart.yaml: icon is recommended -[WARNING] templates/: directory not found -[ERROR] : unable to load chart - error unpacking bad-subchart in chart-with-bad-subcharts: validation: chart.metadata.name is required - -==> Linting testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart -[ERROR] Chart.yaml: name is required -[ERROR] Chart.yaml: apiVersion is required. The value must be either "v1" or "v2" -[ERROR] Chart.yaml: version is required -[INFO] Chart.yaml: icon is recommended -[WARNING] templates/: directory not found -[ERROR] : unable to load chart - validation: chart.metadata.name is required - -==> Linting testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart -[INFO] Chart.yaml: icon is recommended -[WARNING] templates/: directory not found - -Error: 3 chart(s) linted, 2 chart(s) failed diff --git a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt b/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt deleted file mode 100644 index 265e555f7..000000000 --- a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt +++ /dev/null @@ -1,7 +0,0 @@ -==> Linting testdata/testcharts/chart-with-bad-subcharts -[INFO] Chart.yaml: icon is recommended -[WARNING] templates/: directory not found -[ERROR] : unable to load chart - error unpacking bad-subchart in chart-with-bad-subcharts: validation: chart.metadata.name is required - -Error: 1 chart(s) linted, 1 chart(s) failed diff --git a/cmd/helm/testdata/output/lint-quiet-with-error.txt b/cmd/helm/testdata/output/lint-quiet-with-error.txt deleted file mode 100644 index a4e8575f8..000000000 --- a/cmd/helm/testdata/output/lint-quiet-with-error.txt +++ /dev/null @@ -1,8 +0,0 @@ -==> Linting testdata/testcharts/chart-bad-requirements -[ERROR] Chart.yaml: unable to parse YAML - error converting YAML to JSON: yaml: line 6: did not find expected '-' indicator -[WARNING] templates/: directory not found -[ERROR] : unable to load chart - cannot load Chart.yaml: error converting YAML to JSON: yaml: line 6: did not find expected '-' indicator - -Error: 2 chart(s) linted, 1 chart(s) failed diff --git a/cmd/helm/testdata/output/lint-quiet-with-warning.txt b/cmd/helm/testdata/output/lint-quiet-with-warning.txt deleted file mode 100644 index 02c6fa592..000000000 --- a/cmd/helm/testdata/output/lint-quiet-with-warning.txt +++ /dev/null @@ -1,4 +0,0 @@ -==> Linting testdata/testcharts/chart-with-only-crds -[WARNING] templates/: directory not found - -1 chart(s) linted, 0 chart(s) failed diff --git a/cmd/helm/testdata/output/lint-quiet.txt b/cmd/helm/testdata/output/lint-quiet.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/output/list-all.txt b/cmd/helm/testdata/output/list-all.txt deleted file mode 100644 index ef6d44cd5..000000000 --- a/cmd/helm/testdata/output/list-all.txt +++ /dev/null @@ -1,9 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1 -gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1 -groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1 -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 -thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-date-reversed.txt b/cmd/helm/testdata/output/list-date-reversed.txt deleted file mode 100644 index 8b4e71a38..000000000 --- a/cmd/helm/testdata/output/list-date-reversed.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-date.txt b/cmd/helm/testdata/output/list-date.txt deleted file mode 100644 index 3d2b27ad8..000000000 --- a/cmd/helm/testdata/output/list-date.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-failed.txt b/cmd/helm/testdata/output/list-failed.txt deleted file mode 100644 index a8ec3e132..000000000 --- a/cmd/helm/testdata/output/list-failed.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-filter.txt b/cmd/helm/testdata/output/list-filter.txt deleted file mode 100644 index 0a820922b..000000000 --- a/cmd/helm/testdata/output/list-filter.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-max.txt b/cmd/helm/testdata/output/list-max.txt deleted file mode 100644 index a909322b4..000000000 --- a/cmd/helm/testdata/output/list-max.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-namespace.txt b/cmd/helm/testdata/output/list-namespace.txt deleted file mode 100644 index 9382327d6..000000000 --- a/cmd/helm/testdata/output/list-namespace.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -starlord milano 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-no-headers.txt b/cmd/helm/testdata/output/list-no-headers.txt deleted file mode 100644 index 9d11d0caf..000000000 --- a/cmd/helm/testdata/output/list-no-headers.txt +++ /dev/null @@ -1,4 +0,0 @@ -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-offset.txt b/cmd/helm/testdata/output/list-offset.txt deleted file mode 100644 index 36e963ca5..000000000 --- a/cmd/helm/testdata/output/list-offset.txt +++ /dev/null @@ -1,4 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-pending.txt b/cmd/helm/testdata/output/list-pending.txt deleted file mode 100644 index f3d7aa03b..000000000 --- a/cmd/helm/testdata/output/list-pending.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -thanos default 1 2016-01-16 00:00:01 +0000 UTC pending-install chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-reverse.txt b/cmd/helm/testdata/output/list-reverse.txt deleted file mode 100644 index da178b2c3..000000000 --- a/cmd/helm/testdata/output/list-reverse.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-short-json.txt b/cmd/helm/testdata/output/list-short-json.txt deleted file mode 100644 index acbf1e44d..000000000 --- a/cmd/helm/testdata/output/list-short-json.txt +++ /dev/null @@ -1 +0,0 @@ -["hummingbird","iguana","rocket","starlord"] diff --git a/cmd/helm/testdata/output/list-short-yaml.txt b/cmd/helm/testdata/output/list-short-yaml.txt deleted file mode 100644 index 86fb3d670..000000000 --- a/cmd/helm/testdata/output/list-short-yaml.txt +++ /dev/null @@ -1,4 +0,0 @@ -- hummingbird -- iguana -- rocket -- starlord diff --git a/cmd/helm/testdata/output/list-short.txt b/cmd/helm/testdata/output/list-short.txt deleted file mode 100644 index 0a63be990..000000000 --- a/cmd/helm/testdata/output/list-short.txt +++ /dev/null @@ -1,4 +0,0 @@ -hummingbird -iguana -rocket -starlord diff --git a/cmd/helm/testdata/output/list-superseded.txt b/cmd/helm/testdata/output/list-superseded.txt deleted file mode 100644 index 50b435874..000000000 --- a/cmd/helm/testdata/output/list-superseded.txt +++ /dev/null @@ -1,3 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -gamora default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1 -starlord default 1 2016-01-16 00:00:01 +0000 UTC superseded chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-uninstalled.txt b/cmd/helm/testdata/output/list-uninstalled.txt deleted file mode 100644 index 430cf32fb..000000000 --- a/cmd/helm/testdata/output/list-uninstalled.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -groot default 1 2016-01-16 00:00:01 +0000 UTC uninstalled chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list-uninstalling.txt b/cmd/helm/testdata/output/list-uninstalling.txt deleted file mode 100644 index 922896391..000000000 --- a/cmd/helm/testdata/output/list-uninstalling.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -drax default 1 2016-01-16 00:00:01 +0000 UTC uninstalling chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/list.txt b/cmd/helm/testdata/output/list.txt deleted file mode 100644 index 0a820922b..000000000 --- a/cmd/helm/testdata/output/list.txt +++ /dev/null @@ -1,5 +0,0 @@ -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -hummingbird default 1 2016-01-16 00:00:03 +0000 UTC deployed chickadee-1.0.0 0.0.1 -iguana default 2 2016-01-16 00:00:04 +0000 UTC deployed chickadee-1.0.0 0.0.1 -rocket default 1 2016-01-16 00:00:02 +0000 UTC failed chickadee-1.0.0 0.0.1 -starlord default 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/cmd/helm/testdata/output/object-order.txt b/cmd/helm/testdata/output/object-order.txt deleted file mode 100644 index 307f928f2..000000000 --- a/cmd/helm/testdata/output/object-order.txt +++ /dev/null @@ -1,191 +0,0 @@ ---- -# Source: object-order/templates/01-a.yml -# 1 -kind: NetworkPolicy -apiVersion: networking.k8s.io/v1 -metadata: - name: first -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/01-a.yml -# 2 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: second -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/01-a.yml -# 3 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: third -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 5 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: fifth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 7 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: seventh -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 8 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: eighth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 9 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: ninth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 10 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: tenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 11 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: eleventh -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 12 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: twelfth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 13 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: thirteenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 14 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: fourteenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/02-b.yml -# 15 (11th object within 02-b.yml, in order to test `SplitManifests` which assigns `manifest-10` -# to this object which should then come *after* `manifest-9`) -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: fifteenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress ---- -# Source: object-order/templates/01-a.yml -# 4 (Deployment should come after all NetworkPolicy manifests, since 'helm template' outputs in install order) -apiVersion: apps/v1 -kind: Deployment -metadata: - name: fourth -spec: - selector: - matchLabels: - pod: fourth - replicas: 1 - template: - metadata: - labels: - pod: fourth - spec: - containers: - - name: hello-world - image: gcr.io/google-samples/node-hello:1.0 ---- -# Source: object-order/templates/02-b.yml -# 6 (implementation detail: currently, 'helm template' outputs hook manifests last; and yes, NetworkPolicy won't make a reasonable hook, this is just a dummy unit test manifest) -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - annotations: - "helm.sh/hook": pre-install - name: sixth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress diff --git a/cmd/helm/testdata/output/output-comp.txt b/cmd/helm/testdata/output/output-comp.txt deleted file mode 100644 index 6232b2928..000000000 --- a/cmd/helm/testdata/output/output-comp.txt +++ /dev/null @@ -1,5 +0,0 @@ -json Output result in JSON format -table Output result in human-readable format -yaml Output result in YAML format -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/plugin_args_comp.txt b/cmd/helm/testdata/output/plugin_args_comp.txt deleted file mode 100644 index 4070cb1e6..000000000 --- a/cmd/helm/testdata/output/plugin_args_comp.txt +++ /dev/null @@ -1,6 +0,0 @@ -plugin.complete was called -Namespace: default -Num args received: 1 -Args received: -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/plugin_args_flag_comp.txt b/cmd/helm/testdata/output/plugin_args_flag_comp.txt deleted file mode 100644 index 87300fa97..000000000 --- a/cmd/helm/testdata/output/plugin_args_flag_comp.txt +++ /dev/null @@ -1,6 +0,0 @@ -plugin.complete was called -Namespace: default -Num args received: 2 -Args received: --myflag -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/plugin_args_many_args_comp.txt b/cmd/helm/testdata/output/plugin_args_many_args_comp.txt deleted file mode 100644 index f3c386b6d..000000000 --- a/cmd/helm/testdata/output/plugin_args_many_args_comp.txt +++ /dev/null @@ -1,6 +0,0 @@ -plugin.complete was called -Namespace: mynamespace -Num args received: 2 -Args received: --myflag start -:2 -Completion ended with directive: ShellCompDirectiveNoSpace diff --git a/cmd/helm/testdata/output/plugin_args_ns_comp.txt b/cmd/helm/testdata/output/plugin_args_ns_comp.txt deleted file mode 100644 index 13bfcd3f4..000000000 --- a/cmd/helm/testdata/output/plugin_args_ns_comp.txt +++ /dev/null @@ -1,6 +0,0 @@ -plugin.complete was called -Namespace: mynamespace -Num args received: 1 -Args received: -:2 -Completion ended with directive: ShellCompDirectiveNoSpace diff --git a/cmd/helm/testdata/output/plugin_echo_no_directive.txt b/cmd/helm/testdata/output/plugin_echo_no_directive.txt deleted file mode 100644 index 99cc47c13..000000000 --- a/cmd/helm/testdata/output/plugin_echo_no_directive.txt +++ /dev/null @@ -1,6 +0,0 @@ -echo plugin.complete was called -Namespace: mynamespace -Num args received: 1 -Args received: -:0 -Completion ended with directive: ShellCompDirectiveDefault diff --git a/cmd/helm/testdata/output/plugin_list_comp.txt b/cmd/helm/testdata/output/plugin_list_comp.txt deleted file mode 100644 index 833efc5e9..000000000 --- a/cmd/helm/testdata/output/plugin_list_comp.txt +++ /dev/null @@ -1,7 +0,0 @@ -args echo args -echo echo stuff -env env stuff -exitwith exitwith code -fullenv show env vars -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/plugin_repeat_comp.txt b/cmd/helm/testdata/output/plugin_repeat_comp.txt deleted file mode 100644 index 3fa05f0b3..000000000 --- a/cmd/helm/testdata/output/plugin_repeat_comp.txt +++ /dev/null @@ -1,6 +0,0 @@ -echo echo stuff -env env stuff -exitwith exitwith code -fullenv show env vars -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/release_list_comp.txt b/cmd/helm/testdata/output/release_list_comp.txt deleted file mode 100644 index 226c378a9..000000000 --- a/cmd/helm/testdata/output/release_list_comp.txt +++ /dev/null @@ -1,5 +0,0 @@ -aramis foo-0.1.0-beta.1 -> deployed -athos foo-0.1.0-beta.1 -> deployed -porthos foo-0.1.0-beta.1 -> deployed -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/release_list_repeat_comp.txt b/cmd/helm/testdata/output/release_list_repeat_comp.txt deleted file mode 100644 index aa330f47f..000000000 --- a/cmd/helm/testdata/output/release_list_repeat_comp.txt +++ /dev/null @@ -1,4 +0,0 @@ -aramis foo-0.1.0-beta.1 -> deployed -athos foo-0.1.0-beta.1 -> deployed -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/repo-add.txt b/cmd/helm/testdata/output/repo-add.txt deleted file mode 100644 index e8882321e..000000000 --- a/cmd/helm/testdata/output/repo-add.txt +++ /dev/null @@ -1 +0,0 @@ -"test-name" has been added to your repositories diff --git a/cmd/helm/testdata/output/repo-add2.txt b/cmd/helm/testdata/output/repo-add2.txt deleted file mode 100644 index 263ffa9e4..000000000 --- a/cmd/helm/testdata/output/repo-add2.txt +++ /dev/null @@ -1 +0,0 @@ -"test-name" already exists with the same configuration, skipping diff --git a/cmd/helm/testdata/output/repo_list_comp.txt b/cmd/helm/testdata/output/repo_list_comp.txt deleted file mode 100644 index 289e0d2e1..000000000 --- a/cmd/helm/testdata/output/repo_list_comp.txt +++ /dev/null @@ -1,5 +0,0 @@ -foo -bar -baz -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/repo_repeat_comp.txt b/cmd/helm/testdata/output/repo_repeat_comp.txt deleted file mode 100644 index ed8ed89fa..000000000 --- a/cmd/helm/testdata/output/repo_repeat_comp.txt +++ /dev/null @@ -1,4 +0,0 @@ -bar -baz -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/revision-comp.txt b/cmd/helm/testdata/output/revision-comp.txt deleted file mode 100644 index fe9faf1f1..000000000 --- a/cmd/helm/testdata/output/revision-comp.txt +++ /dev/null @@ -1,6 +0,0 @@ -8 App: 1.0, Chart: foo-0.1.0-beta.1 -9 App: 1.0, Chart: foo-0.1.0-beta.1 -10 App: 1.0, Chart: foo-0.1.0-beta.1 -11 App: 1.0, Chart: foo-0.1.0-beta.1 -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/revision-wrong-args-comp.txt b/cmd/helm/testdata/output/revision-wrong-args-comp.txt deleted file mode 100644 index 8d9fad576..000000000 --- a/cmd/helm/testdata/output/revision-wrong-args-comp.txt +++ /dev/null @@ -1,2 +0,0 @@ -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/rollback-comp.txt b/cmd/helm/testdata/output/rollback-comp.txt deleted file mode 100644 index 2cfeed1f9..000000000 --- a/cmd/helm/testdata/output/rollback-comp.txt +++ /dev/null @@ -1,4 +0,0 @@ -carabins foo-0.1.0-beta.1 -> superseded -musketeers foo-0.1.0-beta.1 -> deployed -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/rollback-no-args.txt b/cmd/helm/testdata/output/rollback-no-args.txt deleted file mode 100644 index a1bc30b7a..000000000 --- a/cmd/helm/testdata/output/rollback-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm rollback" requires at least 1 argument - -Usage: helm rollback [REVISION] [flags] diff --git a/cmd/helm/testdata/output/rollback-no-revision.txt b/cmd/helm/testdata/output/rollback-no-revision.txt deleted file mode 100644 index ae3c6f1c4..000000000 --- a/cmd/helm/testdata/output/rollback-no-revision.txt +++ /dev/null @@ -1 +0,0 @@ -Rollback was a success! Happy Helming! diff --git a/cmd/helm/testdata/output/rollback-timeout.txt b/cmd/helm/testdata/output/rollback-timeout.txt deleted file mode 100644 index ae3c6f1c4..000000000 --- a/cmd/helm/testdata/output/rollback-timeout.txt +++ /dev/null @@ -1 +0,0 @@ -Rollback was a success! Happy Helming! diff --git a/cmd/helm/testdata/output/rollback-wait-for-jobs.txt b/cmd/helm/testdata/output/rollback-wait-for-jobs.txt deleted file mode 100644 index ae3c6f1c4..000000000 --- a/cmd/helm/testdata/output/rollback-wait-for-jobs.txt +++ /dev/null @@ -1 +0,0 @@ -Rollback was a success! Happy Helming! diff --git a/cmd/helm/testdata/output/rollback-wait.txt b/cmd/helm/testdata/output/rollback-wait.txt deleted file mode 100644 index ae3c6f1c4..000000000 --- a/cmd/helm/testdata/output/rollback-wait.txt +++ /dev/null @@ -1 +0,0 @@ -Rollback was a success! Happy Helming! diff --git a/cmd/helm/testdata/output/rollback-wrong-args-comp.txt b/cmd/helm/testdata/output/rollback-wrong-args-comp.txt deleted file mode 100644 index 8d9fad576..000000000 --- a/cmd/helm/testdata/output/rollback-wrong-args-comp.txt +++ /dev/null @@ -1,2 +0,0 @@ -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/rollback.txt b/cmd/helm/testdata/output/rollback.txt deleted file mode 100644 index ae3c6f1c4..000000000 --- a/cmd/helm/testdata/output/rollback.txt +++ /dev/null @@ -1 +0,0 @@ -Rollback was a success! Happy Helming! diff --git a/cmd/helm/testdata/output/schema-negative-cli.txt b/cmd/helm/testdata/output/schema-negative-cli.txt deleted file mode 100644 index c4a5cc516..000000000 --- a/cmd/helm/testdata/output/schema-negative-cli.txt +++ /dev/null @@ -1,4 +0,0 @@ -Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s): -empty: -- age: Must be greater than or equal to 0 - diff --git a/cmd/helm/testdata/output/schema-negative.txt b/cmd/helm/testdata/output/schema-negative.txt deleted file mode 100644 index 929af5518..000000000 --- a/cmd/helm/testdata/output/schema-negative.txt +++ /dev/null @@ -1,5 +0,0 @@ -Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s): -empty: -- (root): employmentInfo is required -- age: Must be greater than or equal to 0 - diff --git a/cmd/helm/testdata/output/schema.txt b/cmd/helm/testdata/output/schema.txt deleted file mode 100644 index 22a94b3f4..000000000 --- a/cmd/helm/testdata/output/schema.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: schema -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/search-constraint-single.txt b/cmd/helm/testdata/output/search-constraint-single.txt deleted file mode 100644 index a1f75099f..000000000 --- a/cmd/helm/testdata/output/search-constraint-single.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.2.0 2.3.4 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-constraint.txt b/cmd/helm/testdata/output/search-constraint.txt deleted file mode 100644 index 9fb22fe76..000000000 --- a/cmd/helm/testdata/output/search-constraint.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.1.0 1.2.3 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-multiple-devel-release.txt b/cmd/helm/testdata/output/search-multiple-devel-release.txt deleted file mode 100644 index 7e29a8f7e..000000000 --- a/cmd/helm/testdata/output/search-multiple-devel-release.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.3.0-rc.1 3.0.0 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-multiple-stable-release.txt b/cmd/helm/testdata/output/search-multiple-stable-release.txt deleted file mode 100644 index a1f75099f..000000000 --- a/cmd/helm/testdata/output/search-multiple-stable-release.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.2.0 2.3.4 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-multiple-versions-constraints.txt b/cmd/helm/testdata/output/search-multiple-versions-constraints.txt deleted file mode 100644 index a6a388858..000000000 --- a/cmd/helm/testdata/output/search-multiple-versions-constraints.txt +++ /dev/null @@ -1,3 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.2.0 2.3.4 Deploy a basic Alpine Linux pod -testing/alpine 0.1.0 1.2.3 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-multiple-versions.txt b/cmd/helm/testdata/output/search-multiple-versions.txt deleted file mode 100644 index a6a388858..000000000 --- a/cmd/helm/testdata/output/search-multiple-versions.txt +++ /dev/null @@ -1,3 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.2.0 2.3.4 Deploy a basic Alpine Linux pod -testing/alpine 0.1.0 1.2.3 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-not-found.txt b/cmd/helm/testdata/output/search-not-found.txt deleted file mode 100644 index 4f2a9fd07..000000000 --- a/cmd/helm/testdata/output/search-not-found.txt +++ /dev/null @@ -1 +0,0 @@ -No results found diff --git a/cmd/helm/testdata/output/search-output-json.txt b/cmd/helm/testdata/output/search-output-json.txt deleted file mode 100644 index 9b211e1b5..000000000 --- a/cmd/helm/testdata/output/search-output-json.txt +++ /dev/null @@ -1 +0,0 @@ -[{"name":"testing/mariadb","version":"0.3.0","app_version":"","description":"Chart for MariaDB"}] diff --git a/cmd/helm/testdata/output/search-output-yaml.txt b/cmd/helm/testdata/output/search-output-yaml.txt deleted file mode 100644 index 122b7f345..000000000 --- a/cmd/helm/testdata/output/search-output-yaml.txt +++ /dev/null @@ -1,4 +0,0 @@ -- app_version: 2.3.4 - description: Deploy a basic Alpine Linux pod - name: testing/alpine - version: 0.2.0 diff --git a/cmd/helm/testdata/output/search-regex.txt b/cmd/helm/testdata/output/search-regex.txt deleted file mode 100644 index a1f75099f..000000000 --- a/cmd/helm/testdata/output/search-regex.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.2.0 2.3.4 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-versions-constraint.txt b/cmd/helm/testdata/output/search-versions-constraint.txt deleted file mode 100644 index 9fb22fe76..000000000 --- a/cmd/helm/testdata/output/search-versions-constraint.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/alpine 0.1.0 1.2.3 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/status-comp.txt b/cmd/helm/testdata/output/status-comp.txt deleted file mode 100644 index 4c408c974..000000000 --- a/cmd/helm/testdata/output/status-comp.txt +++ /dev/null @@ -1,5 +0,0 @@ -aramis Aramis-chart-0.0.0 -> uninstalled -athos Athos-chart-1.2.3 -> deployed -porthos Porthos-chart-111.222.333 -> failed -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/status-with-desc.txt b/cmd/helm/testdata/output/status-with-desc.txt deleted file mode 100644 index c681fe3ec..000000000 --- a/cmd/helm/testdata/output/status-with-desc.txt +++ /dev/null @@ -1,7 +0,0 @@ -NAME: flummoxed-chickadee -LAST DEPLOYED: Sat Jan 16 00:00:00 2016 -NAMESPACE: default -STATUS: deployed -REVISION: 0 -DESCRIPTION: Mock description -TEST SUITE: None diff --git a/cmd/helm/testdata/output/status-with-notes.txt b/cmd/helm/testdata/output/status-with-notes.txt deleted file mode 100644 index e992ce91e..000000000 --- a/cmd/helm/testdata/output/status-with-notes.txt +++ /dev/null @@ -1,8 +0,0 @@ -NAME: flummoxed-chickadee -LAST DEPLOYED: Sat Jan 16 00:00:00 2016 -NAMESPACE: default -STATUS: deployed -REVISION: 0 -TEST SUITE: None -NOTES: -release notes diff --git a/cmd/helm/testdata/output/status-with-test-suite.txt b/cmd/helm/testdata/output/status-with-test-suite.txt deleted file mode 100644 index 58c67e103..000000000 --- a/cmd/helm/testdata/output/status-with-test-suite.txt +++ /dev/null @@ -1,13 +0,0 @@ -NAME: flummoxed-chickadee -LAST DEPLOYED: Sat Jan 16 00:00:00 2016 -NAMESPACE: default -STATUS: deployed -REVISION: 0 -TEST SUITE: passing-test -Last Started: Mon Jan 2 15:04:05 2006 -Last Completed: Mon Jan 2 15:04:07 2006 -Phase: Succeeded -TEST SUITE: failing-test -Last Started: Mon Jan 2 15:10:05 2006 -Last Completed: Mon Jan 2 15:10:07 2006 -Phase: Failed diff --git a/cmd/helm/testdata/output/status-wrong-args-comp.txt b/cmd/helm/testdata/output/status-wrong-args-comp.txt deleted file mode 100644 index 8d9fad576..000000000 --- a/cmd/helm/testdata/output/status-wrong-args-comp.txt +++ /dev/null @@ -1,2 +0,0 @@ -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/status.json b/cmd/helm/testdata/output/status.json deleted file mode 100644 index 4b499c935..000000000 --- a/cmd/helm/testdata/output/status.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"flummoxed-chickadee","info":{"first_deployed":"","last_deployed":"2016-01-16T00:00:00Z","deleted":"","status":"deployed","notes":"release notes"},"namespace":"default"} diff --git a/cmd/helm/testdata/output/status.txt b/cmd/helm/testdata/output/status.txt deleted file mode 100644 index a326c3db0..000000000 --- a/cmd/helm/testdata/output/status.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: flummoxed-chickadee -LAST DEPLOYED: Sat Jan 16 00:00:00 2016 -NAMESPACE: default -STATUS: deployed -REVISION: 0 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/subchart-schema-cli-negative.txt b/cmd/helm/testdata/output/subchart-schema-cli-negative.txt deleted file mode 100644 index 7396b4bfe..000000000 --- a/cmd/helm/testdata/output/subchart-schema-cli-negative.txt +++ /dev/null @@ -1,4 +0,0 @@ -Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s): -subchart-with-schema: -- age: Must be greater than or equal to 0 - diff --git a/cmd/helm/testdata/output/subchart-schema-cli.txt b/cmd/helm/testdata/output/subchart-schema-cli.txt deleted file mode 100644 index 22a94b3f4..000000000 --- a/cmd/helm/testdata/output/subchart-schema-cli.txt +++ /dev/null @@ -1,6 +0,0 @@ -NAME: schema -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/subchart-schema-negative.txt b/cmd/helm/testdata/output/subchart-schema-negative.txt deleted file mode 100644 index 7b1f654a2..000000000 --- a/cmd/helm/testdata/output/subchart-schema-negative.txt +++ /dev/null @@ -1,6 +0,0 @@ -Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s): -chart-without-schema: -- (root): lastname is required -subchart-with-schema: -- (root): age is required - diff --git a/cmd/helm/testdata/output/template-chart-bad-type.txt b/cmd/helm/testdata/output/template-chart-bad-type.txt deleted file mode 100644 index d8a3bf275..000000000 --- a/cmd/helm/testdata/output/template-chart-bad-type.txt +++ /dev/null @@ -1 +0,0 @@ -Error: validation: chart.metadata.type must be application or library diff --git a/cmd/helm/testdata/output/template-chart-with-template-lib-archive-dep.txt b/cmd/helm/testdata/output/template-chart-with-template-lib-archive-dep.txt deleted file mode 100644 index c954b8e14..000000000 --- a/cmd/helm/testdata/output/template-chart-with-template-lib-archive-dep.txt +++ /dev/null @@ -1,61 +0,0 @@ ---- -# Source: chart-with-template-lib-archive-dep/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: chart-with-template-lib-archive-dep - chart: chart-with-template-lib-archive-dep-0.1.0 - heritage: Helm - release: release-name - name: release-name-chart-with-template-lib-archive-dep -spec: - ports: - - name: http - port: 80 - targetPort: http - selector: - app: chart-with-template-lib-archive-dep - release: release-name - type: ClusterIP ---- -# Source: chart-with-template-lib-archive-dep/templates/deployment.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: release-name-chart-with-template-lib-archive-dep - labels: - app: chart-with-template-lib-archive-dep - chart: chart-with-template-lib-archive-dep-0.1.0 - release: release-name - heritage: Helm -spec: - replicas: 1 - selector: - matchLabels: - app: chart-with-template-lib-archive-dep - release: release-name - template: - metadata: - labels: - app: chart-with-template-lib-archive-dep - release: release-name - spec: - containers: - - name: chart-with-template-lib-archive-dep - image: "nginx:stable" - imagePullPolicy: IfNotPresent - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {} diff --git a/cmd/helm/testdata/output/template-chart-with-template-lib-dep.txt b/cmd/helm/testdata/output/template-chart-with-template-lib-dep.txt deleted file mode 100644 index 74a2a2df8..000000000 --- a/cmd/helm/testdata/output/template-chart-with-template-lib-dep.txt +++ /dev/null @@ -1,61 +0,0 @@ ---- -# Source: chart-with-template-lib-dep/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: chart-with-template-lib-dep - chart: chart-with-template-lib-dep-0.1.0 - heritage: Helm - release: release-name - name: release-name-chart-with-template-lib-dep -spec: - ports: - - name: http - port: 80 - targetPort: http - selector: - app: chart-with-template-lib-dep - release: release-name - type: ClusterIP ---- -# Source: chart-with-template-lib-dep/templates/deployment.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: release-name-chart-with-template-lib-dep - labels: - app: chart-with-template-lib-dep - chart: chart-with-template-lib-dep-0.1.0 - release: release-name - heritage: Helm -spec: - replicas: 1 - selector: - matchLabels: - app: chart-with-template-lib-dep - release: release-name - template: - metadata: - labels: - app: chart-with-template-lib-dep - release: release-name - spec: - containers: - - name: chart-with-template-lib-dep - image: "nginx:stable" - imagePullPolicy: IfNotPresent - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {} diff --git a/cmd/helm/testdata/output/template-lib-chart.txt b/cmd/helm/testdata/output/template-lib-chart.txt deleted file mode 100644 index d8a3bf275..000000000 --- a/cmd/helm/testdata/output/template-lib-chart.txt +++ /dev/null @@ -1 +0,0 @@ -Error: validation: chart.metadata.type must be application or library diff --git a/cmd/helm/testdata/output/template-name-template.txt b/cmd/helm/testdata/output/template-name-template.txt deleted file mode 100644 index 9406048dd..000000000 --- a/cmd/helm/testdata/output/template-name-template.txt +++ /dev/null @@ -1,114 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "foobar-ywjj-baz" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "foobar-ywjj-baz-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "foobar-ywjj-baz-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "foobar-ywjj-baz-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/template-no-args.txt b/cmd/helm/testdata/output/template-no-args.txt deleted file mode 100644 index f72f2b8cf..000000000 --- a/cmd/helm/testdata/output/template-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm template" requires at least 1 argument - -Usage: helm template [NAME] [CHART] [flags] diff --git a/cmd/helm/testdata/output/template-set.txt b/cmd/helm/testdata/output/template-set.txt deleted file mode 100644 index 4040991cf..000000000 --- a/cmd/helm/testdata/output/template-set.txt +++ /dev/null @@ -1,114 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "release-name-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "release-name-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/template-show-only-glob.txt b/cmd/helm/testdata/output/template-show-only-glob.txt deleted file mode 100644 index b2d2b1c2d..000000000 --- a/cmd/helm/testdata/output/template-show-only-glob.txt +++ /dev/null @@ -1,24 +0,0 @@ ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default diff --git a/cmd/helm/testdata/output/template-show-only-multiple.txt b/cmd/helm/testdata/output/template-show-only-multiple.txt deleted file mode 100644 index 1aac3081a..000000000 --- a/cmd/helm/testdata/output/template-show-only-multiple.txt +++ /dev/null @@ -1,38 +0,0 @@ ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta diff --git a/cmd/helm/testdata/output/template-show-only-one.txt b/cmd/helm/testdata/output/template-show-only-one.txt deleted file mode 100644 index 9cc34f515..000000000 --- a/cmd/helm/testdata/output/template-show-only-one.txt +++ /dev/null @@ -1,21 +0,0 @@ ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart diff --git a/cmd/helm/testdata/output/template-skip-tests.txt b/cmd/helm/testdata/output/template-skip-tests.txt deleted file mode 100644 index 5c907b563..000000000 --- a/cmd/helm/testdata/output/template-skip-tests.txt +++ /dev/null @@ -1,85 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart diff --git a/cmd/helm/testdata/output/template-values-files.txt b/cmd/helm/testdata/output/template-values-files.txt deleted file mode 100644 index 4040991cf..000000000 --- a/cmd/helm/testdata/output/template-values-files.txt +++ /dev/null @@ -1,114 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "release-name-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "release-name-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/template-with-api-version.txt b/cmd/helm/testdata/output/template-with-api-version.txt deleted file mode 100644 index 7e1c35001..000000000 --- a/cmd/helm/testdata/output/template-with-api-version.txt +++ /dev/null @@ -1,115 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" - kube-api-version/test: v1 -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "release-name-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "release-name-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/template-with-crds.txt b/cmd/helm/testdata/output/template-with-crds.txt deleted file mode 100644 index dd58480c9..000000000 --- a/cmd/helm/testdata/output/template-with-crds.txt +++ /dev/null @@ -1,131 +0,0 @@ ---- -# Source: crds/crdA.yaml -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: testcrds.testcrdgroups.example.com -spec: - group: testcrdgroups.example.com - version: v1alpha1 - names: - kind: TestCRD - listKind: TestCRDList - plural: testcrds - shortNames: - - tc - singular: authconfig - ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "release-name-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "release-name-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt b/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt deleted file mode 100644 index 909c543d3..000000000 --- a/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt +++ /dev/null @@ -1,13 +0,0 @@ ---- -# Source: chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-my-alpine" -spec: - containers: - - name: waiter - image: "alpine:3.9" - command: ["/bin/sleep","9000"] -invalid -Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':' diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml.txt b/cmd/helm/testdata/output/template-with-invalid-yaml.txt deleted file mode 100644 index 687227b90..000000000 --- a/cmd/helm/testdata/output/template-with-invalid-yaml.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':' - -Use --debug flag to render out invalid YAML diff --git a/cmd/helm/testdata/output/template-with-kube-version.txt b/cmd/helm/testdata/output/template-with-kube-version.txt deleted file mode 100644 index 9d326f328..000000000 --- a/cmd/helm/testdata/output/template-with-kube-version.txt +++ /dev/null @@ -1,114 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "16" - kube-version/version: "v1.16.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "release-name-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "release-name-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/template.txt b/cmd/helm/testdata/output/template.txt deleted file mode 100644 index 58c480b47..000000000 --- a/cmd/helm/testdata/output/template.txt +++ /dev/null @@ -1,114 +0,0 @@ ---- -# Source: subchart/templates/subdir/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: subchart-sa ---- -# Source: subchart/templates/subdir/role.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: subchart-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] ---- -# Source: subchart/templates/subdir/rolebinding.yaml -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: subchart-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: subchart-role -subjects: -- kind: ServiceAccount - name: subchart-sa - namespace: default ---- -# Source: subchart/charts/subcharta/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subcharta - labels: - helm.sh/chart: "subcharta-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: apache - selector: - app.kubernetes.io/name: subcharta ---- -# Source: subchart/charts/subchartb/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchartb - labels: - helm.sh/chart: "subchartb-0.1.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchartb ---- -# Source: subchart/templates/service.yaml -apiVersion: v1 -kind: Service -metadata: - name: subchart - labels: - helm.sh/chart: "subchart-0.1.0" - app.kubernetes.io/instance: "release-name" - kube-version/major: "1" - kube-version/minor: "20" - kube-version/version: "v1.20.0" -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 80 - protocol: TCP - name: nginx - selector: - app.kubernetes.io/name: subchart ---- -# Source: subchart/templates/tests/test-config.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: "release-name-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World ---- -# Source: subchart/templates/tests/test-nothing.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "release-name-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "release-name-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/output/uninstall-keep-history.txt b/cmd/helm/testdata/output/uninstall-keep-history.txt deleted file mode 100644 index f5454b88d..000000000 --- a/cmd/helm/testdata/output/uninstall-keep-history.txt +++ /dev/null @@ -1 +0,0 @@ -release "aeneas" uninstalled diff --git a/cmd/helm/testdata/output/uninstall-multiple.txt b/cmd/helm/testdata/output/uninstall-multiple.txt deleted file mode 100644 index ee1c67d2f..000000000 --- a/cmd/helm/testdata/output/uninstall-multiple.txt +++ /dev/null @@ -1,2 +0,0 @@ -release "aeneas" uninstalled -release "aeneas2" uninstalled diff --git a/cmd/helm/testdata/output/uninstall-no-args.txt b/cmd/helm/testdata/output/uninstall-no-args.txt deleted file mode 100644 index fc01a75b9..000000000 --- a/cmd/helm/testdata/output/uninstall-no-args.txt +++ /dev/null @@ -1,3 +0,0 @@ -Error: "helm uninstall" requires at least 1 argument - -Usage: helm uninstall RELEASE_NAME [...] [flags] diff --git a/cmd/helm/testdata/output/uninstall-no-hooks.txt b/cmd/helm/testdata/output/uninstall-no-hooks.txt deleted file mode 100644 index f5454b88d..000000000 --- a/cmd/helm/testdata/output/uninstall-no-hooks.txt +++ /dev/null @@ -1 +0,0 @@ -release "aeneas" uninstalled diff --git a/cmd/helm/testdata/output/uninstall-timeout.txt b/cmd/helm/testdata/output/uninstall-timeout.txt deleted file mode 100644 index f5454b88d..000000000 --- a/cmd/helm/testdata/output/uninstall-timeout.txt +++ /dev/null @@ -1 +0,0 @@ -release "aeneas" uninstalled diff --git a/cmd/helm/testdata/output/uninstall-wait.txt b/cmd/helm/testdata/output/uninstall-wait.txt deleted file mode 100644 index f5454b88d..000000000 --- a/cmd/helm/testdata/output/uninstall-wait.txt +++ /dev/null @@ -1 +0,0 @@ -release "aeneas" uninstalled diff --git a/cmd/helm/testdata/output/uninstall.txt b/cmd/helm/testdata/output/uninstall.txt deleted file mode 100644 index f5454b88d..000000000 --- a/cmd/helm/testdata/output/uninstall.txt +++ /dev/null @@ -1 +0,0 @@ -release "aeneas" uninstalled diff --git a/cmd/helm/testdata/output/upgrade-with-bad-dependencies.txt b/cmd/helm/testdata/output/upgrade-with-bad-dependencies.txt deleted file mode 100644 index 6dddc7344..000000000 --- a/cmd/helm/testdata/output/upgrade-with-bad-dependencies.txt +++ /dev/null @@ -1 +0,0 @@ -Error: cannot load Chart.yaml: error converting YAML to JSON: yaml: line 6: did not find expected '-' indicator diff --git a/cmd/helm/testdata/output/upgrade-with-bad-or-missing-existing-release.txt b/cmd/helm/testdata/output/upgrade-with-bad-or-missing-existing-release.txt deleted file mode 100644 index 8f24574a6..000000000 --- a/cmd/helm/testdata/output/upgrade-with-bad-or-missing-existing-release.txt +++ /dev/null @@ -1 +0,0 @@ -Error: UPGRADE FAILED: "funny-bunny" has no deployed releases diff --git a/cmd/helm/testdata/output/upgrade-with-dependency-update.txt b/cmd/helm/testdata/output/upgrade-with-dependency-update.txt deleted file mode 100644 index 0e7e5842e..000000000 --- a/cmd/helm/testdata/output/upgrade-with-dependency-update.txt +++ /dev/null @@ -1,9 +0,0 @@ -Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 3 -TEST SUITE: None -NOTES: -PARENT NOTES diff --git a/cmd/helm/testdata/output/upgrade-with-install-timeout.txt b/cmd/helm/testdata/output/upgrade-with-install-timeout.txt deleted file mode 100644 index 5d8d3a4ea..000000000 --- a/cmd/helm/testdata/output/upgrade-with-install-timeout.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "crazy-bunny" has been upgraded. Happy Helming! -NAME: crazy-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 2 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade-with-install.txt b/cmd/helm/testdata/output/upgrade-with-install.txt deleted file mode 100644 index af61212bd..000000000 --- a/cmd/helm/testdata/output/upgrade-with-install.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "zany-bunny" has been upgraded. Happy Helming! -NAME: zany-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 2 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade-with-missing-dependencies.txt b/cmd/helm/testdata/output/upgrade-with-missing-dependencies.txt deleted file mode 100644 index adf2ae899..000000000 --- a/cmd/helm/testdata/output/upgrade-with-missing-dependencies.txt +++ /dev/null @@ -1 +0,0 @@ -Error: An error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies: found in Chart.yaml, but missing in charts/ directory: reqsubchart2 diff --git a/cmd/helm/testdata/output/upgrade-with-pending-install.txt b/cmd/helm/testdata/output/upgrade-with-pending-install.txt deleted file mode 100644 index 57a8e7873..000000000 --- a/cmd/helm/testdata/output/upgrade-with-pending-install.txt +++ /dev/null @@ -1 +0,0 @@ -Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress diff --git a/cmd/helm/testdata/output/upgrade-with-reset-values.txt b/cmd/helm/testdata/output/upgrade-with-reset-values.txt deleted file mode 100644 index 01f1c0ac8..000000000 --- a/cmd/helm/testdata/output/upgrade-with-reset-values.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 5 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade-with-reset-values2.txt b/cmd/helm/testdata/output/upgrade-with-reset-values2.txt deleted file mode 100644 index fdd1d2db7..000000000 --- a/cmd/helm/testdata/output/upgrade-with-reset-values2.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 6 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade-with-timeout.txt b/cmd/helm/testdata/output/upgrade-with-timeout.txt deleted file mode 100644 index be3a42368..000000000 --- a/cmd/helm/testdata/output/upgrade-with-timeout.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 4 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt b/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt deleted file mode 100644 index 500d07a11..000000000 --- a/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "crazy-bunny" has been upgraded. Happy Helming! -NAME: crazy-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 3 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade-with-wait.txt b/cmd/helm/testdata/output/upgrade-with-wait.txt deleted file mode 100644 index 500d07a11..000000000 --- a/cmd/helm/testdata/output/upgrade-with-wait.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "crazy-bunny" has been upgraded. Happy Helming! -NAME: crazy-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 3 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/upgrade.txt b/cmd/helm/testdata/output/upgrade.txt deleted file mode 100644 index bea42db54..000000000 --- a/cmd/helm/testdata/output/upgrade.txt +++ /dev/null @@ -1,7 +0,0 @@ -Release "funny-bunny" has been upgraded. Happy Helming! -NAME: funny-bunny -LAST DEPLOYED: Fri Sep 2 22:04:05 1977 -NAMESPACE: default -STATUS: deployed -REVISION: 3 -TEST SUITE: None diff --git a/cmd/helm/testdata/output/values.json b/cmd/helm/testdata/output/values.json deleted file mode 100644 index ea8308627..000000000 --- a/cmd/helm/testdata/output/values.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"value"} diff --git a/cmd/helm/testdata/output/values.yaml b/cmd/helm/testdata/output/values.yaml deleted file mode 100644 index 54ab03c93..000000000 --- a/cmd/helm/testdata/output/values.yaml +++ /dev/null @@ -1 +0,0 @@ -name: value diff --git a/cmd/helm/testdata/output/version-client-shorthand.txt b/cmd/helm/testdata/output/version-client-shorthand.txt deleted file mode 100644 index 9eb69189d..000000000 --- a/cmd/helm/testdata/output/version-client-shorthand.txt +++ /dev/null @@ -1 +0,0 @@ -version.BuildInfo{Version:"v3.10", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/output/version-client.txt b/cmd/helm/testdata/output/version-client.txt deleted file mode 100644 index 9eb69189d..000000000 --- a/cmd/helm/testdata/output/version-client.txt +++ /dev/null @@ -1 +0,0 @@ -version.BuildInfo{Version:"v3.10", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/output/version-comp.txt b/cmd/helm/testdata/output/version-comp.txt deleted file mode 100644 index 5b0556cf5..000000000 --- a/cmd/helm/testdata/output/version-comp.txt +++ /dev/null @@ -1,5 +0,0 @@ -0.3.0-rc.1 App: 3.0.0, Created: November 12, 2020 -0.2.0 App: 2.3.4, Created: July 9, 2018 -0.1.0 App: 1.2.3, Created: June 27, 2018 (deprecated) -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/version-invalid-comp.txt b/cmd/helm/testdata/output/version-invalid-comp.txt deleted file mode 100644 index 8d9fad576..000000000 --- a/cmd/helm/testdata/output/version-invalid-comp.txt +++ /dev/null @@ -1,2 +0,0 @@ -:4 -Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/cmd/helm/testdata/output/version-short.txt b/cmd/helm/testdata/output/version-short.txt deleted file mode 100644 index 1d17edb02..000000000 --- a/cmd/helm/testdata/output/version-short.txt +++ /dev/null @@ -1 +0,0 @@ -v3.10 diff --git a/cmd/helm/testdata/output/version-template.txt b/cmd/helm/testdata/output/version-template.txt deleted file mode 100644 index 02ffe32fd..000000000 --- a/cmd/helm/testdata/output/version-template.txt +++ /dev/null @@ -1 +0,0 @@ -Version: v3.10 \ No newline at end of file diff --git a/cmd/helm/testdata/output/version.txt b/cmd/helm/testdata/output/version.txt deleted file mode 100644 index 9eb69189d..000000000 --- a/cmd/helm/testdata/output/version.txt +++ /dev/null @@ -1 +0,0 @@ -version.BuildInfo{Version:"v3.10", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/password b/cmd/helm/testdata/password deleted file mode 100644 index f3097ab13..000000000 --- a/cmd/helm/testdata/password +++ /dev/null @@ -1 +0,0 @@ -password diff --git a/cmd/helm/testdata/plugins.yaml b/cmd/helm/testdata/plugins.yaml deleted file mode 100644 index 69086973e..000000000 --- a/cmd/helm/testdata/plugins.yaml +++ /dev/null @@ -1,3 +0,0 @@ -plugins: -- name: testplugin - url: testdata/testplugin diff --git a/cmd/helm/testdata/repositories.yaml b/cmd/helm/testdata/repositories.yaml deleted file mode 100644 index 6be26b771..000000000 --- a/cmd/helm/testdata/repositories.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -repositories: - - name: charts - url: "https://charts.helm.sh/stable" - - name: firstexample - url: "http://firstexample.com" - - name: secondexample - url: "http://secondexample.com" - diff --git a/cmd/helm/testdata/testcharts/alpine/Chart.yaml b/cmd/helm/testdata/testcharts/alpine/Chart.yaml deleted file mode 100644 index 1d6bad825..000000000 --- a/cmd/helm/testdata/testcharts/alpine/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -appVersion: "3.9" -description: Deploy a basic Alpine Linux pod -home: https://helm.sh/helm -name: alpine -sources: -- https://github.com/helm/helm -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/alpine/README.md b/cmd/helm/testdata/testcharts/alpine/README.md deleted file mode 100644 index 05d39dbbc..000000000 --- a/cmd/helm/testdata/testcharts/alpine/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Alpine: A simple Helm chart - -Run a single pod of Alpine Linux. - -This example was generated using the command `helm create alpine`. - -The `templates/` directory contains a very simple pod resource with a -couple of parameters. - -The `values.yaml` file contains the default values for the -`alpine-pod.yaml` template. - -You can install this example using `helm install ./alpine`. diff --git a/cmd/helm/testdata/testcharts/alpine/extra_values.yaml b/cmd/helm/testdata/testcharts/alpine/extra_values.yaml deleted file mode 100644 index 468bbacbc..000000000 --- a/cmd/helm/testdata/testcharts/alpine/extra_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - Name: extra-values diff --git a/cmd/helm/testdata/testcharts/alpine/more_values.yaml b/cmd/helm/testdata/testcharts/alpine/more_values.yaml deleted file mode 100644 index 3d21e1fed..000000000 --- a/cmd/helm/testdata/testcharts/alpine/more_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - Name: more-values diff --git a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml deleted file mode 100644 index a1a44e53f..000000000 --- a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{.Release.Name}}-{{.Values.Name}}" - labels: - # The "app.kubernetes.io/managed-by" label is used to track which tool - # deployed a given chart. It is useful for admins who want to see what - # releases a particular tool is responsible for. - app.kubernetes.io/managed-by: {{.Release.Service | quote }} - # The "app.kubernetes.io/instance" convention makes it easy to tie a release - # to all of the Kubernetes resources that were created as part of that - # release. - app.kubernetes.io/instance: {{.Release.Name | quote }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} - # This makes it easy to audit chart usage. - helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - values: {{.Values.Name}} -spec: - # This shows how to use a simple value. This will look for a passed-in value - # called restartPolicy. If it is not found, it will use the default value. - # {{default "Never" .restartPolicy}} is a slightly optimized version of the - # more conventional syntax: {{.restartPolicy | default "Never"}} - restartPolicy: {{default "Never" .Values.restartPolicy}} - containers: - - name: waiter - image: "alpine:{{ .Chart.AppVersion }}" - command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/alpine/values.yaml b/cmd/helm/testdata/testcharts/alpine/values.yaml deleted file mode 100644 index 807e12aea..000000000 --- a/cmd/helm/testdata/testcharts/alpine/values.yaml +++ /dev/null @@ -1 +0,0 @@ -Name: my-alpine diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/.helmignore b/cmd/helm/testdata/testcharts/chart-bad-requirements/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/Chart.yaml b/cmd/helm/testdata/testcharts/chart-bad-requirements/Chart.yaml deleted file mode 100644 index 1f445ee11..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: chart-missing-deps -version: 0.1.0 -dependencies: - - name: reqsubchart - version: 0.1.0 - repository: "https://example.com/charts" diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore b/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml deleted file mode 100644 index 356135537..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: reqsubchart -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml b/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml deleted file mode 100644 index 0f0b63f2a..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqsubchart. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/values.yaml b/cmd/helm/testdata/testcharts/chart-bad-requirements/values.yaml deleted file mode 100644 index d57f76b07..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqtest. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/Chart.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/Chart.yaml deleted file mode 100644 index e77b5afaa..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-type/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -description: Deploy a basic Alpine Linux pod -home: https://helm.sh/helm -name: chart-bad-type -sources: - - https://github.com/helm/helm -version: 0.1.0 -type: foobar diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/README.md b/cmd/helm/testdata/testcharts/chart-bad-type/README.md deleted file mode 100644 index fcf7ee017..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-type/README.md +++ /dev/null @@ -1,13 +0,0 @@ -#Alpine: A simple Helm chart - -Run a single pod of Alpine Linux. - -This example was generated using the command `helm create alpine`. - -The `templates/` directory contains a very simple pod resource with a -couple of parameters. - -The `values.yaml` file contains the default values for the -`alpine-pod.yaml` template. - -You can install this example using `helm install ./alpine`. diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/extra_values.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/extra_values.yaml deleted file mode 100644 index 468bbacbc..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-type/extra_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - Name: extra-values diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/more_values.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/more_values.yaml deleted file mode 100644 index 3d21e1fed..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-type/more_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - Name: more-values diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml deleted file mode 100644 index a40ae32d7..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{.Release.Name}}-{{.Values.Name}}" - labels: - # The "app.kubernetes.io/managed-by" label is used to track which tool - # deployed a given chart. It is useful for admins who want to see what - # releases a particular tool is responsible for. - app.kubernetes.io/managed-by: {{.Release.Service | quote }} - # The "release" convention makes it easy to tie a release to all of the - # Kubernetes resources that were created as part of that release. - app.kubernetes.io/instance: {{.Release.Name | quote }} - # This makes it easy to audit chart usage. - helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - values: {{.Values.test.Name}} -spec: - # This shows how to use a simple value. This will look for a passed-in value - # called restartPolicy. If it is not found, it will use the default value. - # {{default "Never" .restartPolicy}} is a slightly optimized version of the - # more conventional syntax: {{.restartPolicy | default "Never"}} - restartPolicy: {{default "Never" .Values.restartPolicy}} - containers: - - name: waiter - image: "alpine:3.9" - command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/values.yaml b/cmd/helm/testdata/testcharts/chart-bad-type/values.yaml deleted file mode 100644 index 807e12aea..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-type/values.yaml +++ /dev/null @@ -1 +0,0 @@ -Name: my-alpine diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore b/cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml b/cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml deleted file mode 100644 index 9605636db..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: chart-missing-deps -version: 0.1.0 -dependencies: - - name: reqsubchart - version: 0.1.0 - repository: "https://example.com/charts" - - name: reqsubchart2 - version: 0.2.0 - repository: "https://example.com/charts" diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore b/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml deleted file mode 100644 index 356135537..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: reqsubchart -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml b/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml deleted file mode 100644 index 0f0b63f2a..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqsubchart. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml b/cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml deleted file mode 100644 index d57f76b07..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqtest. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml deleted file mode 100644 index a575aa9f8..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: Chart with bad subcharts -name: chart-with-bad-subcharts -version: 0.0.1 diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml deleted file mode 100644 index a6754b24f..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml +++ /dev/null @@ -1 +0,0 @@ -description: Bad subchart diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml deleted file mode 100644 index 895433e31..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: Good subchart -name: good-subchart -version: 0.0.1 \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml deleted file mode 100644 index de2fbb4dd..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml +++ /dev/null @@ -1,5 +0,0 @@ -dependencies: - - name: good-subchart - version: 0.0.1 - - name: bad-subchart - version: 0.0.1 \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/.helmignore b/cmd/helm/testdata/testcharts/chart-with-lib-dep/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/Chart.yaml deleted file mode 100644 index 773cc9f32..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: chart-with-lib-dep -type: application -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz b/cmd/helm/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz deleted file mode 100644 index ca0a64ae3..000000000 Binary files a/cmd/helm/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt deleted file mode 100644 index a758b7971..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "chart-with-lib-dep.fullname" . }}) - export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "chart-with-lib-dep.fullname" . }}' - export SERVICE_IP=$(kubectl get svc {{ template "chart-with-lib-dep.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods -l "app={{ template "chart-with-lib-dep.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl deleted file mode 100644 index b8be8cad6..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "chart-with-lib-dep.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "chart-with-lib-dep.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "chart-with-lib-dep.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml deleted file mode 100644 index 521fa5972..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "chart-with-lib-dep.fullname" . }} - labels: - app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} - helm.sh/chart: {{ template "chart-with-lib-dep.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - template: - metadata: - labels: - app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml deleted file mode 100644 index 42afd0879..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "chart-with-lib-dep.fullname" . -}} -{{- $ingressPath := .Values.ingress.path -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app.kubernetes.io/name: {{ template "chart-with-lib-dep.name" . }} - helm.sh/chart: {{ template "chart-with-lib-dep.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/service.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/service.yaml deleted file mode 100644 index 4c2b91a5a..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/service.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- template "common.service" (list . "mychart.service") -}} -{{- define "mychart.service" -}} -## Define overrides for your Service resource here, e.g. -# metadata: -# labels: -# custom: label -# spec: -# ports: -# - port: 8080 -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/values.yaml b/cmd/helm/testdata/testcharts/chart-with-lib-dep/values.yaml deleted file mode 100644 index a0cc07e9e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-lib-dep/values.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Default values for chart-with-lib-dep. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent - -nameOverride: "" -fullnameOverride: "" - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/cmd/helm/testdata/testcharts/chart-with-only-crds/.helmignore b/cmd/helm/testdata/testcharts/chart-with-only-crds/.helmignore deleted file mode 100644 index 0e8a0eb36..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-only-crds/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/cmd/helm/testdata/testcharts/chart-with-only-crds/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-only-crds/Chart.yaml deleted file mode 100644 index ec3497670..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-only-crds/Chart.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v2 -name: crd-test -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application and it is recommended to use it with quotes. -appVersion: "1.16.0" diff --git a/cmd/helm/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml b/cmd/helm/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml deleted file mode 100644 index 1d7350f1d..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: tests.test.io -spec: - group: test.io - names: - kind: Test - listKind: TestList - plural: tests - singular: test - scope: Namespaced - versions: - - name : v1alpha2 - served: true - storage: true - - name : v1alpha1 - served: true - storage: false diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml deleted file mode 100644 index 4e24c2ebb..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -name: chart-without-schema -description: A Helm chart for Kubernetes -type: application -version: 0.1.0 -appVersion: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml deleted file mode 100644 index b5a77c5db..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -name: subchart-with-schema -description: A Helm chart for Kubernetes -type: application -version: 0.1.0 -appVersion: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml deleted file mode 100644 index c80812f6e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# This file is intentionally blank diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json deleted file mode 100644 index 4ff791844..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Values", - "type": "object", - "properties": { - "age": { - "description": "Age", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "age" - ] -} diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml deleted file mode 100644 index c80812f6e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# This file is intentionally blank diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json deleted file mode 100644 index f30948038..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Values", - "type": "object", - "properties": { - "firstname": { - "description": "First name", - "type": "string" - }, - "lastname": { - "type": "string" - } - }, - "required": [ - "firstname", - "lastname" - ] -} diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.yaml deleted file mode 100644 index c9deafc00..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.yaml +++ /dev/null @@ -1 +0,0 @@ -firstname: "John" diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-negative/Chart.yaml deleted file mode 100644 index 395d24f6a..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-negative/Chart.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -description: Empty testing chart -home: https://k8s.io/helm -name: empty -sources: -- https://github.com/kubernetes/helm -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml deleted file mode 100644 index c80812f6e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# This file is intentionally blank diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.schema.json b/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.schema.json deleted file mode 100644 index 4df89bbe8..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.schema.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "properties": { - "addresses": { - "description": "List of addresses", - "items": { - "properties": { - "city": { - "type": "string" - }, - "number": { - "type": "number" - }, - "street": { - "type": "string" - } - }, - "type": "object" - }, - "type": "array" - }, - "age": { - "description": "Age", - "minimum": 0, - "type": "integer" - }, - "employmentInfo": { - "properties": { - "salary": { - "minimum": 0, - "type": "number" - }, - "title": { - "type": "string" - } - }, - "required": [ - "salary" - ], - "type": "object" - }, - "firstname": { - "description": "First name", - "type": "string" - }, - "lastname": { - "type": "string" - }, - "likesCoffee": { - "type": "boolean" - }, - "phoneNumbers": { - "items": { - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "firstname", - "lastname", - "addresses", - "employmentInfo" - ], - "title": "Values", - "type": "object" -} diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.yaml b/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.yaml deleted file mode 100644 index 5a1250bff..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.yaml +++ /dev/null @@ -1,14 +0,0 @@ -firstname: John -lastname: Doe -age: -5 -likesCoffee: true -addresses: - - city: Springfield - street: Main - number: 12345 - - city: New York - street: Broadway - number: 67890 -phoneNumbers: - - "(888) 888-8888" - - "(555) 555-5555" diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-schema/Chart.yaml deleted file mode 100644 index 395d24f6a..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema/Chart.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -description: Empty testing chart -home: https://k8s.io/helm -name: empty -sources: -- https://github.com/kubernetes/helm -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/extra-values.yaml b/cmd/helm/testdata/testcharts/chart-with-schema/extra-values.yaml deleted file mode 100644 index 76c290c4f..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema/extra-values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -age: -5 -employmentInfo: null diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/templates/empty.yaml b/cmd/helm/testdata/testcharts/chart-with-schema/templates/empty.yaml deleted file mode 100644 index c80812f6e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema/templates/empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# This file is intentionally blank diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/values.schema.json b/cmd/helm/testdata/testcharts/chart-with-schema/values.schema.json deleted file mode 100644 index 4df89bbe8..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema/values.schema.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "properties": { - "addresses": { - "description": "List of addresses", - "items": { - "properties": { - "city": { - "type": "string" - }, - "number": { - "type": "number" - }, - "street": { - "type": "string" - } - }, - "type": "object" - }, - "type": "array" - }, - "age": { - "description": "Age", - "minimum": 0, - "type": "integer" - }, - "employmentInfo": { - "properties": { - "salary": { - "minimum": 0, - "type": "number" - }, - "title": { - "type": "string" - } - }, - "required": [ - "salary" - ], - "type": "object" - }, - "firstname": { - "description": "First name", - "type": "string" - }, - "lastname": { - "type": "string" - }, - "likesCoffee": { - "type": "boolean" - }, - "phoneNumbers": { - "items": { - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "firstname", - "lastname", - "addresses", - "employmentInfo" - ], - "title": "Values", - "type": "object" -} diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/values.yaml b/cmd/helm/testdata/testcharts/chart-with-schema/values.yaml deleted file mode 100644 index 042dea664..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-schema/values.yaml +++ /dev/null @@ -1,17 +0,0 @@ -firstname: John -lastname: Doe -age: 25 -likesCoffee: true -employmentInfo: - title: Software Developer - salary: 100000 -addresses: - - city: Springfield - street: Main - number: 12345 - - city: New York - street: Broadway - number: 67890 -phoneNumbers: - - "(888) 888-8888" - - "(555) 555-5555" diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml deleted file mode 100644 index 90545a6a3..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v2 -description: Chart with subchart notes -name: chart-with-subchart-notes -version: 0.0.1 -dependencies: - - name: subchart-with-notes - version: 0.0.1 diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml deleted file mode 100644 index f0fead9ee..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v2 -description: Subchart with notes -name: subchart-with-notes -version: 0.0.1 diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt deleted file mode 100644 index 1f61a294e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt +++ /dev/null @@ -1 +0,0 @@ -SUBCHART NOTES diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt deleted file mode 100644 index 9e166d370..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt +++ /dev/null @@ -1 +0,0 @@ -PARENT NOTES diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.lock b/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.lock deleted file mode 100644 index 31cda6bd6..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: subchart-with-notes - repository: file://../chart-with-subchart-notes/charts/subchart-with-notes - version: 0.0.1 -digest: sha256:8ca45f73ae3f6170a09b64a967006e98e13cd91eb51e5ab0599bb87296c7df0a -generated: "2021-05-02T15:07:22.1099921+02:00" diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.yaml deleted file mode 100644 index 1bc230200..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v2 -description: Chart with subchart that needs to be fetched -name: chart-with-subchart-update -version: 0.0.1 -dependencies: - - name: subchart-with-notes - version: 0.0.1 - repository: file://../chart-with-subchart-notes/charts diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml deleted file mode 100644 index f0fead9ee..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v2 -description: Subchart with notes -name: subchart-with-notes -version: 0.0.1 diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt deleted file mode 100644 index 1f61a294e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt +++ /dev/null @@ -1 +0,0 @@ -SUBCHART NOTES diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt deleted file mode 100644 index 9e166d370..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt +++ /dev/null @@ -1 +0,0 @@ -PARENT NOTES diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml deleted file mode 100644 index de53ce5e3..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: chart-with-template-lib-archive-dep -type: application -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz deleted file mode 100644 index 465517824..000000000 Binary files a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt deleted file mode 100644 index 5c53ac03d..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "chart-with-template-lib-archive-dep.fullname" . }}) - export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "chart-with-template-lib-archive-dep.fullname" . }}' - export SERVICE_IP=$(kubectl get svc {{ template "chart-with-template-lib-archive-dep.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods -l "app={{ template "chart-with-template-lib-archive-dep.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl deleted file mode 100644 index 76ca56b81..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "chart-with-template-lib-archive-dep.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "chart-with-template-lib-archive-dep.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "chart-with-template-lib-archive-dep.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml deleted file mode 100644 index a49572f4a..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "chart-with-template-lib-archive-dep.fullname" . }} - labels: - app: {{ template "chart-with-template-lib-archive-dep.name" . }} - chart: {{ template "chart-with-template-lib-archive-dep.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "chart-with-template-lib-archive-dep.name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template "chart-with-template-lib-archive-dep.name" . }} - release: {{ .Release.Name }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml deleted file mode 100644 index d3325cf18..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "chart-with-template-lib-archive-dep.fullname" . -}} -{{- $ingressPath := .Values.ingress.path -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "chart-with-template-lib-archive-dep.name" . }} - chart: {{ template "chart-with-template-lib-archive-dep.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml deleted file mode 100644 index bfcb080b4..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- template "common.service" (list . "chart-with-template-lib-archive-dep.service") -}} -{{- define "chart-with-template-lib-archive-dep.service" -}} -## Define overrides for your Service resource here, e.g. -# metadata: -# labels: -# custom: label -# spec: -# ports: -# - port: 8080 -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml deleted file mode 100644 index b5474cbbd..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Default values for chart-with-template-lib-archive-dep. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent - -nameOverride: "" -fullnameOverride: "" - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/.helmignore b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml deleted file mode 100644 index cf6fc390b..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: chart-with-template-lib-dep -type: application -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore deleted file mode 100755 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml deleted file mode 100755 index ba14ca089..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -appVersion: 0.0.5 -description: Common chartbuilding components and helpers -home: https://helm.sh -maintainers: -- email: technosophos@gmail.com - name: technosophos -- email: adnan@bitnami.com - name: prydonius -name: common -version: 0.0.5 -type: library diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md deleted file mode 100755 index 0e06414d6..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md +++ /dev/null @@ -1,831 +0,0 @@ -# Common: The Helm Helper Chart - -This chart is designed to make it easier for you to build and maintain Helm -charts. - -It provides utilities that reflect best practices of Kubernetes chart development, -making it faster for you to write charts. - -## Tips - -A few tips for working with Common: - -- Be careful when using functions that generate random data (like `common.fullname.unique`). - They may trigger unwanted upgrades or have other side effects. - -In this document, we use `release-name` as the name of the release. - -## Resource Kinds - -Kubernetes defines a variety of resource kinds, from `Secret` to `StatefulSet`. -We define some of the most common kinds in a way that lets you easily work with -them. - -The resource kind templates are designed to make it much faster for you to -define _basic_ versions of these resources. They allow you to extend and modify -just what you need, without having to copy around lots of boilerplate. - -To make use of these templates you must define a template that will extend the -base template (though it can be empty). The name of this template is then passed -to the base template, for example: - -```yaml -{{- template "common.service" (list . "mychart.service") -}} -{{- define "mychart.service" -}} -## Define overrides for your Service resource here, e.g. -# metadata: -# labels: -# custom: label -# spec: -# ports: -# - port: 8080 -{{- end -}} -``` - -Note that the `common.service` template defines two parameters: - - - The root context (usually `.`) - - A template name containing the service definition overrides - -A limitation of the Go template library is that a template can only take a -single argument. The `list` function is used to workaround this by constructing -a list or array of arguments that is passed to the template. - -The `common.service` template is responsible for rendering the templates with -the root context and merging any overrides. As you can see, this makes it very -easy to create a basic `Service` resource without having to copy around the -standard metadata and labels. - -Each implemented base resource is described in greater detail below. - -### `common.service` - -The `common.service` template creates a basic `Service` resource with the -following defaults: - -- Service type (ClusterIP, NodePort, LoadBalancer) made configurable by `.Values.service.type` -- Named port `http` configured on port 80 -- Selector set to `app: {{ template "common.name" }}, release: {{ .Release.Name | quote }}` to match the default used in the `Deployment` resource - -Example template: - -```yaml -{{- template "common.service" (list . "mychart.mail.service") -}} -{{- define "mychart.mail.service" -}} -metadata: - name: {{ template "common.fullname" . }}-mail # overrides the default name to add a suffix - labels: # appended to the labels section - protocol: mail -spec: - ports: # composes the `ports` section of the service definition. - - name: smtp - port: 25 - targetPort: 25 - - name: imaps - port: 993 - targetPort: 993 - selector: # this is appended to the default selector - protocol: mail -{{- end -}} ---- -{{ template "common.service" (list . "mychart.web.service") -}} -{{- define "mychart.web.service" -}} -metadata: - name: {{ template "common.fullname" . }}-www # overrides the default name to add a suffix - labels: # appended to the labels section - protocol: www -spec: - ports: # composes the `ports` section of the service definition. - - name: www - port: 80 - targetPort: 8080 -{{- end -}} -``` - -The above template defines _two_ services: a web service and a mail service. - -The most important part of a service definition is the `ports` object, which -defines the ports that this service will listen on. Most of the time, -`selector` is computed for you. But you can replace it or add to it. - -The output of the example above is: - -```yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: service - chart: service-0.1.0 - heritage: Tiller - protocol: mail - release: release-name - name: release-name-service-mail -spec: - ports: - - name: smtp - port: 25 - targetPort: 25 - - name: imaps - port: 993 - targetPort: 993 - selector: - app: service - release: release-name - protocol: mail - type: ClusterIP ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app: service - chart: service-0.1.0 - heritage: Tiller - protocol: www - release: release-name - name: release-name-service-www -spec: - ports: - - name: www - port: 80 - targetPort: 8080 - type: ClusterIP -``` - -## `common.deployment` - -The `common.deployment` template defines a basic `Deployment`. Underneath the -hood, it uses `common.container` (see next section). - -By default, the pod template within the deployment defines the labels `app: {{ template "common.name" . }}` -and `release: {{ .Release.Name | quote }` as this is also used as the selector. The -standard set of labels are not used as some of these can change during upgrades, -which causes the replica sets and pods to not correctly match. - -Example use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -## Define overrides for your Deployment resource here, e.g. -spec: - replicas: {{ .Values.replicaCount }} -{{- end -}} -``` - -## `common.container` - -The `common.container` template creates a basic `Container` spec to be used -within a `Deployment` or `ReplicaSet`. It holds the following defaults: - -- The name is set to the chart name -- Uses `.Values.image` to describe the image to run, with the following spec: - ```yaml - image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent - ``` -- Exposes the named port `http` as port 80 -- Lays out the compute resources using `.Values.resources` - -Example use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -## Define overrides for your Deployment resource here, e.g. -spec: - template: - spec: - containers: - - {{ template "common.container" (list . "mychart.deployment.container") }} -{{- end -}} -{{- define "mychart.deployment.container" -}} -## Define overrides for your Container here, e.g. -livenessProbe: - httpGet: - path: / - port: 80 -readinessProbe: - httpGet: - path: / - port: 80 -{{- end -}} -``` - -The above example creates a `Deployment` resource which makes use of the -`common.container` template to populate the PodSpec's container list. The usage -of this template is similar to the other resources, you must define and -reference a template that contains overrides for the container object. - -The most important part of a container definition is the image you want to run. -As mentioned above, this is derived from `.Values.image` by default. It is a -best practice to define the image, tag and pull policy in your charts' values as -this makes it easy for an operator to change the image registry, or use a -specific tag or version. Another example of configuration that should be exposed -to chart operators is the container's required compute resources, as this is -also very specific to an operators environment. An example `values.yaml` for -your chart could look like: - -```yaml -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent -resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi -``` - -The output of running the above values through the earlier template is: - -```yaml -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - labels: - app: deployment - chart: deployment-0.1.0 - heritage: Tiller - release: release-name - name: release-name-deployment -spec: - template: - metadata: - labels: - app: deployment - spec: - containers: - - image: nginx:stable - imagePullPolicy: IfNotPresent - livenessProbe: - httpGet: - path: / - port: 80 - name: deployment - ports: - - containerPort: 80 - name: http - readinessProbe: - httpGet: - path: / - port: 80 - resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi -``` - -## `common.configmap` - -The `common.configmap` template creates an empty `ConfigMap` resource that you -can override with your configuration. - -Example use: - -```yaml -{{- template "common.configmap" (list . "mychart.configmap") -}} -{{- define "mychart.configmap" -}} -data: - zeus: cat - athena: cat - julius: cat - one: |- - {{ .Files.Get "file1.txt" }} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: v1 -data: - athena: cat - julius: cat - one: This is a file. - zeus: cat -kind: ConfigMap -metadata: - labels: - app: configmap - chart: configmap-0.1.0 - heritage: Tiller - release: release-name - name: release-name-configmap -``` - -## `common.secret` - -The `common.secret` template creates an empty `Secret` resource that you -can override with your secrets. - -Example use: - -```yaml -{{- template "common.secret" (list . "mychart.secret") -}} -{{- define "mychart.secret" -}} -data: - zeus: {{ print "cat" | b64enc }} - athena: {{ print "cat" | b64enc }} - julius: {{ print "cat" | b64enc }} - one: |- - {{ .Files.Get "file1.txt" | b64enc }} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: v1 -data: - athena: Y2F0 - julius: Y2F0 - one: VGhpcyBpcyBhIGZpbGUuCg== - zeus: Y2F0 -kind: Secret -metadata: - labels: - app: secret - chart: secret-0.1.0 - heritage: Tiller - release: release-name - name: release-name-secret -type: Opaque -``` - -## `common.ingress` - -The `common.ingress` template is designed to give you a well-defined `Ingress` -resource, that can be configured using `.Values.ingress`. An example values file -that can be used to configure the `Ingress` resource is: - -```yaml -ingress: - hosts: - - chart-example.local - annotations: - kubernetes.io/ingress.class: nginx - kubernetes.io/tls-acme: "true" - tls: - - secretName: chart-example-tls - hosts: - - chart-example.local -``` - -Example use: - -```yaml -{{- template "common.ingress" (list . "mychart.ingress") -}} -{{- define "mychart.ingress" -}} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: nginx - kubernetes.io/tls-acme: "true" - labels: - app: ingress - chart: ingress-0.1.0 - heritage: Tiller - release: release-name - name: release-name-ingress -spec: - rules: - - host: chart-example.local - http: - paths: - - backend: - serviceName: release-name-ingress - servicePort: 80 - path: / - tls: - - hosts: - - chart-example.local - secretName: chart-example-tls -``` - -## `common.persistentvolumeclaim` - -`common.persistentvolumeclaim` can be used to easily add a -`PersistentVolumeClaim` resource to your chart that can be configured using -`.Values.persistence`: - -| Value | Description | -| ------------------------- | ------------------------------------------------------------------------------------------------------- | -| persistence.enabled | Whether or not to claim a persistent volume. If false, `common.volume.pvc` will use an emptyDir instead | -| persistence.storageClass | `StorageClass` name | -| persistence.accessMode | Access mode for persistent volume | -| persistence.size | Size of persistent volume | -| persistence.existingClaim | If defined, `PersistentVolumeClaim` is not created and `common.volume.pvc` helper uses this claim | - -An example values file that can be used to configure the -`PersistentVolumeClaim` resource is: - -```yaml -persistence: - enabled: true - storageClass: fast - accessMode: ReadWriteOnce - size: 8Gi -``` - -Example use: - -```yaml -{{- template "common.persistentvolumeclaim" (list . "mychart.persistentvolumeclaim") -}} -{{- define "mychart.persistentvolumeclaim" -}} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - labels: - app: persistentvolumeclaim - chart: persistentvolumeclaim-0.1.0 - heritage: Tiller - release: release-name - name: release-name-persistentvolumeclaim -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 8Gi - storageClassName: "fast" -``` - -## Partial API Objects - -When writing Kubernetes resources, you may find the following helpers useful to -construct parts of the spec. - -### EnvVar - -Use the EnvVar helpers within a container spec to simplify specifying key-value -environment variables or referencing secrets as values. - -Example Use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -spec: - template: - spec: - containers: - - {{ template "common.container" (list . "mychart.deployment.container") }} -{{- end -}} -{{- define "mychart.deployment.container" -}} -{{- $fullname := include "common.fullname" . -}} -env: -- {{ template "common.envvar.value" (list "ZEUS" "cat") }} -- {{ template "common.envvar.secret" (list "ATHENA" "secret-name" "athena") }} -{{- end -}} -``` - -Output: - -```yaml -... - spec: - containers: - - env: - - name: ZEUS - value: cat - - name: ATHENA - valueFrom: - secretKeyRef: - key: athena - name: secret-name -... -``` - -### Volume - -Use the Volume helpers within a `Deployment` spec to help define ConfigMap and -PersistentVolumeClaim volumes. - -Example Use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -spec: - template: - spec: - volumes: - - {{ template "common.volume.configMap" (list "config" "configmap-name") }} - - {{ template "common.volume.pvc" (list "data" "pvc-name" .Values.persistence) }} -{{- end -}} -``` - -Output: - -```yaml -... - spec: - volumes: - - configMap: - name: configmap-name - name: config - - name: data - persistentVolumeClaim: - claimName: pvc-name -... -``` - -The `common.volume.pvc` helper uses the following configuration from the `.Values.persistence` object: - -| Value | Description | -| ------------------------- | ----------------------------------------------------- | -| persistence.enabled | If false, creates an `emptyDir` instead | -| persistence.existingClaim | If set, uses this instead of the passed in claim name | - -## Utilities - -### `common.fullname` - -The `common.fullname` template generates a name suitable for the `name:` field -in Kubernetes metadata. It is used like this: - -```yaml -name: {{ template "common.fullname" . }} -``` - -The following different values can influence it: - -```yaml -# By default, fullname uses '{{ .Release.Name }}-{{ .Chart.Name }}'. This -# overrides that and uses the given string instead. -fullnameOverride: "some-name" - -# This adds a prefix -fullnamePrefix: "pre-" -# This appends a suffix -fullnameSuffix: "-suf" - -# Global versions of the above -global: - fullnamePrefix: "pp-" - fullnameSuffix: "-ps" -``` - -Example output: - -```yaml ---- -# with the values above -name: pp-pre-some-name-suf-ps - ---- -# the default, for release "happy-panda" and chart "wordpress" -name: happy-panda-wordpress -``` - -Output of this function is truncated at 54 characters, which leaves 9 additional -characters for customized overriding. Thus you can easily extend this name -in your own charts: - -```yaml -{{- define "my.fullname" -}} - {{ template "common.fullname" . }}-my-stuff -{{- end -}} -``` - -### `common.fullname.unique` - -The `common.fullname.unique` variant of fullname appends a unique seven-character -sequence to the end of the common name field. - -This takes all of the same parameters as `common.fullname` - -Example template: - -```yaml -uniqueName: {{ template "common.fullname.unique" . }} -``` - -Example output: - -```yaml -uniqueName: release-name-fullname-jl0dbwx -``` - -It is also impacted by the prefix and suffix definitions, as well as by -`.Values.fullnameOverride` - -Note that the effective maximum length of this function is 63 characters, not 54. - -### `common.name` - -The `common.name` template generates a name suitable for the `app` label. It is used like this: - -```yaml -app: {{ template "common.name" . }} -``` - -The following different values can influence it: - -```yaml -# By default, name uses '{{ .Chart.Name }}'. This -# overrides that and uses the given string instead. -nameOverride: "some-name" - -# This adds a prefix -namePrefix: "pre-" -# This appends a suffix -nameSuffix: "-suf" - -# Global versions of the above -global: - namePrefix: "pp-" - nameSuffix: "-ps" -``` - -Example output: - -```yaml ---- -# with the values above -name: pp-pre-some-name-suf-ps - ---- -# the default, for chart "wordpress" -name: wordpress -``` - -Output of this function is truncated at 54 characters, which leaves 9 additional -characters for customized overriding. Thus you can easily extend this name -in your own charts: - -```yaml -{{- define "my.name" -}} - {{ template "common.name" . }}-my-stuff -{{- end -}} -``` - -### `common.metadata` - -The `common.metadata` helper generates the `metadata:` section of a Kubernetes -resource. - -This takes three objects: - - .top: top context - - .fullnameOverride: override the fullname with this name - - .metadata - - .labels: key/value list of labels - - .annotations: key/value list of annotations - - .hook: name(s) of hook(s) - -It generates standard labels, annotations, hooks, and a name field. - -Example template: - -```yaml -{{ template "common.metadata" (dict "top" . "metadata" .Values.bio) }} ---- -{{ template "common.metadata" (dict "top" . "metadata" .Values.pet "fullnameOverride" .Values.pet.fullnameOverride) }} -``` - -Example values: - -```yaml -bio: - name: example - labels: - first: matt - last: butcher - nick: technosophos - annotations: - format: bio - destination: archive - hook: pre-install - -pet: - fullnameOverride: Zeus - -``` - -Example output: - -```yaml -metadata: - name: release-name-metadata - labels: - app: metadata - heritage: "Tiller" - release: "release-name" - chart: metadata-0.1.0 - first: "matt" - last: "butcher" - nick: "technosophos" - annotations: - "destination": "archive" - "format": "bio" - "helm.sh/hook": "pre-install" ---- -metadata: - name: Zeus - labels: - app: metadata - heritage: "Tiller" - release: "release-name" - chart: metadata-0.1.0 - annotations: -``` - -Most of the common templates that define a resource type (e.g. `common.configmap` -or `common.job`) use this to generate the metadata, which means they inherit -the same `labels`, `annotations`, `nameOverride`, and `hook` fields. - -### `common.labelize` - -`common.labelize` turns a map into a set of labels. - -Example template: - -```yaml -{{- $map := dict "first" "1" "second" "2" "third" "3" -}} -{{- template "common.labelize" $map -}} -``` - -Example output: - -```yaml -first: "1" -second: "2" -third: "3" -``` - -### `common.labels.standard` - -`common.labels.standard` prints the standard set of labels. - -Example usage: - -``` -{{ template "common.labels.standard" . }} -``` - -Example output: - -```yaml -app: labelizer -heritage: "Tiller" -release: "release-name" -chart: labelizer-0.1.0 -``` - -### `common.hook` - -The `common.hook` template is a convenience for defining hooks. - -Example template: - -```yaml -{{ template "common.hook" "pre-install,post-install" }} -``` - -Example output: - -```yaml -"helm.sh/hook": "pre-install,post-install" -``` - -### `common.chartref` - -The `common.chartref` helper prints the chart name and version, escaped to be -legal in a Kubernetes label field. - -Example template: - -```yaml -chartref: {{ template "common.chartref" . }} -``` - -For the chart `foo` with version `1.2.3-beta.55+1234`, this will render: - -```yaml -chartref: foo-1.2.3-beta.55_1234 -``` - -(Note that `+` is an illegal character in label values) diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl deleted file mode 100755 index e6c14866f..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl +++ /dev/null @@ -1,14 +0,0 @@ -{{- /* -common.chartref prints a chart name and version. - -It does minimal escaping for use in Kubernetes labels. - -Example output: - - zookeeper-1.2.3 - wordpress-3.2.1_20170219 - -*/ -}} -{{- define "common.chartref" -}} - {{- replace "+" "_" .Chart.Version | printf "%s-%s" .Chart.Name -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml deleted file mode 100755 index 03dbbf858..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -{{- define "common.configmap.tpl" -}} -apiVersion: v1 -kind: ConfigMap -{{ template "common.metadata" . }} -data: {} -{{- end -}} -{{- define "common.configmap" -}} -{{- template "common.util.merge" (append . "common.configmap.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml deleted file mode 100755 index 540eb0e6a..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml +++ /dev/null @@ -1,15 +0,0 @@ -{{- define "common.container.tpl" -}} -name: {{ .Chart.Name }} -image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" -imagePullPolicy: {{ .Values.image.pullPolicy }} -ports: -- name: http - containerPort: 80 -resources: -{{ toYaml .Values.resources | indent 2 }} -{{- end -}} -{{- define "common.container" -}} -{{- /* clear new line so indentation works correctly */ -}} -{{- println "" -}} -{{- include "common.util.merge" (append . "common.container.tpl") | indent 8 -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml deleted file mode 100755 index c49dae3eb..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml +++ /dev/null @@ -1,18 +0,0 @@ -{{- define "common.deployment.tpl" -}} -apiVersion: extensions/v1beta1 -kind: Deployment -{{ template "common.metadata" . }} -spec: - template: - metadata: - labels: - app: {{ template "common.name" . }} - release: {{ .Release.Name | quote }} - spec: - containers: - - -{{ include "common.container.tpl" . | indent 8 }} -{{- end -}} -{{- define "common.deployment" -}} -{{- template "common.util.merge" (append . "common.deployment.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl deleted file mode 100755 index 709251f8f..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{{- define "common.envvar.value" -}} - {{- $name := index . 0 -}} - {{- $value := index . 1 -}} - - name: {{ $name }} - value: {{ default "" $value | quote }} -{{- end -}} - -{{- define "common.envvar.configmap" -}} - {{- $name := index . 0 -}} - {{- $configMapName := index . 1 -}} - {{- $configMapKey := index . 2 -}} - - name: {{ $name }} - valueFrom: - configMapKeyRef: - name: {{ $configMapName }} - key: {{ $configMapKey }} -{{- end -}} - -{{- define "common.envvar.secret" -}} - {{- $name := index . 0 -}} - {{- $secretName := index . 1 -}} - {{- $secretKey := index . 2 -}} - - name: {{ $name }} - valueFrom: - secretKeyRef: - name: {{ $secretName }} - key: {{ $secretKey }} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl deleted file mode 100755 index 2da6cdf18..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{{- /* -fullname defines a suitably unique name for a resource by combining -the release name and the chart name. - -The prevailing wisdom is that names should only contain a-z, 0-9 plus dot (.) and dash (-), and should -not exceed 63 characters. - -Parameters: - -- .Values.fullnameOverride: Replaces the computed name with this given name -- .Values.fullnamePrefix: Prefix -- .Values.global.fullnamePrefix: Global prefix -- .Values.fullnameSuffix: Suffix -- .Values.global.fullnameSuffix: Global suffix - -The applied order is: "global prefix + prefix + name + suffix + global suffix" - -Usage: 'name: "{{- template "common.fullname" . -}}"' -*/ -}} -{{- define "common.fullname"}} - {{- $global := default (dict) .Values.global -}} - {{- $base := default (printf "%s-%s" .Release.Name .Chart.Name) .Values.fullnameOverride -}} - {{- $gpre := default "" $global.fullnamePrefix -}} - {{- $pre := default "" .Values.fullnamePrefix -}} - {{- $suf := default "" .Values.fullnameSuffix -}} - {{- $gsuf := default "" $global.fullnameSuffix -}} - {{- $name := print $gpre $pre $base $suf $gsuf -}} - {{- $name | lower | trunc 54 | trimSuffix "-" -}} -{{- end -}} - -{{- /* -common.fullname.unique adds a random suffix to the unique name. - -This takes the same parameters as common.fullname - -*/ -}} -{{- define "common.fullname.unique" -}} - {{ template "common.fullname" . }}-{{ randAlphaNum 7 | lower }} -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml deleted file mode 100755 index 78411e15b..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml +++ /dev/null @@ -1,27 +0,0 @@ -{{- define "common.ingress.tpl" -}} -apiVersion: extensions/v1beta1 -kind: Ingress -{{ template "common.metadata" . }} - {{- if .Values.ingress.annotations }} - annotations: - {{ include "common.annotate" .Values.ingress.annotations | indent 4 }} - {{- end }} -spec: - rules: - {{- range $host := .Values.ingress.hosts }} - - host: {{ $host }} - http: - paths: - - path: / - backend: - serviceName: {{ template "common.fullname" $ }} - servicePort: 80 - {{- end }} - {{- if .Values.ingress.tls }} - tls: -{{ toYaml .Values.ingress.tls | indent 4 }} - {{- end -}} -{{- end -}} -{{- define "common.ingress" -}} -{{- template "common.util.merge" (append . "common.ingress.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml deleted file mode 100755 index f96ed09fe..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- /* -common.metadata creates a standard metadata header. -It creates a 'metadata:' section with name and labels. -*/ -}} -{{ define "common.metadata" -}} -metadata: - name: {{ template "common.fullname" . }} - labels: -{{ include "common.labels.standard" . | indent 4 -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl deleted file mode 100755 index dffe1eca9..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl +++ /dev/null @@ -1,18 +0,0 @@ -{{- /* -common.hook defines a hook. - -This is to be used in a 'metadata.annotations' section. - -This should be called as 'template "common.metadata.hook" "post-install"' - -Any valid hook may be passed in. Separate multiple hooks with a ",". -*/ -}} -{{- define "common.hook" -}} -"helm.sh/hook": {{printf "%s" . | quote}} -{{- end -}} - -{{- define "common.annotate" -}} -{{- range $k, $v := . }} -{{ $k | quote }}: {{ $v | quote }} -{{- end -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl deleted file mode 100755 index 15fe00c5f..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{{- /* -common.labelize takes a dict or map and generates labels. - -Values will be quoted. Keys will not. - -Example output: - - first: "Matt" - last: "Butcher" - -*/ -}} -{{- define "common.labelize" -}} -{{- range $k, $v := . }} -{{ $k }}: {{ $v | quote }} -{{- end -}} -{{- end -}} - -{{- /* -common.labels.standard prints the standard Helm labels. - -The standard labels are frequently used in metadata. -*/ -}} -{{- define "common.labels.standard" -}} -app: {{ template "common.name" . }} -chart: {{ template "common.chartref" . }} -heritage: {{ .Release.Service | quote }} -release: {{ .Release.Name | quote }} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl deleted file mode 100755 index 1d42fb068..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{{- /* -name defines a template for the name of the chart. It should be used for the `app` label. -This is common practice in many Kubernetes manifests, and is not Helm-specific. - -The prevailing wisdom is that names should only contain a-z, 0-9 plus dot (.) and dash (-), and should -not exceed 63 characters. - -Parameters: - -- .Values.nameOverride: Replaces the computed name with this given name -- .Values.namePrefix: Prefix -- .Values.global.namePrefix: Global prefix -- .Values.nameSuffix: Suffix -- .Values.global.nameSuffix: Global suffix - -The applied order is: "global prefix + prefix + name + suffix + global suffix" - -Usage: 'name: "{{- template "common.name" . -}}"' -*/ -}} -{{- define "common.name"}} - {{- $global := default (dict) .Values.global -}} - {{- $base := default .Chart.Name .Values.nameOverride -}} - {{- $gpre := default "" $global.namePrefix -}} - {{- $pre := default "" .Values.namePrefix -}} - {{- $suf := default "" .Values.nameSuffix -}} - {{- $gsuf := default "" $global.nameSuffix -}} - {{- $name := print $gpre $pre $base $suf $gsuf -}} - {{- $name | lower | trunc 54 | trimSuffix "-" -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml deleted file mode 100755 index 6c1578c7e..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml +++ /dev/null @@ -1,24 +0,0 @@ -{{- define "common.persistentvolumeclaim.tpl" -}} -apiVersion: v1 -kind: PersistentVolumeClaim -{{ template "common.metadata" . }} -spec: - accessModes: - - {{ .Values.persistence.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.size | quote }} -{{- if .Values.persistence.storageClass }} -{{- if (eq "-" .Values.persistence.storageClass) }} - storageClassName: "" -{{- else }} - storageClassName: "{{ .Values.persistence.storageClass }}" -{{- end }} -{{- end }} -{{- end -}} -{{- define "common.persistentvolumeclaim" -}} -{{- $top := first . -}} -{{- if and $top.Values.persistence.enabled (not $top.Values.persistence.existingClaim) -}} -{{- template "common.util.merge" (append . "common.persistentvolumeclaim.tpl") -}} -{{- end -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml deleted file mode 100755 index 0615d35cb..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- define "common.secret.tpl" -}} -apiVersion: v1 -kind: Secret -{{ template "common.metadata" . }} -type: Opaque -data: {} -{{- end -}} -{{- define "common.secret" -}} -{{- template "common.util.merge" (append . "common.secret.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml deleted file mode 100755 index 67379525f..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- define "common.service.tpl" -}} -apiVersion: v1 -kind: Service -{{ template "common.metadata" . }} -spec: - type: {{ .Values.service.type }} - ports: - - name: http - port: 80 - targetPort: http - selector: - app: {{ template "common.name" . }} - release: {{ .Release.Name | quote }} -{{- end -}} -{{- define "common.service" -}} -{{- template "common.util.merge" (append . "common.service.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl deleted file mode 100755 index a7d4cc751..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl +++ /dev/null @@ -1,15 +0,0 @@ -{{- /* -common.util.merge will merge two YAML templates and output the result. - -This takes an array of three values: -- the top context -- the template name of the overrides (destination) -- the template name of the base (source) - -*/ -}} -{{- define "common.util.merge" -}} -{{- $top := first . -}} -{{- $overrides := fromYaml (include (index . 1) $top) | default (dict ) -}} -{{- $tpl := fromYaml (include (index . 2) $top) | default (dict ) -}} -{{- toYaml (merge $overrides $tpl) -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl deleted file mode 100755 index 521a1f48b..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl +++ /dev/null @@ -1,22 +0,0 @@ -{{- define "common.volume.configMap" -}} - {{- $name := index . 0 -}} - {{- $configMapName := index . 1 -}} - - name: {{ $name }} - configMap: - name: {{ $configMapName }} -{{- end -}} - -{{- define "common.volume.pvc" -}} - {{- $name := index . 0 -}} - {{- $claimName := index . 1 -}} - {{- $persistence := index . 2 -}} - - name: {{ $name }} - {{- if $persistence.enabled }} - persistentVolumeClaim: - claimName: {{ $persistence.existingClaim | default $claimName }} - {{- else }} - emptyDir: {} - {{- end -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml deleted file mode 100644 index b5bf1dfc3..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: common-configmap -data: - myvalue: "Hello World" diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml deleted file mode 100755 index b7cf514d5..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for commons. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt deleted file mode 100644 index 8f6bb9b1d..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "chart-with-template-lib-dep.fullname" . }}) - export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "chart-with-template-lib-dep.fullname" . }}' - export SERVICE_IP=$(kubectl get svc {{ template "chart-with-template-lib-dep.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods -l "app={{ template "chart-with-template-lib-dep.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl deleted file mode 100644 index 0ab79743d..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "chart-with-template-lib-dep.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "chart-with-template-lib-dep.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "chart-with-template-lib-dep.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml deleted file mode 100644 index 6b950d139..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "chart-with-template-lib-dep.fullname" . }} - labels: - app: {{ template "chart-with-template-lib-dep.name" . }} - chart: {{ template "chart-with-template-lib-dep.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "chart-with-template-lib-dep.name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template "chart-with-template-lib-dep.name" . }} - release: {{ .Release.Name }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml deleted file mode 100644 index a978df4e7..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "chart-with-template-lib-dep.fullname" . -}} -{{- $ingressPath := .Values.ingress.path -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "chart-with-template-lib-dep.name" . }} - chart: {{ template "chart-with-template-lib-dep.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} -{{- end }} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml deleted file mode 100644 index d532bb3d8..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- template "common.service" (list . "chart-with-template-lib-dep.service") -}} -{{- define "chart-with-template-lib-dep.service" -}} -## Define overrides for your Service resource here, e.g. -# metadata: -# labels: -# custom: label -# spec: -# ports: -# - port: 8080 -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/values.yaml b/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/values.yaml deleted file mode 100644 index d49955c26..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/values.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Default values for chart-with-template-lib-dep. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent - -nameOverride: "" -fullnameOverride: "" - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml deleted file mode 100644 index 29b477b06..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -description: Deploy a basic Alpine Linux pod -home: https://helm.sh/helm -name: chart-with-template-with-invalid-yaml -sources: - - https://github.com/helm/helm -version: 0.1.0 -type: application diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md deleted file mode 100644 index fcf7ee017..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md +++ /dev/null @@ -1,13 +0,0 @@ -#Alpine: A simple Helm chart - -Run a single pod of Alpine Linux. - -This example was generated using the command `helm create alpine`. - -The `templates/` directory contains a very simple pod resource with a -couple of parameters. - -The `values.yaml` file contains the default values for the -`alpine-pod.yaml` template. - -You can install this example using `helm install ./alpine`. diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml deleted file mode 100644 index 697cb50fe..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{.Release.Name}}-{{.Values.Name}}" -spec: - containers: - - name: waiter - image: "alpine:3.9" - command: ["/bin/sleep","9000"] -invalid diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml deleted file mode 100644 index 807e12aea..000000000 --- a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml +++ /dev/null @@ -1 +0,0 @@ -Name: my-alpine diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz b/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz deleted file mode 100644 index 3c9c24d76..000000000 Binary files a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz b/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz deleted file mode 100644 index 3c9c24d76..000000000 Binary files a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz b/cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz deleted file mode 100644 index 16a644a79..000000000 Binary files a/cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz b/cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz deleted file mode 100644 index 051bd6fd9..000000000 Binary files a/cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz b/cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz deleted file mode 100644 index 379210a92..000000000 Binary files a/cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/deprecated/Chart.yaml b/cmd/helm/testdata/testcharts/deprecated/Chart.yaml deleted file mode 100644 index 10185beeb..000000000 --- a/cmd/helm/testdata/testcharts/deprecated/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -description: Deprecated testing chart -home: https://helm.sh/helm -name: deprecated -sources: - - https://github.com/helm/helm -version: 0.1.0 -deprecated: true diff --git a/cmd/helm/testdata/testcharts/deprecated/README.md b/cmd/helm/testdata/testcharts/deprecated/README.md deleted file mode 100644 index 0df9a8bbc..000000000 --- a/cmd/helm/testdata/testcharts/deprecated/README.md +++ /dev/null @@ -1,3 +0,0 @@ -#Deprecated - -This space intentionally left blank. diff --git a/cmd/helm/testdata/testcharts/empty/Chart.yaml b/cmd/helm/testdata/testcharts/empty/Chart.yaml deleted file mode 100644 index 4f1dc0012..000000000 --- a/cmd/helm/testdata/testcharts/empty/Chart.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -description: Empty testing chart -home: https://helm.sh/helm -name: empty -sources: - - https://github.com/helm/helm -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/empty/README.md b/cmd/helm/testdata/testcharts/empty/README.md deleted file mode 100644 index ed73c1797..000000000 --- a/cmd/helm/testdata/testcharts/empty/README.md +++ /dev/null @@ -1,3 +0,0 @@ -#Empty - -This space intentionally left blank. diff --git a/cmd/helm/testdata/testcharts/empty/templates/empty.yaml b/cmd/helm/testdata/testcharts/empty/templates/empty.yaml deleted file mode 100644 index c80812f6e..000000000 --- a/cmd/helm/testdata/testcharts/empty/templates/empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# This file is intentionally blank diff --git a/cmd/helm/testdata/testcharts/empty/values.yaml b/cmd/helm/testdata/testcharts/empty/values.yaml deleted file mode 100644 index 1f0ff00e3..000000000 --- a/cmd/helm/testdata/testcharts/empty/values.yaml +++ /dev/null @@ -1 +0,0 @@ -Name: my-empty diff --git a/cmd/helm/testdata/testcharts/issue-7233/.helmignore b/cmd/helm/testdata/testcharts/issue-7233/.helmignore deleted file mode 100644 index 50af03172..000000000 --- a/cmd/helm/testdata/testcharts/issue-7233/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml b/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml deleted file mode 100644 index b31997acb..000000000 --- a/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: issue-7233 -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/issue-7233/requirements.lock b/cmd/helm/testdata/testcharts/issue-7233/requirements.lock deleted file mode 100644 index 62744125b..000000000 --- a/cmd/helm/testdata/testcharts/issue-7233/requirements.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: alpine - repository: file://../alpine - version: 0.1.0 -digest: sha256:7b380b1a826e7be1eecb089f66209d6d3df54be4bf879d4a8e6f8a9e871710e5 -generated: "2020-01-31T11:30:21.911547651Z" diff --git a/cmd/helm/testdata/testcharts/issue-7233/requirements.yaml b/cmd/helm/testdata/testcharts/issue-7233/requirements.yaml deleted file mode 100644 index f0195cb15..000000000 --- a/cmd/helm/testdata/testcharts/issue-7233/requirements.yaml +++ /dev/null @@ -1,4 +0,0 @@ -dependencies: -- name: alpine - version: 0.1.0 - repository: file://../alpine diff --git a/cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml b/cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml deleted file mode 100644 index 53880b25d..000000000 --- a/cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }}-configmap -data: - myvalue: "Hello World" - drink: {{ .Values.favoriteDrink }} diff --git a/cmd/helm/testdata/testcharts/issue-7233/values.yaml b/cmd/helm/testdata/testcharts/issue-7233/values.yaml deleted file mode 100644 index b1aa168d7..000000000 --- a/cmd/helm/testdata/testcharts/issue-7233/values.yaml +++ /dev/null @@ -1 +0,0 @@ -favoriteDrink: coffee diff --git a/cmd/helm/testdata/testcharts/issue1979/Chart.yaml b/cmd/helm/testdata/testcharts/issue1979/Chart.yaml deleted file mode 100644 index 5269b5cf6..000000000 --- a/cmd/helm/testdata/testcharts/issue1979/Chart.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -description: Deploy a basic Alpine Linux pod -home: https://helm.sh/helm -name: alpine -sources: - - https://github.com/helm/helm -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/issue1979/README.md b/cmd/helm/testdata/testcharts/issue1979/README.md deleted file mode 100644 index fcf7ee017..000000000 --- a/cmd/helm/testdata/testcharts/issue1979/README.md +++ /dev/null @@ -1,13 +0,0 @@ -#Alpine: A simple Helm chart - -Run a single pod of Alpine Linux. - -This example was generated using the command `helm create alpine`. - -The `templates/` directory contains a very simple pod resource with a -couple of parameters. - -The `values.yaml` file contains the default values for the -`alpine-pod.yaml` template. - -You can install this example using `helm install ./alpine`. diff --git a/cmd/helm/testdata/testcharts/issue1979/extra_values.yaml b/cmd/helm/testdata/testcharts/issue1979/extra_values.yaml deleted file mode 100644 index 468bbacbc..000000000 --- a/cmd/helm/testdata/testcharts/issue1979/extra_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - Name: extra-values diff --git a/cmd/helm/testdata/testcharts/issue1979/more_values.yaml b/cmd/helm/testdata/testcharts/issue1979/more_values.yaml deleted file mode 100644 index 3d21e1fed..000000000 --- a/cmd/helm/testdata/testcharts/issue1979/more_values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - Name: more-values diff --git a/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml deleted file mode 100644 index 6f025fecb..000000000 --- a/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{.Release.Name}}-{{.Values.Name}}" - labels: - # The "app.kubernetes.io/managed-by" label is used to track which tool - # deployed a given chart. It is useful for admins who want to see what - # releases a particular tool is responsible for. - app.kubernetes.io/managed-by: {{.Release.Service | quote }} - # The "app.kubernetes.io/instance" convention makes it easy to tie a release - # to all of the Kubernetes resources that were created as part of that - # release. - app.kubernetes.io/instance: {{.Release.Name | quote }} - # This makes it easy to audit chart usage. - helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - values: {{.Values.test.Name}} -spec: - # This shows how to use a simple value. This will look for a passed-in value - # called restartPolicy. If it is not found, it will use the default value. - # {{default "Never" .restartPolicy}} is a slightly optimized version of the - # more conventional syntax: {{.restartPolicy | default "Never"}} - restartPolicy: {{default "Never" .Values.restartPolicy}} - containers: - - name: waiter - image: "alpine:3.9" - command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/issue1979/values.yaml b/cmd/helm/testdata/testcharts/issue1979/values.yaml deleted file mode 100644 index 879d760f9..000000000 --- a/cmd/helm/testdata/testcharts/issue1979/values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -# The pod name -Name: my-alpine diff --git a/cmd/helm/testdata/testcharts/lib-chart/.helmignore b/cmd/helm/testdata/testcharts/lib-chart/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/lib-chart/Chart.yaml b/cmd/helm/testdata/testcharts/lib-chart/Chart.yaml deleted file mode 100755 index 4dcddc85e..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/Chart.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -description: Common chartbuilding components and helpers -name: lib-chart -version: 0.0.5 -appVersion: 0.0.5 -home: https://helm.sh -maintainers: -- name: technosophos - email: technosophos@gmail.com -- name: prydonius - email: adnan@bitnami.com -type: Library diff --git a/cmd/helm/testdata/testcharts/lib-chart/README.md b/cmd/helm/testdata/testcharts/lib-chart/README.md deleted file mode 100644 index 87b753f25..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/README.md +++ /dev/null @@ -1,831 +0,0 @@ -# Common: The Helm Helper Chart - -This chart is designed to make it easier for you to build and maintain Helm -charts. - -It provides utilities that reflect best practices of Kubernetes chart development, -making it faster for you to write charts. - -## Tips - -A few tips for working with Common: - -- Be careful when using functions that generate random data (like `common.fullname.unique`). - They may trigger unwanted upgrades or have other side effects. - -In this document, we use `release-name` as the name of the release. - -## Resource Kinds - -Kubernetes defines a variety of resource kinds, from `Secret` to `StatefulSet`. -We define some of the most common kinds in a way that lets you easily work with -them. - -The resource kind templates are designed to make it much faster for you to -define _basic_ versions of these resources. They allow you to extend and modify -just what you need, without having to copy around lots of boilerplate. - -To make use of these templates you must define a template that will extend the -base template (though it can be empty). The name of this template is then passed -to the base template, for example: - -```yaml -{{- template "common.service" (list . "mychart.service") -}} -{{- define "mychart.service" -}} -## Define overrides for your Service resource here, e.g. -# metadata: -# labels: -# custom: label -# spec: -# ports: -# - port: 8080 -{{- end -}} -``` - -Note that the `common.service` template defines two parameters: - - - The root context (usually `.`) - - A template name containing the service definition overrides - -A limitation of the Go template library is that a template can only take a -single argument. The `list` function is used to workaround this by constructing -a list or array of arguments that is passed to the template. - -The `common.service` template is responsible for rendering the templates with -the root context and merging any overrides. As you can see, this makes it very -easy to create a basic `Service` resource without having to copy around the -standard metadata and labels. - -Each implemented base resource is described in greater detail below. - -### `common.service` - -The `common.service` template creates a basic `Service` resource with the -following defaults: - -- Service type (ClusterIP, NodePort, LoadBalancer) made configurable by `.Values.service.type` -- Named port `http` configured on port 80 -- Selector set to `app.kubernetes.io/name: {{ template "common.name" }}, app.kubernetes.io/instance: {{ .Release.Name | quote }}` to match the default used in the `Deployment` resource - -Example template: - -```yaml -{{- template "common.service" (list . "mychart.mail.service") -}} -{{- define "mychart.mail.service" -}} -metadata: - name: {{ template "common.fullname" . }}-mail # overrides the default name to add a suffix - labels: # appended to the labels section - protocol: mail -spec: - ports: # composes the `ports` section of the service definition. - - name: smtp - port: 25 - targetPort: 25 - - name: imaps - port: 993 - targetPort: 993 - selector: # this is appended to the default selector - protocol: mail -{{- end -}} ---- -{{ template "common.service" (list . "mychart.web.service") -}} -{{- define "mychart.web.service" -}} -metadata: - name: {{ template "common.fullname" . }}-www # overrides the default name to add a suffix - labels: # appended to the labels section - protocol: www -spec: - ports: # composes the `ports` section of the service definition. - - name: www - port: 80 - targetPort: 8080 -{{- end -}} -``` - -The above template defines _two_ services: a web service and a mail service. - -The most important part of a service definition is the `ports` object, which -defines the ports that this service will listen on. Most of the time, -`selector` is computed for you. But you can replace it or add to it. - -The output of the example above is: - -```yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/name: service - helm.sh/chart: service-0.1.0 - app.kubernetes.io/managed-by: Helm - protocol: mail - app.kubernetes.io/instance: release-name - name: release-name-service-mail -spec: - ports: - - name: smtp - port: 25 - targetPort: 25 - - name: imaps - port: 993 - targetPort: 993 - selector: - app.kubernetes.io/name: service - app.kubernetes.io/instance: release-name - protocol: mail - type: ClusterIP ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/name: service - helm.sh/chart: service-0.1.0 - app.kubernetes.io/managed-by: Helm - protocol: www - app.kubernetes.io/instance: release-name - name: release-name-service-www -spec: - ports: - - name: www - port: 80 - targetPort: 8080 - type: ClusterIP -``` - -## `common.deployment` - -The `common.deployment` template defines a basic `Deployment`. Underneath the -hood, it uses `common.container` (see next section). - -By default, the pod template within the deployment defines the labels `app: {{ template "common.name" . }}` -and `release: {{ .Release.Name | quote }` as this is also used as the selector. The -standard set of labels are not used as some of these can change during upgrades, -which causes the replica sets and pods to not correctly match. - -Example use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -## Define overrides for your Deployment resource here, e.g. -spec: - replicas: {{ .Values.replicaCount }} -{{- end -}} -``` - -## `common.container` - -The `common.container` template creates a basic `Container` spec to be used -within a `Deployment` or `ReplicaSet`. It holds the following defaults: - -- The name is set to the chart name -- Uses `.Values.image` to describe the image to run, with the following spec: - ```yaml - image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent - ``` -- Exposes the named port `http` as port 80 -- Lays out the compute resources using `.Values.resources` - -Example use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -## Define overrides for your Deployment resource here, e.g. -spec: - template: - spec: - containers: - - {{ template "common.container" (list . "mychart.deployment.container") }} -{{- end -}} -{{- define "mychart.deployment.container" -}} -## Define overrides for your Container here, e.g. -livenessProbe: - httpGet: - path: / - port: 80 -readinessProbe: - httpGet: - path: / - port: 80 -{{- end -}} -``` - -The above example creates a `Deployment` resource which makes use of the -`common.container` template to populate the PodSpec's container list. The usage -of this template is similar to the other resources, you must define and -reference a template that contains overrides for the container object. - -The most important part of a container definition is the image you want to run. -As mentioned above, this is derived from `.Values.image` by default. It is a -best practice to define the image, tag and pull policy in your charts' values as -this makes it easy for an operator to change the image registry, or use a -specific tag or version. Another example of configuration that should be exposed -to chart operators is the container's required compute resources, as this is -also very specific to an operators environment. An example `values.yaml` for -your chart could look like: - -```yaml -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent -resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi -``` - -The output of running the above values through the earlier template is: - -```yaml -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - labels: - app.kubernetes.io/name: deployment - helm.sh/chart: deployment-0.1.0 - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/instance: release-name - name: release-name-deployment -spec: - template: - metadata: - labels: - app.kubernetes.io/name: deployment - spec: - containers: - - image: nginx:stable - imagePullPolicy: IfNotPresent - livenessProbe: - httpGet: - path: / - port: 80 - name: deployment - ports: - - containerPort: 80 - name: http - readinessProbe: - httpGet: - path: / - port: 80 - resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi -``` - -## `common.configmap` - -The `common.configmap` template creates an empty `ConfigMap` resource that you -can override with your configuration. - -Example use: - -```yaml -{{- template "common.configmap" (list . "mychart.configmap") -}} -{{- define "mychart.configmap" -}} -data: - zeus: cat - athena: cat - julius: cat - one: |- - {{ .Files.Get "file1.txt" }} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: v1 -data: - athena: cat - julius: cat - one: This is a file. - zeus: cat -kind: ConfigMap -metadata: - labels: - app.kubernetes.io/name: configmap - helm.sh/chart: configmap-0.1.0 - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/instance: release-name - name: release-name-configmap -``` - -## `common.secret` - -The `common.secret` template creates an empty `Secret` resource that you -can override with your secrets. - -Example use: - -```yaml -{{- template "common.secret" (list . "mychart.secret") -}} -{{- define "mychart.secret" -}} -data: - zeus: {{ print "cat" | b64enc }} - athena: {{ print "cat" | b64enc }} - julius: {{ print "cat" | b64enc }} - one: |- - {{ .Files.Get "file1.txt" | b64enc }} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: v1 -data: - athena: Y2F0 - julius: Y2F0 - one: VGhpcyBpcyBhIGZpbGUuCg== - zeus: Y2F0 -kind: Secret -metadata: - labels: - app.kubernetes.io/name: secret - helm.sh/chart: secret-0.1.0 - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/instance: release-name - name: release-name-secret -type: Opaque -``` - -## `common.ingress` - -The `common.ingress` template is designed to give you a well-defined `Ingress` -resource, that can be configured using `.Values.ingress`. An example values file -that can be used to configure the `Ingress` resource is: - -```yaml -ingress: - hosts: - - chart-example.local - annotations: - kubernetes.io/ingress.class: nginx - kubernetes.io/tls-acme: "true" - tls: - - secretName: chart-example-tls - hosts: - - chart-example.local -``` - -Example use: - -```yaml -{{- template "common.ingress" (list . "mychart.ingress") -}} -{{- define "mychart.ingress" -}} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: nginx - kubernetes.io/tls-acme: "true" - labels: - app.kubernetes.io/name: ingress - helm.sh/chart: ingress-0.1.0 - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/instance: release-name - name: release-name-ingress -spec: - rules: - - host: chart-example.local - http: - paths: - - backend: - serviceName: release-name-ingress - servicePort: 80 - path: / - tls: - - hosts: - - chart-example.local - secretName: chart-example-tls -``` - -## `common.persistentvolumeclaim` - -`common.persistentvolumeclaim` can be used to easily add a -`PersistentVolumeClaim` resource to your chart that can be configured using -`.Values.persistence`: - -| Value | Description | -| ------------------------- | ------------------------------------------------------------------------------------------------------- | -| persistence.enabled | Whether or not to claim a persistent volume. If false, `common.volume.pvc` will use an emptyDir instead | -| persistence.storageClass | `StorageClass` name | -| persistence.accessMode | Access mode for persistent volume | -| persistence.size | Size of persistent volume | -| persistence.existingClaim | If defined, `PersistentVolumeClaim` is not created and `common.volume.pvc` helper uses this claim | - -An example values file that can be used to configure the -`PersistentVolumeClaim` resource is: - -```yaml -persistence: - enabled: true - storageClass: fast - accessMode: ReadWriteOnce - size: 8Gi -``` - -Example use: - -```yaml -{{- template "common.persistentvolumeclaim" (list . "mychart.persistentvolumeclaim") -}} -{{- define "mychart.persistentvolumeclaim" -}} -{{- end -}} -``` - -Output: - -```yaml -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - labels: - app.kubernetes.io/name: persistentvolumeclaim - helm.sh/chart: persistentvolumeclaim-0.1.0 - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/instance: release-name - name: release-name-persistentvolumeclaim -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 8Gi - storageClassName: "fast" -``` - -## Partial API Objects - -When writing Kubernetes resources, you may find the following helpers useful to -construct parts of the spec. - -### EnvVar - -Use the EnvVar helpers within a container spec to simplify specifying key-value -environment variables or referencing secrets as values. - -Example Use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -spec: - template: - spec: - containers: - - {{ template "common.container" (list . "mychart.deployment.container") }} -{{- end -}} -{{- define "mychart.deployment.container" -}} -{{- $fullname := include "common.fullname" . -}} -env: -- {{ template "common.envvar.value" (list "ZEUS" "cat") }} -- {{ template "common.envvar.secret" (list "ATHENA" "secret-name" "athena") }} -{{- end -}} -``` - -Output: - -```yaml -... - spec: - containers: - - env: - - name: ZEUS - value: cat - - name: ATHENA - valueFrom: - secretKeyRef: - key: athena - name: secret-name -... -``` - -### Volume - -Use the Volume helpers within a `Deployment` spec to help define ConfigMap and -PersistentVolumeClaim volumes. - -Example Use: - -```yaml -{{- template "common.deployment" (list . "mychart.deployment") -}} -{{- define "mychart.deployment" -}} -spec: - template: - spec: - volumes: - - {{ template "common.volume.configMap" (list "config" "configmap-name") }} - - {{ template "common.volume.pvc" (list "data" "pvc-name" .Values.persistence) }} -{{- end -}} -``` - -Output: - -```yaml -... - spec: - volumes: - - configMap: - name: configmap-name - name: config - - name: data - persistentVolumeClaim: - claimName: pvc-name -... -``` - -The `common.volume.pvc` helper uses the following configuration from the `.Values.persistence` object: - -| Value | Description | -| ------------------------- | ----------------------------------------------------- | -| persistence.enabled | If false, creates an `emptyDir` instead | -| persistence.existingClaim | If set, uses this instead of the passed in claim name | - -## Utilities - -### `common.fullname` - -The `common.fullname` template generates a name suitable for the `name:` field -in Kubernetes metadata. It is used like this: - -```yaml -name: {{ template "common.fullname" . }} -``` - -The following different values can influence it: - -```yaml -# By default, fullname uses '{{ .Release.Name }}-{{ .Chart.Name }}'. This -# overrides that and uses the given string instead. -fullnameOverride: "some-name" - -# This adds a prefix -fullnamePrefix: "pre-" -# This appends a suffix -fullnameSuffix: "-suf" - -# Global versions of the above -global: - fullnamePrefix: "pp-" - fullnameSuffix: "-ps" -``` - -Example output: - -```yaml ---- -# with the values above -name: pp-pre-some-name-suf-ps - ---- -# the default, for release "happy-panda" and chart "wordpress" -name: happy-panda-wordpress -``` - -Output of this function is truncated at 54 characters, which leaves 9 additional -characters for customized overriding. Thus you can easily extend this name -in your own charts: - -```yaml -{{- define "my.fullname" -}} - {{ template "common.fullname" . }}-my-stuff -{{- end -}} -``` - -### `common.fullname.unique` - -The `common.fullname.unique` variant of fullname appends a unique seven-character -sequence to the end of the common name field. - -This takes all of the same parameters as `common.fullname` - -Example template: - -```yaml -uniqueName: {{ template "common.fullname.unique" . }} -``` - -Example output: - -```yaml -uniqueName: release-name-fullname-jl0dbwx -``` - -It is also impacted by the prefix and suffix definitions, as well as by -`.Values.fullnameOverride` - -Note that the effective maximum length of this function is 63 characters, not 54. - -### `common.name` - -The `common.name` template generates a name suitable for the `app` label. It is used like this: - -```yaml -app: {{ template "common.name" . }} -``` - -The following different values can influence it: - -```yaml -# By default, name uses '{{ .Chart.Name }}'. This -# overrides that and uses the given string instead. -nameOverride: "some-name" - -# This adds a prefix -namePrefix: "pre-" -# This appends a suffix -nameSuffix: "-suf" - -# Global versions of the above -global: - namePrefix: "pp-" - nameSuffix: "-ps" -``` - -Example output: - -```yaml ---- -# with the values above -name: pp-pre-some-name-suf-ps - ---- -# the default, for chart "wordpress" -name: wordpress -``` - -Output of this function is truncated at 54 characters, which leaves 9 additional -characters for customized overriding. Thus you can easily extend this name -in your own charts: - -```yaml -{{- define "my.name" -}} - {{ template "common.name" . }}-my-stuff -{{- end -}} -``` - -### `common.metadata` - -The `common.metadata` helper generates the `metadata:` section of a Kubernetes -resource. - -This takes three objects: - - .top: top context - - .fullnameOverride: override the fullname with this name - - .metadata - - .labels: key/value list of labels - - .annotations: key/value list of annotations - - .hook: name(s) of hook(s) - -It generates standard labels, annotations, hooks, and a name field. - -Example template: - -```yaml -{{ template "common.metadata" (dict "top" . "metadata" .Values.bio) }} ---- -{{ template "common.metadata" (dict "top" . "metadata" .Values.pet "fullnameOverride" .Values.pet.fullnameOverride) }} -``` - -Example values: - -```yaml -bio: - name: example - labels: - first: matt - last: butcher - nick: technosophos - annotations: - format: bio - destination: archive - hook: pre-install - -pet: - fullnameOverride: Zeus - -``` - -Example output: - -```yaml -metadata: - name: release-name-metadata - labels: - app.kubernetes.io/name: metadata - app.kubernetes.io/managed-by: "Helm" - app.kubernetes.io/instance: "release-name" - helm.sh/chart: metadata-0.1.0 - first: "matt" - last: "butcher" - nick: "technosophos" - annotations: - "destination": "archive" - "format": "bio" - "helm.sh/hook": "pre-install" ---- -metadata: - name: Zeus - labels: - app.kubernetes.io/name: metadata - app.kubernetes.io/managed-by: "Helm" - app.kubernetes.io/instance: "release-name" - helm.sh/chart: metadata-0.1.0 - annotations: -``` - -Most of the common templates that define a resource type (e.g. `common.configmap` -or `common.job`) use this to generate the metadata, which means they inherit -the same `labels`, `annotations`, `nameOverride`, and `hook` fields. - -### `common.labelize` - -`common.labelize` turns a map into a set of labels. - -Example template: - -```yaml -{{- $map := dict "first" "1" "second" "2" "third" "3" -}} -{{- template "common.labelize" $map -}} -``` - -Example output: - -```yaml -first: "1" -second: "2" -third: "3" -``` - -### `common.labels.standard` - -`common.labels.standard` prints the standard set of labels. - -Example usage: - -``` -{{ template "common.labels.standard" . }} -``` - -Example output: - -```yaml -app.kubernetes.io/name: labelizer -app.kubernetes.io/managed-by: "Tiller" -app.kubernetes.io/instance: "release-name" -helm.sh/chart: labelizer-0.1.0 -``` - -### `common.hook` - -The `common.hook` template is a convenience for defining hooks. - -Example template: - -```yaml -{{ template "common.hook" "pre-install,post-install" }} -``` - -Example output: - -```yaml -"helm.sh/hook": "pre-install,post-install" -``` - -### `common.chartref` - -The `common.chartref` helper prints the chart name and version, escaped to be -legal in a Kubernetes label field. - -Example template: - -```yaml -chartref: {{ template "common.chartref" . }} -``` - -For the chart `foo` with version `1.2.3-beta.55+1234`, this will render: - -```yaml -chartref: foo-1.2.3-beta.55_1234 -``` - -(Note that `+` is an illegal character in label values) diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_chartref.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_chartref.tpl deleted file mode 100644 index e6c14866f..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_chartref.tpl +++ /dev/null @@ -1,14 +0,0 @@ -{{- /* -common.chartref prints a chart name and version. - -It does minimal escaping for use in Kubernetes labels. - -Example output: - - zookeeper-1.2.3 - wordpress-3.2.1_20170219 - -*/ -}} -{{- define "common.chartref" -}} - {{- replace "+" "_" .Chart.Version | printf "%s-%s" .Chart.Name -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_configmap.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_configmap.yaml deleted file mode 100644 index 03dbbf858..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_configmap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -{{- define "common.configmap.tpl" -}} -apiVersion: v1 -kind: ConfigMap -{{ template "common.metadata" . }} -data: {} -{{- end -}} -{{- define "common.configmap" -}} -{{- template "common.util.merge" (append . "common.configmap.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_container.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_container.yaml deleted file mode 100644 index 540eb0e6a..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_container.yaml +++ /dev/null @@ -1,15 +0,0 @@ -{{- define "common.container.tpl" -}} -name: {{ .Chart.Name }} -image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" -imagePullPolicy: {{ .Values.image.pullPolicy }} -ports: -- name: http - containerPort: 80 -resources: -{{ toYaml .Values.resources | indent 2 }} -{{- end -}} -{{- define "common.container" -}} -{{- /* clear new line so indentation works correctly */ -}} -{{- println "" -}} -{{- include "common.util.merge" (append . "common.container.tpl") | indent 8 -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml deleted file mode 100644 index e99a8cd33..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml +++ /dev/null @@ -1,18 +0,0 @@ -{{- define "common.deployment.tpl" -}} -apiVersion: extensions/v1beta1 -kind: Deployment -{{ template "common.metadata" . }} -spec: - template: - metadata: - labels: - app.kubernetes.io/name: {{ template "common.name" . }} - app.kubernetes.io/instance: {{ .Release.Name | quote }} - spec: - containers: - - -{{ include "common.container.tpl" . | indent 8 }} -{{- end -}} -{{- define "common.deployment" -}} -{{- template "common.util.merge" (append . "common.deployment.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_envvar.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_envvar.tpl deleted file mode 100644 index 709251f8f..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_envvar.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{{- define "common.envvar.value" -}} - {{- $name := index . 0 -}} - {{- $value := index . 1 -}} - - name: {{ $name }} - value: {{ default "" $value | quote }} -{{- end -}} - -{{- define "common.envvar.configmap" -}} - {{- $name := index . 0 -}} - {{- $configMapName := index . 1 -}} - {{- $configMapKey := index . 2 -}} - - name: {{ $name }} - valueFrom: - configMapKeyRef: - name: {{ $configMapName }} - key: {{ $configMapKey }} -{{- end -}} - -{{- define "common.envvar.secret" -}} - {{- $name := index . 0 -}} - {{- $secretName := index . 1 -}} - {{- $secretKey := index . 2 -}} - - name: {{ $name }} - valueFrom: - secretKeyRef: - name: {{ $secretName }} - key: {{ $secretKey }} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_fullname.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_fullname.tpl deleted file mode 100644 index 2da6cdf18..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_fullname.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{{- /* -fullname defines a suitably unique name for a resource by combining -the release name and the chart name. - -The prevailing wisdom is that names should only contain a-z, 0-9 plus dot (.) and dash (-), and should -not exceed 63 characters. - -Parameters: - -- .Values.fullnameOverride: Replaces the computed name with this given name -- .Values.fullnamePrefix: Prefix -- .Values.global.fullnamePrefix: Global prefix -- .Values.fullnameSuffix: Suffix -- .Values.global.fullnameSuffix: Global suffix - -The applied order is: "global prefix + prefix + name + suffix + global suffix" - -Usage: 'name: "{{- template "common.fullname" . -}}"' -*/ -}} -{{- define "common.fullname"}} - {{- $global := default (dict) .Values.global -}} - {{- $base := default (printf "%s-%s" .Release.Name .Chart.Name) .Values.fullnameOverride -}} - {{- $gpre := default "" $global.fullnamePrefix -}} - {{- $pre := default "" .Values.fullnamePrefix -}} - {{- $suf := default "" .Values.fullnameSuffix -}} - {{- $gsuf := default "" $global.fullnameSuffix -}} - {{- $name := print $gpre $pre $base $suf $gsuf -}} - {{- $name | lower | trunc 54 | trimSuffix "-" -}} -{{- end -}} - -{{- /* -common.fullname.unique adds a random suffix to the unique name. - -This takes the same parameters as common.fullname - -*/ -}} -{{- define "common.fullname.unique" -}} - {{ template "common.fullname" . }}-{{ randAlphaNum 7 | lower }} -{{- end }} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_ingress.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_ingress.yaml deleted file mode 100644 index 78411e15b..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_ingress.yaml +++ /dev/null @@ -1,27 +0,0 @@ -{{- define "common.ingress.tpl" -}} -apiVersion: extensions/v1beta1 -kind: Ingress -{{ template "common.metadata" . }} - {{- if .Values.ingress.annotations }} - annotations: - {{ include "common.annotate" .Values.ingress.annotations | indent 4 }} - {{- end }} -spec: - rules: - {{- range $host := .Values.ingress.hosts }} - - host: {{ $host }} - http: - paths: - - path: / - backend: - serviceName: {{ template "common.fullname" $ }} - servicePort: 80 - {{- end }} - {{- if .Values.ingress.tls }} - tls: -{{ toYaml .Values.ingress.tls | indent 4 }} - {{- end -}} -{{- end -}} -{{- define "common.ingress" -}} -{{- template "common.util.merge" (append . "common.ingress.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata.yaml deleted file mode 100644 index f96ed09fe..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- /* -common.metadata creates a standard metadata header. -It creates a 'metadata:' section with name and labels. -*/ -}} -{{ define "common.metadata" -}} -metadata: - name: {{ template "common.fullname" . }} - labels: -{{ include "common.labels.standard" . | indent 4 -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl deleted file mode 100644 index dffe1eca9..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl +++ /dev/null @@ -1,18 +0,0 @@ -{{- /* -common.hook defines a hook. - -This is to be used in a 'metadata.annotations' section. - -This should be called as 'template "common.metadata.hook" "post-install"' - -Any valid hook may be passed in. Separate multiple hooks with a ",". -*/ -}} -{{- define "common.hook" -}} -"helm.sh/hook": {{printf "%s" . | quote}} -{{- end -}} - -{{- define "common.annotate" -}} -{{- range $k, $v := . }} -{{ $k | quote }}: {{ $v | quote }} -{{- end -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl deleted file mode 100644 index bcb8cdaa8..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{{- /* -common.labelize takes a dict or map and generates labels. - -Values will be quoted. Keys will not. - -Example output: - - first: "Matt" - last: "Butcher" - -*/ -}} -{{- define "common.labelize" -}} -{{- range $k, $v := . }} -{{ $k }}: {{ $v | quote }} -{{- end -}} -{{- end -}} - -{{- /* -common.labels.standard prints the standard Helm labels. - -The standard labels are frequently used in metadata. -*/ -}} -{{- define "common.labels.standard" -}} -app.kubernetes.io/name: {{ template "common.name" . }} -helm.sh/chart: {{ template "common.chartref" . }} -app.kubernetes.io/managed-by: {{ .Release.Service | quote }} -app.kubernetes.io/instance: {{ .Release.Name | quote }} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_name.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_name.tpl deleted file mode 100644 index 1d42fb068..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_name.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{{- /* -name defines a template for the name of the chart. It should be used for the `app` label. -This is common practice in many Kubernetes manifests, and is not Helm-specific. - -The prevailing wisdom is that names should only contain a-z, 0-9 plus dot (.) and dash (-), and should -not exceed 63 characters. - -Parameters: - -- .Values.nameOverride: Replaces the computed name with this given name -- .Values.namePrefix: Prefix -- .Values.global.namePrefix: Global prefix -- .Values.nameSuffix: Suffix -- .Values.global.nameSuffix: Global suffix - -The applied order is: "global prefix + prefix + name + suffix + global suffix" - -Usage: 'name: "{{- template "common.name" . -}}"' -*/ -}} -{{- define "common.name"}} - {{- $global := default (dict) .Values.global -}} - {{- $base := default .Chart.Name .Values.nameOverride -}} - {{- $gpre := default "" $global.namePrefix -}} - {{- $pre := default "" .Values.namePrefix -}} - {{- $suf := default "" .Values.nameSuffix -}} - {{- $gsuf := default "" $global.nameSuffix -}} - {{- $name := print $gpre $pre $base $suf $gsuf -}} - {{- $name | lower | trunc 54 | trimSuffix "-" -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml deleted file mode 100644 index 6c1578c7e..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml +++ /dev/null @@ -1,24 +0,0 @@ -{{- define "common.persistentvolumeclaim.tpl" -}} -apiVersion: v1 -kind: PersistentVolumeClaim -{{ template "common.metadata" . }} -spec: - accessModes: - - {{ .Values.persistence.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.size | quote }} -{{- if .Values.persistence.storageClass }} -{{- if (eq "-" .Values.persistence.storageClass) }} - storageClassName: "" -{{- else }} - storageClassName: "{{ .Values.persistence.storageClass }}" -{{- end }} -{{- end }} -{{- end -}} -{{- define "common.persistentvolumeclaim" -}} -{{- $top := first . -}} -{{- if and $top.Values.persistence.enabled (not $top.Values.persistence.existingClaim) -}} -{{- template "common.util.merge" (append . "common.persistentvolumeclaim.tpl") -}} -{{- end -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_secret.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_secret.yaml deleted file mode 100644 index 0615d35cb..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_secret.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- define "common.secret.tpl" -}} -apiVersion: v1 -kind: Secret -{{ template "common.metadata" . }} -type: Opaque -data: {} -{{- end -}} -{{- define "common.secret" -}} -{{- template "common.util.merge" (append . "common.secret.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml b/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml deleted file mode 100644 index b9dfc378a..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- define "common.service.tpl" -}} -apiVersion: v1 -kind: Service -{{ template "common.metadata" . }} -spec: - type: {{ .Values.service.type }} - ports: - - name: http - port: 80 - targetPort: http - selector: - app.kubernetes.io/name: {{ template "common.name" . }} - app.kubernetes.io/instance: {{ .Release.Name | quote }} -{{- end -}} -{{- define "common.service" -}} -{{- template "common.util.merge" (append . "common.service.tpl") -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_util.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_util.tpl deleted file mode 100644 index a7d4cc751..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_util.tpl +++ /dev/null @@ -1,15 +0,0 @@ -{{- /* -common.util.merge will merge two YAML templates and output the result. - -This takes an array of three values: -- the top context -- the template name of the overrides (destination) -- the template name of the base (source) - -*/ -}} -{{- define "common.util.merge" -}} -{{- $top := first . -}} -{{- $overrides := fromYaml (include (index . 1) $top) | default (dict ) -}} -{{- $tpl := fromYaml (include (index . 2) $top) | default (dict ) -}} -{{- toYaml (merge $overrides $tpl) -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_volume.tpl b/cmd/helm/testdata/testcharts/lib-chart/templates/_volume.tpl deleted file mode 100644 index 521a1f48b..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/templates/_volume.tpl +++ /dev/null @@ -1,22 +0,0 @@ -{{- define "common.volume.configMap" -}} - {{- $name := index . 0 -}} - {{- $configMapName := index . 1 -}} - - name: {{ $name }} - configMap: - name: {{ $configMapName }} -{{- end -}} - -{{- define "common.volume.pvc" -}} - {{- $name := index . 0 -}} - {{- $claimName := index . 1 -}} - {{- $persistence := index . 2 -}} - - name: {{ $name }} - {{- if $persistence.enabled }} - persistentVolumeClaim: - claimName: {{ $persistence.existingClaim | default $claimName }} - {{- else }} - emptyDir: {} - {{- end -}} -{{- end -}} diff --git a/cmd/helm/testdata/testcharts/lib-chart/values.yaml b/cmd/helm/testdata/testcharts/lib-chart/values.yaml deleted file mode 100644 index b7cf514d5..000000000 --- a/cmd/helm/testdata/testcharts/lib-chart/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for commons. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/object-order/Chart.yaml b/cmd/helm/testdata/testcharts/object-order/Chart.yaml deleted file mode 100644 index d2eb42fd7..000000000 --- a/cmd/helm/testdata/testcharts/object-order/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v2 -name: object-order -description: Test ordering of manifests in output -type: application -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml b/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml deleted file mode 100644 index 32aa4a475..000000000 --- a/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml +++ /dev/null @@ -1,57 +0,0 @@ -# 1 -kind: NetworkPolicy -apiVersion: networking.k8s.io/v1 -metadata: - name: first -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 2 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: second -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 3 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: third -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 4 (Deployment should come after all NetworkPolicy manifests, since 'helm template' outputs in install order) -apiVersion: apps/v1 -kind: Deployment -metadata: - name: fourth -spec: - selector: - matchLabels: - pod: fourth - replicas: 1 - template: - metadata: - labels: - pod: fourth - spec: - containers: - - name: hello-world - image: gcr.io/google-samples/node-hello:1.0 diff --git a/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml b/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml deleted file mode 100644 index 895db8cf7..000000000 --- a/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml +++ /dev/null @@ -1,143 +0,0 @@ -# 5 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: fifth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 6 (implementation detail: currently, 'helm template' outputs hook manifests last; and yes, NetworkPolicy won't make a reasonable hook, this is just a dummy unit test manifest) -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - annotations: - "helm.sh/hook": pre-install - name: sixth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 7 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: seventh -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 8 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: eighth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 9 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: ninth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 10 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: tenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 11 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: eleventh -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 12 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: twelfth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 13 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: thirteenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 14 -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: fourteenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress - ---- - -# 15 (11th object within 02-b.yml, in order to test `SplitManifests` which assigns `manifest-10` -# to this object which should then come *after* `manifest-9`) -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - name: fifteenth -spec: - podSelector: {} - policyTypes: - - Egress - - Ingress diff --git a/cmd/helm/testdata/testcharts/object-order/values.yaml b/cmd/helm/testdata/testcharts/object-order/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/testcharts/oci-dependent-chart-0.1.0.tgz b/cmd/helm/testdata/testcharts/oci-dependent-chart-0.1.0.tgz deleted file mode 100644 index 7b4cbeccc..000000000 Binary files a/cmd/helm/testdata/testcharts/oci-dependent-chart-0.1.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz b/cmd/helm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz deleted file mode 100644 index 5d5770fed..000000000 Binary files a/cmd/helm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/reqtest-0.1.0.tgz b/cmd/helm/testdata/testcharts/reqtest-0.1.0.tgz deleted file mode 100644 index 5d8e46a50..000000000 Binary files a/cmd/helm/testdata/testcharts/reqtest-0.1.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/reqtest/.helmignore b/cmd/helm/testdata/testcharts/reqtest/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/reqtest/Chart.lock b/cmd/helm/testdata/testcharts/reqtest/Chart.lock deleted file mode 100755 index ab1ae8cc0..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/Chart.lock +++ /dev/null @@ -1,3 +0,0 @@ -dependencies: [] -digest: Not implemented -generated: 2016-09-13T17:25:17.593788787-06:00 diff --git a/cmd/helm/testdata/testcharts/reqtest/Chart.yaml b/cmd/helm/testdata/testcharts/reqtest/Chart.yaml deleted file mode 100644 index 07b6e2c97..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/Chart.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: reqtest -version: 0.1.0 -dependencies: - - name: reqsubchart - version: 0.1.0 - repository: "https://example.com/charts" - - name: reqsubchart2 - version: 0.2.0 - repository: "https://example.com/charts" - - name: reqsubchart3 - version: ">=0.1.0" - repository: "https://example.com/charts" diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml deleted file mode 100644 index 356135537..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: reqsubchart -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml deleted file mode 100644 index 0f0b63f2a..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqsubchart. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml deleted file mode 100644 index 5b9277370..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: reqsubchart2 -version: 0.2.0 diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml deleted file mode 100644 index 0f0b63f2a..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqsubchart. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz b/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz deleted file mode 100644 index 37962b0ab..000000000 Binary files a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/reqtest/values.yaml b/cmd/helm/testdata/testcharts/reqtest/values.yaml deleted file mode 100644 index d57f76b07..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/values.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Default values for reqtest. -# This is a YAML-formatted file. -# Declare name/value pairs to be passed into your templates. -# name: value diff --git a/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz b/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz deleted file mode 100644 index c74e5b0ef..000000000 Binary files a/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz and /dev/null differ diff --git a/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz.prov b/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz.prov deleted file mode 100644 index d325bb266..000000000 --- a/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz.prov +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA512 - -apiVersion: v1 -description: A Helm chart for Kubernetes -name: signtest -version: 0.1.0 - -... -files: - signtest-0.1.0.tgz: sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55 ------BEGIN PGP SIGNATURE----- - -wsBcBAEBCgAQBQJcoosfCRCEO7+YH8GHYgAA220IALAs8T8NPgkcLvHu+5109cAN -BOCNPSZDNsqLZW/2Dc9cKoBG7Jen4Qad+i5l9351kqn3D9Gm6eRfAWcjfggRobV/ -9daZ19h0nl4O1muQNAkjvdgZt8MOP3+PB3I3/Tu2QCYjI579SLUmuXlcZR5BCFPR -PJy+e3QpV2PcdeU2KZLG4tjtlrq+3QC9ZHHEJLs+BVN9d46Dwo6CxJdHJrrrAkTw -M8MhA92vbiTTPRSCZI9x5qDAwJYhoq0oxLflpuL2tIlo3qVoCsaTSURwMESEHO32 -XwYG7BaVDMELWhAorBAGBGBwWFbJ1677qQ2gd9CN0COiVhekWlFRcnn60800r84= -=k9Y9 ------END PGP SIGNATURE----- \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/signtest/.helmignore b/cmd/helm/testdata/testcharts/signtest/.helmignore deleted file mode 100644 index 435b756d8..000000000 --- a/cmd/helm/testdata/testcharts/signtest/.helmignore +++ /dev/null @@ -1,5 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -.git diff --git a/cmd/helm/testdata/testcharts/signtest/Chart.yaml b/cmd/helm/testdata/testcharts/signtest/Chart.yaml deleted file mode 100644 index f1f73723a..000000000 --- a/cmd/helm/testdata/testcharts/signtest/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: signtest -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/Chart.yaml b/cmd/helm/testdata/testcharts/signtest/alpine/Chart.yaml deleted file mode 100644 index eec261220..000000000 --- a/cmd/helm/testdata/testcharts/signtest/alpine/Chart.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -description: Deploy a basic Alpine Linux pod -home: https://helm.sh/helm -name: alpine -sources: -- https://github.com/helm/helm -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/README.md b/cmd/helm/testdata/testcharts/signtest/alpine/README.md deleted file mode 100644 index 28bebae07..000000000 --- a/cmd/helm/testdata/testcharts/signtest/alpine/README.md +++ /dev/null @@ -1,9 +0,0 @@ -This example was generated using the command `helm create alpine`. - -The `templates/` directory contains a very simple pod resource with a -couple of parameters. - -The `values.yaml` file contains the default values for the -`alpine-pod.yaml` template. - -You can install this example using `helm install ./alpine`. diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml deleted file mode 100644 index 5bbae10af..000000000 --- a/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: {{.Release.Name}}-{{.Chart.Name}} - labels: - app.kubernetes.io/managed-by: {{.Release.Service}} - chartName: {{.Chart.Name}} - chartVersion: {{.Chart.Version | quote}} -spec: - restartPolicy: {{default "Never" .restart_policy}} - containers: - - name: waiter - image: "alpine:3.3" - command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/values.yaml b/cmd/helm/testdata/testcharts/signtest/alpine/values.yaml deleted file mode 100644 index bb6c06ae4..000000000 --- a/cmd/helm/testdata/testcharts/signtest/alpine/values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -# The pod name -name: my-alpine diff --git a/cmd/helm/testdata/testcharts/signtest/templates/pod.yaml b/cmd/helm/testdata/testcharts/signtest/templates/pod.yaml deleted file mode 100644 index 9b00ccaf7..000000000 --- a/cmd/helm/testdata/testcharts/signtest/templates/pod.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: signtest -spec: - restartPolicy: Never - containers: - - name: waiter - image: "alpine:3.3" - command: ["/bin/sleep","9000"] diff --git a/cmd/helm/testdata/testcharts/signtest/values.yaml b/cmd/helm/testdata/testcharts/signtest/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmd/helm/testdata/testcharts/subchart/Chart.yaml b/cmd/helm/testdata/testcharts/subchart/Chart.yaml deleted file mode 100644 index b03ea3cd3..000000000 --- a/cmd/helm/testdata/testcharts/subchart/Chart.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: subchart -version: 0.1.0 -dependencies: - - name: subcharta - repository: http://localhost:10191 - version: 0.1.0 - condition: subcharta.enabled - tags: - - front-end - - subcharta - import-values: - - child: SCAdata - parent: imported-chartA - - child: SCAdata - parent: overridden-chartA - - child: SCAdata - parent: imported-chartA-B - - - name: subchartb - repository: http://localhost:10191 - version: 0.1.0 - condition: subchartb.enabled - import-values: - - child: SCBdata - parent: imported-chartB - - child: SCBdata - parent: imported-chartA-B - - child: exports.SCBexported2 - parent: exports.SCBexported2 - - SCBexported1 - - tags: - - front-end - - subchartb diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/Chart.yaml b/cmd/helm/testdata/testcharts/subchart/charts/subchartA/Chart.yaml deleted file mode 100644 index be3edcefb..000000000 --- a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: subcharta -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml b/cmd/helm/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml deleted file mode 100644 index 27501e1e0..000000000 --- a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Chart.Name }} - labels: - helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.externalPort }} - targetPort: {{ .Values.service.internalPort }} - protocol: TCP - name: {{ .Values.service.name }} - selector: - app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/values.yaml b/cmd/helm/testdata/testcharts/subchart/charts/subchartA/values.yaml deleted file mode 100644 index f0381ae6a..000000000 --- a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/values.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Default values for subchart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -# subchartA -service: - name: apache - type: ClusterIP - externalPort: 80 - internalPort: 80 -SCAdata: - SCAbool: false - SCAfloat: 3.1 - SCAint: 55 - SCAstring: "jabba" - SCAnested1: - SCAnested2: true - diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/Chart.yaml b/cmd/helm/testdata/testcharts/subchart/charts/subchartB/Chart.yaml deleted file mode 100644 index c3c6bbaf0..000000000 --- a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: subchartb -version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml b/cmd/helm/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml deleted file mode 100644 index 27501e1e0..000000000 --- a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Chart.Name }} - labels: - helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.externalPort }} - targetPort: {{ .Values.service.internalPort }} - protocol: TCP - name: {{ .Values.service.name }} - selector: - app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/values.yaml b/cmd/helm/testdata/testcharts/subchart/charts/subchartB/values.yaml deleted file mode 100644 index 774fdd75c..000000000 --- a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/values.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Default values for subchart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -service: - name: nginx - type: ClusterIP - externalPort: 80 - internalPort: 80 - -SCBdata: - SCBbool: true - SCBfloat: 7.77 - SCBint: 33 - SCBstring: "boba" - -exports: - SCBexported1: - SCBexported1A: - SCBexported1B: 1965 - - SCBexported2: - SCBexported2A: "blaster" - -global: - kolla: - nova: - api: - all: - port: 8774 - metadata: - all: - port: 8775 - - - diff --git a/cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml b/cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml deleted file mode 100644 index ad770b632..000000000 --- a/cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: testcrds.testcrdgroups.example.com -spec: - group: testcrdgroups.example.com - version: v1alpha1 - names: - kind: TestCRD - listKind: TestCRDList - plural: testcrds - shortNames: - - tc - singular: authconfig diff --git a/cmd/helm/testdata/testcharts/subchart/templates/NOTES.txt b/cmd/helm/testdata/testcharts/subchart/templates/NOTES.txt deleted file mode 100644 index 4bdf443f6..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/NOTES.txt +++ /dev/null @@ -1 +0,0 @@ -Sample notes for {{ .Chart.Name }} \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/subchart/templates/service.yaml b/cmd/helm/testdata/testcharts/subchart/templates/service.yaml deleted file mode 100644 index fee94dced..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/service.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Chart.Name }} - labels: - helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - app.kubernetes.io/instance: "{{ .Release.Name }}" - kube-version/major: "{{ .Capabilities.KubeVersion.Major }}" - kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}" - kube-version/version: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0" -{{- if .Capabilities.APIVersions.Has "helm.k8s.io/test" }} - kube-api-version/test: v1 -{{- end }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.externalPort }} - targetPort: {{ .Values.service.internalPort }} - protocol: TCP - name: {{ .Values.service.name }} - selector: - app.kubernetes.io/name: {{ .Chart.Name }} diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/role.yaml b/cmd/helm/testdata/testcharts/subchart/templates/subdir/role.yaml deleted file mode 100644 index 31cff9200..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/subdir/role.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: {{ .Chart.Name }}-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get","list","watch"] diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml b/cmd/helm/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml deleted file mode 100644 index 5d193f1a6..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: {{ .Chart.Name }}-binding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: {{ .Chart.Name }}-role -subjects: -- kind: ServiceAccount - name: {{ .Chart.Name }}-sa - namespace: default diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml b/cmd/helm/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml deleted file mode 100644 index 7126c7d89..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ .Chart.Name }}-sa diff --git a/cmd/helm/testdata/testcharts/subchart/templates/tests/test-config.yaml b/cmd/helm/testdata/testcharts/subchart/templates/tests/test-config.yaml deleted file mode 100644 index 0aa3eea29..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/tests/test-config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: "{{ .Release.Name }}-testconfig" - annotations: - "helm.sh/hook": test -data: - message: Hello World diff --git a/cmd/helm/testdata/testcharts/subchart/templates/tests/test-nothing.yaml b/cmd/helm/testdata/testcharts/subchart/templates/tests/test-nothing.yaml deleted file mode 100644 index 0fe6dbbf3..000000000 --- a/cmd/helm/testdata/testcharts/subchart/templates/tests/test-nothing.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ .Release.Name }}-test" - annotations: - "helm.sh/hook": test -spec: - containers: - - name: test - image: "alpine:latest" - envFrom: - - configMapRef: - name: "{{ .Release.Name }}-testconfig" - command: - - echo - - "$message" - restartPolicy: Never diff --git a/cmd/helm/testdata/testcharts/subchart/values.yaml b/cmd/helm/testdata/testcharts/subchart/values.yaml deleted file mode 100644 index 8a3ab6c64..000000000 --- a/cmd/helm/testdata/testcharts/subchart/values.yaml +++ /dev/null @@ -1,55 +0,0 @@ -# Default values for subchart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -# subchart -service: - name: nginx - type: ClusterIP - externalPort: 80 - internalPort: 80 - - -SC1data: - SC1bool: true - SC1float: 3.14 - SC1int: 100 - SC1string: "dollywood" - SC1extra1: 11 - -imported-chartA: - SC1extra2: 1.337 - -overridden-chartA: - SCAbool: true - SCAfloat: 3.14 - SCAint: 100 - SCAstring: "jabbathehut" - SC1extra3: true - -imported-chartA-B: - SC1extra5: "tiller" - -overridden-chartA-B: - SCAbool: true - SCAfloat: 3.33 - SCAint: 555 - SCAstring: "wormwood" - SCAextra1: 23 - - SCBbool: true - SCBfloat: 0.25 - SCBint: 98 - SCBstring: "murkwood" - SCBextra1: 13 - - SC1extra6: 77 - -SCBexported1A: - SC1extra7: true - -exports: - SC1exported1: - global: - SC1exported2: - all: - SC1exported3: "SC1expstr" diff --git a/cmd/helm/testdata/testcharts/upgradetest/templates/configmap.yaml b/cmd/helm/testdata/testcharts/upgradetest/templates/configmap.yaml deleted file mode 100644 index b6b90efba..000000000 --- a/cmd/helm/testdata/testcharts/upgradetest/templates/configmap.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: "{{ .Release.Name }}-configmap" -data: - myvalue: "Hello World" - drink: {{ .Values.favoriteDrink }} \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/upgradetest/values.yaml b/cmd/helm/testdata/testcharts/upgradetest/values.yaml deleted file mode 100644 index c429f41f4..000000000 --- a/cmd/helm/testdata/testcharts/upgradetest/values.yaml +++ /dev/null @@ -1 +0,0 @@ -favoriteDrink: beer \ No newline at end of file diff --git a/cmd/helm/testdata/testplugin/plugin.yaml b/cmd/helm/testdata/testplugin/plugin.yaml deleted file mode 100644 index 890292cbf..000000000 --- a/cmd/helm/testdata/testplugin/plugin.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: testplugin -usage: "echo test" -description: "This echos test" -command: "echo test" diff --git a/cmd/helm/testdata/testserver/index.yaml b/cmd/helm/testdata/testserver/index.yaml deleted file mode 100644 index 9cde8e8dd..000000000 --- a/cmd/helm/testdata/testserver/index.yaml +++ /dev/null @@ -1 +0,0 @@ -apiVersion: v1 diff --git a/cmd/helm/testdata/testserver/repository/repositories.yaml b/cmd/helm/testdata/testserver/repository/repositories.yaml deleted file mode 100644 index 271301c95..000000000 --- a/cmd/helm/testdata/testserver/repository/repositories.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -generated: 2016-10-04T13:50:02.87649685-06:00 -repositories: -- cache: "" - name: test - url: http://127.0.0.1:49216 diff --git a/cmd/helm/uninstall.go b/cmd/helm/uninstall.go deleted file mode 100644 index 67f778f15..000000000 --- a/cmd/helm/uninstall.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -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 ( - "fmt" - "io" - "time" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const uninstallDesc = ` -This command takes a release name and uninstalls the release. - -It removes all of the resources associated with the last release of the chart -as well as the release history, freeing it up for future use. - -Use the '--dry-run' flag to see which releases will be uninstalled without actually -uninstalling them. -` - -func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewUninstall(cfg) - - cmd := &cobra.Command{ - Use: "uninstall RELEASE_NAME [...]", - Aliases: []string{"del", "delete", "un"}, - SuggestFor: []string{"remove", "rm"}, - Short: "uninstall a release", - Long: uninstallDesc, - Args: require.MinimumNArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return compListReleases(toComplete, args, cfg) - }, - RunE: func(cmd *cobra.Command, args []string) error { - for i := 0; i < len(args); i++ { - - res, err := client.Run(args[i]) - if err != nil { - return err - } - if res != nil && res.Info != "" { - fmt.Fprintln(out, res.Info) - } - - fmt.Fprintf(out, "release \"%s\" uninstalled\n", args[i]) - } - return nil - }, - } - - f := cmd.Flags() - f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall") - f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") - f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history") - f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all the resources are deleted before returning. It will wait for as long as --timeout") - f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.StringVar(&client.Description, "description", "", "add a custom description") - - return cmd -} diff --git a/cmd/helm/uninstall_test.go b/cmd/helm/uninstall_test.go deleted file mode 100644 index 23b61058e..000000000 --- a/cmd/helm/uninstall_test.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -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 ( - "testing" - - "helm.sh/helm/v3/pkg/release" -) - -func TestUninstall(t *testing.T) { - tests := []cmdTestCase{ - { - name: "basic uninstall", - cmd: "uninstall aeneas", - golden: "output/uninstall.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, - }, - { - name: "multiple uninstall", - cmd: "uninstall aeneas aeneas2", - golden: "output/uninstall-multiple.txt", - rels: []*release.Release{ - release.Mock(&release.MockReleaseOptions{Name: "aeneas"}), - release.Mock(&release.MockReleaseOptions{Name: "aeneas2"}), - }, - }, - { - name: "uninstall with timeout", - cmd: "uninstall aeneas --timeout 120s", - golden: "output/uninstall-timeout.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, - }, - { - name: "uninstall without hooks", - cmd: "uninstall aeneas --no-hooks", - golden: "output/uninstall-no-hooks.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, - }, - { - name: "keep history", - cmd: "uninstall aeneas --keep-history", - golden: "output/uninstall-keep-history.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, - }, - { - name: "wait", - cmd: "uninstall aeneas --wait", - golden: "output/uninstall-wait.txt", - rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "aeneas"})}, - }, - { - name: "uninstall without release", - cmd: "uninstall", - golden: "output/uninstall-no-args.txt", - wantError: true, - }, - } - runTestCmd(t, tests) -} - -func TestUninstallCompletion(t *testing.T) { - checkReleaseCompletion(t, "uninstall", true) -} - -func TestUninstallFileCompletion(t *testing.T) { - checkFileCompletion(t, "uninstall", false) - checkFileCompletion(t, "uninstall myrelease", false) -} diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go deleted file mode 100644 index 33db703c4..000000000 --- a/cmd/helm/upgrade.go +++ /dev/null @@ -1,251 +0,0 @@ -/* -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 ( - "context" - "fmt" - "io" - "log" - "os" - "os/signal" - "syscall" - "time" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chart/loader" - "helm.sh/helm/v3/pkg/cli/output" - "helm.sh/helm/v3/pkg/cli/values" - "helm.sh/helm/v3/pkg/downloader" - "helm.sh/helm/v3/pkg/getter" - "helm.sh/helm/v3/pkg/storage/driver" -) - -const upgradeDesc = ` -This command upgrades a release to a new version of a chart. - -The upgrade arguments must be a release and chart. The chart -argument can be either: a chart reference('example/mariadb'), a path to a chart directory, -a packaged chart, or a fully qualified URL. For chart references, the latest -version will be specified unless the '--version' flag is set. - -To override values in a chart, use either the '--values' flag and pass in a file -or use the '--set' flag and pass configuration from the command line, to force string -values, use '--set-string'. You can use '--set-file' to set individual -values from a file when the value itself is too long for the command line -or is dynamically generated. You can also use '--set-json' to set json values -(scalars/objects/arrays) from the command line. - -You can specify the '--values'/'-f' flag multiple times. The priority will be given to the -last (right-most) file specified. For example, if both myvalues.yaml and override.yaml -contained a key called 'Test', the value set in override.yaml would take precedence: - - $ helm upgrade -f myvalues.yaml -f override.yaml redis ./redis - -You can specify the '--set' flag multiple times. The priority will be given to the -last (right-most) set specified. For example, if both 'bar' and 'newbar' values are -set for a key called 'foo', the 'newbar' value would take precedence: - - $ helm upgrade --set foo=bar --set foo=newbar redis ./redis -` - -func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - client := action.NewUpgrade(cfg) - valueOpts := &values.Options{} - var outfmt output.Format - var createNamespace bool - - cmd := &cobra.Command{ - Use: "upgrade [RELEASE] [CHART]", - Short: "upgrade a release", - Long: upgradeDesc, - Args: require.ExactArgs(2), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - return compListReleases(toComplete, args, cfg) - } - if len(args) == 1 { - return compListCharts(toComplete, true) - } - return nil, cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - client.Namespace = settings.Namespace() - - // Fixes #7002 - Support reading values from STDIN for `upgrade` command - // Must load values AFTER determining if we have to call install so that values loaded from stdin are are not read twice - if client.Install { - // If a release does not exist, install it. - histClient := action.NewHistory(cfg) - histClient.Max = 1 - if _, err := histClient.Run(args[0]); err == driver.ErrReleaseNotFound { - // Only print this to stdout for table output - if outfmt == output.Table { - fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0]) - } - instClient := action.NewInstall(cfg) - instClient.CreateNamespace = createNamespace - instClient.ChartPathOptions = client.ChartPathOptions - instClient.DryRun = client.DryRun - instClient.DisableHooks = client.DisableHooks - instClient.SkipCRDs = client.SkipCRDs - instClient.Timeout = client.Timeout - instClient.Wait = client.Wait - instClient.WaitForJobs = client.WaitForJobs - instClient.Devel = client.Devel - instClient.Namespace = client.Namespace - instClient.Atomic = client.Atomic - instClient.PostRenderer = client.PostRenderer - instClient.DisableOpenAPIValidation = client.DisableOpenAPIValidation - instClient.SubNotes = client.SubNotes - instClient.Description = client.Description - instClient.DependencyUpdate = client.DependencyUpdate - - rel, err := runInstall(args, instClient, valueOpts, out) - if err != nil { - return err - } - return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false}) - } else if err != nil { - return err - } - } - - if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") - client.Version = ">0.0.0-0" - } - - chartPath, err := client.ChartPathOptions.LocateChart(args[1], settings) - if err != nil { - return err - } - - p := getter.All(settings) - vals, err := valueOpts.MergeValues(p) - if err != nil { - return err - } - - // Check chart dependencies to make sure all are present in /charts - ch, err := loader.Load(chartPath) - if err != nil { - return err - } - if req := ch.Metadata.Dependencies; req != nil { - if err := action.CheckDependencies(ch, req); err != nil { - err = errors.Wrap(err, "An error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies") - if client.DependencyUpdate { - man := &downloader.Manager{ - Out: out, - ChartPath: chartPath, - Keyring: client.ChartPathOptions.Keyring, - SkipUpdate: false, - Getters: p, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } - if err := man.Update(); err != nil { - return err - } - // Reload the chart with the updated Chart.lock file. - if ch, err = loader.Load(chartPath); err != nil { - return errors.Wrap(err, "failed reloading chart after repo update") - } - } else { - return err - } - } - } - - if ch.Metadata.Deprecated { - warning("This chart is deprecated") - } - - // Create context and prepare the handle of SIGTERM - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - - // Set up channel on which to send signal notifications. - // We must use a buffered channel or risk missing the signal - // if we're not ready to receive when the signal is sent. - cSignal := make(chan os.Signal, 2) - signal.Notify(cSignal, os.Interrupt, syscall.SIGTERM) - go func() { - <-cSignal - fmt.Fprintf(out, "Release %s has been cancelled.\n", args[0]) - cancel() - }() - - rel, err := client.RunWithContext(ctx, args[0], ch, vals) - if err != nil { - return errors.Wrap(err, "UPGRADE FAILED") - } - - if outfmt == output.Table { - fmt.Fprintf(out, "Release %q has been upgraded. Happy Helming!\n", args[0]) - } - - return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false}) - }, - } - - f := cmd.Flags() - f.BoolVar(&createNamespace, "create-namespace", false, "if --install is set, create the release namespace if not present") - f.BoolVarP(&client.Install, "install", "i", false, "if a release by this name doesn't already exist, run an install") - 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.DryRun, "dry-run", false, "simulate an upgrade") - f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") - f.MarkDeprecated("recreate-pods", "functionality will no longer be updated. Consult the documentation for other methods to recreate pods") - f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") - f.BoolVar(&client.DisableHooks, "no-hooks", false, "disable pre/post upgrade hooks") - f.BoolVar(&client.DisableOpenAPIValidation, "disable-openapi-validation", false, "if set, the upgrade process will not validate rendered templates against the Kubernetes OpenAPI Schema") - f.BoolVar(&client.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed when an upgrade is performed with install flag enabled. By default, CRDs are installed if not already present, when an upgrade is performed with install flag enabled") - f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&client.ResetValues, "reset-values", false, "when upgrading, reset the values to the ones built into the chart") - f.BoolVar(&client.ReuseValues, "reuse-values", false, "when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored") - f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") - f.BoolVar(&client.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout") - f.BoolVar(&client.Atomic, "atomic", false, "if set, upgrade process rolls back changes made in case of failed upgrade. The --wait flag will be set automatically if --atomic is used") - f.IntVar(&client.MaxHistory, "history-max", settings.MaxHistory, "limit the maximum number of revisions saved per release. Use 0 for no limit") - f.BoolVar(&client.CleanupOnFail, "cleanup-on-fail", false, "allow deletion of new resources created in this upgrade when upgrade fails") - f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent") - f.StringVar(&client.Description, "description", "", "add a custom description") - f.BoolVar(&client.DependencyUpdate, "dependency-update", false, "update dependencies if they are missing before installing the chart") - addChartPathOptionsFlags(f, &client.ChartPathOptions) - addValueOptionsFlags(f, valueOpts) - bindOutputFlag(cmd, &outfmt) - bindPostRenderFlag(cmd, &client.PostRenderer) - - err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) != 2 { - return nil, cobra.ShellCompDirectiveNoFileComp - } - return compVersionFlag(args[1], toComplete) - }) - - if err != nil { - log.Fatal(err) - } - - return cmd -} diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go deleted file mode 100644 index 8afcb139b..000000000 --- a/cmd/helm/upgrade_test.go +++ /dev/null @@ -1,433 +0,0 @@ -/* -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 ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - "testing" - - "helm.sh/helm/v3/internal/test/ensure" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chart/loader" - "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/release" -) - -func TestUpgradeCmd(t *testing.T) { - - tmpChart := ensure.TempDir(t) - cfile := &chart.Chart{ - Metadata: &chart.Metadata{ - APIVersion: chart.APIVersionV1, - Name: "testUpgradeChart", - Description: "A Helm chart for Kubernetes", - Version: "0.1.0", - }, - } - chartPath := filepath.Join(tmpChart, cfile.Metadata.Name) - if err := chartutil.SaveDir(cfile, tmpChart); err != nil { - t.Fatalf("Error creating chart for upgrade: %v", err) - } - ch, err := loader.Load(chartPath) - if err != nil { - t.Fatalf("Error loading chart: %v", err) - } - _ = release.Mock(&release.MockReleaseOptions{ - Name: "funny-bunny", - Chart: ch, - }) - - // update chart version - cfile.Metadata.Version = "0.1.2" - - if err := chartutil.SaveDir(cfile, tmpChart); err != nil { - t.Fatalf("Error creating chart: %v", err) - } - ch, err = loader.Load(chartPath) - if err != nil { - t.Fatalf("Error loading updated chart: %v", err) - } - - // update chart version again - cfile.Metadata.Version = "0.1.3" - - if err := chartutil.SaveDir(cfile, tmpChart); err != nil { - t.Fatalf("Error creating chart: %v", err) - } - var ch2 *chart.Chart - ch2, err = loader.Load(chartPath) - if err != nil { - t.Fatalf("Error loading updated chart: %v", err) - } - - missingDepsPath := "testdata/testcharts/chart-missing-deps" - badDepsPath := "testdata/testcharts/chart-bad-requirements" - presentDepsPath := "testdata/testcharts/chart-with-subchart-update" - - relWithStatusMock := func(n string, v int, ch *chart.Chart, status release.Status) *release.Release { - return release.Mock(&release.MockReleaseOptions{Name: n, Version: v, Chart: ch, Status: status}) - } - - relMock := func(n string, v int, ch *chart.Chart) *release.Release { - return release.Mock(&release.MockReleaseOptions{Name: n, Version: v, Chart: ch}) - } - - tests := []cmdTestCase{ - { - name: "upgrade a release", - cmd: fmt.Sprintf("upgrade funny-bunny '%s'", chartPath), - golden: "output/upgrade.txt", - rels: []*release.Release{relMock("funny-bunny", 2, ch)}, - }, - { - name: "upgrade a release with timeout", - cmd: fmt.Sprintf("upgrade funny-bunny --timeout 120s '%s'", chartPath), - golden: "output/upgrade-with-timeout.txt", - rels: []*release.Release{relMock("funny-bunny", 3, ch2)}, - }, - { - name: "upgrade a release with --reset-values", - cmd: fmt.Sprintf("upgrade funny-bunny --reset-values '%s'", chartPath), - golden: "output/upgrade-with-reset-values.txt", - rels: []*release.Release{relMock("funny-bunny", 4, ch2)}, - }, - { - name: "upgrade a release with --reuse-values", - cmd: fmt.Sprintf("upgrade funny-bunny --reuse-values '%s'", chartPath), - golden: "output/upgrade-with-reset-values2.txt", - rels: []*release.Release{relMock("funny-bunny", 5, ch2)}, - }, - { - name: "install a release with 'upgrade --install'", - cmd: fmt.Sprintf("upgrade zany-bunny -i '%s'", chartPath), - golden: "output/upgrade-with-install.txt", - rels: []*release.Release{relMock("zany-bunny", 1, ch)}, - }, - { - name: "install a release with 'upgrade --install' and timeout", - cmd: fmt.Sprintf("upgrade crazy-bunny -i --timeout 120s '%s'", chartPath), - golden: "output/upgrade-with-install-timeout.txt", - rels: []*release.Release{relMock("crazy-bunny", 1, ch)}, - }, - { - name: "upgrade a release with wait", - cmd: fmt.Sprintf("upgrade crazy-bunny --wait '%s'", chartPath), - golden: "output/upgrade-with-wait.txt", - rels: []*release.Release{relMock("crazy-bunny", 2, ch2)}, - }, - { - name: "upgrade a release with wait-for-jobs", - cmd: fmt.Sprintf("upgrade crazy-bunny --wait --wait-for-jobs '%s'", chartPath), - golden: "output/upgrade-with-wait-for-jobs.txt", - rels: []*release.Release{relMock("crazy-bunny", 2, ch2)}, - }, - { - name: "upgrade a release with missing dependencies", - cmd: fmt.Sprintf("upgrade bonkers-bunny %s", missingDepsPath), - golden: "output/upgrade-with-missing-dependencies.txt", - wantError: true, - }, - { - name: "upgrade a release with bad dependencies", - cmd: fmt.Sprintf("upgrade bonkers-bunny '%s'", badDepsPath), - golden: "output/upgrade-with-bad-dependencies.txt", - wantError: true, - }, - { - name: "upgrade a release with resolving missing dependencies", - cmd: fmt.Sprintf("upgrade --dependency-update funny-bunny %s", presentDepsPath), - golden: "output/upgrade-with-dependency-update.txt", - rels: []*release.Release{relMock("funny-bunny", 2, ch2)}, - }, - { - name: "upgrade a non-existent release", - cmd: fmt.Sprintf("upgrade funny-bunny '%s'", chartPath), - golden: "output/upgrade-with-bad-or-missing-existing-release.txt", - wantError: true, - }, - { - name: "upgrade a failed release", - cmd: fmt.Sprintf("upgrade funny-bunny '%s'", chartPath), - golden: "output/upgrade.txt", - rels: []*release.Release{relWithStatusMock("funny-bunny", 2, ch, release.StatusFailed)}, - }, - { - name: "upgrade a pending install release", - cmd: fmt.Sprintf("upgrade funny-bunny '%s'", chartPath), - golden: "output/upgrade-with-pending-install.txt", - wantError: true, - rels: []*release.Release{relWithStatusMock("funny-bunny", 2, ch, release.StatusPendingInstall)}, - }, - } - runTestCmd(t, tests) -} - -func TestUpgradeWithValue(t *testing.T) { - releaseName := "funny-bunny-v2" - relMock, ch, chartPath := prepareMockRelease(releaseName, t) - - defer resetEnv()() - - store := storageFixture() - - store.Create(relMock(releaseName, 3, ch)) - - cmd := fmt.Sprintf("upgrade %s --set favoriteDrink=tea '%s'", releaseName, chartPath) - _, _, err := executeActionCommandC(store, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - updatedRel, err := store.Get(releaseName, 4) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(updatedRel.Manifest, "drink: tea") { - t.Errorf("The value is not set correctly. manifest: %s", updatedRel.Manifest) - } - -} - -func TestUpgradeWithStringValue(t *testing.T) { - releaseName := "funny-bunny-v3" - relMock, ch, chartPath := prepareMockRelease(releaseName, t) - - defer resetEnv()() - - store := storageFixture() - - store.Create(relMock(releaseName, 3, ch)) - - cmd := fmt.Sprintf("upgrade %s --set-string favoriteDrink=coffee '%s'", releaseName, chartPath) - _, _, err := executeActionCommandC(store, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - updatedRel, err := store.Get(releaseName, 4) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(updatedRel.Manifest, "drink: coffee") { - t.Errorf("The value is not set correctly. manifest: %s", updatedRel.Manifest) - } - -} - -func TestUpgradeInstallWithSubchartNotes(t *testing.T) { - - releaseName := "wacky-bunny-v1" - relMock, ch, _ := prepareMockRelease(releaseName, t) - - defer resetEnv()() - - store := storageFixture() - - store.Create(relMock(releaseName, 1, ch)) - - cmd := fmt.Sprintf("upgrade %s -i --render-subchart-notes '%s'", releaseName, "testdata/testcharts/chart-with-subchart-notes") - _, _, err := executeActionCommandC(store, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - upgradedRel, err := store.Get(releaseName, 2) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(upgradedRel.Info.Notes, "PARENT NOTES") { - t.Errorf("The parent notes are not set correctly. NOTES: %s", upgradedRel.Info.Notes) - } - - if !strings.Contains(upgradedRel.Info.Notes, "SUBCHART NOTES") { - t.Errorf("The subchart notes are not set correctly. NOTES: %s", upgradedRel.Info.Notes) - } - -} - -func TestUpgradeWithValuesFile(t *testing.T) { - - releaseName := "funny-bunny-v4" - relMock, ch, chartPath := prepareMockRelease(releaseName, t) - - defer resetEnv()() - - store := storageFixture() - - store.Create(relMock(releaseName, 3, ch)) - - cmd := fmt.Sprintf("upgrade %s --values testdata/testcharts/upgradetest/values.yaml '%s'", releaseName, chartPath) - _, _, err := executeActionCommandC(store, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - updatedRel, err := store.Get(releaseName, 4) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(updatedRel.Manifest, "drink: beer") { - t.Errorf("The value is not set correctly. manifest: %s", updatedRel.Manifest) - } - -} - -func TestUpgradeWithValuesFromStdin(t *testing.T) { - - releaseName := "funny-bunny-v5" - relMock, ch, chartPath := prepareMockRelease(releaseName, t) - - defer resetEnv()() - - store := storageFixture() - - store.Create(relMock(releaseName, 3, ch)) - - in, err := os.Open("testdata/testcharts/upgradetest/values.yaml") - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - cmd := fmt.Sprintf("upgrade %s --values - '%s'", releaseName, chartPath) - _, _, err = executeActionCommandStdinC(store, in, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - updatedRel, err := store.Get(releaseName, 4) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(updatedRel.Manifest, "drink: beer") { - t.Errorf("The value is not set correctly. manifest: %s", updatedRel.Manifest) - } -} - -func TestUpgradeInstallWithValuesFromStdin(t *testing.T) { - - releaseName := "funny-bunny-v6" - _, _, chartPath := prepareMockRelease(releaseName, t) - - defer resetEnv()() - - store := storageFixture() - - in, err := os.Open("testdata/testcharts/upgradetest/values.yaml") - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - cmd := fmt.Sprintf("upgrade %s -f - --install '%s'", releaseName, chartPath) - _, _, err = executeActionCommandStdinC(store, in, cmd) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - updatedRel, err := store.Get(releaseName, 1) - if err != nil { - t.Errorf("unexpected error, got '%v'", err) - } - - if !strings.Contains(updatedRel.Manifest, "drink: beer") { - t.Errorf("The value is not set correctly. manifest: %s", updatedRel.Manifest) - } - -} - -func prepareMockRelease(releaseName string, t *testing.T) (func(n string, v int, ch *chart.Chart) *release.Release, *chart.Chart, string) { - tmpChart := ensure.TempDir(t) - configmapData, err := ioutil.ReadFile("testdata/testcharts/upgradetest/templates/configmap.yaml") - if err != nil { - t.Fatalf("Error loading template yaml %v", err) - } - cfile := &chart.Chart{ - Metadata: &chart.Metadata{ - APIVersion: chart.APIVersionV1, - Name: "testUpgradeChart", - Description: "A Helm chart for Kubernetes", - Version: "0.1.0", - }, - Templates: []*chart.File{{Name: "templates/configmap.yaml", Data: configmapData}}, - } - chartPath := filepath.Join(tmpChart, cfile.Metadata.Name) - if err := chartutil.SaveDir(cfile, tmpChart); err != nil { - t.Fatalf("Error creating chart for upgrade: %v", err) - } - ch, err := loader.Load(chartPath) - if err != nil { - t.Fatalf("Error loading chart: %v", err) - } - _ = release.Mock(&release.MockReleaseOptions{ - Name: releaseName, - Chart: ch, - }) - - relMock := func(n string, v int, ch *chart.Chart) *release.Release { - return release.Mock(&release.MockReleaseOptions{Name: n, Version: v, Chart: ch}) - } - - return relMock, ch, chartPath -} - -func TestUpgradeOutputCompletion(t *testing.T) { - outputFlagCompletionTest(t, "upgrade") -} - -func TestUpgradeVersionCompletion(t *testing.T) { - repoFile := "testdata/helmhome/helm/repositories.yaml" - repoCache := "testdata/helmhome/helm/repository" - - repoSetup := fmt.Sprintf("--repository-config %s --repository-cache %s", repoFile, repoCache) - - tests := []cmdTestCase{{ - name: "completion for upgrade version flag", - cmd: fmt.Sprintf("%s __complete upgrade releasename testing/alpine --version ''", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for upgrade version flag, no filter", - cmd: fmt.Sprintf("%s __complete upgrade releasename testing/alpine --version 0.3", repoSetup), - golden: "output/version-comp.txt", - }, { - name: "completion for upgrade version flag too few args", - cmd: fmt.Sprintf("%s __complete upgrade releasename --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for upgrade version flag too many args", - cmd: fmt.Sprintf("%s __complete upgrade releasename testing/alpine badarg --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }, { - name: "completion for upgrade version flag invalid chart", - cmd: fmt.Sprintf("%s __complete upgrade releasename invalid/invalid --version ''", repoSetup), - golden: "output/version-invalid-comp.txt", - }} - runTestCmd(t, tests) -} - -func TestUpgradeFileCompletion(t *testing.T) { - checkFileCompletion(t, "upgrade", false) - checkFileCompletion(t, "upgrade myrelease", true) - checkFileCompletion(t, "upgrade myrelease repo/chart", false) -} diff --git a/cmd/helm/verify.go b/cmd/helm/verify.go deleted file mode 100644 index d126c9ef3..000000000 --- a/cmd/helm/verify.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -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 ( - "fmt" - "io" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/pkg/action" -) - -const verifyDesc = ` -Verify that the given chart has a valid provenance file. - -Provenance files provide cryptographic verification that a chart has not been -tampered with, and was packaged by a trusted provider. - -This command can be used to verify a local chart. Several other commands provide -'--verify' flags that run the same validation. To generate a signed package, use -the 'helm package --sign' command. -` - -func newVerifyCmd(out io.Writer) *cobra.Command { - client := action.NewVerify() - - cmd := &cobra.Command{ - Use: "verify PATH", - Short: "verify that a chart at the given path has been signed and is valid", - Long: verifyDesc, - Args: require.ExactArgs(1), - ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) == 0 { - // Allow file completion when completing the argument for the path - return nil, cobra.ShellCompDirectiveDefault - } - // No more completions, so disable file completion - return nil, cobra.ShellCompDirectiveNoFileComp - }, - RunE: func(cmd *cobra.Command, args []string) error { - err := client.Run(args[0]) - if err != nil { - return err - } - - fmt.Fprint(out, client.Out) - - return nil - }, - } - - cmd.Flags().StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") - - return cmd -} diff --git a/cmd/helm/verify_test.go b/cmd/helm/verify_test.go deleted file mode 100644 index 23b793557..000000000 --- a/cmd/helm/verify_test.go +++ /dev/null @@ -1,97 +0,0 @@ -/* -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 ( - "fmt" - "runtime" - "testing" -) - -func TestVerifyCmd(t *testing.T) { - - statExe := "stat" - statPathMsg := "no such file or directory" - statFileMsg := statPathMsg - if runtime.GOOS == "windows" { - statExe = "FindFirstFile" - statPathMsg = "The system cannot find the path specified." - statFileMsg = "The system cannot find the file specified." - } - - tests := []struct { - name string - cmd string - expect string - wantError bool - }{ - { - name: "verify requires a chart", - cmd: "verify", - expect: "\"helm verify\" requires 1 argument\n\nUsage: helm verify PATH [flags]", - wantError: true, - }, - { - name: "verify requires that chart exists", - cmd: "verify no/such/file", - expect: fmt.Sprintf("%s no/such/file: %s", statExe, statPathMsg), - wantError: true, - }, - { - name: "verify requires that chart is not a directory", - cmd: "verify testdata/testcharts/signtest", - expect: "unpacked charts cannot be verified", - wantError: true, - }, - { - name: "verify requires that chart has prov file", - cmd: "verify testdata/testcharts/compressedchart-0.1.0.tgz", - expect: fmt.Sprintf("could not load provenance file testdata/testcharts/compressedchart-0.1.0.tgz.prov: %s testdata/testcharts/compressedchart-0.1.0.tgz.prov: %s", statExe, statFileMsg), - wantError: true, - }, - { - name: "verify validates a properly signed chart", - cmd: "verify testdata/testcharts/signtest-0.1.0.tgz --keyring testdata/helm-test-key.pub", - expect: "Signed by: Helm Testing (This key should only be used for testing. DO NOT TRUST.) \nUsing Key With Fingerprint: 5E615389B53CA37F0EE60BD3843BBF981FC18762\nChart Hash Verified: sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55\n", - wantError: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _, out, err := executeActionCommand(tt.cmd) - if tt.wantError { - if err == nil { - t.Errorf("Expected error, but got none: %q", out) - } - if err.Error() != tt.expect { - t.Errorf("Expected error %q, got %q", tt.expect, err) - } - return - } else if err != nil { - t.Errorf("Unexpected error: %s", err) - } - if out != tt.expect { - t.Errorf("Expected %q, got %q", tt.expect, out) - } - }) - } -} - -func TestVerifyFileCompletion(t *testing.T) { - checkFileCompletion(t, "verify", true) - checkFileCompletion(t, "verify mypath", false) -} diff --git a/cmd/helm/version.go b/cmd/helm/version.go deleted file mode 100644 index d62778f7b..000000000 --- a/cmd/helm/version.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -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 ( - "fmt" - "io" - "text/template" - - "github.com/spf13/cobra" - - "helm.sh/helm/v3/cmd/helm/require" - "helm.sh/helm/v3/internal/version" -) - -const versionDesc = ` -Show the version for Helm. - -This will print a representation the version of Helm. -The output will look something like this: - -version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a", GitTreeState:"clean", GoVersion:"go1.13.10"} - -- Version is the semantic version of the release. -- GitCommit is the SHA for the commit that this version was built from. -- GitTreeState is "clean" if there are no local code changes when this binary was - built, and "dirty" if the binary was built from locally modified code. -- GoVersion is the version of Go that was used to compile Helm. - -When using the --template flag the following properties are available to use in -the template: - -- .Version contains the semantic version of Helm -- .GitCommit is the git commit -- .GitTreeState is the state of the git tree when Helm was built -- .GoVersion contains the version of Go that Helm was compiled with - -For example, --template='Version: {{.Version}}' outputs 'Version: v3.2.1'. -` - -type versionOptions struct { - short bool - template string -} - -func newVersionCmd(out io.Writer) *cobra.Command { - o := &versionOptions{} - - cmd := &cobra.Command{ - Use: "version", - Short: "print the client version information", - Long: versionDesc, - Args: require.NoArgs, - ValidArgsFunction: noCompletions, - RunE: func(cmd *cobra.Command, args []string) error { - return o.run(out) - }, - } - f := cmd.Flags() - f.BoolVar(&o.short, "short", false, "print the version number") - f.StringVar(&o.template, "template", "", "template for version string format") - f.BoolP("client", "c", true, "display client version information") - f.MarkHidden("client") - - return cmd -} - -func (o *versionOptions) run(out io.Writer) error { - if o.template != "" { - tt, err := template.New("_").Parse(o.template) - if err != nil { - return err - } - return tt.Execute(out, version.Get()) - } - fmt.Fprintln(out, formatVersion(o.short)) - return nil -} - -func formatVersion(short bool) string { - v := version.Get() - if short { - if len(v.GitCommit) >= 7 { - return fmt.Sprintf("%s+g%s", v.Version, v.GitCommit[:7]) - } - return version.GetVersion() - } - return fmt.Sprintf("%#v", v) -} diff --git a/cmd/helm/version_test.go b/cmd/helm/version_test.go deleted file mode 100644 index aa3cbfb7d..000000000 --- a/cmd/helm/version_test.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -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 ( - "testing" -) - -func TestVersion(t *testing.T) { - tests := []cmdTestCase{{ - name: "default", - cmd: "version", - golden: "output/version.txt", - }, { - name: "short", - cmd: "version --short", - golden: "output/version-short.txt", - }, { - name: "template", - cmd: "version --template='Version: {{.Version}}'", - golden: "output/version-template.txt", - }, { - name: "client", - cmd: "version --client", - golden: "output/version-client.txt", - }, { - name: "client shorthand", - cmd: "version -c", - golden: "output/version-client-shorthand.txt", - }} - runTestCmd(t, tests) -} - -func TestVersionFileCompletion(t *testing.T) { - checkFileCompletion(t, "version", false) -}