From c86a8cbd53cacc6ef127d45122cfade0b50c0c0d Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Mon, 4 Jul 2022 18:43:29 -0300 Subject: [PATCH 001/271] perf(dep-up): do not update the same repo multiple times Signed-off-by: Felipe Santos --- pkg/downloader/manager.go | 18 +++++++++ pkg/downloader/manager_test.go | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index a5b0af080..d0f101dab 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -659,9 +659,27 @@ func (m *Manager) UpdateRepositories() error { return nil } +// Filter out duplicate repos by URL, including those with trailing slashes. +func dedupeRepos(repos []*repo.Entry) []*repo.Entry { + seen := make(map[string]*repo.Entry) + for _, r := range repos { + // Normalize URL by removing trailing slashes. + r.URL = strings.TrimSuffix(r.URL, "/") + seen[r.URL] = r + } + var unique []*repo.Entry + for _, r := range seen { + unique = append(unique, r) + } + return unique +} + func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error { var wg sync.WaitGroup + + repos = dedupeRepos(repos) + for _, c := range repos { r, err := repo.NewChartRepository(c, m.Getters) if err != nil { diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index f7ab1a568..13c94e116 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -26,6 +26,7 @@ import ( "helm.sh/helm/v3/pkg/chart/loader" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/getter" + "helm.sh/helm/v3/pkg/repo" "helm.sh/helm/v3/pkg/repo/repotest" ) @@ -572,3 +573,71 @@ func TestKey(t *testing.T) { } } } + +// Test dedupeRepos tests that the dedupeRepos function correctly deduplicates +func TestDedupeRepos(t *testing.T) { + tests := []struct { + name string + repos []*repo.Entry + want []*repo.Entry + }{ + { + name: "no duplicates", + repos: []*repo.Entry{ + { + URL: "https://example.com/charts", + }, + { + URL: "https://example.com/charts2", + }, + }, + want: []*repo.Entry{ + { + URL: "https://example.com/charts", + }, + { + URL: "https://example.com/charts2", + }, + }, + }, + { + name: "duplicates", + repos: []*repo.Entry{ + { + URL: "https://example.com/charts", + }, + { + URL: "https://example.com/charts", + }, + }, + want: []*repo.Entry{ + { + URL: "https://example.com/charts", + }, + }, + }, + { + name: "duplicates with trailing slash", + repos: []*repo.Entry{ + { + URL: "https://example.com/charts", + }, + { + URL: "https://example.com/charts/", + }, + }, + want: []*repo.Entry{ + { + URL: "https://example.com/charts", + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := dedupeRepos(tt.repos); !reflect.DeepEqual(got, tt.want) { + t.Errorf("received:\n%v\nwant:\n%v", got, tt.want) + } + }) + } +} From 2c8cfaea4175a41cce086ed45871c2113644899c Mon Sep 17 00:00:00 2001 From: KISHOREKUMAR THUDI Date: Sun, 17 Nov 2024 11:04:25 -0500 Subject: [PATCH 002/271] Replacing NewSimpleClientSet to NewClientSet due to deprecation Signed-off-by: KISHOREKUMAR THUDI --- pkg/action/action_test.go | 2 +- pkg/kube/ready_test.go | 60 +++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 149eb85b1..3bf64c3e0 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -344,7 +344,7 @@ func TestConfiguration_Init(t *testing.T) { } func TestGetVersionSet(t *testing.T) { - client := fakeclientset.NewSimpleClientset() + client := fakeclientset.NewClientset() vs, err := GetVersionSet(client.Discovery()) if err != nil { diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index 14bf8588b..32840fb6e 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -58,7 +58,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { { name: "IsReady Pod", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -74,7 +74,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { { name: "IsReady Pod returns error", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -134,7 +134,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { { name: "IsReady Job error while getting job", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -150,7 +150,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { { name: "IsReady Job", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -210,7 +210,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { { name: "IsReady Deployments error while getting current Deployment", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -227,7 +227,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { { name: "IsReady Deployments", //TODO fix this one fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -291,7 +291,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { { name: "IsReady PersistentVolumeClaim", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -307,7 +307,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { { name: "IsReady PersistentVolumeClaim with error", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -366,7 +366,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { { name: "IsReady Service", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -382,7 +382,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { { name: "IsReady Service with error", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -441,7 +441,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { { name: "IsReady DaemonSet", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -457,7 +457,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { { name: "IsReady DaemonSet with error", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -516,7 +516,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { { name: "IsReady StatefulSet", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -532,7 +532,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { { name: "IsReady StatefulSet with error", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -591,7 +591,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { { name: "IsReady ReplicationController", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -607,7 +607,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { { name: "IsReady ReplicationController with error", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -623,7 +623,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { { name: "IsReady ReplicationController and pods not ready for object", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -682,7 +682,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { { name: "IsReady ReplicaSet", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -698,7 +698,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { { name: "IsReady ReplicaSet not ready", fields: fields{ - client: fake.NewSimpleClientset(), + client: fake.NewClientset(), log: func(string, ...interface{}) {}, checkJobs: true, pausedAsReady: false, @@ -793,7 +793,7 @@ func Test_ReadyChecker_deploymentReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) if got := c.deploymentReady(tt.args.rs, tt.args.dep); got != tt.want { t.Errorf("deploymentReady() = %v, want %v", got, tt.want) } @@ -827,7 +827,7 @@ func Test_ReadyChecker_replicaSetReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) if got := c.replicaSetReady(tt.args.rs); got != tt.want { t.Errorf("replicaSetReady() = %v, want %v", got, tt.want) } @@ -861,7 +861,7 @@ func Test_ReadyChecker_replicationControllerReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) if got := c.replicationControllerReady(tt.args.rc); got != tt.want { t.Errorf("replicationControllerReady() = %v, want %v", got, tt.want) } @@ -916,7 +916,7 @@ func Test_ReadyChecker_daemonSetReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) if got := c.daemonSetReady(tt.args.ds); got != tt.want { t.Errorf("daemonSetReady() = %v, want %v", got, tt.want) } @@ -992,7 +992,7 @@ func Test_ReadyChecker_statefulSetReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) if got := c.statefulSetReady(tt.args.sts); got != tt.want { t.Errorf("statefulSetReady() = %v, want %v", got, tt.want) } @@ -1051,7 +1051,7 @@ func Test_ReadyChecker_podsReadyForObject(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) for _, pod := range tt.existPods { if _, err := c.client.CoreV1().Pods(defaultNamespace).Create(context.TODO(), &pod, metav1.CreateOptions{}); err != nil { t.Errorf("Failed to create Pod error: %v", err) @@ -1130,7 +1130,7 @@ func Test_ReadyChecker_jobReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) got, err := c.jobReady(tt.args.job) if (err != nil) != tt.wantErr { t.Errorf("jobReady() error = %v, wantErr %v", err, tt.wantErr) @@ -1169,7 +1169,7 @@ func Test_ReadyChecker_volumeReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) if got := c.volumeReady(tt.args.v); got != tt.want { t.Errorf("volumeReady() = %v, want %v", got, tt.want) } @@ -1214,7 +1214,7 @@ func Test_ReadyChecker_serviceReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) got := c.serviceReady(tt.args.service) if got != tt.want { t.Errorf("serviceReady() = %v, want %v", got, tt.want) @@ -1283,7 +1283,7 @@ func Test_ReadyChecker_crdBetaReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) got := c.crdBetaReady(tt.args.crdBeta) if got != tt.want { t.Errorf("crdBetaReady() = %v, want %v", got, tt.want) @@ -1352,7 +1352,7 @@ func Test_ReadyChecker_crdReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewSimpleClientset(), nil) + c := NewReadyChecker(fake.NewClientset(), nil) got := c.crdReady(tt.args.crdBeta) if got != tt.want { t.Errorf("crdBetaReady() = %v, want %v", got, tt.want) From baf8bffc124c49bab69ad6f6462a66e951210fdf Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 25 Nov 2024 11:20:22 +0000 Subject: [PATCH 003/271] feat: Add flags to enable CPU and memory profiling Add capability to profile cli command using https://go.dev/blog/pprof Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 14 +++++++- cmd/helm/profiling.go | 76 +++++++++++++++++++++++++++++++++++++++++++ cmd/helm/root.go | 23 +++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 cmd/helm/profiling.go diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c2f88453..aa67b5aef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -276,12 +276,24 @@ Like any good open source project, we use Pull Requests (PRs) to track code chan or explicitly request another OWNER do that for them. - If the owner of a PR is _not_ listed in `OWNERS`, any core maintainer may merge the PR. -#### Documentation PRs +### Documentation PRs Documentation PRs should be made on the docs repo: . Keeping Helm's documentation up to date is highly desirable, and is recommended for all user facing changes. Accurate and helpful documentation is critical for effectively communicating Helm's behavior to a wide audience. Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which would benefit from documentation changes, should apply the `docs needed` label. Larger changes associated with a HIP should track docs via that HIP. The `docs needed` label doesn't block PRs, and maintainers/PR reviewers should apply discretion judging in whether the `docs needed` label should be applied. +### Testing PRs + +During development, you need to add automated tests where possible. There are a few `make test*` targets that you can use to execute your unit or integration tests. If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to run collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the profiling data. + +Example invocation that collects profiling data +``` +helm show all bitnami/nginx --memprofile mem.prof --cpuprofile cpu.prof + +# Visualize graphs. You need to have installed graphviz in you system +go tool pprof -http=":8000" cpu.prof +``` + ## The Triager Each week, one of the core maintainers will serve as the designated "triager" starting after the diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go new file mode 100644 index 000000000..090532416 --- /dev/null +++ b/cmd/helm/profiling.go @@ -0,0 +1,76 @@ +// Profile CPU and memory usage of Helm commands + +package main + +import ( + "fmt" + "os" + "runtime" + "runtime/pprof" + "strings" + + "github.com/spf13/cobra" +) + +var ( + cpuProfileFile *os.File +) + +// startProfiling starts profiling CPU usage +func startProfiling(cpuprofile string) error { + if cpuprofile != "" { + var err error + cpuProfileFile, err = os.Create(cpuprofile) + if err != nil { + return fmt.Errorf("could not create CPU profile: %w", err) + } + if err := pprof.StartCPUProfile(cpuProfileFile); err != nil { + cpuProfileFile.Close() + cpuProfileFile = nil + return fmt.Errorf("could not start CPU profile: %w", err) + } + } + return nil +} + +// stopProfiling stops profiling CPU and memory usage and writes the results to +// the files specified by --cpuprofile and --memprofile flags respectively. +func stopProfiling(memprofile string) error { + errs := []string{} + + // Stop CPU profiling if it was started + if cpuProfileFile != nil { + pprof.StopCPUProfile() + err := cpuProfileFile.Close() + if err != nil { + errs = append(errs, err.Error()) + } + cpuProfileFile = nil + } + + if memprofile != "" { + f, err := os.Create(memprofile) + if err != nil { + errs = append(errs, err.Error()) + } + defer f.Close() + + runtime.GC() // get up-to-date statistics + if err := pprof.WriteHeapProfile(f); err != nil { + errs = append(errs, err.Error()) + } + } + + if len(errs) > 0 { + return fmt.Errorf("errors while stopping profiling: [%s]", strings.Join(errs, ", ")) + } + + return nil +} + +// addProfilingFlags adds the --cpuprofile and --memprofile flags to the given command. +func addProfilingFlags(cmd *cobra.Command) { + // Persistent flags to make available to subcommands + cmd.PersistentFlags().String("cpuprofile", "", "File path to write cpu profiling data") + cmd.PersistentFlags().String("memprofile", "", "File path to write memory profiling data") +} diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 2ba8a882e..fa1e6c6d0 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -95,6 +95,26 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Short: "The Helm package manager for Kubernetes.", Long: globalUsage, SilenceUsage: true, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + cpuprof, err := cmd.Flags().GetString("cpuprofile") + if err != nil { + log.Printf("Warning: Failed to get cpuprofile flag: %v", err) + } + + if err := startProfiling(cpuprof); err != nil { + log.Printf("Warning: Failed to start profiling: %v", err) + } + }, + PersistentPostRun: func(cmd *cobra.Command, args []string) { + memprof, err := cmd.Flags().GetString("memprofile") + if err != nil { + log.Printf("Warning: Failed to get memprofile flag: %v", err) + } + + if err := stopProfiling(memprof); err != nil { + log.Printf("Warning: Failed to stop profiling: %v", err) + } + }, } flags := cmd.PersistentFlags() @@ -206,6 +226,9 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string // Check for expired repositories checkForExpiredRepos(settings.RepositoryConfig) + // CPU and memory profiling flags that are available to all commands + addProfilingFlags(cmd) + return cmd, nil } From af622e8887fc104e020df6ed8deb6464653b34b6 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 25 Nov 2024 12:01:18 +0000 Subject: [PATCH 004/271] Additional review fixes from PR Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 6 +++--- cmd/helm/profiling.go | 16 +++++++++++++++- cmd/helm/root.go | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa67b5aef..796c661bc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -284,13 +284,13 @@ Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which wou ### Testing PRs -During development, you need to add automated tests where possible. There are a few `make test*` targets that you can use to execute your unit or integration tests. If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to run collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the profiling data. +During development, you need to add automated tests where possible. There are a few `make test*` targets that you can use to execute your unit or integration tests. If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. -Example invocation that collects profiling data +Example analysing collected profiling data ``` helm show all bitnami/nginx --memprofile mem.prof --cpuprofile cpu.prof -# Visualize graphs. You need to have installed graphviz in you system +# Visualize graphs. You need to have installed graphviz package in your system go tool pprof -http=":8000" cpu.prof ``` diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go index 090532416..e1ca62853 100644 --- a/cmd/helm/profiling.go +++ b/cmd/helm/profiling.go @@ -1,4 +1,18 @@ -// Profile CPU and memory usage of Helm commands +/* +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 diff --git a/cmd/helm/root.go b/cmd/helm/root.go index fa1e6c6d0..50cb87e37 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -95,7 +95,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Short: "The Helm package manager for Kubernetes.", Long: globalUsage, SilenceUsage: true, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { cpuprof, err := cmd.Flags().GetString("cpuprofile") if err != nil { log.Printf("Warning: Failed to get cpuprofile flag: %v", err) @@ -105,7 +105,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string log.Printf("Warning: Failed to start profiling: %v", err) } }, - PersistentPostRun: func(cmd *cobra.Command, args []string) { + PersistentPostRun: func(cmd *cobra.Command, _ []string) { memprof, err := cmd.Flags().GetString("memprofile") if err != nil { log.Printf("Warning: Failed to get memprofile flag: %v", err) From e6f829e6b61a2052adf35b35acef2543674f9a44 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Wed, 11 Dec 2024 14:15:58 +0000 Subject: [PATCH 005/271] Update CONTRIBUTING.md Co-authored-by: Terry Howe Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 796c661bc..fb875c2ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -282,7 +282,7 @@ Documentation PRs should be made on the docs repo: Date: Wed, 11 Dec 2024 14:20:54 +0000 Subject: [PATCH 006/271] Update CONTRIBUTING.md Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fb875c2ea..7b4254592 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -284,7 +284,7 @@ Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which wou ### Profiling PRs -During development, you need to add automated tests where possible. There are a few `make test*` targets that you can use to execute your unit or integration tests. If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. +If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. Example analysing collected profiling data ``` From d4175cfcff087420675451b177ef610a760802e4 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Wed, 11 Dec 2024 15:17:30 +0000 Subject: [PATCH 007/271] Move pprof paths to HELM_PPROF env variable Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 4 +- cmd/helm/profiling.go | 44 ++++++++++++++++++--- cmd/helm/profiling_test.go | 79 ++++++++++++++++++++++++++++++++++++++ cmd/helm/root.go | 14 +------ 4 files changed, 122 insertions(+), 19 deletions(-) create mode 100644 cmd/helm/profiling_test.go diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b4254592..0a90054d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -284,11 +284,11 @@ Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which wou ### Profiling PRs -If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. +If your contribution requires profiling to check memory and/or CPU usage, you can set `HELM_PPROF=cpu=/path/to/cpu.prof,mem=/path/to/mem.prof` environment variable to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. Example analysing collected profiling data ``` -helm show all bitnami/nginx --memprofile mem.prof --cpuprofile cpu.prof +HELM_PPROF=cpu=/path/to/cpu.prof,mem=/path/to/mem.prof helm show all bitnami/nginx # Visualize graphs. You need to have installed graphviz package in your system go tool pprof -http=":8000" cpu.prof diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go index e1ca62853..e231a3e0a 100644 --- a/cmd/helm/profiling.go +++ b/cmd/helm/profiling.go @@ -19,6 +19,8 @@ package main import ( "fmt" "os" + "path" + "path/filepath" "runtime" "runtime/pprof" "strings" @@ -28,11 +30,17 @@ import ( var ( cpuProfileFile *os.File + pprofPaths map[string]string ) +func init() { + pprofPaths = parsePProfPaths(os.Getenv("HELM_PPROF")) +} + // startProfiling starts profiling CPU usage -func startProfiling(cpuprofile string) error { - if cpuprofile != "" { +func startProfiling() error { + cpuprofile, ok := pprofPaths["cpu"] + if ok && cpuprofile != "" { var err error cpuProfileFile, err = os.Create(cpuprofile) if err != nil { @@ -48,8 +56,8 @@ func startProfiling(cpuprofile string) error { } // stopProfiling stops profiling CPU and memory usage and writes the results to -// the files specified by --cpuprofile and --memprofile flags respectively. -func stopProfiling(memprofile string) error { +// the files specified by HELM_PPROF=cpu=/path/to/cpu.prof,mem=/path/to/mem.prof +func stopProfiling() error { errs := []string{} // Stop CPU profiling if it was started @@ -62,7 +70,8 @@ func stopProfiling(memprofile string) error { cpuProfileFile = nil } - if memprofile != "" { + memprofile, ok := pprofPaths["mem"] + if ok && memprofile != "" { f, err := os.Create(memprofile) if err != nil { errs = append(errs, err.Error()) @@ -88,3 +97,28 @@ func addProfilingFlags(cmd *cobra.Command) { cmd.PersistentFlags().String("cpuprofile", "", "File path to write cpu profiling data") cmd.PersistentFlags().String("memprofile", "", "File path to write memory profiling data") } + +func parsePProfPaths(env string) map[string]string { + // Initial empty paths + m := map[string]string{} + for _, pprofs := range strings.Split(env, ",") { + // Is of the format mem=/path/to/memprof + tuple := strings.Split(pprofs, "=") + if len(tuple) != 2 { + continue + } + if tuple[0] != "cpu" && tuple[0] != "mem" { + continue + } + + s, err := filepath.Abs(path.Clean(tuple[1])) + if err != nil { + continue + } + if !strings.HasSuffix(s, string(filepath.Separator)) { + // Ensure its not a directory + m[tuple[0]] = s + } + } + return m +} diff --git a/cmd/helm/profiling_test.go b/cmd/helm/profiling_test.go new file mode 100644 index 000000000..65928edbb --- /dev/null +++ b/cmd/helm/profiling_test.go @@ -0,0 +1,79 @@ +/* +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" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_parsePProfPaths(t *testing.T) { + cwd, err := os.Getwd() + require.NoError(t, err) + + tests := []struct { + name string + env string + want map[string]string + }{ + { + name: "no env", + env: "", + want: map[string]string{}, + }, + { + name: "single path", + env: "cpu=cpu.pprof", + want: map[string]string{ + "cpu": cwd + "/cpu.pprof", + }, + }, + { + name: "mem and cpu paths", + env: "cpu=cpu.pprof,mem=mem.pprof", + want: map[string]string{ + "cpu": cwd + "/cpu.pprof", + "mem": cwd + "/mem.pprof", + }, + }, + { + name: "extra commas", + env: "cpu=cpu.pprof,mem=mem.pprof,", + want: map[string]string{ + "cpu": cwd + "/cpu.pprof", + "mem": cwd + "/mem.pprof", + }, + }, + { + name: "unknown keys", + env: "cpu=cpu.pprof,mem=mem.pprof,foo=bar", + want: map[string]string{ + "cpu": cwd + "/cpu.pprof", + "mem": cwd + "/mem.pprof", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := parsePProfPaths(tt.env) + assert.Equalf(t, tt.want, got, "parsePProfPaths() = %v, want %v", got, tt.want) + }) + } +} diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 50cb87e37..5f739d248 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -96,22 +96,12 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Long: globalUsage, SilenceUsage: true, PersistentPreRun: func(cmd *cobra.Command, _ []string) { - cpuprof, err := cmd.Flags().GetString("cpuprofile") - if err != nil { - log.Printf("Warning: Failed to get cpuprofile flag: %v", err) - } - - if err := startProfiling(cpuprof); err != nil { + if err := startProfiling(); err != nil { log.Printf("Warning: Failed to start profiling: %v", err) } }, PersistentPostRun: func(cmd *cobra.Command, _ []string) { - memprof, err := cmd.Flags().GetString("memprofile") - if err != nil { - log.Printf("Warning: Failed to get memprofile flag: %v", err) - } - - if err := stopProfiling(memprof); err != nil { + if err := stopProfiling(); err != nil { log.Printf("Warning: Failed to stop profiling: %v", err) } }, From 5b1eb784cb2a1a90ecf4710b3088d2312c3875d4 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Wed, 11 Dec 2024 15:20:45 +0000 Subject: [PATCH 008/271] Fix linter warning Signed-off-by: Evans Mungai --- cmd/helm/root.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 5f739d248..edc6376ae 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -95,12 +95,12 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Short: "The Helm package manager for Kubernetes.", Long: globalUsage, SilenceUsage: true, - PersistentPreRun: func(cmd *cobra.Command, _ []string) { + PersistentPreRun: func(_ *cobra.Command, _ []string) { if err := startProfiling(); err != nil { log.Printf("Warning: Failed to start profiling: %v", err) } }, - PersistentPostRun: func(cmd *cobra.Command, _ []string) { + PersistentPostRun: func(_ *cobra.Command, _ []string) { if err := stopProfiling(); err != nil { log.Printf("Warning: Failed to stop profiling: %v", err) } From e3e84343d256ef29b7aff5f6b6e6b4f41d101a64 Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Sat, 14 Dec 2024 21:24:30 -0800 Subject: [PATCH 009/271] refactor: tlsutil use options pattern Signed-off-by: George Jenkins --- cmd/helm/root.go | 7 +- internal/tlsutil/cfg.go | 58 --------------- internal/tlsutil/tls.go | 118 +++++++++++++++++++++---------- internal/tlsutil/tls_test.go | 105 +++++++++++++++++++++++++++ internal/tlsutil/tlsutil_test.go | 114 ----------------------------- pkg/getter/httpgetter.go | 6 +- pkg/getter/httpgetter_test.go | 6 +- pkg/getter/ocigetter.go | 6 +- pkg/pusher/ocipusher.go | 6 +- pkg/registry/util.go | 6 +- pkg/registry/utils_test.go | 9 ++- pkg/repo/repotest/server.go | 6 +- 12 files changed, 229 insertions(+), 218 deletions(-) delete mode 100644 internal/tlsutil/cfg.go create mode 100644 internal/tlsutil/tls_test.go delete mode 100644 internal/tlsutil/tlsutil_test.go diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 2ba8a882e..02d9b5404 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -297,7 +297,12 @@ func newDefaultRegistryClient(plainHTTP bool, username, password string) (*regis func newRegistryClientWithTLS( certFile, keyFile, caFile string, insecureSkipTLSverify bool, username, password string, ) (*registry.Client, error) { - tlsConf, err := tlsutil.NewClientTLS(certFile, keyFile, caFile, insecureSkipTLSverify) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(insecureSkipTLSverify), + tlsutil.WithCertKeyPairFiles(certFile, keyFile), + tlsutil.WithCAFile(caFile), + ) + if err != nil { return nil, fmt.Errorf("can't create TLS config for client: %w", err) } diff --git a/internal/tlsutil/cfg.go b/internal/tlsutil/cfg.go deleted file mode 100644 index 8b9d4329f..000000000 --- a/internal/tlsutil/cfg.go +++ /dev/null @@ -1,58 +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 tlsutil - -import ( - "crypto/tls" - "crypto/x509" - "os" - - "github.com/pkg/errors" -) - -// Options represents configurable options used to create client and server TLS configurations. -type Options struct { - CaCertFile string - // If either the KeyFile or CertFile is empty, ClientConfig() will not load them. - KeyFile string - CertFile string - // Client-only options - InsecureSkipVerify bool -} - -// ClientConfig returns a TLS configuration for use by a Helm client. -func ClientConfig(opts Options) (cfg *tls.Config, err error) { - var cert *tls.Certificate - var pool *x509.CertPool - - if opts.CertFile != "" || opts.KeyFile != "" { - if cert, err = CertFromFilePair(opts.CertFile, opts.KeyFile); err != nil { - if os.IsNotExist(err) { - return nil, errors.Wrapf(err, "could not load x509 key pair (cert: %q, key: %q)", opts.CertFile, opts.KeyFile) - } - return nil, errors.Wrapf(err, "could not read x509 key pair (cert: %q, key: %q)", opts.CertFile, opts.KeyFile) - } - } - if !opts.InsecureSkipVerify && opts.CaCertFile != "" { - if pool, err = CertPoolFromFile(opts.CaCertFile); err != nil { - return nil, err - } - } - - cfg = &tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify, Certificates: []tls.Certificate{*cert}, RootCAs: pool} - return cfg, nil -} diff --git a/internal/tlsutil/tls.go b/internal/tlsutil/tls.go index 7cd1dace9..645834c29 100644 --- a/internal/tlsutil/tls.go +++ b/internal/tlsutil/tls.go @@ -19,60 +19,104 @@ package tlsutil import ( "crypto/tls" "crypto/x509" + "fmt" "os" - "github.com/pkg/errors" + "errors" ) -// NewClientTLS returns tls.Config appropriate for client auth. -func NewClientTLS(certFile, keyFile, caFile string, insecureSkipTLSverify bool) (*tls.Config, error) { - config := tls.Config{ - InsecureSkipVerify: insecureSkipTLSverify, +type TLSConfigOptions struct { + insecureSkipTLSverify bool + certPEMBlock, keyPEMBlock []byte + caPEMBlock []byte +} + +type TLSConfigOption func(options *TLSConfigOptions) error + +func WithInsecureSkipVerify(insecureSkipTLSverify bool) TLSConfigOption { + return func(options *TLSConfigOptions) error { + options.insecureSkipTLSverify = insecureSkipTLSverify + + return nil } +} + +func WithCertKeyPairFiles(certFile, keyFile string) TLSConfigOption { + return func(options *TLSConfigOptions) error { + if certFile == "" && keyFile == "" { + return nil + } - if certFile != "" && keyFile != "" { - cert, err := CertFromFilePair(certFile, keyFile) + certPEMBlock, err := os.ReadFile(certFile) if err != nil { - return nil, err + return fmt.Errorf("unable to read cert file: %q: %w", certFile, err) } - config.Certificates = []tls.Certificate{*cert} - } - if caFile != "" { - cp, err := CertPoolFromFile(caFile) + keyPEMBlock, err := os.ReadFile(keyFile) if err != nil { - return nil, err + return fmt.Errorf("unable to read key file: %q: %w", keyFile, err) } - config.RootCAs = cp + + options.certPEMBlock = certPEMBlock + options.keyPEMBlock = keyPEMBlock + + return nil } +} - return &config, nil +func WithCAFile(caFile string) TLSConfigOption { + return func(options *TLSConfigOptions) error { + if caFile == "" { + return nil + } + + caPEMBlock, err := os.ReadFile(caFile) + if err != nil { + return fmt.Errorf("can't read CA file: %q: %w", caFile, err) + } + + options.caPEMBlock = caPEMBlock + + return nil + } } -// CertPoolFromFile returns an x509.CertPool containing the certificates -// in the given PEM-encoded file. -// Returns an error if the file could not be read, a certificate could not -// be parsed, or if the file does not contain any certificates -func CertPoolFromFile(filename string) (*x509.CertPool, error) { - b, err := os.ReadFile(filename) - if err != nil { - return nil, errors.Errorf("can't read CA file: %v", filename) +func NewTLSConfig(options ...TLSConfigOption) (*tls.Config, error) { + to := TLSConfigOptions{} + + errs := []error{} + for _, option := range options { + err := option(&to) + if err != nil { + errs = append(errs, err) + } } - cp := x509.NewCertPool() - if !cp.AppendCertsFromPEM(b) { - return nil, errors.Errorf("failed to append certificates from file: %s", filename) + + if len(errs) > 0 { + return nil, errors.Join(errs...) } - return cp, nil -} -// CertFromFilePair returns a tls.Certificate containing the -// certificates public/private key pair from a pair of given PEM-encoded files. -// Returns an error if the file could not be read, a certificate could not -// be parsed, or if the file does not contain any certificates -func CertFromFilePair(certFile, keyFile string) (*tls.Certificate, error) { - cert, err := tls.LoadX509KeyPair(certFile, keyFile) - if err != nil { - return nil, errors.Wrapf(err, "can't load key pair from cert %s and key %s", certFile, keyFile) + config := tls.Config{ + InsecureSkipVerify: to.insecureSkipTLSverify, } - return &cert, err + + if len(to.certPEMBlock) > 0 && len(to.keyPEMBlock) > 0 { + cert, err := tls.X509KeyPair(to.certPEMBlock, to.keyPEMBlock) + if err != nil { + return nil, fmt.Errorf("unable to load cert from key pair: %w", err) + } + + config.Certificates = []tls.Certificate{cert} + } + + if len(to.caPEMBlock) > 0 { + cp := x509.NewCertPool() + if !cp.AppendCertsFromPEM(to.caPEMBlock) { + return nil, fmt.Errorf("failed to append certificates from pem block") + } + + config.RootCAs = cp + } + + return &config, nil } diff --git a/internal/tlsutil/tls_test.go b/internal/tlsutil/tls_test.go new file mode 100644 index 000000000..eb1cc183e --- /dev/null +++ b/internal/tlsutil/tls_test.go @@ -0,0 +1,105 @@ +/* +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 tlsutil + +import ( + "path/filepath" + "testing" +) + +const tlsTestDir = "../../testdata" + +const ( + testCaCertFile = "rootca.crt" + testCertFile = "crt.pem" + testKeyFile = "key.pem" +) + +func testfile(t *testing.T, file string) (path string) { + var err error + if path, err = filepath.Abs(filepath.Join(tlsTestDir, file)); err != nil { + t.Fatalf("error getting absolute path to test file %q: %v", file, err) + } + return path +} + +func TestNewTLSConfig(t *testing.T) { + certFile := testfile(t, testCertFile) + keyFile := testfile(t, testKeyFile) + caCertFile := testfile(t, testCaCertFile) + insecureSkipTLSverify := false + + { + cfg, err := NewTLSConfig( + WithInsecureSkipVerify(insecureSkipTLSverify), + WithCertKeyPairFiles(certFile, keyFile), + WithCAFile(caCertFile), + ) + if err != nil { + t.Error(err) + } + + if got := len(cfg.Certificates); got != 1 { + t.Fatalf("expecting 1 client certificates, got %d", got) + } + if cfg.InsecureSkipVerify { + t.Fatalf("insecure skip verify mismatch, expecting false") + } + if cfg.RootCAs == nil { + t.Fatalf("mismatch tls RootCAs, expecting non-nil") + } + } + { + cfg, err := NewTLSConfig( + WithInsecureSkipVerify(insecureSkipTLSverify), + WithCAFile(caCertFile), + ) + if err != nil { + t.Error(err) + } + + if got := len(cfg.Certificates); got != 0 { + t.Fatalf("expecting 0 client certificates, got %d", got) + } + if cfg.InsecureSkipVerify { + t.Fatalf("insecure skip verify mismatch, expecting false") + } + if cfg.RootCAs == nil { + t.Fatalf("mismatch tls RootCAs, expecting non-nil") + } + } + + { + cfg, err := NewTLSConfig( + WithInsecureSkipVerify(insecureSkipTLSverify), + WithCertKeyPairFiles(certFile, keyFile), + ) + if err != nil { + t.Error(err) + } + + if got := len(cfg.Certificates); got != 1 { + t.Fatalf("expecting 1 client certificates, got %d", got) + } + if cfg.InsecureSkipVerify { + t.Fatalf("insecure skip verify mismatch, expecting false") + } + if cfg.RootCAs != nil { + t.Fatalf("mismatch tls RootCAs, expecting nil") + } + } +} diff --git a/internal/tlsutil/tlsutil_test.go b/internal/tlsutil/tlsutil_test.go deleted file mode 100644 index e31a873d3..000000000 --- a/internal/tlsutil/tlsutil_test.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 tlsutil - -import ( - "path/filepath" - "testing" -) - -const tlsTestDir = "../../testdata" - -const ( - testCaCertFile = "rootca.crt" - testCertFile = "crt.pem" - testKeyFile = "key.pem" -) - -func TestClientConfig(t *testing.T) { - opts := Options{ - CaCertFile: testfile(t, testCaCertFile), - CertFile: testfile(t, testCertFile), - KeyFile: testfile(t, testKeyFile), - InsecureSkipVerify: false, - } - - cfg, err := ClientConfig(opts) - if err != nil { - t.Fatalf("error building tls client config: %v", err) - } - - if got := len(cfg.Certificates); got != 1 { - t.Fatalf("expecting 1 client certificates, got %d", got) - } - if cfg.InsecureSkipVerify { - t.Fatalf("insecure skip verify mismatch, expecting false") - } - if cfg.RootCAs == nil { - t.Fatalf("mismatch tls RootCAs, expecting non-nil") - } -} - -func testfile(t *testing.T, file string) (path string) { - var err error - if path, err = filepath.Abs(filepath.Join(tlsTestDir, file)); err != nil { - t.Fatalf("error getting absolute path to test file %q: %v", file, err) - } - return path -} - -func TestNewClientTLS(t *testing.T) { - certFile := testfile(t, testCertFile) - keyFile := testfile(t, testKeyFile) - caCertFile := testfile(t, testCaCertFile) - insecureSkipTLSverify := false - - cfg, err := NewClientTLS(certFile, keyFile, caCertFile, insecureSkipTLSverify) - if err != nil { - t.Error(err) - } - - if got := len(cfg.Certificates); got != 1 { - t.Fatalf("expecting 1 client certificates, got %d", got) - } - if cfg.InsecureSkipVerify { - t.Fatalf("insecure skip verify mismatch, expecting false") - } - if cfg.RootCAs == nil { - t.Fatalf("mismatch tls RootCAs, expecting non-nil") - } - - cfg, err = NewClientTLS("", "", caCertFile, insecureSkipTLSverify) - if err != nil { - t.Error(err) - } - - if got := len(cfg.Certificates); got != 0 { - t.Fatalf("expecting 0 client certificates, got %d", got) - } - if cfg.InsecureSkipVerify { - t.Fatalf("insecure skip verify mismatch, expecting false") - } - if cfg.RootCAs == nil { - t.Fatalf("mismatch tls RootCAs, expecting non-nil") - } - - cfg, err = NewClientTLS(certFile, keyFile, "", insecureSkipTLSverify) - if err != nil { - t.Error(err) - } - - if got := len(cfg.Certificates); got != 1 { - t.Fatalf("expecting 1 client certificates, got %d", got) - } - if cfg.InsecureSkipVerify { - t.Fatalf("insecure skip verify mismatch, expecting false") - } - if cfg.RootCAs != nil { - t.Fatalf("mismatch tls RootCAs, expecting nil") - } -} diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index df3dcd910..6931e2031 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -128,7 +128,11 @@ func (g *HTTPGetter) httpClient() (*http.Client, error) { }) if (g.opts.certFile != "" && g.opts.keyFile != "") || g.opts.caFile != "" || g.opts.insecureSkipVerifyTLS { - tlsConf, err := tlsutil.NewClientTLS(g.opts.certFile, g.opts.keyFile, g.opts.caFile, g.opts.insecureSkipVerifyTLS) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(g.opts.insecureSkipVerifyTLS), + tlsutil.WithCertKeyPairFiles(g.opts.certFile, g.opts.keyFile), + tlsutil.WithCAFile(g.opts.caFile), + ) if err != nil { return nil, errors.Wrap(err, "can't create TLS config for client") } diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 2c38c6154..c38966bff 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -311,7 +311,11 @@ func TestDownloadTLS(t *testing.T) { insecureSkipTLSverify := false tlsSrv := httptest.NewUnstartedServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})) - tlsConf, err := tlsutil.NewClientTLS(pub, priv, ca, insecureSkipTLSverify) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(insecureSkipTLSverify), + tlsutil.WithCertKeyPairFiles(pub, priv), + tlsutil.WithCAFile(ca), + ) if err != nil { t.Fatal(errors.Wrap(err, "can't create TLS config for client")) } diff --git a/pkg/getter/ocigetter.go b/pkg/getter/ocigetter.go index 0547cdcbb..c6e80dc65 100644 --- a/pkg/getter/ocigetter.go +++ b/pkg/getter/ocigetter.go @@ -124,7 +124,11 @@ func (g *OCIGetter) newRegistryClient() (*registry.Client, error) { }) if (g.opts.certFile != "" && g.opts.keyFile != "") || g.opts.caFile != "" || g.opts.insecureSkipVerifyTLS { - tlsConf, err := tlsutil.NewClientTLS(g.opts.certFile, g.opts.keyFile, g.opts.caFile, g.opts.insecureSkipVerifyTLS) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(g.opts.insecureSkipVerifyTLS), + tlsutil.WithCertKeyPairFiles(g.opts.certFile, g.opts.keyFile), + tlsutil.WithCAFile(g.opts.caFile), + ) if err != nil { return nil, fmt.Errorf("can't create TLS config for client: %w", err) } diff --git a/pkg/pusher/ocipusher.go b/pkg/pusher/ocipusher.go index 33296aadd..dad498432 100644 --- a/pkg/pusher/ocipusher.go +++ b/pkg/pusher/ocipusher.go @@ -111,7 +111,11 @@ func NewOCIPusher(ops ...Option) (Pusher, error) { func (pusher *OCIPusher) newRegistryClient() (*registry.Client, error) { if (pusher.opts.certFile != "" && pusher.opts.keyFile != "") || pusher.opts.caFile != "" || pusher.opts.insecureSkipTLSverify { - tlsConf, err := tlsutil.NewClientTLS(pusher.opts.certFile, pusher.opts.keyFile, pusher.opts.caFile, pusher.opts.insecureSkipTLSverify) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(pusher.opts.insecureSkipTLSverify), + tlsutil.WithCertKeyPairFiles(pusher.opts.certFile, pusher.opts.keyFile), + tlsutil.WithCAFile(pusher.opts.caFile), + ) if err != nil { return nil, errors.Wrap(err, "can't create TLS config for client") } diff --git a/pkg/registry/util.go b/pkg/registry/util.go index 727cdae03..c1a0b4194 100644 --- a/pkg/registry/util.go +++ b/pkg/registry/util.go @@ -142,7 +142,11 @@ func parseReference(raw string) (registry.Reference, error) { // NewRegistryClientWithTLS is a helper function to create a new registry client with TLS enabled. func NewRegistryClientWithTLS(out io.Writer, certFile, keyFile, caFile string, insecureSkipTLSverify bool, registryConfig string, debug bool) (*Client, error) { - tlsConf, err := tlsutil.NewClientTLS(certFile, keyFile, caFile, insecureSkipTLSverify) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(insecureSkipTLSverify), + tlsutil.WithCertKeyPairFiles(certFile, keyFile), + tlsutil.WithCAFile(caFile), + ) if err != nil { return nil, fmt.Errorf("can't create TLS config for client: %s", err) } diff --git a/pkg/registry/utils_test.go b/pkg/registry/utils_test.go index ee78ea76f..e10e5b500 100644 --- a/pkg/registry/utils_test.go +++ b/pkg/registry/utils_test.go @@ -95,9 +95,14 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry { if tlsEnabled { var tlsConf *tls.Config if insecure { - tlsConf, err = tlsutil.NewClientTLS("", "", "", true) + tlsConf, err = tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(true), + ) } else { - tlsConf, err = tlsutil.NewClientTLS(tlsCert, tlsKey, tlsCA, false) + tlsConf, err = tlsutil.NewTLSConfig( + tlsutil.WithCertKeyPairFiles(tlsCert, tlsKey), + tlsutil.WithCAFile(tlsCA), + ) } httpClient := &http.Client{ Transport: &http.Transport{ diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index 4a86707cf..cc7494d54 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -367,7 +367,11 @@ func (s *Server) StartTLS() { } http.FileServer(http.Dir(s.Root())).ServeHTTP(w, r) })) - tlsConf, err := tlsutil.NewClientTLS(pub, priv, ca, insecure) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(insecure), + tlsutil.WithCertKeyPairFiles(pub, priv), + tlsutil.WithCAFile(ca), + ) if err != nil { panic(err) } From 41700f02480ad9ab14924974231cb9b6ec17cde5 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 17 Dec 2024 23:48:57 +0000 Subject: [PATCH 010/271] WIP Signed-off-by: Austin Abro --- go.mod | 3 +++ go.sum | 15 +++++++++++ pkg/kube/client.go | 67 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 9d27e2b1f..d7500a674 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/kubectl v0.31.3 oras.land/oras-go v1.2.5 + sigs.k8s.io/cli-utils v0.37.2 sigs.k8s.io/yaml v1.4.0 ) @@ -76,6 +77,7 @@ require ( github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/color v1.13.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -183,6 +185,7 @@ require ( k8s.io/component-base v0.31.3 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect + sigs.k8s.io/controller-runtime v0.18.4 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kustomize/api v0.17.2 // indirect sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect diff --git a/go.sum b/go.sum index 654fc5178..a575e35cf 100644 --- a/go.sum +++ b/go.sum @@ -112,6 +112,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= +github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= @@ -136,6 +138,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -146,6 +150,7 @@ github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= @@ -443,6 +448,10 @@ go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93V go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -454,6 +463,8 @@ golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72 golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -630,6 +641,10 @@ k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1 k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo= oras.land/oras-go v1.2.5/go.mod h1:PuAwRShRZCsZb7g8Ar3jKKQR/2A/qN+pkYxIOd/FAoo= +sigs.k8s.io/cli-utils v0.37.2 h1:GOfKw5RV2HDQZDJlru5KkfLO1tbxqMoyn1IYUxqBpNg= +sigs.k8s.io/cli-utils v0.37.2/go.mod h1:V+IZZr4UoGj7gMJXklWBg6t5xbdThFBcpj4MrZuCYco= +sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= +sigs.k8s.io/controller-runtime v0.18.4/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/api v0.17.2 h1:E7/Fjk7V5fboiuijoZHgs4aHuexi5Y2loXlVOAVAG5g= diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 4d93c91b9..f2bb06130 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -36,6 +36,13 @@ import ( apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" + "sigs.k8s.io/cli-utils/pkg/kstatus/status" + "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" + "sigs.k8s.io/cli-utils/pkg/object" multierror "github.com/hashicorp/go-multierror" "k8s.io/apimachinery/pkg/api/meta" @@ -44,7 +51,6 @@ import ( metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/watch" @@ -296,6 +302,65 @@ func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { return w.waitForResources(resources) } +// WaitForReady waits for all of the objects to reach a ready state. +func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, resourceList ResourceList) error { + cancelCtx, cancel := context.WithCancel(ctx) + defer cancel() + // TODO maybe a simpler way to transfer the objects + runtimeObjs := []runtime.Object{} + for _, resource := range resourceList { + runtimeObjs = append(runtimeObjs, resource.Object) + } + resources := []object.ObjMetadata{} + for _, runtimeObj := range runtimeObjs { + obj, err := object.RuntimeToObjMeta(runtimeObj) + if err != nil { + return err + } + resources = append(resources, obj) + } + + eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) + statusCollector := collector.NewResourceStatusCollector(resources) + done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( + func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { + rss := []*event.ResourceStatus{} + for _, rs := range statusCollector.ResourceStatuses { + if rs == nil { + continue + } + rss = append(rss, rs) + } + desired := status.CurrentStatus + if aggregator.AggregateStatus(rss, desired) == desired { + cancel() + return + } + }), + ) + <-done + + if statusCollector.Error != nil { + return statusCollector.Error + } + + // Only check parent context error, otherwise we would error when desired status is achieved. + if ctx.Err() != nil { + // todo use err + var err error + for _, id := range resources { + rs := statusCollector.ResourceStatuses[id] + if rs.Status == status.CurrentStatus { + continue + } + err = fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status) + } + return fmt.Errorf("not all resources ready: %w: %w", ctx.Err(), err) + } + + return nil +} + // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. func (c *Client) WaitWithJobs(resources ResourceList, timeout time.Duration) error { cs, err := c.getKubeClient() From 6f7ac066ae8a487621c169a5e588ebd4a19df284 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 23 Dec 2024 22:29:22 +0000 Subject: [PATCH 011/271] extending factory to enable getting a watcher Signed-off-by: Austin Abro --- pkg/kube/client.go | 45 ++++++++++++++++++++++++++++++++--------- pkg/kube/client_test.go | 5 +++++ pkg/kube/factory.go | 6 ++++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 8bcd4824f..a25a6fcc3 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -43,6 +43,7 @@ import ( "sigs.k8s.io/cli-utils/pkg/kstatus/status" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" "sigs.k8s.io/cli-utils/pkg/object" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" multierror "github.com/hashicorp/go-multierror" "k8s.io/apimachinery/pkg/api/meta" @@ -56,6 +57,7 @@ import ( "k8s.io/apimachinery/pkg/watch" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" + "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" @@ -289,17 +291,43 @@ func getResource(info *resource.Info) (runtime.Object, error) { // Wait waits up to the given timeout for the specified resources to be ready. func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { - cs, err := c.getKubeClient() + // cs, err := c.getKubeClient() + // if err != nil { + // return err + // } + // checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) + // w := waiter{ + // c: checker, + // log: c.Log, + // timeout: timeout, + // } + cfg, err := c.Factory.ToRESTConfig() if err != nil { return err } - checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) - w := waiter{ - c: checker, - log: c.Log, - timeout: timeout, + dynamicClient, err := dynamic.NewForConfig(cfg) + if err != nil { + return err } - return w.waitForResources(resources) + // Not sure if I should use factory methods to get this http client or I should do this + // For example, I could likely use this as well, but it seems like I should use the factory methods instead + // httpClient, err := rest.HTTPClientFor(cfg) + // if err != nil { + // return err + // } + client, err := c.Factory.RESTClient() + if err != nil { + return err + } + restMapper, err := apiutil.NewDynamicRESTMapper(cfg, client.Client) + if err != nil { + return err + } + sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) + // return sw, nil + ctx, cancel := context.WithTimeout(context.TODO(), timeout) + defer cancel() + return WaitForReady(ctx, sw, resources) } // WaitForReady waits for all of the objects to reach a ready state. @@ -319,7 +347,6 @@ func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, resourceList Re } resources = append(resources, obj) } - eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( @@ -346,7 +373,6 @@ func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, resourceList Re // Only check parent context error, otherwise we would error when desired status is achieved. if ctx.Err() != nil { - // todo use err var err error for _, id := range resources { rs := statusCollector.ResourceStatuses[id] @@ -357,7 +383,6 @@ func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, resourceList Re } return fmt.Errorf("not all resources ready: %w: %w", ctx.Err(), err) } - return nil } diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index f2d6bcb59..7f3ba65be 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -453,12 +453,17 @@ func TestPerform(t *testing.T) { } } +// Likely it is not possible to get this test to work with kstatus given that it seems +// kstatus is not making constant get checks on the resources and is instead waiting for events +// Potentially the test could be reworked to make the pods after five seconds +// would need this -> func TestWait(t *testing.T) { podList := newPodList("starfish", "otter", "squid") var created *time.Time c := newTestClient(t) + c.Factory.(*cmdtesting.TestFactory).ClientConfigVal = cmdtesting.DefaultClientConfig() c.Factory.(*cmdtesting.TestFactory).Client = &fake.RESTClient{ NegotiatedSerializer: unstructuredSerializer, Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { diff --git a/pkg/kube/factory.go b/pkg/kube/factory.go index f19d62dc3..b0b506282 100644 --- a/pkg/kube/factory.go +++ b/pkg/kube/factory.go @@ -17,9 +17,11 @@ limitations under the License. package kube // import "helm.sh/helm/v3/pkg/kube" import ( + "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" + restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/kubectl/pkg/validation" ) @@ -33,6 +35,7 @@ import ( // Helm does not need are not impacted or exposed. This minimizes the impact of Kubernetes changes // being exposed. type Factory interface { + genericclioptions.RESTClientGetter // ToRawKubeConfigLoader return kubeconfig loader as-is ToRawKubeConfigLoader() clientcmd.ClientConfig @@ -42,6 +45,9 @@ type Factory interface { // KubernetesClientSet gives you back an external clientset KubernetesClientSet() (*kubernetes.Clientset, error) + // Returns a RESTClient for accessing Kubernetes resources or an error. + RESTClient() (*restclient.RESTClient, error) + // NewBuilder returns an object that assists in loading objects from both disk and the server // and which implements the common patterns for CLI interactions with generic resources. NewBuilder() *resource.Builder From a61a35240e3e99af8386605de8cdbd9564051d2f Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 23 Dec 2024 22:55:09 +0000 Subject: [PATCH 012/271] understand it better Signed-off-by: Austin Abro --- pkg/kube/client.go | 1 + pkg/kube/interface.go | 1 + pkg/kube/kready.go | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 pkg/kube/kready.go diff --git a/pkg/kube/client.go b/pkg/kube/client.go index a25a6fcc3..b38b4b094 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -301,6 +301,7 @@ func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { // log: c.Log, // timeout: timeout, // } + // w.waitForResources() cfg, err := c.Factory.ToRESTConfig() if err != nil { return err diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index ce42ed950..af3823a3e 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -33,6 +33,7 @@ type Interface interface { Create(resources ResourceList) (*Result, error) // Wait waits up to the given timeout for the specified resources to be ready. + // TODO introduce another interface for the waiting of the KubeClient Wait(resources ResourceList, timeout time.Duration) error // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. diff --git a/pkg/kube/kready.go b/pkg/kube/kready.go new file mode 100644 index 000000000..0752ba481 --- /dev/null +++ b/pkg/kube/kready.go @@ -0,0 +1,18 @@ +/* +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 kube // import "helm.sh/helm/v3/pkg/kube" + From 4c1758143fd5bfed4ed42fa73fd051ae6e90f642 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 26 Dec 2024 16:09:54 +0000 Subject: [PATCH 013/271] basic design up and balling Signed-off-by: Austin Abro --- pkg/action/action.go | 3 +- pkg/kube/client.go | 99 ++++++++++++++++++++--------------------- pkg/kube/client_test.go | 36 +++++++++++++-- pkg/kube/interface.go | 32 +++++++------ pkg/kube/kready.go | 80 +++++++++++++++++++++++++++++++++ pkg/kube/wait.go | 13 ++++++ 6 files changed, 193 insertions(+), 70 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 45f1a14e2..8fa3ae289 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -371,7 +371,8 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - kc := kube.New(getter) + // TODO I don't love that this ends up using nil instead of a real watcher + kc := kube.New(getter, nil) kc.Log = log lazyClient := &lazyClient{ diff --git a/pkg/kube/client.go b/pkg/kube/client.go index b38b4b094..b1b1d4835 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -92,6 +92,11 @@ type Client struct { Namespace string kubeClient *kubernetes.Clientset + // Another potential option rather than having the waiter as a field + // would be to have a field that decides what type of waiter to use + // then instantiate it during the method + // of course the fields could take a waiter as well + waiter Waiter } func init() { @@ -105,14 +110,53 @@ func init() { } } +func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { + cfg, err := factory.ToRESTConfig() + if err != nil { + return nil, err + } + // factory.DynamicClient() may be a better choice here + dynamicClient, err := dynamic.NewForConfig(cfg) + if err != nil { + return nil, err + } + // Not sure if I should use factory methods to get this http client or I should do this + // For example, I could likely use this as well, but it seems like I should use the factory methods instead + // httpClient, err := rest.HTTPClientFor(cfg) + // if err != nil { + // return err + // } + client, err := factory.RESTClient() + if err != nil { + return nil, err + } + restMapper, err := apiutil.NewDynamicRESTMapper(cfg, client.Client) + if err != nil { + return nil, err + } + sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) + return sw, nil +} + // New creates a new Client. -func New(getter genericclioptions.RESTClientGetter) *Client { +func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { if getter == nil { getter = genericclioptions.NewConfigFlags(true) + } + factory := cmdutil.NewFactory(getter) + if waiter == nil { + sw, err := getStatusWatcher(factory) + if err != nil { + // TODO, likely will move how the stats watcher is created so it doesn't need to be created + // unless it's going to be used + panic(err) + } + waiter = &kstatusWaiter{sw, nopLogger} } return &Client{ - Factory: cmdutil.NewFactory(getter), + Factory: factory, Log: nopLogger, + waiter: waiter, } } @@ -291,44 +335,7 @@ func getResource(info *resource.Info) (runtime.Object, error) { // Wait waits up to the given timeout for the specified resources to be ready. func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { - // cs, err := c.getKubeClient() - // if err != nil { - // return err - // } - // checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) - // w := waiter{ - // c: checker, - // log: c.Log, - // timeout: timeout, - // } - // w.waitForResources() - cfg, err := c.Factory.ToRESTConfig() - if err != nil { - return err - } - dynamicClient, err := dynamic.NewForConfig(cfg) - if err != nil { - return err - } - // Not sure if I should use factory methods to get this http client or I should do this - // For example, I could likely use this as well, but it seems like I should use the factory methods instead - // httpClient, err := rest.HTTPClientFor(cfg) - // if err != nil { - // return err - // } - client, err := c.Factory.RESTClient() - if err != nil { - return err - } - restMapper, err := apiutil.NewDynamicRESTMapper(cfg, client.Client) - if err != nil { - return err - } - sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) - // return sw, nil - ctx, cancel := context.WithTimeout(context.TODO(), timeout) - defer cancel() - return WaitForReady(ctx, sw, resources) + return c.waiter.Wait(resources, timeout) } // WaitForReady waits for all of the objects to reach a ready state. @@ -389,17 +396,7 @@ func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, resourceList Re // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. func (c *Client) WaitWithJobs(resources ResourceList, timeout time.Duration) error { - cs, err := c.getKubeClient() - if err != nil { - return err - } - checker := NewReadyChecker(cs, c.Log, PausedAsReady(true), CheckJobs(true)) - w := waiter{ - c: checker, - log: c.Log, - timeout: timeout, - } - return w.waitForResources(resources) + return c.waiter.WaitWithJobs(resources, timeout) } // WaitForDelete wait up to the given timeout for the specified resources to be deleted. diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 7f3ba65be..b12897121 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -24,6 +24,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -453,10 +454,10 @@ func TestPerform(t *testing.T) { } } -// Likely it is not possible to get this test to work with kstatus given that it seems +// Likely it is not possible to get this test to work with kstatus given that it seems // kstatus is not making constant get checks on the resources and is instead waiting for events // Potentially the test could be reworked to make the pods after five seconds -// would need this -> +// would need this -> func TestWait(t *testing.T) { podList := newPodList("starfish", "otter", "squid") @@ -517,6 +518,15 @@ func TestWait(t *testing.T) { } }), } + cs, err := c.getKubeClient() + require.NoError(t, err) + checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) + w := &waiter{ + c: checker, + log: c.Log, + timeout: time.Second * 30, + } + c.waiter = w resources, err := c.Build(objBody(&podList), false) if err != nil { t.Fatal(err) @@ -569,6 +579,15 @@ func TestWaitJob(t *testing.T) { } }), } + cs, err := c.getKubeClient() + require.NoError(t, err) + checker := NewReadyChecker(cs, c.Log, PausedAsReady(true), CheckJobs(true)) + w := &waiter{ + c: checker, + log: c.Log, + timeout: time.Second * 30, + } + c.waiter = w resources, err := c.Build(objBody(job), false) if err != nil { t.Fatal(err) @@ -623,6 +642,15 @@ func TestWaitDelete(t *testing.T) { } }), } + cs, err := c.getKubeClient() + require.NoError(t, err) + checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) + w := &waiter{ + c: checker, + log: c.Log, + timeout: time.Second * 30, + } + c.waiter = w resources, err := c.Build(objBody(&pod), false) if err != nil { t.Fatal(err) @@ -649,7 +677,7 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c := New(nil) + c := New(nil, nil) resources, err := c.Build(strings.NewReader(guestbookManifest), false) if err != nil { t.Fatal(err) @@ -659,7 +687,7 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c = New(nil) + c = New(nil, nil) resources, err = c.Build(strings.NewReader(testSvcEndpointManifest), false) if err != nil { t.Fatal(err) diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index af3823a3e..40880005a 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -32,16 +32,13 @@ type Interface interface { // Create creates one or more resources. Create(resources ResourceList) (*Result, error) - // Wait waits up to the given timeout for the specified resources to be ready. - // TODO introduce another interface for the waiting of the KubeClient - Wait(resources ResourceList, timeout time.Duration) error - - // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. - WaitWithJobs(resources ResourceList, timeout time.Duration) error - // Delete destroys one or more resources. Delete(resources ResourceList) (*Result, []error) + // Update updates one or more resources or creates the resource + // if it doesn't exist. + Update(original, target ResourceList, force bool) (*Result, error) + // WatchUntilReady watches the resources given and waits until it is ready. // // This method is mainly for hook implementations. It watches for a resource to @@ -51,11 +48,12 @@ type Interface interface { // For Pods, "ready" means the Pod phase is marked "succeeded". // For all other kinds, it means the kind was created or modified without // error. + // TODO: Is watch until ready really behavior we want over the resources actually being ready? WatchUntilReady(resources ResourceList, timeout time.Duration) error - // Update updates one or more resources or creates the resource - // if it doesn't exist. - Update(original, target ResourceList, force bool) (*Result, error) + // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase + // and returns said phase (PodSucceeded or PodFailed qualify). + WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) // Build creates a resource list from a Reader. // @@ -65,12 +63,18 @@ type Interface interface { // Validates against OpenAPI schema if validate is true. Build(reader io.Reader, validate bool) (ResourceList, error) - // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase - // and returns said phase (PodSucceeded or PodFailed qualify). - WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) - // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error + Waiter +} + +// Waiter defines methods related to waiting for resource states. +type Waiter interface { + // Wait waits up to the given timeout for the specified resources to be ready. + Wait(resources ResourceList, timeout time.Duration) error + + // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. + WaitWithJobs(resources ResourceList, timeout time.Duration) error } // InterfaceExt is introduced to avoid breaking backwards compatibility for Interface implementers. diff --git a/pkg/kube/kready.go b/pkg/kube/kready.go index 0752ba481..c199eecc6 100644 --- a/pkg/kube/kready.go +++ b/pkg/kube/kready.go @@ -16,3 +16,83 @@ limitations under the License. package kube // import "helm.sh/helm/v3/pkg/kube" +import ( + "context" + "fmt" + "time" + + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" + "sigs.k8s.io/cli-utils/pkg/kstatus/status" + "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" + "sigs.k8s.io/cli-utils/pkg/object" +) + +type kstatusWaiter struct { + // Add any necessary dependencies, e.g., Kubernetes API client. + sw watcher.StatusWatcher + log func(string, ...interface{}) +} + +func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { + ctx := context.TODO() + cancelCtx, cancel := context.WithCancel(ctx) + defer cancel() + // TODO maybe a simpler way to transfer the objects + runtimeObjs := []runtime.Object{} + for _, resource := range resourceList { + runtimeObjs = append(runtimeObjs, resource.Object) + } + resources := []object.ObjMetadata{} + for _, runtimeObj := range runtimeObjs { + obj, err := object.RuntimeToObjMeta(runtimeObj) + if err != nil { + return err + } + resources = append(resources, obj) + } + eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) + statusCollector := collector.NewResourceStatusCollector(resources) + done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( + func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { + rss := []*event.ResourceStatus{} + for _, rs := range statusCollector.ResourceStatuses { + if rs == nil { + continue + } + rss = append(rss, rs) + } + desired := status.CurrentStatus + if aggregator.AggregateStatus(rss, desired) == desired { + cancel() + return + } + }), + ) + <-done + + if statusCollector.Error != nil { + return statusCollector.Error + } + + // Only check parent context error, otherwise we would error when desired status is achieved. + if ctx.Err() != nil { + var err error + for _, id := range resources { + rs := statusCollector.ResourceStatuses[id] + if rs.Status == status.CurrentStatus { + continue + } + err = fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status) + } + return fmt.Errorf("not all resources ready: %w: %w", ctx.Err(), err) + } + return nil +} + +func (w *kstatusWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { + // Implementation + panic("not implemented") +} diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index bdafc8255..de00aae47 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -44,6 +44,19 @@ type waiter struct { log func(string, ...interface{}) } +func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error { + w.timeout = timeout + return w.waitForResources(resources) +} + +func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { + // Implementation + // TODO this function doesn't make sense unless you pass a readyChecker to it + // TODO pass context instead + w.timeout = timeout + return w.waitForResources(resources) +} + // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached func (w *waiter) waitForResources(created ResourceList) error { From 4564b8f7121083b21721e3f098e5ab487b3b159a Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 26 Dec 2024 17:26:03 +0000 Subject: [PATCH 014/271] make a working test Signed-off-by: Austin Abro --- go.mod | 3 +- pkg/kube/client.go | 75 ++--------- pkg/kube/client_test.go | 19 ++- pkg/kube/{kready.go => kwait.go} | 4 +- pkg/kube/kwait_test.go | 213 +++++++++++++++++++++++++++++++ 5 files changed, 238 insertions(+), 76 deletions(-) rename pkg/kube/{kready.go => kwait.go} (95%) create mode 100644 pkg/kube/kwait_test.go diff --git a/go.mod b/go.mod index feefb8932..e70781ac5 100644 --- a/go.mod +++ b/go.mod @@ -47,6 +47,7 @@ require ( k8s.io/kubectl v0.31.3 oras.land/oras-go v1.2.5 sigs.k8s.io/cli-utils v0.37.2 + sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/yaml v1.4.0 ) @@ -128,6 +129,7 @@ require ( github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect + github.com/onsi/gomega v1.33.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -185,7 +187,6 @@ require ( k8s.io/component-base v0.31.3 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect - sigs.k8s.io/controller-runtime v0.18.4 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kustomize/api v0.17.2 // indirect sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect diff --git a/pkg/kube/client.go b/pkg/kube/client.go index b1b1d4835..149017b17 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -37,12 +37,7 @@ import ( apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" - "sigs.k8s.io/cli-utils/pkg/object" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" multierror "github.com/hashicorp/go-multierror" @@ -92,10 +87,12 @@ type Client struct { Namespace string kubeClient *kubernetes.Clientset - // Another potential option rather than having the waiter as a field - // would be to have a field that decides what type of waiter to use - // then instantiate it during the method - // of course the fields could take a waiter as well + // I see a couple different options for how waiter could be handled here + // - The waiter could be instantiated in New or at the start of each wait function // + // - The waiter could be completely separate from the client interface, + // I don't like that this causes consumers to need another interface on top of kube + // - The waiter could be bundled with the resource manager into a client object. The waiter doesn't need factory / + // Another option still would be to waiter Waiter } @@ -142,7 +139,7 @@ func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { if getter == nil { getter = genericclioptions.NewConfigFlags(true) - } + } factory := cmdutil.NewFactory(getter) if waiter == nil { sw, err := getStatusWatcher(factory) @@ -156,7 +153,7 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { return &Client{ Factory: factory, Log: nopLogger, - waiter: waiter, + waiter: waiter, } } @@ -338,62 +335,6 @@ func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { return c.waiter.Wait(resources, timeout) } -// WaitForReady waits for all of the objects to reach a ready state. -func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, resourceList ResourceList) error { - cancelCtx, cancel := context.WithCancel(ctx) - defer cancel() - // TODO maybe a simpler way to transfer the objects - runtimeObjs := []runtime.Object{} - for _, resource := range resourceList { - runtimeObjs = append(runtimeObjs, resource.Object) - } - resources := []object.ObjMetadata{} - for _, runtimeObj := range runtimeObjs { - obj, err := object.RuntimeToObjMeta(runtimeObj) - if err != nil { - return err - } - resources = append(resources, obj) - } - eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) - statusCollector := collector.NewResourceStatusCollector(resources) - done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( - func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { - rss := []*event.ResourceStatus{} - for _, rs := range statusCollector.ResourceStatuses { - if rs == nil { - continue - } - rss = append(rss, rs) - } - desired := status.CurrentStatus - if aggregator.AggregateStatus(rss, desired) == desired { - cancel() - return - } - }), - ) - <-done - - if statusCollector.Error != nil { - return statusCollector.Error - } - - // Only check parent context error, otherwise we would error when desired status is achieved. - if ctx.Err() != nil { - var err error - for _, id := range resources { - rs := statusCollector.ResourceStatuses[id] - if rs.Status == status.CurrentStatus { - continue - } - err = fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status) - } - return fmt.Errorf("not all resources ready: %w: %w", ctx.Err(), err) - } - return nil -} - // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. func (c *Client) WaitWithJobs(resources ResourceList, timeout time.Duration) error { return c.waiter.WaitWithJobs(resources, timeout) diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index b12897121..de61a3862 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -24,7 +24,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -519,14 +518,16 @@ func TestWait(t *testing.T) { }), } cs, err := c.getKubeClient() - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) w := &waiter{ c: checker, log: c.Log, timeout: time.Second * 30, } - c.waiter = w + c.waiter = w resources, err := c.Build(objBody(&podList), false) if err != nil { t.Fatal(err) @@ -580,14 +581,16 @@ func TestWaitJob(t *testing.T) { }), } cs, err := c.getKubeClient() - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } checker := NewReadyChecker(cs, c.Log, PausedAsReady(true), CheckJobs(true)) w := &waiter{ c: checker, log: c.Log, timeout: time.Second * 30, } - c.waiter = w + c.waiter = w resources, err := c.Build(objBody(job), false) if err != nil { t.Fatal(err) @@ -643,14 +646,16 @@ func TestWaitDelete(t *testing.T) { }), } cs, err := c.getKubeClient() - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) w := &waiter{ c: checker, log: c.Log, timeout: time.Second * 30, } - c.waiter = w + c.waiter = w resources, err := c.Build(objBody(&pod), false) if err != nil { t.Fatal(err) diff --git a/pkg/kube/kready.go b/pkg/kube/kwait.go similarity index 95% rename from pkg/kube/kready.go rename to pkg/kube/kwait.go index c199eecc6..d74c913ea 100644 --- a/pkg/kube/kready.go +++ b/pkg/kube/kwait.go @@ -37,7 +37,8 @@ type kstatusWaiter struct { } func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { - ctx := context.TODO() + ctx, cancel := context.WithTimeout(context.TODO(), timeout) + defer cancel() cancelCtx, cancel := context.WithCancel(ctx) defer cancel() // TODO maybe a simpler way to transfer the objects @@ -62,6 +63,7 @@ func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) e if rs == nil { continue } + fmt.Println("this is the status of object", rs.Status) rss = append(rss, rs) } desired := status.CurrentStatus diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go new file mode 100644 index 000000000..1d9a69959 --- /dev/null +++ b/pkg/kube/kwait_test.go @@ -0,0 +1,213 @@ +/* +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 kube // import "helm.sh/helm/v3/pkg/kube" + +import ( + "errors" + "fmt" + "testing" + "time" + + "github.com/stretchr/testify/require" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/yaml" + dynamicfake "k8s.io/client-go/dynamic/fake" + "k8s.io/kubectl/pkg/scheme" + "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" + "sigs.k8s.io/cli-utils/pkg/testutil" +) + +var podCurrentYaml = ` +apiVersion: v1 +kind: Pod +metadata: + name: good-pod + namespace: ns +status: + conditions: + - type: Ready + status: "True" + phase: Running +` + +var podYaml = ` +apiVersion: v1 +kind: Pod +metadata: + name: in-progress-pod + namespace: ns +` + +func TestRunHealthChecks(t *testing.T) { + t.Parallel() + tests := []struct { + name string + podYamls []string + expectErrs []error + }{ + { + name: "Pod is ready", + podYamls: []string{podCurrentYaml}, + expectErrs: nil, + }, + { + name: "one of the pods never becomes ready", + podYamls: []string{podYaml, podCurrentYaml}, + // TODO, make this better + expectErrs: []error{errors.New("not all resources ready: context deadline exceeded: in-progress-pod: Pod not ready, status: InProgress")}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + c := newTestClient(t) + fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) + fakeMapper := testutil.NewFakeRESTMapper( + v1.SchemeGroupVersion.WithKind("Pod"), + ) + // ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) + // defer cancel() + pods := []runtime.Object{} + statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) + for _, podYaml := range tt.podYamls { + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(podYaml), &m) + require.NoError(t, err) + pod := &unstructured.Unstructured{Object: m} + pods = append(pods, pod) + fmt.Println(pod.GetName()) + podGVR := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} + err = fakeClient.Tracker().Create(podGVR, pod, pod.GetNamespace()) + require.NoError(t, err) + } + c.waiter = &kstatusWaiter{ + sw: statusWatcher, + log: c.Log, + } + + resourceList := ResourceList{} + for _, pod := range pods { + list, err := c.Build(objBody(pod), false) + if err != nil { + t.Fatal(err) + } + resourceList = append(resourceList, list...) + } + + err := c.Wait(resourceList, time.Second*5) + if tt.expectErrs != nil { + require.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) + return + } + require.NoError(t, err) + }) + } +} + +// func TestWait1(t *testing.T) { +// podList := newPodList("starfish", "otter", "squid") + +// var created *time.Time + +// c := newTestClient(t) +// c.Factory.(*cmdtesting.TestFactory).ClientConfigVal = cmdtesting.DefaultClientConfig() +// c.Factory.(*cmdtesting.TestFactory).Client = &fake.RESTClient{ +// NegotiatedSerializer: unstructuredSerializer, +// Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { +// p, m := req.URL.Path, req.Method +// t.Logf("got request %s %s", p, m) +// switch { +// case p == "/api/v1/namespaces/default/pods/starfish" && m == "GET": +// pod := &podList.Items[0] +// if created != nil && time.Since(*created) >= time.Second*5 { +// pod.Status.Conditions = []v1.PodCondition{ +// { +// Type: v1.PodReady, +// Status: v1.ConditionTrue, +// }, +// } +// } +// return newResponse(200, pod) +// case p == "/api/v1/namespaces/default/pods/otter" && m == "GET": +// pod := &podList.Items[1] +// if created != nil && time.Since(*created) >= time.Second*5 { +// pod.Status.Conditions = []v1.PodCondition{ +// { +// Type: v1.PodReady, +// Status: v1.ConditionTrue, +// }, +// } +// } +// return newResponse(200, pod) +// case p == "/api/v1/namespaces/default/pods/squid" && m == "GET": +// pod := &podList.Items[2] +// if created != nil && time.Since(*created) >= time.Second*5 { +// pod.Status.Conditions = []v1.PodCondition{ +// { +// Type: v1.PodReady, +// Status: v1.ConditionTrue, +// }, +// } +// } +// return newResponse(200, pod) +// case p == "/namespaces/default/pods" && m == "POST": +// resources, err := c.Build(req.Body, false) +// if err != nil { +// t.Fatal(err) +// } +// now := time.Now() +// created = &now +// return newResponse(200, resources[0].Object) +// default: +// t.Fatalf("unexpected request: %s %s", req.Method, req.URL.Path) +// return nil, nil +// } +// }), +// } +// cs, err := c.getKubeClient() +// require.NoError(t, err) +// checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) +// w := &waiter{ +// c: checker, +// log: c.Log, +// timeout: time.Second * 30, +// } +// c.waiter = w +// resources, err := c.Build(objBody(&podList), false) +// if err != nil { +// t.Fatal(err) +// } +// result, err := c.Create(resources) +// if err != nil { +// t.Fatal(err) +// } +// if len(result.Created) != 3 { +// t.Errorf("expected 3 resource created, got %d", len(result.Created)) +// } + +// if err := c.Wait(resources, time.Second*30); err != nil { +// t.Errorf("expected wait without error, got %s", err) +// } + +// if time.Since(*created) < time.Second*5 { +// t.Errorf("expected to wait at least 5 seconds before ready status was detected, but got %s", time.Since(*created)) +// } +// } From ad1f1c02efda335320ec652c3a32cfbbc39b6337 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 13:25:02 +0000 Subject: [PATCH 015/271] cleanup test Signed-off-by: Austin Abro --- pkg/kube/kwait_test.go | 92 ------------------------------------------ 1 file changed, 92 deletions(-) diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 1d9a69959..1702f0990 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -83,8 +83,6 @@ func TestRunHealthChecks(t *testing.T) { fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), ) - // ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) - // defer cancel() pods := []runtime.Object{} statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) for _, podYaml := range tt.podYamls { @@ -121,93 +119,3 @@ func TestRunHealthChecks(t *testing.T) { }) } } - -// func TestWait1(t *testing.T) { -// podList := newPodList("starfish", "otter", "squid") - -// var created *time.Time - -// c := newTestClient(t) -// c.Factory.(*cmdtesting.TestFactory).ClientConfigVal = cmdtesting.DefaultClientConfig() -// c.Factory.(*cmdtesting.TestFactory).Client = &fake.RESTClient{ -// NegotiatedSerializer: unstructuredSerializer, -// Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { -// p, m := req.URL.Path, req.Method -// t.Logf("got request %s %s", p, m) -// switch { -// case p == "/api/v1/namespaces/default/pods/starfish" && m == "GET": -// pod := &podList.Items[0] -// if created != nil && time.Since(*created) >= time.Second*5 { -// pod.Status.Conditions = []v1.PodCondition{ -// { -// Type: v1.PodReady, -// Status: v1.ConditionTrue, -// }, -// } -// } -// return newResponse(200, pod) -// case p == "/api/v1/namespaces/default/pods/otter" && m == "GET": -// pod := &podList.Items[1] -// if created != nil && time.Since(*created) >= time.Second*5 { -// pod.Status.Conditions = []v1.PodCondition{ -// { -// Type: v1.PodReady, -// Status: v1.ConditionTrue, -// }, -// } -// } -// return newResponse(200, pod) -// case p == "/api/v1/namespaces/default/pods/squid" && m == "GET": -// pod := &podList.Items[2] -// if created != nil && time.Since(*created) >= time.Second*5 { -// pod.Status.Conditions = []v1.PodCondition{ -// { -// Type: v1.PodReady, -// Status: v1.ConditionTrue, -// }, -// } -// } -// return newResponse(200, pod) -// case p == "/namespaces/default/pods" && m == "POST": -// resources, err := c.Build(req.Body, false) -// if err != nil { -// t.Fatal(err) -// } -// now := time.Now() -// created = &now -// return newResponse(200, resources[0].Object) -// default: -// t.Fatalf("unexpected request: %s %s", req.Method, req.URL.Path) -// return nil, nil -// } -// }), -// } -// cs, err := c.getKubeClient() -// require.NoError(t, err) -// checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) -// w := &waiter{ -// c: checker, -// log: c.Log, -// timeout: time.Second * 30, -// } -// c.waiter = w -// resources, err := c.Build(objBody(&podList), false) -// if err != nil { -// t.Fatal(err) -// } -// result, err := c.Create(resources) -// if err != nil { -// t.Fatal(err) -// } -// if len(result.Created) != 3 { -// t.Errorf("expected 3 resource created, got %d", len(result.Created)) -// } - -// if err := c.Wait(resources, time.Second*30); err != nil { -// t.Errorf("expected wait without error, got %s", err) -// } - -// if time.Since(*created) < time.Second*5 { -// t.Errorf("expected to wait at least 5 seconds before ready status was detected, but got %s", time.Since(*created)) -// } -// } From 859ff9b54882c4344cc5564c6cd4f993a300e20c Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 14:37:33 +0000 Subject: [PATCH 016/271] change structure of client Signed-off-by: Austin Abro --- pkg/kube/client.go | 21 +++------------------ pkg/kube/client_test.go | 9 +++------ pkg/kube/interface.go | 10 +++++----- pkg/kube/kwait_test.go | 2 +- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 149017b17..9e31a64e1 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -87,13 +87,8 @@ type Client struct { Namespace string kubeClient *kubernetes.Clientset - // I see a couple different options for how waiter could be handled here - // - The waiter could be instantiated in New or at the start of each wait function // - // - The waiter could be completely separate from the client interface, - // I don't like that this causes consumers to need another interface on top of kube - // - The waiter could be bundled with the resource manager into a client object. The waiter doesn't need factory / - // Another option still would be to - waiter Waiter + ResourceManager + Waiter } func init() { @@ -153,7 +148,7 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { return &Client{ Factory: factory, Log: nopLogger, - waiter: waiter, + Waiter: waiter, } } @@ -330,16 +325,6 @@ func getResource(info *resource.Info) (runtime.Object, error) { return obj, nil } -// Wait waits up to the given timeout for the specified resources to be ready. -func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { - return c.waiter.Wait(resources, timeout) -} - -// WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. -func (c *Client) WaitWithJobs(resources ResourceList, timeout time.Duration) error { - return c.waiter.WaitWithJobs(resources, timeout) -} - // WaitForDelete wait up to the given timeout for the specified resources to be deleted. func (c *Client) WaitForDelete(resources ResourceList, timeout time.Duration) error { w := waiter{ diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index de61a3862..a6e095942 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -522,12 +522,11 @@ func TestWait(t *testing.T) { t.Fatal(err) } checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) - w := &waiter{ + c.Waiter = &waiter{ c: checker, log: c.Log, timeout: time.Second * 30, } - c.waiter = w resources, err := c.Build(objBody(&podList), false) if err != nil { t.Fatal(err) @@ -585,12 +584,11 @@ func TestWaitJob(t *testing.T) { t.Fatal(err) } checker := NewReadyChecker(cs, c.Log, PausedAsReady(true), CheckJobs(true)) - w := &waiter{ + c.Waiter = &waiter{ c: checker, log: c.Log, timeout: time.Second * 30, } - c.waiter = w resources, err := c.Build(objBody(job), false) if err != nil { t.Fatal(err) @@ -650,12 +648,11 @@ func TestWaitDelete(t *testing.T) { t.Fatal(err) } checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) - w := &waiter{ + c.Waiter = &waiter{ c: checker, log: c.Log, timeout: time.Second * 30, } - c.waiter = w resources, err := c.Build(objBody(&pod), false) if err != nil { t.Fatal(err) diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 40880005a..d2230b244 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -29,6 +29,11 @@ import ( // // A KubernetesClient must be concurrency safe. type Interface interface { + ResourceManager + Waiter +} + +type ResourceManager interface { // Create creates one or more resources. Create(resources ResourceList) (*Result, error) @@ -38,7 +43,6 @@ type Interface interface { // Update updates one or more resources or creates the resource // if it doesn't exist. Update(original, target ResourceList, force bool) (*Result, error) - // WatchUntilReady watches the resources given and waits until it is ready. // // This method is mainly for hook implementations. It watches for a resource to @@ -50,11 +54,9 @@ type Interface interface { // error. // TODO: Is watch until ready really behavior we want over the resources actually being ready? WatchUntilReady(resources ResourceList, timeout time.Duration) error - // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase // and returns said phase (PodSucceeded or PodFailed qualify). WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) - // Build creates a resource list from a Reader. // // Reader must contain a YAML stream (one or more YAML documents separated @@ -62,10 +64,8 @@ type Interface interface { // // Validates against OpenAPI schema if validate is true. Build(reader io.Reader, validate bool) (ResourceList, error) - // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error - Waiter } // Waiter defines methods related to waiting for resource states. diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 1702f0990..9854f2d60 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -96,7 +96,7 @@ func TestRunHealthChecks(t *testing.T) { err = fakeClient.Tracker().Create(podGVR, pod, pod.GetNamespace()) require.NoError(t, err) } - c.waiter = &kstatusWaiter{ + c.Waiter = &kstatusWaiter{ sw: statusWatcher, log: c.Log, } From aacaa08be2b689e7c688f483ab0946dedac154ab Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 14:49:11 +0000 Subject: [PATCH 017/271] only emebed waiter Signed-off-by: Austin Abro --- pkg/kube/client.go | 1 - pkg/kube/interface.go | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 9e31a64e1..469a89b35 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -87,7 +87,6 @@ type Client struct { Namespace string kubeClient *kubernetes.Clientset - ResourceManager Waiter } diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index d2230b244..edc062c49 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -29,11 +29,6 @@ import ( // // A KubernetesClient must be concurrency safe. type Interface interface { - ResourceManager - Waiter -} - -type ResourceManager interface { // Create creates one or more resources. Create(resources ResourceList) (*Result, error) @@ -66,6 +61,7 @@ type ResourceManager interface { Build(reader io.Reader, validate bool) (ResourceList, error) // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error + Waiter } // Waiter defines methods related to waiting for resource states. From 947425ee64b0047896ba9a96d130420c5ca60175 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 14:51:22 +0000 Subject: [PATCH 018/271] refactor new Signed-off-by: Austin Abro --- pkg/action/action.go | 6 ++++-- pkg/kube/client.go | 8 +++----- pkg/kube/client_test.go | 10 ++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 8fa3ae289..8759597b4 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -371,8 +371,10 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - // TODO I don't love that this ends up using nil instead of a real watcher - kc := kube.New(getter, nil) + kc, err := kube.New(getter, nil) + if err != nil { + return err + } kc.Log = log lazyClient := &lazyClient{ diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 469a89b35..a50655a40 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -130,7 +130,7 @@ func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { } // New creates a new Client. -func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { +func New(getter genericclioptions.RESTClientGetter, waiter Waiter) (*Client, error) { if getter == nil { getter = genericclioptions.NewConfigFlags(true) } @@ -138,9 +138,7 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { if waiter == nil { sw, err := getStatusWatcher(factory) if err != nil { - // TODO, likely will move how the stats watcher is created so it doesn't need to be created - // unless it's going to be used - panic(err) + return nil, err } waiter = &kstatusWaiter{sw, nopLogger} } @@ -148,7 +146,7 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client { Factory: factory, Log: nopLogger, Waiter: waiter, - } + }, nil } var nopLogger = func(_ string, _ ...interface{}) {} diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index a6e095942..037719219 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -679,7 +679,10 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c := New(nil, nil) + c, err := New(nil, nil) + if err != nil { + t.Fatal(err) + } resources, err := c.Build(strings.NewReader(guestbookManifest), false) if err != nil { t.Fatal(err) @@ -689,7 +692,10 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c = New(nil, nil) + c, err = New(nil, nil) + if err != nil { + t.Fatal(err) + } resources, err = c.Build(strings.NewReader(testSvcEndpointManifest), false) if err != nil { t.Fatal(err) From 807cc925f532323fcb143b566d8e44498bcaac32 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 16:33:33 +0000 Subject: [PATCH 019/271] refactor test Signed-off-by: Austin Abro --- pkg/kube/client.go | 5 ++- pkg/kube/kwait.go | 5 +-- pkg/kube/kwait_test.go | 80 +++++++++++++++++++++++++++++++++--------- 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index a50655a40..cbef8fece 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -140,7 +140,10 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) (*Client, err if err != nil { return nil, err } - waiter = &kstatusWaiter{sw, nopLogger} + waiter = &kstatusWaiter{ + sw: sw, + log: nopLogger, + pausedAsReady: true} } return &Client{ Factory: factory, diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index d74c913ea..6c1d5b748 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -32,8 +32,9 @@ import ( type kstatusWaiter struct { // Add any necessary dependencies, e.g., Kubernetes API client. - sw watcher.StatusWatcher - log func(string, ...interface{}) + sw watcher.StatusWatcher + log func(string, ...interface{}) + pausedAsReady bool } func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 9854f2d60..372735462 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -18,12 +18,12 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "errors" - "fmt" "testing" "time" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/cli-utils/pkg/testutil" ) -var podCurrentYaml = ` +var podCurrent = ` apiVersion: v1 kind: Pod metadata: @@ -47,7 +47,7 @@ status: phase: Running ` -var podYaml = ` +var podNoStatus = ` apiVersion: v1 kind: Pod metadata: @@ -55,21 +55,62 @@ metadata: namespace: ns ` -func TestRunHealthChecks(t *testing.T) { +var jobNoStatus = ` +apiVersion: batch/v1 +kind: Job +metadata: + name: test + namespace: qual + generation: 1 +` + +var jobComplete = ` +apiVersion: batch/v1 +kind: Job +metadata: + name: test + namespace: qual + generation: 1 +status: + succeeded: 1 + active: 0 + conditions: + - type: Complete + status: "True" +` + +func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured) schema.GroupVersionResource { + gvk := obj.GroupVersionKind() + mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version) + require.NoError(t, err) + return mapping.Resource +} + +func TestKWaitJob(t *testing.T) { t.Parallel() tests := []struct { name string - podYamls []string + objYamls []string expectErrs []error }{ + { + name: "Job is complete", + objYamls: []string{jobComplete}, + expectErrs: nil, + }, + { + name: "Job is not complete", + objYamls: []string{jobNoStatus}, + expectErrs: []error{errors.New("not all resources ready: context deadline exceeded: test: Job not ready, status: InProgress")}, + }, { name: "Pod is ready", - podYamls: []string{podCurrentYaml}, + objYamls: []string{podCurrent}, expectErrs: nil, }, { name: "one of the pods never becomes ready", - podYamls: []string{podYaml, podCurrentYaml}, + objYamls: []string{podNoStatus, podCurrent}, // TODO, make this better expectErrs: []error{errors.New("not all resources ready: context deadline exceeded: in-progress-pod: Pod not ready, status: InProgress")}, }, @@ -82,18 +123,22 @@ func TestRunHealthChecks(t *testing.T) { fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), + schema.GroupVersionKind{ + Group: "batch", + Version: "v1", + Kind: "Job", + }, ) - pods := []runtime.Object{} + objs := []runtime.Object{} statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) - for _, podYaml := range tt.podYamls { + for _, podYaml := range tt.objYamls { m := make(map[string]interface{}) err := yaml.Unmarshal([]byte(podYaml), &m) require.NoError(t, err) - pod := &unstructured.Unstructured{Object: m} - pods = append(pods, pod) - fmt.Println(pod.GetName()) - podGVR := schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"} - err = fakeClient.Tracker().Create(podGVR, pod, pod.GetNamespace()) + resource := &unstructured.Unstructured{Object: m} + objs = append(objs, resource) + gvr := getGVR(t, fakeMapper, resource) + err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) require.NoError(t, err) } c.Waiter = &kstatusWaiter{ @@ -102,16 +147,17 @@ func TestRunHealthChecks(t *testing.T) { } resourceList := ResourceList{} - for _, pod := range pods { - list, err := c.Build(objBody(pod), false) + for _, obj := range objs { + list, err := c.Build(objBody(obj), false) if err != nil { t.Fatal(err) } resourceList = append(resourceList, list...) } - err := c.Wait(resourceList, time.Second*5) + err := c.Wait(resourceList, time.Second*3) if tt.expectErrs != nil { + //TODO remove require require.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return } From a6e5466942df67dccea00fbaa7b2ed4e5a8e619d Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 16:54:33 +0000 Subject: [PATCH 020/271] refactor test Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 8 +++++--- pkg/kube/kwait_test.go | 23 ++++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index 6c1d5b748..639794322 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -18,6 +18,7 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "context" + "errors" "fmt" "time" @@ -82,15 +83,16 @@ func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) e // Only check parent context error, otherwise we would error when desired status is achieved. if ctx.Err() != nil { - var err error + errs := []error{} for _, id := range resources { rs := statusCollector.ResourceStatuses[id] if rs.Status == status.CurrentStatus { continue } - err = fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status) + errs = append(errs, fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } - return fmt.Errorf("not all resources ready: %w: %w", ctx.Err(), err) + errs = append(errs, ctx.Err()) + return errors.Join(errs...) } return nil } diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 372735462..fd5cd0b57 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -21,6 +21,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" @@ -101,7 +102,7 @@ func TestKWaitJob(t *testing.T) { { name: "Job is not complete", objYamls: []string{jobNoStatus}, - expectErrs: []error{errors.New("not all resources ready: context deadline exceeded: test: Job not ready, status: InProgress")}, + expectErrs: []error{errors.New("test: Job not ready, status: InProgress"), errors.New("context deadline exceeded")}, }, { name: "Pod is ready", @@ -109,10 +110,9 @@ func TestKWaitJob(t *testing.T) { expectErrs: nil, }, { - name: "one of the pods never becomes ready", - objYamls: []string{podNoStatus, podCurrent}, - // TODO, make this better - expectErrs: []error{errors.New("not all resources ready: context deadline exceeded: in-progress-pod: Pod not ready, status: InProgress")}, + name: "one of the pods never becomes ready", + objYamls: []string{podNoStatus, podCurrent}, + expectErrs: []error{errors.New("in-progress-pod: Pod not ready, status: InProgress"), errors.New("context deadline exceeded")}, }, } @@ -134,12 +134,12 @@ func TestKWaitJob(t *testing.T) { for _, podYaml := range tt.objYamls { m := make(map[string]interface{}) err := yaml.Unmarshal([]byte(podYaml), &m) - require.NoError(t, err) + assert.NoError(t, err) resource := &unstructured.Unstructured{Object: m} objs = append(objs, resource) gvr := getGVR(t, fakeMapper, resource) err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) - require.NoError(t, err) + assert.NoError(t, err) } c.Waiter = &kstatusWaiter{ sw: statusWatcher, @@ -149,19 +149,16 @@ func TestKWaitJob(t *testing.T) { resourceList := ResourceList{} for _, obj := range objs { list, err := c.Build(objBody(obj), false) - if err != nil { - t.Fatal(err) - } + assert.NoError(t, err) resourceList = append(resourceList, list...) } err := c.Wait(resourceList, time.Second*3) if tt.expectErrs != nil { - //TODO remove require - require.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) + assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return } - require.NoError(t, err) + assert.NoError(t, err) }) } } From 7b896df4d1089a7c6abded0caaf16fb84a2f90a7 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 17:34:26 +0000 Subject: [PATCH 021/271] option to wait for jobs Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 24 +++++++++++++++++------- pkg/kube/kwait_test.go | 24 ++++++++++++++++-------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index 639794322..c1822d87c 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -22,6 +22,7 @@ import ( "fmt" "time" + batchv1 "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" @@ -39,6 +40,15 @@ type kstatusWaiter struct { } func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { + return w.wait(resourceList, timeout, false) +} + +func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { + // Implementation + return w.wait(resourceList, timeout, true) +} + +func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, waitWithJobs bool) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() cancelCtx, cancel := context.WithCancel(ctx) @@ -46,6 +56,12 @@ func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) e // TODO maybe a simpler way to transfer the objects runtimeObjs := []runtime.Object{} for _, resource := range resourceList { + switch AsVersioned(resource).(type) { + case *batchv1.Job: + if !waitWithJobs { + continue + } + } runtimeObjs = append(runtimeObjs, resource.Object) } resources := []object.ObjMetadata{} @@ -65,7 +81,6 @@ func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) e if rs == nil { continue } - fmt.Println("this is the status of object", rs.Status) rss = append(rss, rs) } desired := status.CurrentStatus @@ -89,15 +104,10 @@ func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) e if rs.Status == status.CurrentStatus { continue } - errs = append(errs, fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + errs = append(errs, fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } errs = append(errs, ctx.Err()) return errors.Join(errs...) } return nil } - -func (w *kstatusWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { - // Implementation - panic("not implemented") -} diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index fd5cd0b57..e595f9ed3 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -90,9 +90,10 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured func TestKWaitJob(t *testing.T) { t.Parallel() tests := []struct { - name string - objYamls []string - expectErrs []error + name string + objYamls []string + expectErrs []error + waitForJobs bool }{ { name: "Job is complete", @@ -100,9 +101,16 @@ func TestKWaitJob(t *testing.T) { expectErrs: nil, }, { - name: "Job is not complete", - objYamls: []string{jobNoStatus}, - expectErrs: []error{errors.New("test: Job not ready, status: InProgress"), errors.New("context deadline exceeded")}, + name: "Job is not complete", + objYamls: []string{jobNoStatus}, + expectErrs: []error{errors.New("test: Job not ready, status: InProgress"), errors.New("context deadline exceeded")}, + waitForJobs: true, + }, + { + name: "Job is not ready, but we pass wait anyway", + objYamls: []string{jobNoStatus}, + expectErrs: nil, + waitForJobs: false, }, { name: "Pod is ready", @@ -141,7 +149,7 @@ func TestKWaitJob(t *testing.T) { err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) assert.NoError(t, err) } - c.Waiter = &kstatusWaiter{ + kwaiter := kstatusWaiter{ sw: statusWatcher, log: c.Log, } @@ -153,7 +161,7 @@ func TestKWaitJob(t *testing.T) { resourceList = append(resourceList, list...) } - err := c.Wait(resourceList, time.Second*3) + err := kwaiter.wait(resourceList, time.Second*3, tt.waitForJobs) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return From 22af71f125ca467a109eff50e78c5b7aea0e8642 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 17:35:32 +0000 Subject: [PATCH 022/271] comments Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index c1822d87c..674552432 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -33,7 +33,6 @@ import ( ) type kstatusWaiter struct { - // Add any necessary dependencies, e.g., Kubernetes API client. sw watcher.StatusWatcher log func(string, ...interface{}) pausedAsReady bool @@ -44,7 +43,6 @@ func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) e } func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { - // Implementation return w.wait(resourceList, timeout, true) } From e18f22071d036832f8a8573a99bd2955745faef8 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 17:43:18 +0000 Subject: [PATCH 023/271] paused as ready now working Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 11 +++++++--- pkg/kube/kwait_test.go | 50 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index 674552432..936445037 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -22,6 +22,7 @@ import ( "fmt" "time" + appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" @@ -46,7 +47,7 @@ func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dur return w.wait(resourceList, timeout, true) } -func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, waitWithJobs bool) error { +func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, waitForJobs bool) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() cancelCtx, cancel := context.WithCancel(ctx) @@ -54,9 +55,13 @@ func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, w // TODO maybe a simpler way to transfer the objects runtimeObjs := []runtime.Object{} for _, resource := range resourceList { - switch AsVersioned(resource).(type) { + switch value := AsVersioned(resource).(type) { case *batchv1.Job: - if !waitWithJobs { + if !waitForJobs { + continue + } + case *appsv1.Deployment: + if w.pausedAsReady && value.Spec.Paused { continue } } diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index e595f9ed3..8504025da 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -23,6 +23,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + batchv1 "k8s.io/api/batch/v1" + appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -80,6 +82,31 @@ status: status: "True" ` +var pausedDeploymentYaml = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx + namespace: ns-1 + generation: 1 +spec: + paused: true + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.19.6 + ports: + - containerPort: 80 +` + func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured) schema.GroupVersionResource { gvk := obj.GroupVersionKind() mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version) @@ -90,10 +117,11 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured func TestKWaitJob(t *testing.T) { t.Parallel() tests := []struct { - name string - objYamls []string - expectErrs []error - waitForJobs bool + name string + objYamls []string + expectErrs []error + waitForJobs bool + pausedAsReady bool }{ { name: "Job is complete", @@ -122,6 +150,12 @@ func TestKWaitJob(t *testing.T) { objYamls: []string{podNoStatus, podCurrent}, expectErrs: []error{errors.New("in-progress-pod: Pod not ready, status: InProgress"), errors.New("context deadline exceeded")}, }, + { + name: "paused deployment passes", + objYamls: []string{pausedDeploymentYaml}, + expectErrs: nil, + pausedAsReady: true, + }, } for _, tt := range tests { @@ -131,11 +165,8 @@ func TestKWaitJob(t *testing.T) { fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), - schema.GroupVersionKind{ - Group: "batch", - Version: "v1", - Kind: "Job", - }, + appsv1.SchemeGroupVersion.WithKind("Deployment"), + batchv1.SchemeGroupVersion.WithKind("Job"), ) objs := []runtime.Object{} statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) @@ -152,6 +183,7 @@ func TestKWaitJob(t *testing.T) { kwaiter := kstatusWaiter{ sw: statusWatcher, log: c.Log, + pausedAsReady: tt.pausedAsReady, } resourceList := ResourceList{} From b337790c102b812807a783bce5d2fbf74fc4f5cd Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 17:59:26 +0000 Subject: [PATCH 024/271] paused as ready Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 1 - pkg/kube/kwait_test.go | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index 936445037..e72e4b93d 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -52,7 +52,6 @@ func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, w defer cancel() cancelCtx, cancel := context.WithCancel(ctx) defer cancel() - // TODO maybe a simpler way to transfer the objects runtimeObjs := []runtime.Object{} for _, resource := range resourceList { switch value := AsVersioned(resource).(type) { diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 8504025da..1bc80d8ee 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -18,13 +18,14 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "errors" + "log" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - batchv1 "k8s.io/api/batch/v1" appsv1 "k8s.io/api/apps/v1" + batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -166,7 +167,7 @@ func TestKWaitJob(t *testing.T) { fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), appsv1.SchemeGroupVersion.WithKind("Deployment"), - batchv1.SchemeGroupVersion.WithKind("Job"), + batchv1.SchemeGroupVersion.WithKind("Job"), ) objs := []runtime.Object{} statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) @@ -181,9 +182,9 @@ func TestKWaitJob(t *testing.T) { assert.NoError(t, err) } kwaiter := kstatusWaiter{ - sw: statusWatcher, - log: c.Log, - pausedAsReady: tt.pausedAsReady, + sw: statusWatcher, + log: log.Printf, + pausedAsReady: tt.pausedAsReady, } resourceList := ResourceList{} From 28a9183ee3fd271ac2b76f4df89170e3c9452fbb Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 29 Dec 2024 18:39:09 +0000 Subject: [PATCH 025/271] context Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 12 +++++++----- pkg/kube/kwait_test.go | 6 +++++- pkg/kube/wait.go | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index e72e4b93d..3d8cfb616 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -40,16 +40,18 @@ type kstatusWaiter struct { } func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { - return w.wait(resourceList, timeout, false) + ctx, cancel := context.WithTimeout(context.TODO(), timeout) + defer cancel() + return w.wait(ctx, resourceList, false) } func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { - return w.wait(resourceList, timeout, true) -} - -func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, waitForJobs bool) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() + return w.wait(ctx, resourceList, true) +} + +func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() runtimeObjs := []runtime.Object{} diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 1bc80d8ee..9598ca216 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -17,6 +17,7 @@ limitations under the License. package kube // import "helm.sh/helm/v3/pkg/kube" import ( + "context" "errors" "log" "testing" @@ -194,7 +195,10 @@ func TestKWaitJob(t *testing.T) { resourceList = append(resourceList, list...) } - err := kwaiter.wait(resourceList, time.Second*3, tt.waitForJobs) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + defer cancel() + + err := kwaiter.wait(ctx, resourceList, tt.waitForJobs) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index de00aae47..34eb55e7c 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -51,8 +51,9 @@ func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error { func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { // Implementation - // TODO this function doesn't make sense unless you pass a readyChecker to it + // TODO this function doesn't make sense unless you pass a readyChecker to it // TODO pass context instead + // checker := NewReadyChecker(cs, w.c.Log, PausedAsReady(true), CheckJobs(true)) w.timeout = timeout return w.waitForResources(resources) } From 265442c5eb2bedc3292e255e38f4b25e1b0463ce Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 30 Dec 2024 14:22:14 +0000 Subject: [PATCH 026/271] simplify things Signed-off-by: Austin Abro --- pkg/kube/client.go | 27 +++++---------------------- pkg/kube/kwait.go | 7 +++---- pkg/kube/kwait_test.go | 9 ++++----- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index cbef8fece..a5441f399 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -38,7 +38,6 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" - "sigs.k8s.io/controller-runtime/pkg/client/apiutil" multierror "github.com/hashicorp/go-multierror" "k8s.io/apimachinery/pkg/api/meta" @@ -52,7 +51,6 @@ import ( "k8s.io/apimachinery/pkg/watch" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" - "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" @@ -102,26 +100,11 @@ func init() { } func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { - cfg, err := factory.ToRESTConfig() + dynamicClient, err := factory.DynamicClient() if err != nil { return nil, err } - // factory.DynamicClient() may be a better choice here - dynamicClient, err := dynamic.NewForConfig(cfg) - if err != nil { - return nil, err - } - // Not sure if I should use factory methods to get this http client or I should do this - // For example, I could likely use this as well, but it seems like I should use the factory methods instead - // httpClient, err := rest.HTTPClientFor(cfg) - // if err != nil { - // return err - // } - client, err := factory.RESTClient() - if err != nil { - return nil, err - } - restMapper, err := apiutil.NewDynamicRESTMapper(cfg, client.Client) + restMapper, err := factory.ToRESTMapper() if err != nil { return nil, err } @@ -141,9 +124,9 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) (*Client, err return nil, err } waiter = &kstatusWaiter{ - sw: sw, - log: nopLogger, - pausedAsReady: true} + sw: sw, + log: nopLogger, + } } return &Client{ Factory: factory, diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index 3d8cfb616..d0dcc9b60 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -34,9 +34,8 @@ import ( ) type kstatusWaiter struct { - sw watcher.StatusWatcher - log func(string, ...interface{}) - pausedAsReady bool + sw watcher.StatusWatcher + log func(string, ...interface{}) } func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { @@ -62,7 +61,7 @@ func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, wai continue } case *appsv1.Deployment: - if w.pausedAsReady && value.Spec.Paused { + if value.Spec.Paused { continue } } diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 9598ca216..527d10a05 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -183,9 +183,8 @@ func TestKWaitJob(t *testing.T) { assert.NoError(t, err) } kwaiter := kstatusWaiter{ - sw: statusWatcher, - log: log.Printf, - pausedAsReady: tt.pausedAsReady, + sw: statusWatcher, + log: log.Printf, } resourceList := ResourceList{} @@ -195,8 +194,8 @@ func TestKWaitJob(t *testing.T) { resourceList = append(resourceList, list...) } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) - defer cancel() + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + defer cancel() err := kwaiter.wait(ctx, resourceList, tt.waitForJobs) if tt.expectErrs != nil { From 9b63459becb190ad9f4ebe43235f40ed720e310d Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 30 Dec 2024 14:49:32 +0000 Subject: [PATCH 027/271] save state while I change up tests Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 6 +++++ pkg/kube/kwait_test.go | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index d0dcc9b60..f173a074e 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -50,6 +50,12 @@ func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dur return w.wait(ctx, resourceList, true) } +func (w *kstatusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { + _, cancel := context.WithCancel(ctx) + defer cancel() + return nil +} + func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 527d10a05..2301c373d 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -29,6 +29,7 @@ import ( batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -116,6 +117,59 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured return mapping.Resource } +func TestKWaitForDelete(t *testing.T) { + t.Parallel() + tests := []struct { + name string + objs []runtime.Object + expectErrs []error + waitForJobs bool + pausedAsReady bool + }{ + { + name: "Pod is deleted", + objs: []runtime.Object{ + &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod", Namespace: "ns"}}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + c := newTestClient(t) + fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) + fakeMapper := testutil.NewFakeRESTMapper( + v1.SchemeGroupVersion.WithKind("Pod"), + appsv1.SchemeGroupVersion.WithKind("Deployment"), + batchv1.SchemeGroupVersion.WithKind("Job"), + ) + statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) + kwaiter := kstatusWaiter{ + sw: statusWatcher, + log: log.Printf, + } + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + defer cancel() + resourceList := ResourceList{} + for _, obj := range tt.objs { + list, err := c.Build(objBody(obj), false) + assert.NoError(t, err) + // gvr := getGVR(t, fakeMapper, obj.) + // err = fakeClient.Tracker().Create(gvr, obj, ) + // assert.NoError(t, err) + // resourceList = append(resourceList, list...) + } + err := kwaiter.waitForDelete(ctx, resourceList) + if tt.expectErrs != nil { + assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) + return + } + assert.NoError(t, err) + }) + } + +} + func TestKWaitJob(t *testing.T) { t.Parallel() tests := []struct { From 4dbdd7ce10cfb5f4d1de4dda2a65b27a83f93c0c Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 30 Dec 2024 14:55:13 +0000 Subject: [PATCH 028/271] wait for delete working Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 53 ++++++++++++++++++++++++++++++++++++++- pkg/kube/kwait_test.go | 56 ++++++++++++++++++++++++------------------ 2 files changed, 84 insertions(+), 25 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index f173a074e..ae7fcbe43 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -51,7 +51,58 @@ func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dur } func (w *kstatusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { - _, cancel := context.WithCancel(ctx) + cancelCtx, cancel := context.WithCancel(ctx) + defer cancel() + runtimeObjs := []runtime.Object{} + for _, resource := range resourceList { + runtimeObjs = append(runtimeObjs, resource.Object) + } + resources := []object.ObjMetadata{} + for _, runtimeObj := range runtimeObjs { + obj, err := object.RuntimeToObjMeta(runtimeObj) + if err != nil { + return err + } + resources = append(resources, obj) + } + eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) + statusCollector := collector.NewResourceStatusCollector(resources) + done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( + func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { + rss := []*event.ResourceStatus{} + for _, rs := range statusCollector.ResourceStatuses { + if rs == nil { + continue + } + rss = append(rss, rs) + } + desired := status.NotFoundStatus + if aggregator.AggregateStatus(rss, desired) == desired { + cancel() + return + } + }), + ) + <-done + + if statusCollector.Error != nil { + return statusCollector.Error + } + + // Only check parent context error, otherwise we would error when desired status is achieved. + if ctx.Err() != nil { + errs := []error{} + for _, id := range resources { + rs := statusCollector.ResourceStatuses[id] + if rs.Status == status.CurrentStatus { + continue + } + errs = append(errs, fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + } + errs = append(errs, ctx.Err()) + return errors.Join(errs...) + } + return nil defer cancel() return nil } diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index 2301c373d..f910a4a9b 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -29,7 +29,6 @@ import ( batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -120,17 +119,15 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured func TestKWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { - name string - objs []runtime.Object - expectErrs []error - waitForJobs bool - pausedAsReady bool + name string + objYamls []string + expectErrs []error + waitForJobs bool }{ { - name: "Pod is deleted", - objs: []runtime.Object{ - &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod", Namespace: "ns"}}, - }, + name: "wait for pod to be deleted", + objYamls: []string{podCurrent}, + expectErrs: nil, }, } for _, tt := range tests { @@ -150,14 +147,27 @@ func TestKWaitForDelete(t *testing.T) { } ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) defer cancel() + objs := []runtime.Object{} + for _, podYaml := range tt.objYamls { + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(podYaml), &m) + assert.NoError(t, err) + resource := &unstructured.Unstructured{Object: m} + objs = append(objs, resource) + gvr := getGVR(t, fakeMapper, resource) + err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) + assert.NoError(t, err) + go func(){ + time.Sleep(2 * time.Second) + err = fakeClient.Tracker().Delete(gvr, resource.GetNamespace(), resource.GetName()) + assert.NoError(t, err) + }() + } resourceList := ResourceList{} - for _, obj := range tt.objs { + for _, obj := range objs { list, err := c.Build(objBody(obj), false) assert.NoError(t, err) - // gvr := getGVR(t, fakeMapper, obj.) - // err = fakeClient.Tracker().Create(gvr, obj, ) - // assert.NoError(t, err) - // resourceList = append(resourceList, list...) + resourceList = append(resourceList, list...) } err := kwaiter.waitForDelete(ctx, resourceList) if tt.expectErrs != nil { @@ -173,11 +183,10 @@ func TestKWaitForDelete(t *testing.T) { func TestKWaitJob(t *testing.T) { t.Parallel() tests := []struct { - name string - objYamls []string - expectErrs []error - waitForJobs bool - pausedAsReady bool + name string + objYamls []string + expectErrs []error + waitForJobs bool }{ { name: "Job is complete", @@ -207,10 +216,9 @@ func TestKWaitJob(t *testing.T) { expectErrs: []error{errors.New("in-progress-pod: Pod not ready, status: InProgress"), errors.New("context deadline exceeded")}, }, { - name: "paused deployment passes", - objYamls: []string{pausedDeploymentYaml}, - expectErrs: nil, - pausedAsReady: true, + name: "paused deployment passes", + objYamls: []string{pausedDeploymentYaml}, + expectErrs: nil, }, } From db90b174846d96cce02d5c50993eb56262a1b681 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 30 Dec 2024 15:01:52 +0000 Subject: [PATCH 029/271] unknown status Signed-off-by: Austin Abro --- pkg/kube/kwait.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index ae7fcbe43..587c41c49 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -94,17 +94,20 @@ func (w *kstatusWaiter) waitForDelete(ctx context.Context, resourceList Resource errs := []error{} for _, id := range resources { rs := statusCollector.ResourceStatuses[id] - if rs.Status == status.CurrentStatus { + if rs.Status == status.NotFoundStatus { continue } - errs = append(errs, fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + if rs.Status == status.UnknownStatus { + errs = append(errs, fmt.Errorf("%s: %s cannot determine if resource exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + continue + } + + errs = append(errs, fmt.Errorf("%s: %s still exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } errs = append(errs, ctx.Err()) return errors.Join(errs...) } return nil - defer cancel() - return nil } func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { From 4b59583670e40a556448f2a3627b100c88166a3f Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 5 Jan 2025 14:05:31 +0000 Subject: [PATCH 030/271] delete wait and get completed phase Signed-off-by: Austin Abro --- pkg/kube/client.go | 32 -------------------------------- pkg/kube/fake/fake.go | 34 ++++++++++++---------------------- pkg/kube/fake/printer.go | 6 ------ pkg/kube/interface.go | 4 ---- pkg/kube/kwait.go | 5 ++--- 5 files changed, 14 insertions(+), 67 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index a5441f399..5b466ea6f 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -821,35 +821,3 @@ func scrubValidationError(err error) error { } return err } - -// WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase -// and returns said phase (PodSucceeded or PodFailed qualify). -func (c *Client) WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) { - client, err := c.getKubeClient() - if err != nil { - return v1.PodUnknown, err - } - to := int64(timeout) - watcher, err := client.CoreV1().Pods(c.namespace()).Watch(context.Background(), metav1.ListOptions{ - FieldSelector: fmt.Sprintf("metadata.name=%s", name), - TimeoutSeconds: &to, - }) - if err != nil { - return v1.PodUnknown, err - } - - for event := range watcher.ResultChan() { - p, ok := event.Object.(*v1.Pod) - if !ok { - return v1.PodUnknown, fmt.Errorf("%s not a pod", name) - } - switch p.Status.Phase { - case v1.PodFailed: - return v1.PodFailed, nil - case v1.PodSucceeded: - return v1.PodSucceeded, nil - } - } - - return v1.PodUnknown, err -} diff --git a/pkg/kube/fake/fake.go b/pkg/kube/fake/fake.go index 267020d57..84e375346 100644 --- a/pkg/kube/fake/fake.go +++ b/pkg/kube/fake/fake.go @@ -21,7 +21,6 @@ import ( "io" "time" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" @@ -34,19 +33,18 @@ import ( // delegates all its calls to `PrintingKubeClient` type FailingKubeClient struct { PrintingKubeClient - CreateError error - GetError error - WaitError error - DeleteError error - DeleteWithPropagationError error - WatchUntilReadyError error - UpdateError error - BuildError error - BuildTableError error - BuildDummy bool - BuildUnstructuredError error - WaitAndGetCompletedPodPhaseError error - WaitDuration time.Duration + CreateError error + GetError error + WaitError error + DeleteError error + DeleteWithPropagationError error + WatchUntilReadyError error + UpdateError error + BuildError error + BuildTableError error + BuildDummy bool + BuildUnstructuredError error + WaitDuration time.Duration } // Create returns the configured error if set or prints @@ -133,14 +131,6 @@ func (f *FailingKubeClient) BuildTable(r io.Reader, _ bool) (kube.ResourceList, return f.PrintingKubeClient.BuildTable(r, false) } -// WaitAndGetCompletedPodPhase returns the configured error if set or prints -func (f *FailingKubeClient) WaitAndGetCompletedPodPhase(s string, d time.Duration) (v1.PodPhase, error) { - if f.WaitAndGetCompletedPodPhaseError != nil { - return v1.PodSucceeded, f.WaitAndGetCompletedPodPhaseError - } - return f.PrintingKubeClient.WaitAndGetCompletedPodPhase(s, d) -} - // DeleteWithPropagationPolicy returns the configured error if set or prints func (f *FailingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceList, policy metav1.DeletionPropagation) (*kube.Result, []error) { if f.DeleteWithPropagationError != nil { diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index cc2c84b40..0fb03c113 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -21,7 +21,6 @@ import ( "strings" "time" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" @@ -111,11 +110,6 @@ func (p *PrintingKubeClient) BuildTable(_ io.Reader, _ bool) (kube.ResourceList, return []*resource.Info{}, nil } -// WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase. -func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(_ string, _ time.Duration) (v1.PodPhase, error) { - return v1.PodSucceeded, nil -} - // DeleteWithPropagationPolicy implements KubeClient delete. // // It only prints out the content to be deleted. diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index edc062c49..6cf33c515 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -20,7 +20,6 @@ import ( "io" "time" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -49,9 +48,6 @@ type Interface interface { // error. // TODO: Is watch until ready really behavior we want over the resources actually being ready? WatchUntilReady(resources ResourceList, timeout time.Duration) error - // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase - // and returns said phase (PodSucceeded or PodFailed qualify). - WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) // Build creates a resource list from a Reader. // // Reader must contain a YAML stream (one or more YAML documents separated diff --git a/pkg/kube/kwait.go b/pkg/kube/kwait.go index 587c41c49..1eb1c2053 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/kwait.go @@ -99,10 +99,9 @@ func (w *kstatusWaiter) waitForDelete(ctx context.Context, resourceList Resource } if rs.Status == status.UnknownStatus { errs = append(errs, fmt.Errorf("%s: %s cannot determine if resource exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) - continue + } else { + errs = append(errs, fmt.Errorf("%s: %s still exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } - - errs = append(errs, fmt.Errorf("%s: %s still exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } errs = append(errs, ctx.Err()) return errors.Join(errs...) From 2cb999d72b0051341775861fbf2eca23cec7f3aa Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 5 Jan 2025 14:28:59 +0000 Subject: [PATCH 031/271] go fmt Signed-off-by: Austin Abro --- pkg/kube/kwait_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/kube/kwait_test.go b/pkg/kube/kwait_test.go index f910a4a9b..1e67bfa75 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/kwait_test.go @@ -132,7 +132,7 @@ func TestKWaitForDelete(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - t.Parallel() + // t.Parallel() c := newTestClient(t) fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( @@ -157,11 +157,11 @@ func TestKWaitForDelete(t *testing.T) { gvr := getGVR(t, fakeMapper, resource) err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) assert.NoError(t, err) - go func(){ - time.Sleep(2 * time.Second) - err = fakeClient.Tracker().Delete(gvr, resource.GetNamespace(), resource.GetName()) - assert.NoError(t, err) - }() + go func() { + time.Sleep(2 * time.Second) + err = fakeClient.Tracker().Delete(gvr, resource.GetNamespace(), resource.GetName()) + assert.NoError(t, err) + }() } resourceList := ResourceList{} for _, obj := range objs { @@ -180,7 +180,7 @@ func TestKWaitForDelete(t *testing.T) { } -func TestKWaitJob(t *testing.T) { +func TestKWait(t *testing.T) { t.Parallel() tests := []struct { name string @@ -224,7 +224,7 @@ func TestKWaitJob(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - t.Parallel() + // t.Parallel() c := newTestClient(t) fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( From 4dd6e19b1d3b2c1d6993f61292dd77d5c2bf4105 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 5 Jan 2025 14:45:18 +0000 Subject: [PATCH 032/271] provide path for creating new legacy waiter Signed-off-by: Austin Abro --- pkg/kube/wait.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index b4cb85080..cbec8fa59 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -34,26 +34,33 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" + "k8s.io/client-go/kubernetes" "k8s.io/apimachinery/pkg/util/wait" ) type waiter struct { - c ReadyChecker - timeout time.Duration - log func(string, ...interface{}) + c ReadyChecker + timeout time.Duration + log func(string, ...interface{}) + kubeClient *kubernetes.Clientset +} + +func (w *waiter) NewLegacyWaiter(kubeClient *kubernetes.Clientset, log func(string, ...interface{})) *waiter { + return &waiter{ + log: log, + kubeClient: kubeClient, + } } func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error { + w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true)) w.timeout = timeout return w.waitForResources(resources) } func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { - // Implementation - // TODO this function doesn't make sense unless you pass a readyChecker to it - // TODO pass context instead - // checker := NewReadyChecker(cs, w.c.Log, PausedAsReady(true), CheckJobs(true)) + w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true), CheckJobs(true)) w.timeout = timeout return w.waitForResources(resources) } From cb6d48e6ae553ddd95ac838ae45fb7c0aabbfa71 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 5 Jan 2025 15:11:05 +0000 Subject: [PATCH 033/271] status wait Signed-off-by: Austin Abro --- pkg/kube/client.go | 2 +- pkg/kube/{kwait.go => statuswait.go} | 10 +++++----- pkg/kube/{kwait_test.go => statuswait_test.go} | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) rename pkg/kube/{kwait.go => statuswait.go} (92%) rename pkg/kube/{kwait_test.go => statuswait_test.go} (97%) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 45d842c4a..91b09eb65 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -123,7 +123,7 @@ func New(getter genericclioptions.RESTClientGetter, waiter Waiter) (*Client, err if err != nil { return nil, err } - waiter = &kstatusWaiter{ + waiter = &statusWaiter{ sw: sw, log: nopLogger, } diff --git a/pkg/kube/kwait.go b/pkg/kube/statuswait.go similarity index 92% rename from pkg/kube/kwait.go rename to pkg/kube/statuswait.go index 1eb1c2053..d58e34cdc 100644 --- a/pkg/kube/kwait.go +++ b/pkg/kube/statuswait.go @@ -33,24 +33,24 @@ import ( "sigs.k8s.io/cli-utils/pkg/object" ) -type kstatusWaiter struct { +type statusWaiter struct { sw watcher.StatusWatcher log func(string, ...interface{}) } -func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { +func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() return w.wait(ctx, resourceList, false) } -func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { +func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() return w.wait(ctx, resourceList, true) } -func (w *kstatusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { +func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() runtimeObjs := []runtime.Object{} @@ -109,7 +109,7 @@ func (w *kstatusWaiter) waitForDelete(ctx context.Context, resourceList Resource return nil } -func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { +func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() runtimeObjs := []runtime.Object{} diff --git a/pkg/kube/kwait_test.go b/pkg/kube/statuswait_test.go similarity index 97% rename from pkg/kube/kwait_test.go rename to pkg/kube/statuswait_test.go index 1e67bfa75..31211d226 100644 --- a/pkg/kube/kwait_test.go +++ b/pkg/kube/statuswait_test.go @@ -116,7 +116,7 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured return mapping.Resource } -func TestKWaitForDelete(t *testing.T) { +func TestStatusWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { name string @@ -132,7 +132,7 @@ func TestKWaitForDelete(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - // t.Parallel() + t.Parallel() c := newTestClient(t) fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( @@ -141,7 +141,7 @@ func TestKWaitForDelete(t *testing.T) { batchv1.SchemeGroupVersion.WithKind("Job"), ) statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) - kwaiter := kstatusWaiter{ + kwaiter := statusWaiter{ sw: statusWatcher, log: log.Printf, } @@ -180,7 +180,7 @@ func TestKWaitForDelete(t *testing.T) { } -func TestKWait(t *testing.T) { +func TestStatusWait(t *testing.T) { t.Parallel() tests := []struct { name string @@ -224,7 +224,7 @@ func TestKWait(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - // t.Parallel() + t.Parallel() c := newTestClient(t) fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( @@ -244,7 +244,7 @@ func TestKWait(t *testing.T) { err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) assert.NoError(t, err) } - kwaiter := kstatusWaiter{ + kwaiter := statusWaiter{ sw: statusWatcher, log: log.Printf, } From 86338215b7aff34bab669c9842c19aab771c5d6b Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 5 Jan 2025 15:42:56 +0000 Subject: [PATCH 034/271] ability to create different waiters Signed-off-by: Austin Abro --- pkg/action/action.go | 2 +- pkg/kube/client.go | 43 +++++++++++++++++++++++++++++++---------- pkg/kube/client_test.go | 35 ++++++++------------------------- pkg/kube/wait.go | 7 ------- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index e8e0a997a..7edb4a1ae 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -371,7 +371,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - kc, err := kube.New(getter, nil) + kc, err := kube.New(getter, kube.StatusWaiter) if err != nil { return err } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 91b09eb65..ce22f265a 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -88,6 +88,13 @@ type Client struct { Waiter } +type WaitStrategy int + +const ( + StatusWaiter WaitStrategy = iota + LegacyWaiter +) + func init() { // Add CRDs to the scheme. They are missing by default. if err := apiextv1.AddToScheme(scheme.Scheme); err != nil { @@ -112,21 +119,37 @@ func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { return sw, nil } -// New creates a new Client. -func New(getter genericclioptions.RESTClientGetter, waiter Waiter) (*Client, error) { - if getter == nil { - getter = genericclioptions.NewConfigFlags(true) - } - factory := cmdutil.NewFactory(getter) - if waiter == nil { +func NewWaiter(strategy WaitStrategy, factory Factory, log func(string, ...interface{})) (Waiter, error) { + switch strategy { + case LegacyWaiter: + kc, err := factory.KubernetesClientSet() + if err != nil { + return nil, err + } + return &waiter{kubeClient: kc, log: log}, nil + case StatusWaiter: sw, err := getStatusWatcher(factory) if err != nil { return nil, err } - waiter = &statusWaiter{ + return &statusWaiter{ sw: sw, - log: nopLogger, - } + log: log, + }, nil + default: + return nil, errors.New("unknown wait strategy") + } +} + +// New creates a new Client. +func New(getter genericclioptions.RESTClientGetter, ws WaitStrategy) (*Client, error) { + if getter == nil { + getter = genericclioptions.NewConfigFlags(true) + } + factory := cmdutil.NewFactory(getter) + waiter, err := NewWaiter(ws, factory, nopLogger) + if err != nil { + return nil, err } return &Client{ Factory: factory, diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 037719219..3ab415a48 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -453,10 +453,6 @@ func TestPerform(t *testing.T) { } } -// Likely it is not possible to get this test to work with kstatus given that it seems -// kstatus is not making constant get checks on the resources and is instead waiting for events -// Potentially the test could be reworked to make the pods after five seconds -// would need this -> func TestWait(t *testing.T) { podList := newPodList("starfish", "otter", "squid") @@ -517,16 +513,11 @@ func TestWait(t *testing.T) { } }), } - cs, err := c.getKubeClient() + waiter, err := NewWaiter(LegacyWaiter, c.Factory, c.Log) if err != nil { t.Fatal(err) } - checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) - c.Waiter = &waiter{ - c: checker, - log: c.Log, - timeout: time.Second * 30, - } + c.Waiter = waiter resources, err := c.Build(objBody(&podList), false) if err != nil { t.Fatal(err) @@ -579,16 +570,11 @@ func TestWaitJob(t *testing.T) { } }), } - cs, err := c.getKubeClient() + waiter, err := NewWaiter(LegacyWaiter, c.Factory, c.Log) if err != nil { t.Fatal(err) } - checker := NewReadyChecker(cs, c.Log, PausedAsReady(true), CheckJobs(true)) - c.Waiter = &waiter{ - c: checker, - log: c.Log, - timeout: time.Second * 30, - } + c.Waiter = waiter resources, err := c.Build(objBody(job), false) if err != nil { t.Fatal(err) @@ -643,16 +629,11 @@ func TestWaitDelete(t *testing.T) { } }), } - cs, err := c.getKubeClient() + waiter, err := NewWaiter(LegacyWaiter, c.Factory, c.Log) if err != nil { t.Fatal(err) } - checker := NewReadyChecker(cs, c.Log, PausedAsReady(true)) - c.Waiter = &waiter{ - c: checker, - log: c.Log, - timeout: time.Second * 30, - } + c.Waiter = waiter resources, err := c.Build(objBody(&pod), false) if err != nil { t.Fatal(err) @@ -679,7 +660,7 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c, err := New(nil, nil) + c, err := New(nil, StatusWaiter) if err != nil { t.Fatal(err) } @@ -692,7 +673,7 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c, err = New(nil, nil) + c, err = New(nil, StatusWaiter) if err != nil { t.Fatal(err) } diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index cbec8fa59..0ee4504cb 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -46,13 +46,6 @@ type waiter struct { kubeClient *kubernetes.Clientset } -func (w *waiter) NewLegacyWaiter(kubeClient *kubernetes.Clientset, log func(string, ...interface{})) *waiter { - return &waiter{ - log: log, - kubeClient: kubeClient, - } -} - func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error { w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true)) w.timeout = timeout From 4c97d1276ca765bc9ba181a6a280b25b75a713dd Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 12:31:43 +0000 Subject: [PATCH 035/271] helm waiter Signed-off-by: Austin Abro --- pkg/kube/client.go | 4 ++-- pkg/kube/statuswait.go | 4 ++++ pkg/kube/statuswait_test.go | 2 +- pkg/kube/wait.go | 14 +++++++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index ce22f265a..fe830747d 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -126,7 +126,7 @@ func NewWaiter(strategy WaitStrategy, factory Factory, log func(string, ...inter if err != nil { return nil, err } - return &waiter{kubeClient: kc, log: log}, nil + return &HelmWaiter{kubeClient: kc, log: log}, nil case StatusWaiter: sw, err := getStatusWatcher(factory) if err != nil { @@ -333,7 +333,7 @@ func getResource(info *resource.Info) (runtime.Object, error) { // WaitForDelete wait up to the given timeout for the specified resources to be deleted. func (c *Client) WaitForDelete(resources ResourceList, timeout time.Duration) error { - w := waiter{ + w := HelmWaiter{ log: c.Log, timeout: timeout, } diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index d58e34cdc..bbc92292d 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -51,6 +51,8 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura } func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { + deadline, _ := ctx.Deadline() + w.log("beginning wait for %d resources to be deleted with timeout of %v", len(resourceList), time.Until(deadline)) cancelCtx, cancel := context.WithCancel(ctx) defer cancel() runtimeObjs := []runtime.Object{} @@ -110,6 +112,8 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { + deadline, _ := ctx.Deadline() + w.log("beginning wait for %d resources with timeout of %v", len(resourceList), deadline) cancelCtx, cancel := context.WithCancel(ctx) defer cancel() runtimeObjs := []runtime.Object{} diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 31211d226..b018691cd 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -143,7 +143,7 @@ func TestStatusWaitForDelete(t *testing.T) { statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) kwaiter := statusWaiter{ sw: statusWatcher, - log: log.Printf, + log: t.Logf, } ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) defer cancel() diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 0ee4504cb..044bbbe1d 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -39,20 +39,20 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ) -type waiter struct { +type HelmWaiter struct { c ReadyChecker timeout time.Duration log func(string, ...interface{}) kubeClient *kubernetes.Clientset } -func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error { +func (w *HelmWaiter) Wait(resources ResourceList, timeout time.Duration) error { w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true)) w.timeout = timeout return w.waitForResources(resources) } -func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { +func (w *HelmWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true), CheckJobs(true)) w.timeout = timeout return w.waitForResources(resources) @@ -60,7 +60,7 @@ func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) err // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached -func (w *waiter) waitForResources(created ResourceList) error { +func (w *HelmWaiter) waitForResources(created ResourceList) error { w.log("beginning wait for %d resources with timeout of %v", len(created), w.timeout) ctx, cancel := context.WithTimeout(context.Background(), w.timeout) @@ -94,7 +94,7 @@ func (w *waiter) waitForResources(created ResourceList) error { }) } -func (w *waiter) isRetryableError(err error, resource *resource.Info) bool { +func (w *HelmWaiter) isRetryableError(err error, resource *resource.Info) bool { if err == nil { return false } @@ -109,12 +109,12 @@ func (w *waiter) isRetryableError(err error, resource *resource.Info) bool { return true } -func (w *waiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { +func (w *HelmWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { return httpStatusCode == 0 || httpStatusCode == http.StatusTooManyRequests || (httpStatusCode >= 500 && httpStatusCode != http.StatusNotImplemented) } // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached -func (w *waiter) waitForDeletedResources(deleted ResourceList) error { +func (w *HelmWaiter) waitForDeletedResources(deleted ResourceList) error { w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), w.timeout) ctx, cancel := context.WithTimeout(context.Background(), w.timeout) From b8bdcc3a2b866296c2639ef683d55a777ef66403 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 12:33:26 +0000 Subject: [PATCH 036/271] Helm waiter Signed-off-by: Austin Abro --- pkg/kube/wait.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 044bbbe1d..e74753e57 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -39,6 +39,8 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ) +// HelmWaiter is the legacy implementation of the Waiter interface. This logic was used by default in Helm 3 +// Helm 4 now uses the StatusWaiter interface instead type HelmWaiter struct { c ReadyChecker timeout time.Duration From ac9012577a8fccd13371966539fb953d4ff043ea Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 13:06:54 +0000 Subject: [PATCH 037/271] status function Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 50 +++++++++++++------------------------ pkg/kube/statuswait_test.go | 3 +-- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index bbc92292d..bec38f7c9 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -69,22 +69,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( - func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { - rss := []*event.ResourceStatus{} - for _, rs := range statusCollector.ResourceStatuses { - if rs == nil { - continue - } - rss = append(rss, rs) - } - desired := status.NotFoundStatus - if aggregator.AggregateStatus(rss, desired) == desired { - cancel() - return - } - }), - ) + done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus)) <-done if statusCollector.Error != nil { @@ -140,22 +125,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait } eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - done := statusCollector.ListenWithObserver(eventCh, collector.ObserverFunc( - func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { - rss := []*event.ResourceStatus{} - for _, rs := range statusCollector.ResourceStatuses { - if rs == nil { - continue - } - rss = append(rss, rs) - } - desired := status.CurrentStatus - if aggregator.AggregateStatus(rss, desired) == desired { - cancel() - return - } - }), - ) + done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus)) <-done if statusCollector.Error != nil { @@ -177,3 +147,19 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait } return nil } + +func statusObserver(cancel context.CancelFunc, desired status.Status) collector.ObserverFunc { + return func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { + rss := []*event.ResourceStatus{} + for _, rs := range statusCollector.ResourceStatuses { + if rs == nil { + continue + } + rss = append(rss, rs) + } + if aggregator.AggregateStatus(rss, desired) == desired { + cancel() + return + } + } +} diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index b018691cd..822204dfe 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -19,7 +19,6 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "context" "errors" - "log" "testing" "time" @@ -246,7 +245,7 @@ func TestStatusWait(t *testing.T) { } kwaiter := statusWaiter{ sw: statusWatcher, - log: log.Printf, + log: t.Logf, } resourceList := ResourceList{} From 6b68a004400cab1f50cd3fa2861585e3fceb4eca Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 13:30:29 +0000 Subject: [PATCH 038/271] change error messages Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 6 ++-- pkg/kube/statuswait_test.go | 63 +++++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index bec38f7c9..8cd8bcfc2 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -85,9 +85,9 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL continue } if rs.Status == status.UnknownStatus { - errs = append(errs, fmt.Errorf("%s: %s cannot determine if resource exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + errs = append(errs, fmt.Errorf("cannot determine resource state, name: %s, kind: %s, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } else { - errs = append(errs, fmt.Errorf("%s: %s still exists, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + errs = append(errs, fmt.Errorf("resource still exists, name: %s, kind: %s, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } } errs = append(errs, ctx.Err()) @@ -140,7 +140,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait if rs.Status == status.CurrentStatus { continue } - errs = append(errs, fmt.Errorf("%s: %s not ready, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) + errs = append(errs, fmt.Errorf("resource not ready, name: %s, kind: %s, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } errs = append(errs, ctx.Err()) return errors.Join(errs...) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 822204dfe..ecd18e183 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -119,20 +119,29 @@ func TestStatusWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { name string - objYamls []string + objToCreate []string + toDelete []string expectErrs []error - waitForJobs bool }{ { - name: "wait for pod to be deleted", - objYamls: []string{podCurrent}, - expectErrs: nil, + name: "wait for pod to be deleted", + objToCreate: []string{podCurrent}, + toDelete: []string{podCurrent}, + expectErrs: nil, + }, + { + name: "error when not all objects are deleted", + objToCreate: []string{jobComplete, podCurrent}, + toDelete: []string{jobComplete}, + expectErrs: []error{errors.New("resource still exists, name: good-pod, kind: Pod, status: Current"), errors.New("context deadline exceeded")}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Parallel() c := newTestClient(t) + timeout := time.Second * 3 + timeToDeletePod := time.Second * 2 fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), @@ -140,35 +149,42 @@ func TestStatusWaitForDelete(t *testing.T) { batchv1.SchemeGroupVersion.WithKind("Job"), ) statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) - kwaiter := statusWaiter{ + statusWaiter := statusWaiter{ sw: statusWatcher, log: t.Logf, } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - objs := []runtime.Object{} - for _, podYaml := range tt.objYamls { + createdObjs := []runtime.Object{} + for _, objYaml := range tt.objToCreate { m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(podYaml), &m) + err := yaml.Unmarshal([]byte(objYaml), &m) assert.NoError(t, err) resource := &unstructured.Unstructured{Object: m} - objs = append(objs, resource) + createdObjs = append(createdObjs, resource) gvr := getGVR(t, fakeMapper, resource) err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) assert.NoError(t, err) + } + for _, objYaml := range tt.toDelete { + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(objYaml), &m) + assert.NoError(t, err) + resource := &unstructured.Unstructured{Object: m} + gvr := getGVR(t, fakeMapper, resource) go func() { - time.Sleep(2 * time.Second) + time.Sleep(timeToDeletePod) err = fakeClient.Tracker().Delete(gvr, resource.GetNamespace(), resource.GetName()) assert.NoError(t, err) }() } resourceList := ResourceList{} - for _, obj := range objs { + for _, obj := range createdObjs { list, err := c.Build(objBody(obj), false) assert.NoError(t, err) resourceList = append(resourceList, list...) } - err := kwaiter.waitForDelete(ctx, resourceList) + err := statusWaiter.waitForDelete(ctx, resourceList) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return @@ -195,7 +211,7 @@ func TestStatusWait(t *testing.T) { { name: "Job is not complete", objYamls: []string{jobNoStatus}, - expectErrs: []error{errors.New("test: Job not ready, status: InProgress"), errors.New("context deadline exceeded")}, + expectErrs: []error{errors.New("resource not ready, name: test, kind: Job, status: InProgress"), errors.New("context deadline exceeded")}, waitForJobs: true, }, { @@ -212,7 +228,7 @@ func TestStatusWait(t *testing.T) { { name: "one of the pods never becomes ready", objYamls: []string{podNoStatus, podCurrent}, - expectErrs: []error{errors.New("in-progress-pod: Pod not ready, status: InProgress"), errors.New("context deadline exceeded")}, + expectErrs: []error{errors.New("resource not ready, name: in-progress-pod, kind: Pod, status: InProgress"), errors.New("context deadline exceeded")}, }, { name: "paused deployment passes", @@ -231,8 +247,13 @@ func TestStatusWait(t *testing.T) { appsv1.SchemeGroupVersion.WithKind("Deployment"), batchv1.SchemeGroupVersion.WithKind("Job"), ) - objs := []runtime.Object{} statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) + statusWaiter := statusWaiter{ + sw: statusWatcher, + log: t.Logf, + } + objs := []runtime.Object{} + for _, podYaml := range tt.objYamls { m := make(map[string]interface{}) err := yaml.Unmarshal([]byte(podYaml), &m) @@ -243,11 +264,6 @@ func TestStatusWait(t *testing.T) { err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) assert.NoError(t, err) } - kwaiter := statusWaiter{ - sw: statusWatcher, - log: t.Logf, - } - resourceList := ResourceList{} for _, obj := range objs { list, err := c.Build(objBody(obj), false) @@ -257,8 +273,7 @@ func TestStatusWait(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) defer cancel() - - err := kwaiter.wait(ctx, resourceList, tt.waitForJobs) + err := statusWaiter.wait(ctx, resourceList, tt.waitForJobs) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return From e6c6a40fe0fed670eaaaf60ada1643a0946ac3e0 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 13:58:34 +0000 Subject: [PATCH 039/271] general error message Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 8cd8bcfc2..8268598e6 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -84,11 +84,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL if rs.Status == status.NotFoundStatus { continue } - if rs.Status == status.UnknownStatus { - errs = append(errs, fmt.Errorf("cannot determine resource state, name: %s, kind: %s, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) - } else { - errs = append(errs, fmt.Errorf("resource still exists, name: %s, kind: %s, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) - } + errs = append(errs, fmt.Errorf("resource still exists, name: %s, kind: %s, status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, rs.Status)) } errs = append(errs, ctx.Err()) return errors.Join(errs...) From 8ce1876192b12db58993a993e5f307a1a17c3f08 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 14:12:34 +0000 Subject: [PATCH 040/271] get rid of ext interface Signed-off-by: Austin Abro --- pkg/action/hooks.go | 8 ++------ pkg/action/uninstall.go | 6 ++---- pkg/kube/client.go | 9 --------- pkg/kube/interface.go | 6 ------ pkg/kube/statuswait.go | 6 ++++++ pkg/kube/statuswait_test.go | 4 +--- pkg/kube/wait.go | 19 ++++++++----------- 7 files changed, 19 insertions(+), 39 deletions(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index ecca1d997..c32b9b3ce 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -22,7 +22,6 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) @@ -138,11 +137,8 @@ func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.Hoo return errors.New(joinErrors(errs)) } - //wait for resources until they are deleted to avoid conflicts - if kubeClient, ok := cfg.KubeClient.(kube.InterfaceExt); ok { - if err := kubeClient.WaitForDelete(resources, timeout); err != nil { - return err - } + if err := cfg.KubeClient.WaitForDelete(resources, timeout); err != nil { + return err } } return nil diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index dda7d6978..75d999976 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -131,10 +131,8 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) res.Info = kept if u.Wait { - if kubeClient, ok := u.cfg.KubeClient.(kube.InterfaceExt); ok { - if err := kubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil { - errs = append(errs, err) - } + if err := u.cfg.KubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil { + errs = append(errs, err) } } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index fe830747d..968e1b951 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -331,15 +331,6 @@ func getResource(info *resource.Info) (runtime.Object, error) { return obj, nil } -// WaitForDelete wait up to the given timeout for the specified resources to be deleted. -func (c *Client) WaitForDelete(resources ResourceList, timeout time.Duration) error { - w := HelmWaiter{ - log: c.Log, - timeout: timeout, - } - return w.waitForDeletedResources(resources) -} - func (c *Client) namespace() string { if c.Namespace != "" { return c.Namespace diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 6cf33c515..30be37f7c 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -67,12 +67,7 @@ type Waiter interface { // WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs. WaitWithJobs(resources ResourceList, timeout time.Duration) error -} -// InterfaceExt is introduced to avoid breaking backwards compatibility for Interface implementers. -// -// TODO Helm 4: Remove InterfaceExt and integrate its method(s) into the Interface. -type InterfaceExt interface { // WaitForDelete wait up to the given timeout for the specified resources to be deleted. WaitForDelete(resources ResourceList, timeout time.Duration) error } @@ -108,6 +103,5 @@ type InterfaceResources interface { } var _ Interface = (*Client)(nil) -var _ InterfaceExt = (*Client)(nil) var _ InterfaceDeletionPropagation = (*Client)(nil) var _ InterfaceResources = (*Client)(nil) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 8268598e6..b1c39948c 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -50,6 +50,12 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura return w.wait(ctx, resourceList, true) } +func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { + ctx, cancel := context.WithTimeout(context.TODO(), timeout) + defer cancel() + return w.waitForDelete(ctx, resourceList) +} + func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { deadline, _ := ctx.Deadline() w.log("beginning wait for %d resources to be deleted with timeout of %v", len(resourceList), time.Until(deadline)) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index ecd18e183..0084606cf 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -153,8 +153,6 @@ func TestStatusWaitForDelete(t *testing.T) { sw: statusWatcher, log: t.Logf, } - ctx, cancel := context.WithTimeout(context.Background(), timeout) - defer cancel() createdObjs := []runtime.Object{} for _, objYaml := range tt.objToCreate { m := make(map[string]interface{}) @@ -184,7 +182,7 @@ func TestStatusWaitForDelete(t *testing.T) { assert.NoError(t, err) resourceList = append(resourceList, list...) } - err := statusWaiter.waitForDelete(ctx, resourceList) + err := statusWaiter.WaitForDelete(resourceList, timeout) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index e74753e57..97fa8b3e1 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -43,29 +43,26 @@ import ( // Helm 4 now uses the StatusWaiter interface instead type HelmWaiter struct { c ReadyChecker - timeout time.Duration log func(string, ...interface{}) kubeClient *kubernetes.Clientset } func (w *HelmWaiter) Wait(resources ResourceList, timeout time.Duration) error { w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true)) - w.timeout = timeout - return w.waitForResources(resources) + return w.waitForResources(resources, timeout) } func (w *HelmWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true), CheckJobs(true)) - w.timeout = timeout - return w.waitForResources(resources) + return w.waitForResources(resources, timeout) } // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached -func (w *HelmWaiter) waitForResources(created ResourceList) error { - w.log("beginning wait for %d resources with timeout of %v", len(created), w.timeout) +func (w *HelmWaiter) waitForResources(created ResourceList, timeout time.Duration) error { + w.log("beginning wait for %d resources with timeout of %v", len(created), timeout) - ctx, cancel := context.WithTimeout(context.Background(), w.timeout) + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() numberOfErrors := make([]int, len(created)) @@ -116,10 +113,10 @@ func (w *HelmWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { } // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached -func (w *HelmWaiter) waitForDeletedResources(deleted ResourceList) error { - w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), w.timeout) +func (w *HelmWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { + w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), timeout) - ctx, cancel := context.WithTimeout(context.Background(), w.timeout) + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) { From c26b44f65172b2d6e41e4ce8f0024c70c595ff6a Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 15:21:11 +0000 Subject: [PATCH 041/271] update names Signed-off-by: Austin Abro --- pkg/action/action.go | 2 +- pkg/kube/client.go | 8 ++++---- pkg/kube/client_test.go | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 7edb4a1ae..0157ce1cc 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -371,7 +371,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - kc, err := kube.New(getter, kube.StatusWaiter) + kc, err := kube.New(getter, kube.StatusWaiterStrategy) if err != nil { return err } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 968e1b951..daa484b69 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -91,8 +91,8 @@ type Client struct { type WaitStrategy int const ( - StatusWaiter WaitStrategy = iota - LegacyWaiter + StatusWaiterStrategy WaitStrategy = iota + LegacyWaiterStrategy ) func init() { @@ -121,13 +121,13 @@ func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { func NewWaiter(strategy WaitStrategy, factory Factory, log func(string, ...interface{})) (Waiter, error) { switch strategy { - case LegacyWaiter: + case LegacyWaiterStrategy: kc, err := factory.KubernetesClientSet() if err != nil { return nil, err } return &HelmWaiter{kubeClient: kc, log: log}, nil - case StatusWaiter: + case StatusWaiterStrategy: sw, err := getStatusWatcher(factory) if err != nil { return nil, err diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 3ab415a48..50fc65cef 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -513,7 +513,7 @@ func TestWait(t *testing.T) { } }), } - waiter, err := NewWaiter(LegacyWaiter, c.Factory, c.Log) + waiter, err := NewWaiter(LegacyWaiterStrategy, c.Factory, c.Log) if err != nil { t.Fatal(err) } @@ -570,7 +570,7 @@ func TestWaitJob(t *testing.T) { } }), } - waiter, err := NewWaiter(LegacyWaiter, c.Factory, c.Log) + waiter, err := NewWaiter(LegacyWaiterStrategy, c.Factory, c.Log) if err != nil { t.Fatal(err) } @@ -629,7 +629,7 @@ func TestWaitDelete(t *testing.T) { } }), } - waiter, err := NewWaiter(LegacyWaiter, c.Factory, c.Log) + waiter, err := NewWaiter(LegacyWaiterStrategy, c.Factory, c.Log) if err != nil { t.Fatal(err) } @@ -660,7 +660,7 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c, err := New(nil, StatusWaiter) + c, err := New(nil, StatusWaiterStrategy) if err != nil { t.Fatal(err) } @@ -673,7 +673,7 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c, err = New(nil, StatusWaiter) + c, err = New(nil, StatusWaiterStrategy) if err != nil { t.Fatal(err) } From 649475265df89f5b514dcd95bcf90d4b32a215f3 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 16:25:49 +0000 Subject: [PATCH 042/271] implement logger Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 22 ++++++++++++++++++++++ pkg/kube/statuswait_test.go | 8 ++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index b1c39948c..bb92ae74e 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -75,6 +75,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) + go logResource(ctx, resources, statusCollector, status.NotFoundStatus, w.log) done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus)) <-done @@ -127,6 +128,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait } eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) + go logResource(cancelCtx, resources, statusCollector, status.CurrentStatus, w.log) done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus)) <-done @@ -165,3 +167,23 @@ func statusObserver(cancel context.CancelFunc, desired status.Status) collector. } } } + +func logResource(ctx context.Context, resources []object.ObjMetadata, sc *collector.ResourceStatusCollector, desiredStatus status.Status, log func(string, ...interface{})) { + ticker := time.NewTicker(1 * time.Second) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + for _, id := range resources { + rs := sc.ResourceStatuses[id] + if rs.Status != desiredStatus { + log("waiting for resource, name: %s, kind: %s, desired status: %s, actual status: %s\n", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, desiredStatus, rs.Status) + // only log one resource to not overwhelm the logs + break + } + } + } + } +} diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 0084606cf..0d635ad79 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -19,6 +19,7 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "context" "errors" + "fmt" "testing" "time" @@ -114,6 +115,9 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured require.NoError(t, err) return mapping.Resource } +func testLogger(message string, args ...interface{}) { + fmt.Printf(message, args...) +} func TestStatusWaitForDelete(t *testing.T) { t.Parallel() @@ -151,7 +155,7 @@ func TestStatusWaitForDelete(t *testing.T) { statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) statusWaiter := statusWaiter{ sw: statusWatcher, - log: t.Logf, + log: testLogger, } createdObjs := []runtime.Object{} for _, objYaml := range tt.objToCreate { @@ -248,7 +252,7 @@ func TestStatusWait(t *testing.T) { statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) statusWaiter := statusWaiter{ sw: statusWatcher, - log: t.Logf, + log: testLogger, } objs := []runtime.Object{} From 71434c0b388a7bf8a1bdf3302779199becc3ce4b Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 16:26:20 +0000 Subject: [PATCH 043/271] implement logger Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 0d635ad79..945131a5e 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -144,8 +144,8 @@ func TestStatusWaitForDelete(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() c := newTestClient(t) - timeout := time.Second * 3 - timeToDeletePod := time.Second * 2 + timeout := time.Second * 2 + timeUntilPodDelete := time.Second * 1 fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), @@ -175,7 +175,7 @@ func TestStatusWaitForDelete(t *testing.T) { resource := &unstructured.Unstructured{Object: m} gvr := getGVR(t, fakeMapper, resource) go func() { - time.Sleep(timeToDeletePod) + time.Sleep(timeUntilPodDelete) err = fakeClient.Tracker().Delete(gvr, resource.GetNamespace(), resource.GetName()) assert.NoError(t, err) }() From e9d98543644b7b59b17c38a0af4ca500ab7e2644 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 16:50:40 +0000 Subject: [PATCH 044/271] introduce test for status wait Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 8 ++++---- pkg/kube/statuswait_test.go | 33 +++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index bb92ae74e..a4590aa42 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -75,7 +75,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - go logResource(ctx, resources, statusCollector, status.NotFoundStatus, w.log) + go logResourceStatus(ctx, resources, statusCollector, status.NotFoundStatus, w.log) done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus)) <-done @@ -128,7 +128,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait } eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - go logResource(cancelCtx, resources, statusCollector, status.CurrentStatus, w.log) + go logResourceStatus(cancelCtx, resources, statusCollector, status.CurrentStatus, w.log) done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus)) <-done @@ -168,7 +168,7 @@ func statusObserver(cancel context.CancelFunc, desired status.Status) collector. } } -func logResource(ctx context.Context, resources []object.ObjMetadata, sc *collector.ResourceStatusCollector, desiredStatus status.Status, log func(string, ...interface{})) { +func logResourceStatus(ctx context.Context, resources []object.ObjMetadata, sc *collector.ResourceStatusCollector, desiredStatus status.Status, log func(string, ...interface{})) { ticker := time.NewTicker(1 * time.Second) defer ticker.Stop() for { @@ -179,7 +179,7 @@ func logResource(ctx context.Context, resources []object.ObjMetadata, sc *collec for _, id := range resources { rs := sc.ResourceStatuses[id] if rs.Status != desiredStatus { - log("waiting for resource, name: %s, kind: %s, desired status: %s, actual status: %s\n", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, desiredStatus, rs.Status) + log("waiting for resource, name: %s, kind: %s, desired status: %s, actual status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, desiredStatus, rs.Status) // only log one resource to not overwhelm the logs break } diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 945131a5e..e94e13313 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -35,7 +35,11 @@ import ( "k8s.io/apimachinery/pkg/util/yaml" dynamicfake "k8s.io/client-go/dynamic/fake" "k8s.io/kubectl/pkg/scheme" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" + "sigs.k8s.io/cli-utils/pkg/kstatus/status" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" + "sigs.k8s.io/cli-utils/pkg/object" "sigs.k8s.io/cli-utils/pkg/testutil" ) @@ -115,8 +119,29 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured require.NoError(t, err) return mapping.Resource } -func testLogger(message string, args ...interface{}) { - fmt.Printf(message, args...) + +func TestStatusLogger(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*1500) + defer cancel() + readyPod := object.ObjMetadata{ + Name: "readyPod", + GroupKind: schema.GroupKind{Kind: "Pod"}, + } + notReadyPod := object.ObjMetadata{ + Name: "notReadyPod", + GroupKind: schema.GroupKind{Kind: "Pod"}, + } + objs := []object.ObjMetadata{readyPod, notReadyPod} + resourceStatusCollector := collector.NewResourceStatusCollector(objs) + resourceStatusCollector.ResourceStatuses[readyPod] = &event.ResourceStatus{ + Identifier: readyPod, + Status: status.CurrentStatus, + } + expectedMessage := "waiting for resource, name: notReadyPod, kind: Pod, desired status: Current, actual status: Unknown" + testLogger := func(message string, args ...interface{}) { + assert.Equal(t, expectedMessage, fmt.Sprintf(message, args...)) + } + logResourceStatus(ctx, objs, resourceStatusCollector, status.CurrentStatus, testLogger) } func TestStatusWaitForDelete(t *testing.T) { @@ -155,7 +180,7 @@ func TestStatusWaitForDelete(t *testing.T) { statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) statusWaiter := statusWaiter{ sw: statusWatcher, - log: testLogger, + log: t.Logf, } createdObjs := []runtime.Object{} for _, objYaml := range tt.objToCreate { @@ -252,7 +277,7 @@ func TestStatusWait(t *testing.T) { statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) statusWaiter := statusWaiter{ sw: statusWatcher, - log: testLogger, + log: t.Logf, } objs := []runtime.Object{} From 674ab0d4f6b0fc66b656ae98bab0d829eac9c5d2 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 16:55:30 +0000 Subject: [PATCH 045/271] t.Parrallel Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index e94e13313..c3aa61a69 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -121,6 +121,7 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured } func TestStatusLogger(t *testing.T) { + t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*1500) defer cancel() readyPod := object.ObjMetadata{ From eaa6e14546ba3bd58150df6f407594330247d2f9 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 16:57:32 +0000 Subject: [PATCH 046/271] test cleanup Signed-off-by: Austin Abro --- pkg/kube/client_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 50fc65cef..abe74022d 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -459,7 +459,6 @@ func TestWait(t *testing.T) { var created *time.Time c := newTestClient(t) - c.Factory.(*cmdtesting.TestFactory).ClientConfigVal = cmdtesting.DefaultClientConfig() c.Factory.(*cmdtesting.TestFactory).Client = &fake.RESTClient{ NegotiatedSerializer: unstructuredSerializer, Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { @@ -659,7 +658,7 @@ func TestWaitDelete(t *testing.T) { } func TestReal(t *testing.T) { - t.Skip("This is a live test, comment this line to run") + // t.Skip("This is a live test, comment this line to run") c, err := New(nil, StatusWaiterStrategy) if err != nil { t.Fatal(err) From d07f546003c0113ab65214c2a0f36727fc1d3c23 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 17:02:50 +0000 Subject: [PATCH 047/271] get rid of rest client Signed-off-by: Austin Abro --- pkg/kube/factory.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/kube/factory.go b/pkg/kube/factory.go index 3b1ec1d6b..78c8323fd 100644 --- a/pkg/kube/factory.go +++ b/pkg/kube/factory.go @@ -21,7 +21,6 @@ import ( "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" - restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/kubectl/pkg/validation" ) @@ -45,9 +44,6 @@ type Factory interface { // KubernetesClientSet gives you back an external clientset KubernetesClientSet() (*kubernetes.Clientset, error) - // Returns a RESTClient for accessing Kubernetes resources or an error. - RESTClient() (*restclient.RESTClient, error) - // NewBuilder returns an object that assists in loading objects from both disk and the server // and which implements the common patterns for CLI interactions with generic resources. NewBuilder() *resource.Builder From f9736d9022d10b0203bd1a5479f5aadc42b93b6e Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 17:06:02 +0000 Subject: [PATCH 048/271] renames Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 92 ++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index c3aa61a69..d853e0012 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -43,7 +43,7 @@ import ( "sigs.k8s.io/cli-utils/pkg/testutil" ) -var podCurrent = ` +var podCurrentManifest = ` apiVersion: v1 kind: Pod metadata: @@ -56,7 +56,7 @@ status: phase: Running ` -var podNoStatus = ` +var podNoStatusManifest = ` apiVersion: v1 kind: Pod metadata: @@ -64,7 +64,7 @@ metadata: namespace: ns ` -var jobNoStatus = ` +var jobNoStatusManifest = ` apiVersion: batch/v1 kind: Job metadata: @@ -73,7 +73,7 @@ metadata: generation: 1 ` -var jobComplete = ` +var jobCompleteManifest = ` apiVersion: batch/v1 kind: Job metadata: @@ -88,7 +88,7 @@ status: status: "True" ` -var pausedDeploymentYaml = ` +var pausedDeploymentManifest = ` apiVersion: apps/v1 kind: Deployment metadata: @@ -148,22 +148,22 @@ func TestStatusLogger(t *testing.T) { func TestStatusWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { - name string - objToCreate []string - toDelete []string - expectErrs []error + name string + manifestsToCreate []string + manifestsToDelete []string + expectErrs []error }{ { - name: "wait for pod to be deleted", - objToCreate: []string{podCurrent}, - toDelete: []string{podCurrent}, - expectErrs: nil, + name: "wait for pod to be deleted", + manifestsToCreate: []string{podCurrentManifest}, + manifestsToDelete: []string{podCurrentManifest}, + expectErrs: nil, }, { - name: "error when not all objects are deleted", - objToCreate: []string{jobComplete, podCurrent}, - toDelete: []string{jobComplete}, - expectErrs: []error{errors.New("resource still exists, name: good-pod, kind: Pod, status: Current"), errors.New("context deadline exceeded")}, + name: "error when not all objects are deleted", + manifestsToCreate: []string{jobCompleteManifest, podCurrentManifest}, + manifestsToDelete: []string{jobCompleteManifest}, + expectErrs: []error{errors.New("resource still exists, name: good-pod, kind: Pod, status: Current"), errors.New("context deadline exceeded")}, }, } for _, tt := range tests { @@ -184,9 +184,9 @@ func TestStatusWaitForDelete(t *testing.T) { log: t.Logf, } createdObjs := []runtime.Object{} - for _, objYaml := range tt.objToCreate { + for _, manifest := range tt.manifestsToCreate { m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(objYaml), &m) + err := yaml.Unmarshal([]byte(manifest), &m) assert.NoError(t, err) resource := &unstructured.Unstructured{Object: m} createdObjs = append(createdObjs, resource) @@ -194,9 +194,9 @@ func TestStatusWaitForDelete(t *testing.T) { err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) assert.NoError(t, err) } - for _, objYaml := range tt.toDelete { + for _, manifest := range tt.manifestsToDelete { m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(objYaml), &m) + err := yaml.Unmarshal([]byte(manifest), &m) assert.NoError(t, err) resource := &unstructured.Unstructured{Object: m} gvr := getGVR(t, fakeMapper, resource) @@ -226,42 +226,42 @@ func TestStatusWaitForDelete(t *testing.T) { func TestStatusWait(t *testing.T) { t.Parallel() tests := []struct { - name string - objYamls []string - expectErrs []error - waitForJobs bool + name string + objManifests []string + expectErrs []error + waitForJobs bool }{ { - name: "Job is complete", - objYamls: []string{jobComplete}, - expectErrs: nil, + name: "Job is complete", + objManifests: []string{jobCompleteManifest}, + expectErrs: nil, }, { - name: "Job is not complete", - objYamls: []string{jobNoStatus}, - expectErrs: []error{errors.New("resource not ready, name: test, kind: Job, status: InProgress"), errors.New("context deadline exceeded")}, - waitForJobs: true, + name: "Job is not complete", + objManifests: []string{jobNoStatusManifest}, + expectErrs: []error{errors.New("resource not ready, name: test, kind: Job, status: InProgress"), errors.New("context deadline exceeded")}, + waitForJobs: true, }, { - name: "Job is not ready, but we pass wait anyway", - objYamls: []string{jobNoStatus}, - expectErrs: nil, - waitForJobs: false, + name: "Job is not ready, but we pass wait anyway", + objManifests: []string{jobNoStatusManifest}, + expectErrs: nil, + waitForJobs: false, }, { - name: "Pod is ready", - objYamls: []string{podCurrent}, - expectErrs: nil, + name: "Pod is ready", + objManifests: []string{podCurrentManifest}, + expectErrs: nil, }, { - name: "one of the pods never becomes ready", - objYamls: []string{podNoStatus, podCurrent}, - expectErrs: []error{errors.New("resource not ready, name: in-progress-pod, kind: Pod, status: InProgress"), errors.New("context deadline exceeded")}, + name: "one of the pods never becomes ready", + objManifests: []string{podNoStatusManifest, podCurrentManifest}, + expectErrs: []error{errors.New("resource not ready, name: in-progress-pod, kind: Pod, status: InProgress"), errors.New("context deadline exceeded")}, }, { - name: "paused deployment passes", - objYamls: []string{pausedDeploymentYaml}, - expectErrs: nil, + name: "paused deployment passes", + objManifests: []string{pausedDeploymentManifest}, + expectErrs: nil, }, } @@ -282,7 +282,7 @@ func TestStatusWait(t *testing.T) { } objs := []runtime.Object{} - for _, podYaml := range tt.objYamls { + for _, podYaml := range tt.objManifests { m := make(map[string]interface{}) err := yaml.Unmarshal([]byte(podYaml), &m) assert.NoError(t, err) From 8fe66998bf9b32c103c2eddbbd6583433dbdb470 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 17:13:59 +0000 Subject: [PATCH 049/271] refactor obj logic Signed-off-by: Austin Abro --- pkg/kube/client_test.go | 2 +- pkg/kube/statuswait.go | 18 +++++------------- pkg/kube/wait.go | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index abe74022d..f63070fe1 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -658,7 +658,7 @@ func TestWaitDelete(t *testing.T) { } func TestReal(t *testing.T) { - // t.Skip("This is a live test, comment this line to run") + t.Skip("This is a live test, comment this line to run") c, err := New(nil, StatusWaiterStrategy) if err != nil { t.Fatal(err) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index a4590aa42..a0378aaf5 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -24,7 +24,6 @@ import ( appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" - "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" @@ -61,13 +60,9 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL w.log("beginning wait for %d resources to be deleted with timeout of %v", len(resourceList), time.Until(deadline)) cancelCtx, cancel := context.WithCancel(ctx) defer cancel() - runtimeObjs := []runtime.Object{} - for _, resource := range resourceList { - runtimeObjs = append(runtimeObjs, resource.Object) - } resources := []object.ObjMetadata{} - for _, runtimeObj := range runtimeObjs { - obj, err := object.RuntimeToObjMeta(runtimeObj) + for _, resource := range resourceList { + obj, err := object.RuntimeToObjMeta(resource.Object) if err != nil { return err } @@ -104,7 +99,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait w.log("beginning wait for %d resources with timeout of %v", len(resourceList), deadline) cancelCtx, cancel := context.WithCancel(ctx) defer cancel() - runtimeObjs := []runtime.Object{} + resources := []object.ObjMetadata{} for _, resource := range resourceList { switch value := AsVersioned(resource).(type) { case *batchv1.Job: @@ -116,16 +111,13 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait continue } } - runtimeObjs = append(runtimeObjs, resource.Object) - } - resources := []object.ObjMetadata{} - for _, runtimeObj := range runtimeObjs { - obj, err := object.RuntimeToObjMeta(runtimeObj) + obj, err := object.RuntimeToObjMeta(resource.Object) if err != nil { return err } resources = append(resources, obj) } + eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) go logResourceStatus(cancelCtx, resources, statusCollector, status.CurrentStatus, w.log) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 97fa8b3e1..525373e4d 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -40,7 +40,7 @@ import ( ) // HelmWaiter is the legacy implementation of the Waiter interface. This logic was used by default in Helm 3 -// Helm 4 now uses the StatusWaiter interface instead +// Helm 4 now uses the StatusWaiter implementation instead type HelmWaiter struct { c ReadyChecker log func(string, ...interface{}) From 9894d3ae78d7d2d2119c9de7f2d17454908c8fbe Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 6 Jan 2025 17:19:39 +0000 Subject: [PATCH 050/271] shorten interface Signed-off-by: Austin Abro --- pkg/kube/factory.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/kube/factory.go b/pkg/kube/factory.go index 78c8323fd..013cd7b73 100644 --- a/pkg/kube/factory.go +++ b/pkg/kube/factory.go @@ -17,7 +17,7 @@ limitations under the License. package kube // import "helm.sh/helm/v4/pkg/kube" import ( - "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/apimachinery/pkg/api/meta" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" @@ -34,7 +34,9 @@ import ( // Helm does not need are not impacted or exposed. This minimizes the impact of Kubernetes changes // being exposed. type Factory interface { - genericclioptions.RESTClientGetter + // ToRESTMapper returns a restmapper + ToRESTMapper() (meta.RESTMapper, error) + // ToRawKubeConfigLoader return kubeconfig loader as-is ToRawKubeConfigLoader() clientcmd.ClientConfig From c2dc44deb99d21320f3d6f4c58777a87c6d0de5b Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 14 Jan 2025 14:59:30 +0000 Subject: [PATCH 051/271] use dynamic rest mapper Signed-off-by: Austin Abro --- pkg/kube/client.go | 11 ++++++++++- pkg/kube/factory.go | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index daa484b69..b607ea3ef 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -38,6 +38,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" multierror "github.com/hashicorp/go-multierror" "k8s.io/apimachinery/pkg/api/meta" @@ -107,11 +108,19 @@ func init() { } func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { + cfg, err := factory.ToRESTConfig() + if err != nil { + return nil, err + } dynamicClient, err := factory.DynamicClient() if err != nil { return nil, err } - restMapper, err := factory.ToRESTMapper() + httpClient, err := rest.HTTPClientFor(cfg) + if err != nil { + return nil, err + } + restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) if err != nil { return nil, err } diff --git a/pkg/kube/factory.go b/pkg/kube/factory.go index 013cd7b73..7f21c85c6 100644 --- a/pkg/kube/factory.go +++ b/pkg/kube/factory.go @@ -21,6 +21,7 @@ import ( "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/kubectl/pkg/validation" ) @@ -37,6 +38,9 @@ type Factory interface { // ToRESTMapper returns a restmapper ToRESTMapper() (meta.RESTMapper, error) + // ToRESTConfig returns restconfig + ToRESTConfig() (*rest.Config, error) + // ToRawKubeConfigLoader return kubeconfig loader as-is ToRawKubeConfigLoader() clientcmd.ClientConfig From a859742e288fd546a3412ed0674d2c4b693e8206 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 14 Jan 2025 15:00:26 +0000 Subject: [PATCH 052/271] remove rest mapper Signed-off-by: Austin Abro --- pkg/kube/factory.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/kube/factory.go b/pkg/kube/factory.go index 7f21c85c6..1d237c307 100644 --- a/pkg/kube/factory.go +++ b/pkg/kube/factory.go @@ -17,7 +17,6 @@ limitations under the License. package kube // import "helm.sh/helm/v4/pkg/kube" import ( - "k8s.io/apimachinery/pkg/api/meta" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" @@ -35,9 +34,6 @@ import ( // Helm does not need are not impacted or exposed. This minimizes the impact of Kubernetes changes // being exposed. type Factory interface { - // ToRESTMapper returns a restmapper - ToRESTMapper() (meta.RESTMapper, error) - // ToRESTConfig returns restconfig ToRESTConfig() (*rest.Config, error) From 816a78685304b45b15e4ae397e75a1760f8d54a0 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 14 Jan 2025 15:01:33 +0000 Subject: [PATCH 053/271] go mod tidy Signed-off-by: Austin Abro --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3274e6b79..65372cdda 100644 --- a/go.mod +++ b/go.mod @@ -47,6 +47,7 @@ require ( k8s.io/kubectl v0.32.0 oras.land/oras-go v1.2.6 sigs.k8s.io/cli-utils v0.37.2 + sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/yaml v1.4.0 ) @@ -185,7 +186,6 @@ require ( k8s.io/component-base v0.32.0 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect - sigs.k8s.io/controller-runtime v0.18.4 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect sigs.k8s.io/kustomize/api v0.18.0 // indirect sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect From e56a6e678f534fea6c7efb331fa3b4a0d9e591eb Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 14 Jan 2025 15:03:21 +0000 Subject: [PATCH 054/271] diff Signed-off-by: Austin Abro --- pkg/kube/interface.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 30be37f7c..f8e3c2ee2 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -34,9 +34,6 @@ type Interface interface { // Delete destroys one or more resources. Delete(resources ResourceList) (*Result, []error) - // Update updates one or more resources or creates the resource - // if it doesn't exist. - Update(original, target ResourceList, force bool) (*Result, error) // WatchUntilReady watches the resources given and waits until it is ready. // // This method is mainly for hook implementations. It watches for a resource to @@ -48,6 +45,11 @@ type Interface interface { // error. // TODO: Is watch until ready really behavior we want over the resources actually being ready? WatchUntilReady(resources ResourceList, timeout time.Duration) error + + // Update updates one or more resources or creates the resource + // if it doesn't exist. + Update(original, target ResourceList, force bool) (*Result, error) + // Build creates a resource list from a Reader. // // Reader must contain a YAML stream (one or more YAML documents separated From 4e12f9d5301f83ab05b9df06c25a1d4e2c7fa2f1 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 14 Jan 2025 15:38:23 +0000 Subject: [PATCH 055/271] simplify messages Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index a0378aaf5..534aece8d 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -40,24 +40,25 @@ type statusWaiter struct { func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() + w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) return w.wait(ctx, resourceList, false) } func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() + w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) return w.wait(ctx, resourceList, true) } func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() + w.log("beginning wait for %d resources to be deleted with timeout of %s", len(resourceList), timeout) return w.waitForDelete(ctx, resourceList) } func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { - deadline, _ := ctx.Deadline() - w.log("beginning wait for %d resources to be deleted with timeout of %v", len(resourceList), time.Until(deadline)) cancelCtx, cancel := context.WithCancel(ctx) defer cancel() resources := []object.ObjMetadata{} @@ -94,9 +95,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL return nil } -func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { - deadline, _ := ctx.Deadline() - w.log("beginning wait for %d resources with timeout of %v", len(resourceList), deadline) +func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() resources := []object.ObjMetadata{} From cf51d714e8cc27ebad0d44d19e69252ef86e5e94 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Wed, 15 Jan 2025 17:33:35 +0000 Subject: [PATCH 056/271] go fmt Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 534aece8d..7ac4706ee 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -95,7 +95,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL return nil } -func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { +func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() resources := []object.ObjMetadata{} From d0053345795b0451ac36f5fc047912e2e0b2a137 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:07:24 +0000 Subject: [PATCH 057/271] Bump golangci/golangci-lint-action from 6.1.1 to 6.2.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.1.1 to 6.2.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/971e284b6050e8a5849b72094c50ab08da042db8...ec5d18412c0aeab7936cb16880d708ba2a64e1ae) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 2a54d0337..cf633ac14 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,6 @@ jobs: go-version: '1.23' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #pin@6.1.1 + uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae #pin@6.2.0 with: version: v1.62 From b73c514a7846db2d343b8729a1c50f5125a8dbba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:56:24 +0000 Subject: [PATCH 058/271] build(deps): bump actions/stale from 9.0.0 to 9.1.0 Bumps [actions/stale](https://github.com/actions/stale) from 9.0.0 to 9.1.0. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/28ca1036281a5e5922ead5184a1bbf96e5fc984e...5bef64f19d7facfb25b37b414482c7164d639639) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/stale-issue-bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale-issue-bot.yaml b/.github/workflows/stale-issue-bot.yaml index b31e08b6e..613d2900c 100644 --- a/.github/workflows/stale-issue-bot.yaml +++ b/.github/workflows/stale-issue-bot.yaml @@ -9,7 +9,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 + - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.' From 5bf47fb21b0030642d24cdc90574e34e8ff7dc1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:56:24 +0000 Subject: [PATCH 059/271] build(deps): bump actions/setup-go from 5.2.0 to 5.3.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.2.0 to 5.3.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/3041bf56c941b39c61721a86cd11f3bb1338122a...f111f3307d8850f501ac008e886eec1fd1932a34) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/govulncheck.yml | 2 +- .github/workflows/release.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index cd43f3ff3..2ccea3d0e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -20,7 +20,7 @@ jobs: - name: Checkout source code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 2a54d0337..13db9340f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index a2f3bfd4b..f8572f2d6 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 146baddd9..c5e7c6840 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 with: go-version: '1.23' @@ -81,7 +81,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # pin@5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 with: go-version: '1.23' check-latest: true From 10d267ed8b126c6425233950145f824205b9902b Mon Sep 17 00:00:00 2001 From: Althaf M Date: Fri, 13 Dec 2024 22:22:59 +0000 Subject: [PATCH 060/271] fix: (toToml) renders int as float This commit fixes the issue where the yaml.Unmarshaller converts all int values into float64, this passes in option to decoder, which enables conversion of int into . Signed-off-by: Althaf M --- cmd/helm/template_test.go | 12 ++++++++++ cmd/helm/testdata/output/issue-totoml.txt | 8 +++++++ .../testcharts/issue-totoml/Chart.yaml | 3 +++ .../issue-totoml/templates/configmap.yaml | 6 +++++ .../testcharts/issue-totoml/values.yaml | 2 ++ pkg/chart/loader/load.go | 11 ++++++---- pkg/chartutil/dependencies_test.go | 22 +++++++++++++++++++ pkg/chartutil/values.go | 11 ++++++---- 8 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 cmd/helm/testdata/output/issue-totoml.txt create mode 100644 cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-totoml/values.yaml diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index e5b939879..28e24ce63 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -22,6 +22,18 @@ import ( "testing" ) +func TestTemplateCmdWithToml(t *testing.T) { + + tests := []cmdTestCase{ + { + name: "check toToml function rendering", + cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/issue-totoml"), + golden: "output/issue-totoml.txt", + }, + } + runTestCmd(t, tests) +} + var chartPath = "testdata/testcharts/subchart" func TestTemplateCmd(t *testing.T) { diff --git a/cmd/helm/testdata/output/issue-totoml.txt b/cmd/helm/testdata/output/issue-totoml.txt new file mode 100644 index 000000000..06cf4bb8d --- /dev/null +++ b/cmd/helm/testdata/output/issue-totoml.txt @@ -0,0 +1,8 @@ +--- +# Source: issue-totoml/templates/configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: issue-totoml +data: | + key = 13 diff --git a/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml b/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml new file mode 100644 index 000000000..f4be7a213 --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: issue-totoml +version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml b/cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml new file mode 100644 index 000000000..621e70d48 --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: issue-totoml +data: | + {{ .Values.global | toToml }} diff --git a/cmd/helm/testdata/testcharts/issue-totoml/values.yaml b/cmd/helm/testdata/testcharts/issue-totoml/values.yaml new file mode 100644 index 000000000..dd0140449 --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-totoml/values.yaml @@ -0,0 +1,2 @@ +global: + key: 13 \ No newline at end of file diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index 67f09c2bb..6ef83cb5e 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -18,13 +18,13 @@ package loader import ( "bytes" + "encoding/json" + "github.com/pkg/errors" "log" "os" "path/filepath" - "strings" - - "github.com/pkg/errors" "sigs.k8s.io/yaml" + "strings" "helm.sh/helm/v4/pkg/chart" ) @@ -104,7 +104,10 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { } case f.Name == "values.yaml": c.Values = make(map[string]interface{}) - if err := yaml.Unmarshal(f.Data, &c.Values); err != nil { + if err := yaml.Unmarshal(f.Data, &c.Values, func(d *json.Decoder) *json.Decoder { + d.UseNumber() + return d + }); err != nil { return c, errors.Wrap(err, "cannot load values.yaml") } case f.Name == "values.schema.json": diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chartutil/dependencies_test.go index af34a3f6b..516239d27 100644 --- a/pkg/chartutil/dependencies_test.go +++ b/pkg/chartutil/dependencies_test.go @@ -15,8 +15,10 @@ limitations under the License. package chartutil import ( + "encoding/json" "os" "path/filepath" + "reflect" "sort" "strconv" "testing" @@ -237,9 +239,24 @@ func TestProcessDependencyImportValues(t *testing.T) { if b := strconv.FormatBool(pv); b != vv { t.Errorf("failed to match imported bool value %v with expected %v for key %q", b, vv, kk) } + case json.Number: + if fv, err := pv.Float64(); err == nil { + if sfv := strconv.FormatFloat(fv, 'f', -1, 64); sfv != vv { + t.Errorf("failed to match imported float value %v with expected %v for key %q", sfv, vv, kk) + } + } + if iv, err := pv.Int64(); err == nil { + if siv := strconv.FormatInt(iv, 10); siv != vv { + t.Errorf("failed to match imported int value %v with expected %v for key %q", siv, vv, kk) + } + } + if pv.String() != vv { + t.Errorf("failed to match imported string value %q with expected %q for key %q", pv, vv, kk) + } default: if pv != vv { t.Errorf("failed to match imported string value %q with expected %q for key %q", pv, vv, kk) + t.Error(reflect.TypeOf(pv)) } } } @@ -309,9 +326,14 @@ func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) { if s := strconv.FormatFloat(pv, 'f', -1, 64); s != vv { t.Errorf("failed to match imported float value %v with expected %v", s, vv) } + case json.Number: + if pv.String() != vv { + t.Errorf("failed to match imported string value %q with expected %q", pv, vv) + } default: if pv != vv { t.Errorf("failed to match imported string value %q with expected %q", pv, vv) + t.Error(reflect.TypeOf(pv)) } } } diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index d41df6e7f..79125083a 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -17,13 +17,13 @@ limitations under the License. package chartutil import ( + "encoding/json" "fmt" + "github.com/pkg/errors" "io" "os" - "strings" - - "github.com/pkg/errors" "sigs.k8s.io/yaml" + "strings" "helm.sh/helm/v4/pkg/chart" ) @@ -105,7 +105,10 @@ func tableLookup(v Values, simple string) (Values, error) { // ReadValues will parse YAML byte data into a Values. func ReadValues(data []byte) (vals Values, err error) { - err = yaml.Unmarshal(data, &vals) + err = yaml.Unmarshal(data, &vals, func(d *json.Decoder) *json.Decoder { + d.UseNumber() + return d + }) if len(vals) == 0 { vals = Values{} } From 57d85993cbbb823f2145f75b0a7a27e40d9aab22 Mon Sep 17 00:00:00 2001 From: Althaf M Date: Sat, 14 Dec 2024 23:22:28 +0000 Subject: [PATCH 061/271] remove debug statements Signed-off-by: Althaf M --- pkg/chartutil/dependencies_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chartutil/dependencies_test.go index 516239d27..ac8e4d76e 100644 --- a/pkg/chartutil/dependencies_test.go +++ b/pkg/chartutil/dependencies_test.go @@ -18,7 +18,6 @@ import ( "encoding/json" "os" "path/filepath" - "reflect" "sort" "strconv" "testing" @@ -256,7 +255,6 @@ func TestProcessDependencyImportValues(t *testing.T) { default: if pv != vv { t.Errorf("failed to match imported string value %q with expected %q for key %q", pv, vv, kk) - t.Error(reflect.TypeOf(pv)) } } } @@ -333,7 +331,6 @@ func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) { default: if pv != vv { t.Errorf("failed to match imported string value %q with expected %q", pv, vv) - t.Error(reflect.TypeOf(pv)) } } } From 88f7dc5329a9cf17fdcdbef3f35e4782817cbd5a Mon Sep 17 00:00:00 2001 From: Althaf M Date: Wed, 22 Jan 2025 09:27:51 +0000 Subject: [PATCH 062/271] merge: fixing merge conflicts Signed-off-by: Althaf M althafm@outlook.com Signed-off-by: Althaf M --- pkg/chart/loader/load.go | 5 +++-- pkg/chartutil/values.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index 6ef83cb5e..7645ba96c 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -19,13 +19,14 @@ package loader import ( "bytes" "encoding/json" - "github.com/pkg/errors" "log" "os" "path/filepath" - "sigs.k8s.io/yaml" "strings" + "github.com/pkg/errors" + "sigs.k8s.io/yaml" + "helm.sh/helm/v4/pkg/chart" ) diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index 79125083a..706c44d48 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -19,12 +19,13 @@ package chartutil import ( "encoding/json" "fmt" - "github.com/pkg/errors" "io" "os" - "sigs.k8s.io/yaml" "strings" + "github.com/pkg/errors" + "sigs.k8s.io/yaml" + "helm.sh/helm/v4/pkg/chart" ) From 7ea1d1df66c56956f9b473035df0ada43bbc2502 Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Fri, 27 Dec 2024 22:07:27 -0800 Subject: [PATCH 063/271] refactor: Remove duplicate `FindChartIn*RepoURL` funcs Signed-off-by: George Jenkins --- pkg/action/install.go | 14 +++++++-- pkg/action/pull.go | 13 +++++++- pkg/repo/chartrepo.go | 62 +++++++++++++++++++++++--------------- pkg/repo/chartrepo_test.go | 13 ++++++-- 4 files changed, 72 insertions(+), 30 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index ec074a8d2..c90746c13 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -789,8 +789,18 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( dl.Verify = downloader.VerifyAlways } if c.RepoURL != "" { - chartURL, err := repo.FindChartInAuthAndTLSAndPassRepoURL(c.RepoURL, c.Username, c.Password, name, version, - c.CertFile, c.KeyFile, c.CaFile, c.InsecureSkipTLSverify, c.PassCredentialsAll, getter.All(settings)) + chartURL, err := repo.FindChartInRepoURL( + c.RepoURL, + name, + version, + c.CertFile, + c.KeyFile, + c.CaFile, + getter.All(settings), + repo.WithUsernamePassword(c.Username, c.Password), + repo.WithInsecureSkipTLSverify(c.InsecureSkipTLSverify), + repo.WithPassCredentialsAll(c.PassCredentialsAll), + ) if err != nil { return "", err } diff --git a/pkg/action/pull.go b/pkg/action/pull.go index 63bc11d3b..a09cbe368 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -117,7 +117,18 @@ func (p *Pull) Run(chartRef string) (string, error) { } if p.RepoURL != "" { - chartURL, err := repo.FindChartInAuthAndTLSAndPassRepoURL(p.RepoURL, p.Username, p.Password, chartRef, p.Version, p.CertFile, p.KeyFile, p.CaFile, p.InsecureSkipTLSverify, p.PassCredentialsAll, getter.All(p.Settings)) + chartURL, err := repo.FindChartInRepoURL( + p.RepoURL, + chartRef, + p.Version, + p.CertFile, + p.KeyFile, + p.CaFile, + getter.All(p.Settings), + repo.WithUsernamePassword(p.Username, p.Password), + repo.WithInsecureSkipTLSverify(p.InsecureSkipTLSverify), + repo.WithPassCredentialsAll(p.PassCredentialsAll), + ) if err != nil { return out.String(), err } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index e20c7e20f..33f790601 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -196,33 +196,45 @@ func (r *ChartRepository) generateIndex() error { return nil } -// FindChartInRepoURL finds chart in chart repository pointed by repoURL -// without adding repo to repositories -func FindChartInRepoURL(repoURL, chartName, chartVersion, certFile, keyFile, caFile string, getters getter.Providers) (string, error) { - return FindChartInAuthRepoURL(repoURL, "", "", chartName, chartVersion, certFile, keyFile, caFile, getters) +type findChartInRepoURLOptions struct { + Username string + Password string + PassCredentialsAll bool + InsecureSkipTLSverify bool +} + +type FindChartInRepoURLOption func(*findChartInRepoURLOptions) + +// WithUsernamePassword specifies the username/password credntials for the repository +func WithUsernamePassword(username, password string) FindChartInRepoURLOption { + return func(options *findChartInRepoURLOptions) { + options.Username = username + options.Password = password + } } -// FindChartInAuthRepoURL finds chart in chart repository pointed by repoURL -// without adding repo to repositories, like FindChartInRepoURL, -// but it also receives credentials for the chart repository. -func FindChartInAuthRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, getters getter.Providers) (string, error) { - return FindChartInAuthAndTLSRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile, false, getters) +// WithPassCredentialsAll flags whether credentials should be passed on to other domains +func WithPassCredentialsAll(passCredentialsAll bool) FindChartInRepoURLOption { + return func(options *findChartInRepoURLOptions) { + options.PassCredentialsAll = passCredentialsAll + } } -// FindChartInAuthAndTLSRepoURL finds chart in chart repository pointed by repoURL -// without adding repo to repositories, like FindChartInRepoURL, -// but it also receives credentials and TLS verify flag for the chart repository. -// TODO Helm 4, FindChartInAuthAndTLSRepoURL should be integrated into FindChartInAuthRepoURL. -func FindChartInAuthAndTLSRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, insecureSkipTLSverify bool, getters getter.Providers) (string, error) { - return FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile, insecureSkipTLSverify, false, getters) +// WithInsecureSkipTLSverify skips TLS verification for repostory communication +func WithInsecureSkipTLSverify(insecureSkipTLSverify bool) FindChartInRepoURLOption { + return func(options *findChartInRepoURLOptions) { + options.InsecureSkipTLSverify = insecureSkipTLSverify + } } -// FindChartInAuthAndTLSAndPassRepoURL finds chart in chart repository pointed by repoURL -// without adding repo to repositories, like FindChartInRepoURL, -// but it also receives credentials, TLS verify flag, and if credentials should -// be passed on to other domains. -// TODO Helm 4, FindChartInAuthAndTLSAndPassRepoURL should be integrated into FindChartInAuthRepoURL. -func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, insecureSkipTLSverify, passCredentialsAll bool, getters getter.Providers) (string, error) { +// FindChartInRepoURL finds chart in chart repository pointed by repoURL +// without adding repo to repositories +func FindChartInRepoURL(repoURL, chartName, chartVersion, certFile, keyFile, caFile string, getters getter.Providers, options ...FindChartInRepoURLOption) (string, error) { + + opts := findChartInRepoURLOptions{} + for _, option := range options { + option(&opts) + } // Download and write the index file to a temporary location buf := make([]byte, 20) @@ -231,14 +243,14 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, c := Entry{ URL: repoURL, - Username: username, - Password: password, - PassCredentialsAll: passCredentialsAll, + Username: opts.Username, + Password: opts.Password, + PassCredentialsAll: opts.PassCredentialsAll, CertFile: certFile, KeyFile: keyFile, CAFile: caFile, Name: name, - InsecureSkipTLSverify: insecureSkipTLSverify, + InsecureSkipTLSverify: opts.InsecureSkipTLSverify, } r, err := NewChartRepository(&c, getters) if err != nil { diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index 341bafadc..836a2d66f 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -297,7 +297,16 @@ func TestFindChartInAuthAndTLSAndPassRepoURL(t *testing.T) { } defer srv.Close() - chartURL, err := FindChartInAuthAndTLSAndPassRepoURL(srv.URL, "", "", "nginx", "", "", "", "", true, false, getter.All(&cli.EnvSettings{})) + chartURL, err := FindChartInRepoURL( + srv.URL, + "nginx", + "", + "", + "", + "", + getter.All(&cli.EnvSettings{}), + WithInsecureSkipTLSverify(true), + ) if err != nil { t.Fatalf("%v", err) } @@ -306,7 +315,7 @@ func TestFindChartInAuthAndTLSAndPassRepoURL(t *testing.T) { } // If the insecureSkipTLSVerify is false, it will return an error that contains "x509: certificate signed by unknown authority". - _, err = FindChartInAuthAndTLSAndPassRepoURL(srv.URL, "", "", "nginx", "0.1.0", "", "", "", false, false, getter.All(&cli.EnvSettings{})) + _, err = FindChartInRepoURL(srv.URL, "nginx", "0.1.0", "", "", "", getter.All(&cli.EnvSettings{})) // Go communicates with the platform and different platforms return different messages. Go itself tests darwin // differently for its message. On newer versions of Darwin the message includes the "Acme Co" portion while older // versions of Darwin do not. As there are people developing Helm using both old and new versions of Darwin we test From 0ce267d907dd776b0cf5ca3f2406f5b5ecce0832 Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Fri, 24 Jan 2025 20:38:12 -0800 Subject: [PATCH 064/271] more options Signed-off-by: George Jenkins --- pkg/action/install.go | 6 ++---- pkg/action/pull.go | 6 ++---- pkg/downloader/manager.go | 2 +- pkg/repo/chartrepo.go | 34 +++++++++++++++++++++++++++------- pkg/repo/chartrepo_test.go | 18 +++++++----------- 5 files changed, 39 insertions(+), 27 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index c90746c13..ef3f0fdc7 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -792,11 +792,9 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( chartURL, err := repo.FindChartInRepoURL( c.RepoURL, name, - version, - c.CertFile, - c.KeyFile, - c.CaFile, getter.All(settings), + repo.WithChartVersion(version), + repo.WithClientTLS(c.CertFile, c.KeyFile, c.CaFile), repo.WithUsernamePassword(c.Username, c.Password), repo.WithInsecureSkipTLSverify(c.InsecureSkipTLSverify), repo.WithPassCredentialsAll(c.PassCredentialsAll), diff --git a/pkg/action/pull.go b/pkg/action/pull.go index a09cbe368..7fc1a9fdb 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -120,11 +120,9 @@ func (p *Pull) Run(chartRef string) (string, error) { chartURL, err := repo.FindChartInRepoURL( p.RepoURL, chartRef, - p.Version, - p.CertFile, - p.KeyFile, - p.CaFile, getter.All(p.Settings), + repo.WithChartVersion(p.Version), + repo.WithClientTLS(p.CertFile, p.KeyFile, p.CaFile), repo.WithUsernamePassword(p.Username, p.Password), repo.WithInsecureSkipTLSverify(p.InsecureSkipTLSverify), repo.WithPassCredentialsAll(p.PassCredentialsAll), diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 5a509646d..f10cbfb8d 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -742,7 +742,7 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]* return } } - url, err = repo.FindChartInRepoURL(repoURL, name, version, certFile, keyFile, caFile, m.Getters) + url, err = repo.FindChartInRepoURL(repoURL, name, m.Getters, repo.WithChartVersion(version), repo.WithClientTLS(certFile, keyFile, caFile)) if err == nil { return url, username, password, false, false, "", "", "", err } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 33f790601..3629bd24b 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -201,10 +201,21 @@ type findChartInRepoURLOptions struct { Password string PassCredentialsAll bool InsecureSkipTLSverify bool + CertFile string + KeyFile string + CAFile string + ChartVersion string } type FindChartInRepoURLOption func(*findChartInRepoURLOptions) +// WithChartVersion specifies the chart version to find +func WithChartVersion(chartVersion string) FindChartInRepoURLOption { + return func(options *findChartInRepoURLOptions) { + options.ChartVersion = chartVersion + } +} + // WithUsernamePassword specifies the username/password credntials for the repository func WithUsernamePassword(username, password string) FindChartInRepoURLOption { return func(options *findChartInRepoURLOptions) { @@ -220,6 +231,15 @@ func WithPassCredentialsAll(passCredentialsAll bool) FindChartInRepoURLOption { } } +// WithClientTLS species the cert, key, and CA files for client mTLS +func WithClientTLS(certFile, keyFile, caFile string) FindChartInRepoURLOption { + return func(options *findChartInRepoURLOptions) { + options.CertFile = certFile + options.KeyFile = keyFile + options.CAFile = caFile + } +} + // WithInsecureSkipTLSverify skips TLS verification for repostory communication func WithInsecureSkipTLSverify(insecureSkipTLSverify bool) FindChartInRepoURLOption { return func(options *findChartInRepoURLOptions) { @@ -229,7 +249,7 @@ func WithInsecureSkipTLSverify(insecureSkipTLSverify bool) FindChartInRepoURLOpt // FindChartInRepoURL finds chart in chart repository pointed by repoURL // without adding repo to repositories -func FindChartInRepoURL(repoURL, chartName, chartVersion, certFile, keyFile, caFile string, getters getter.Providers, options ...FindChartInRepoURLOption) (string, error) { +func FindChartInRepoURL(repoURL string, chartName string, getters getter.Providers, options ...FindChartInRepoURLOption) (string, error) { opts := findChartInRepoURLOptions{} for _, option := range options { @@ -246,9 +266,9 @@ func FindChartInRepoURL(repoURL, chartName, chartVersion, certFile, keyFile, caF Username: opts.Username, Password: opts.Password, PassCredentialsAll: opts.PassCredentialsAll, - CertFile: certFile, - KeyFile: keyFile, - CAFile: caFile, + CertFile: opts.CertFile, + KeyFile: opts.KeyFile, + CAFile: opts.CAFile, Name: name, InsecureSkipTLSverify: opts.InsecureSkipTLSverify, } @@ -272,10 +292,10 @@ func FindChartInRepoURL(repoURL, chartName, chartVersion, certFile, keyFile, caF } errMsg := fmt.Sprintf("chart %q", chartName) - if chartVersion != "" { - errMsg = fmt.Sprintf("%s version %q", errMsg, chartVersion) + if opts.ChartVersion != "" { + errMsg = fmt.Sprintf("%s version %q", errMsg, opts.ChartVersion) } - cv, err := repoIndex.Get(chartName, chartVersion) + cv, err := repoIndex.Get(chartName, opts.ChartVersion) if err != nil { return "", errors.Errorf("%s not found in %s repository", errMsg, repoURL) } diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index 836a2d66f..e3330b8eb 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -300,10 +300,6 @@ func TestFindChartInAuthAndTLSAndPassRepoURL(t *testing.T) { chartURL, err := FindChartInRepoURL( srv.URL, "nginx", - "", - "", - "", - "", getter.All(&cli.EnvSettings{}), WithInsecureSkipTLSverify(true), ) @@ -315,7 +311,7 @@ func TestFindChartInAuthAndTLSAndPassRepoURL(t *testing.T) { } // If the insecureSkipTLSVerify is false, it will return an error that contains "x509: certificate signed by unknown authority". - _, err = FindChartInRepoURL(srv.URL, "nginx", "0.1.0", "", "", "", getter.All(&cli.EnvSettings{})) + _, err = FindChartInRepoURL(srv.URL, "nginx", getter.All(&cli.EnvSettings{}), WithChartVersion("0.1.0")) // Go communicates with the platform and different platforms return different messages. Go itself tests darwin // differently for its message. On newer versions of Darwin the message includes the "Acme Co" portion while older // versions of Darwin do not. As there are people developing Helm using both old and new versions of Darwin we test @@ -336,7 +332,7 @@ func TestFindChartInRepoURL(t *testing.T) { } defer srv.Close() - chartURL, err := FindChartInRepoURL(srv.URL, "nginx", "", "", "", "", getter.All(&cli.EnvSettings{})) + chartURL, err := FindChartInRepoURL(srv.URL, "nginx", getter.All(&cli.EnvSettings{})) if err != nil { t.Fatalf("%v", err) } @@ -344,7 +340,7 @@ func TestFindChartInRepoURL(t *testing.T) { t.Errorf("%s is not the valid URL", chartURL) } - chartURL, err = FindChartInRepoURL(srv.URL, "nginx", "0.1.0", "", "", "", getter.All(&cli.EnvSettings{})) + chartURL, err = FindChartInRepoURL(srv.URL, "nginx", getter.All(&cli.EnvSettings{}), WithChartVersion("0.1.0")) if err != nil { t.Errorf("%s", err) } @@ -359,7 +355,7 @@ func TestErrorFindChartInRepoURL(t *testing.T) { RepositoryCache: t.TempDir(), }) - if _, err := FindChartInRepoURL("http://someserver/something", "nginx", "", "", "", "", g); err == nil { + if _, err := FindChartInRepoURL("http://someserver/something", "nginx", g); err == nil { t.Errorf("Expected error for bad chart URL, but did not get any errors") } else if !strings.Contains(err.Error(), `looks like "http://someserver/something" is not a valid chart repository or cannot be reached`) { t.Errorf("Expected error for bad chart URL, but got a different error (%v)", err) @@ -371,19 +367,19 @@ func TestErrorFindChartInRepoURL(t *testing.T) { } defer srv.Close() - if _, err = FindChartInRepoURL(srv.URL, "nginx1", "", "", "", "", g); err == nil { + if _, err = FindChartInRepoURL(srv.URL, "nginx1", g); err == nil { t.Errorf("Expected error for chart not found, but did not get any errors") } else if err.Error() != `chart "nginx1" not found in `+srv.URL+` repository` { t.Errorf("Expected error for chart not found, but got a different error (%v)", err) } - if _, err = FindChartInRepoURL(srv.URL, "nginx1", "0.1.0", "", "", "", g); err == nil { + if _, err = FindChartInRepoURL(srv.URL, "nginx1", g, WithChartVersion("0.1.0")); err == nil { t.Errorf("Expected error for chart not found, but did not get any errors") } else if err.Error() != `chart "nginx1" version "0.1.0" not found in `+srv.URL+` repository` { t.Errorf("Expected error for chart not found, but got a different error (%v)", err) } - if _, err = FindChartInRepoURL(srv.URL, "chartWithNoURL", "", "", "", "", g); err == nil { + if _, err = FindChartInRepoURL(srv.URL, "chartWithNoURL", g); err == nil { t.Errorf("Expected error for no chart URLs available, but did not get any errors") } else if err.Error() != `chart "chartWithNoURL" has no downloadable URLs` { t.Errorf("Expected error for chart not found, but got a different error (%v)", err) From c68e3456630aed512f8512667a355aa220c9ea45 Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Sat, 25 Jan 2025 11:31:46 -0800 Subject: [PATCH 065/271] fix: Bind repotest server to `localhost` Signed-off-by: George Jenkins --- pkg/repo/repotest/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index 7a6b1e0f2..a2353987f 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -113,7 +113,7 @@ func NewOCIServer(t *testing.T, dir string) (*OCIServer, error) { t.Fatalf("error finding free port for test registry") } - config.HTTP.Addr = fmt.Sprintf(":%d", port) + config.HTTP.Addr = fmt.Sprintf("127.0.0.1:%d", port) config.HTTP.DrainTimeout = time.Duration(10) * time.Second config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}} config.Auth = configuration.Auth{ From 33aa8b53973b9a65e14ffbb6f5f9c99456fca0db Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 27 Jan 2025 13:30:08 +0000 Subject: [PATCH 066/271] Prefer environment variables to CLI flags Signed-off-by: Evans Mungai --- cmd/helm/profiling.go | 61 +++++++---------------------- cmd/helm/profiling_test.go | 79 -------------------------------------- cmd/helm/root.go | 3 -- 3 files changed, 14 insertions(+), 129 deletions(-) delete mode 100644 cmd/helm/profiling_test.go diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go index e231a3e0a..e48441512 100644 --- a/cmd/helm/profiling.go +++ b/cmd/helm/profiling.go @@ -19,30 +19,29 @@ package main import ( "fmt" "os" - "path" - "path/filepath" "runtime" "runtime/pprof" "strings" - - "github.com/spf13/cobra" ) var ( cpuProfileFile *os.File - pprofPaths map[string]string + cpuProfilePath string + memProfilePath string ) func init() { - pprofPaths = parsePProfPaths(os.Getenv("HELM_PPROF")) + cpuProfilePath = os.Getenv("HELM_PPROF_CPU_PROFILE") + memProfilePath = os.Getenv("HELM_PPROF_MEM_PROFILE") } -// startProfiling starts profiling CPU usage +// startProfiling starts profiling CPU usage if HELM_PPROF_CPU_PROFILE is set +// to a file path. It returns an error if the file could not be created or +// CPU profiling could not be started. func startProfiling() error { - cpuprofile, ok := pprofPaths["cpu"] - if ok && cpuprofile != "" { + if cpuProfilePath != "" { var err error - cpuProfileFile, err = os.Create(cpuprofile) + cpuProfileFile, err = os.Create(cpuProfilePath) if err != nil { return fmt.Errorf("could not create CPU profile: %w", err) } @@ -55,8 +54,9 @@ func startProfiling() error { return nil } -// stopProfiling stops profiling CPU and memory usage and writes the results to -// the files specified by HELM_PPROF=cpu=/path/to/cpu.prof,mem=/path/to/mem.prof +// stopProfiling stops profiling CPU and memory usage. +// It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE +// environment variable. func stopProfiling() error { errs := []string{} @@ -70,9 +70,8 @@ func stopProfiling() error { cpuProfileFile = nil } - memprofile, ok := pprofPaths["mem"] - if ok && memprofile != "" { - f, err := os.Create(memprofile) + if memProfilePath != "" { + f, err := os.Create(memProfilePath) if err != nil { errs = append(errs, err.Error()) } @@ -90,35 +89,3 @@ func stopProfiling() error { return nil } - -// addProfilingFlags adds the --cpuprofile and --memprofile flags to the given command. -func addProfilingFlags(cmd *cobra.Command) { - // Persistent flags to make available to subcommands - cmd.PersistentFlags().String("cpuprofile", "", "File path to write cpu profiling data") - cmd.PersistentFlags().String("memprofile", "", "File path to write memory profiling data") -} - -func parsePProfPaths(env string) map[string]string { - // Initial empty paths - m := map[string]string{} - for _, pprofs := range strings.Split(env, ",") { - // Is of the format mem=/path/to/memprof - tuple := strings.Split(pprofs, "=") - if len(tuple) != 2 { - continue - } - if tuple[0] != "cpu" && tuple[0] != "mem" { - continue - } - - s, err := filepath.Abs(path.Clean(tuple[1])) - if err != nil { - continue - } - if !strings.HasSuffix(s, string(filepath.Separator)) { - // Ensure its not a directory - m[tuple[0]] = s - } - } - return m -} diff --git a/cmd/helm/profiling_test.go b/cmd/helm/profiling_test.go deleted file mode 100644 index 65928edbb..000000000 --- a/cmd/helm/profiling_test.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 ( - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func Test_parsePProfPaths(t *testing.T) { - cwd, err := os.Getwd() - require.NoError(t, err) - - tests := []struct { - name string - env string - want map[string]string - }{ - { - name: "no env", - env: "", - want: map[string]string{}, - }, - { - name: "single path", - env: "cpu=cpu.pprof", - want: map[string]string{ - "cpu": cwd + "/cpu.pprof", - }, - }, - { - name: "mem and cpu paths", - env: "cpu=cpu.pprof,mem=mem.pprof", - want: map[string]string{ - "cpu": cwd + "/cpu.pprof", - "mem": cwd + "/mem.pprof", - }, - }, - { - name: "extra commas", - env: "cpu=cpu.pprof,mem=mem.pprof,", - want: map[string]string{ - "cpu": cwd + "/cpu.pprof", - "mem": cwd + "/mem.pprof", - }, - }, - { - name: "unknown keys", - env: "cpu=cpu.pprof,mem=mem.pprof,foo=bar", - want: map[string]string{ - "cpu": cwd + "/cpu.pprof", - "mem": cwd + "/mem.pprof", - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := parsePProfPaths(tt.env) - assert.Equalf(t, tt.want, got, "parsePProfPaths() = %v, want %v", got, tt.want) - }) - } -} diff --git a/cmd/helm/root.go b/cmd/helm/root.go index edc6376ae..f8ed82a60 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -216,9 +216,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string // Check for expired repositories checkForExpiredRepos(settings.RepositoryConfig) - // CPU and memory profiling flags that are available to all commands - addProfilingFlags(cmd) - return cmd, nil } From 58748b06c79f37cb79a816324ef1ab878e303a5b Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 27 Jan 2025 13:37:28 +0000 Subject: [PATCH 067/271] Update CONTRIBUTING guide Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a90054d9..bc225d218 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -284,14 +284,16 @@ Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which wou ### Profiling PRs -If your contribution requires profiling to check memory and/or CPU usage, you can set `HELM_PPROF=cpu=/path/to/cpu.prof,mem=/path/to/mem.prof` environment variable to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. +If your contribution requires profiling to check memory and/or CPU usage, you can set `HELM_PPROF_CPU_PROFILE=/path/to/cpu.prof HELM_PPROF_MEM_PROFILE=/path/to/mem.prof helm show all bitnami/nginx` environment variable to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. Example analysing collected profiling data ``` -HELM_PPROF=cpu=/path/to/cpu.prof,mem=/path/to/mem.prof helm show all bitnami/nginx +HELM_PPROF_CPU_PROFILE=cpu.prof HELM_PPROF_MEM_PROFILE=mem.prof helm show all bitnami/nginx # Visualize graphs. You need to have installed graphviz package in your system go tool pprof -http=":8000" cpu.prof + +go tool pprof -http=":8001" mem.prof ``` ## The Triager From f1b642cb0d227ce6d661ccd636c7cfb6392e93fe Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 27 Jan 2025 16:15:39 +0000 Subject: [PATCH 068/271] unexport newWaiter function Signed-off-by: Austin Abro --- pkg/kube/client.go | 57 ++++++++++++++++++----------------------- pkg/kube/client_test.go | 12 ++++----- 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index b607ea3ef..e3fdb8b3b 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -107,43 +107,35 @@ func init() { } } -func getStatusWatcher(factory Factory) (watcher.StatusWatcher, error) { - cfg, err := factory.ToRESTConfig() - if err != nil { - return nil, err - } - dynamicClient, err := factory.DynamicClient() - if err != nil { - return nil, err - } - httpClient, err := rest.HTTPClientFor(cfg) - if err != nil { - return nil, err - } - restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) - if err != nil { - return nil, err - } - sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) - return sw, nil -} - -func NewWaiter(strategy WaitStrategy, factory Factory, log func(string, ...interface{})) (Waiter, error) { +func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { switch strategy { case LegacyWaiterStrategy: - kc, err := factory.KubernetesClientSet() + kc, err := c.Factory.KubernetesClientSet() if err != nil { return nil, err } - return &HelmWaiter{kubeClient: kc, log: log}, nil + return &HelmWaiter{kubeClient: kc, log: c.Log}, nil case StatusWaiterStrategy: - sw, err := getStatusWatcher(factory) + cfg, err := c.Factory.ToRESTConfig() if err != nil { return nil, err } + dynamicClient, err := c.Factory.DynamicClient() + if err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(cfg) + if err != nil { + return nil, err + } + restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) + if err != nil { + return nil, err + } + sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) return &statusWaiter{ sw: sw, - log: log, + log: c.Log, }, nil default: return nil, errors.New("unknown wait strategy") @@ -156,15 +148,16 @@ func New(getter genericclioptions.RESTClientGetter, ws WaitStrategy) (*Client, e getter = genericclioptions.NewConfigFlags(true) } factory := cmdutil.NewFactory(getter) - waiter, err := NewWaiter(ws, factory, nopLogger) + c := &Client{ + Factory: factory, + Log: nopLogger, + } + var err error + c.Waiter, err = c.newWaiter(ws) if err != nil { return nil, err } - return &Client{ - Factory: factory, - Log: nopLogger, - Waiter: waiter, - }, nil + return c, nil } var nopLogger = func(_ string, _ ...interface{}) {} diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index f63070fe1..cdf75938e 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -512,11 +512,11 @@ func TestWait(t *testing.T) { } }), } - waiter, err := NewWaiter(LegacyWaiterStrategy, c.Factory, c.Log) + var err error + c.Waiter, err = c.newWaiter(LegacyWaiterStrategy) if err != nil { t.Fatal(err) } - c.Waiter = waiter resources, err := c.Build(objBody(&podList), false) if err != nil { t.Fatal(err) @@ -569,11 +569,11 @@ func TestWaitJob(t *testing.T) { } }), } - waiter, err := NewWaiter(LegacyWaiterStrategy, c.Factory, c.Log) + var err error + c.Waiter, err = c.newWaiter(LegacyWaiterStrategy) if err != nil { t.Fatal(err) } - c.Waiter = waiter resources, err := c.Build(objBody(job), false) if err != nil { t.Fatal(err) @@ -628,11 +628,11 @@ func TestWaitDelete(t *testing.T) { } }), } - waiter, err := NewWaiter(LegacyWaiterStrategy, c.Factory, c.Log) + var err error + c.Waiter, err = c.newWaiter(LegacyWaiterStrategy) if err != nil { t.Fatal(err) } - c.Waiter = waiter resources, err := c.Build(objBody(&pod), false) if err != nil { t.Fatal(err) From 8a656b524fc7972ed503d6e3744e29fe4ed1ca7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:51:04 +0000 Subject: [PATCH 069/271] build(deps): bump github.com/evanphx/json-patch Bumps [github.com/evanphx/json-patch](https://github.com/evanphx/json-patch) from 5.9.0+incompatible to 5.9.11+incompatible. - [Release notes](https://github.com/evanphx/json-patch/releases) - [Commits](https://github.com/evanphx/json-patch/compare/v5.9.0...v5.9.11) --- updated-dependencies: - dependency-name: github.com/evanphx/json-patch dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 09b071ef5..77df05ae2 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/containerd/containerd v1.7.25 github.com/cyphar/filepath-securejoin v0.4.0 github.com/distribution/distribution/v3 v3.0.0-rc.2 - github.com/evanphx/json-patch v5.9.0+incompatible + github.com/evanphx/json-patch v5.9.11+incompatible github.com/foxcpp/go-mockdns v1.1.0 github.com/gobwas/glob v0.2.3 github.com/gofrs/flock v0.12.1 diff --git a/go.sum b/go.sum index d70e7733c..be53c4c05 100644 --- a/go.sum +++ b/go.sum @@ -101,8 +101,8 @@ github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arX github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= -github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v5.9.11+incompatible h1:ixHHqfcGvxhWkniF1tWxBHA0yb4Z+d1UQi45df52xW8= +github.com/evanphx/json-patch v5.9.11+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f h1:Wl78ApPPB2Wvf/TIe2xdyJxTlb6obmF18d8QdkxNDu4= github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f/go.mod h1:OSYXu++VVOHnXeitef/D8n/6y4QV8uLHSFXX4NeXMGc= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= From 580150e2dd89180c4076af7d6767841a8b827fe7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 22:11:22 +0000 Subject: [PATCH 070/271] build(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6 Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/spf13/pflag/releases) - [Commits](https://github.com/spf13/pflag/compare/v1.0.5...v1.0.6) --- updated-dependencies: - dependency-name: github.com/spf13/pflag dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 09b071ef5..79296301a 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/rubenv/sql-migrate v1.7.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 - github.com/spf13/pflag v1.0.5 + github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/crypto v0.32.0 diff --git a/go.sum b/go.sum index d70e7733c..feac67269 100644 --- a/go.sum +++ b/go.sum @@ -341,8 +341,9 @@ github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= From 119ae859882d68d4daa1e8d6389349e38e1397f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:12:03 +0000 Subject: [PATCH 071/271] build(deps): bump github.com/cyphar/filepath-securejoin Bumps [github.com/cyphar/filepath-securejoin](https://github.com/cyphar/filepath-securejoin) from 0.4.0 to 0.4.1. - [Release notes](https://github.com/cyphar/filepath-securejoin/releases) - [Changelog](https://github.com/cyphar/filepath-securejoin/blob/main/CHANGELOG.md) - [Commits](https://github.com/cyphar/filepath-securejoin/compare/v0.4.0...v0.4.1) --- updated-dependencies: - dependency-name: github.com/cyphar/filepath-securejoin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6db35856b..8f22e2a67 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/Masterminds/vcs v1.13.3 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 github.com/containerd/containerd v1.7.25 - github.com/cyphar/filepath-securejoin v0.4.0 + github.com/cyphar/filepath-securejoin v0.4.1 github.com/distribution/distribution/v3 v3.0.0-rc.2 github.com/evanphx/json-patch v5.9.11+incompatible github.com/foxcpp/go-mockdns v1.1.0 diff --git a/go.sum b/go.sum index 266ca3add..40d030f88 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/cyphar/filepath-securejoin v0.4.0 h1:PioTG9TBRSApBpYGnDU8HC+miIsX8vitBH9LGNNMoLQ= -github.com/cyphar/filepath-securejoin v0.4.0/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= +github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= +github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= From 5a7046b9bfaf1d7e97c555e33fa8744bba758004 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Thu, 2 Jan 2025 04:59:55 -0700 Subject: [PATCH 072/271] chore(oci): upgrade to ORAS v2 Signed-off-by: Terry Howe Co-authored-by: Zoran Regvart --- cmd/helm/dependency_build_test.go | 6 +- cmd/helm/dependency_update_test.go | 10 +- cmd/helm/pull_test.go | 2 +- cmd/helm/registry_login.go | 5 +- go.mod | 9 +- go.sum | 34 +- pkg/action/registry_login.go | 25 +- pkg/downloader/chart_downloader_test.go | 2 - pkg/registry/client.go | 493 +++++++++++++---------- pkg/registry/client_http_test.go | 17 +- pkg/registry/client_insecure_tls_test.go | 5 +- pkg/registry/client_test.go | 33 ++ pkg/registry/client_tls_test.go | 5 +- pkg/registry/reference.go | 6 +- pkg/registry/util.go | 23 +- pkg/registry/utils_test.go | 16 +- pkg/repo/repotest/server.go | 5 +- 17 files changed, 384 insertions(+), 312 deletions(-) create mode 100644 pkg/registry/client_test.go diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index e443e64cb..189378ce5 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -58,7 +58,7 @@ func TestDependencyBuildCmd(t *testing.T) { 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) + cmd := fmt.Sprintf("dependency build '%s' --repository-config %s --repository-cache %s --plain-http", filepath.Join(rootDir, chartname), repoFile, rootDir) _, out, err := executeActionCommand(cmd) // In the first pass, we basically want the same results as an update. @@ -117,7 +117,7 @@ func TestDependencyBuildCmd(t *testing.T) { 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) + skipRefreshCmd := fmt.Sprintf("dependency build '%s' --skip-refresh --repository-config %s --repository-cache %s --plain-http", filepath.Join(rootDir, chartname), repoFile, rootDir) _, out, err = executeActionCommand(skipRefreshCmd) // In this pass, we check --skip-refresh option becomes effective. @@ -134,7 +134,7 @@ func TestDependencyBuildCmd(t *testing.T) { 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", + cmd = fmt.Sprintf("dependency build '%s' --repository-config %s --repository-cache %s --registry-config %s/config.json --plain-http", dir(ociChartName), dir("repositories.yaml"), dir(), diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index b82ce870d..82a6b875d 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -67,7 +67,7 @@ func TestDependencyUpdateCmd(t *testing.T) { } _, out, err := executeActionCommand( - fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir()), + fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --plain-http", dir(chartname), dir("repositories.yaml"), dir()), ) if err != nil { t.Logf("Output: %s", out) @@ -110,7 +110,7 @@ func TestDependencyUpdateCmd(t *testing.T) { t.Fatal(err) } - _, out, err = executeActionCommand(fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir())) + _, out, err = executeActionCommand(fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --plain-http", dir(chartname), dir("repositories.yaml"), dir())) if err != nil { t.Logf("Output: %s", out) t.Fatal(err) @@ -131,7 +131,7 @@ func TestDependencyUpdateCmd(t *testing.T) { 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", + cmd := fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --registry-config %s/config.json --plain-http", dir(ociChartName), dir("repositories.yaml"), dir(), @@ -169,7 +169,7 @@ func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { } 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())) + _, output, err := executeActionCommand(fmt.Sprintf("dependency update %s --repository-config %s --repository-cache %s --plain-http", dir(chartname), dir("repositories.yaml"), dir())) if err != nil { t.Logf("Output: %s", output) t.Fatal(err) @@ -178,7 +178,7 @@ func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { // 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())) + _, output, err = executeActionCommand(fmt.Sprintf("dependency update %s --repository-config %s --repository-cache %s --plain-http", dir(chartname), dir("repositories.yaml"), dir())) if err == nil { t.Logf("Output: %s", output) t.Fatal("Expected error, got nil") diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index aa75cad49..160e95c76 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -203,7 +203,7 @@ func TestPullCmd(t *testing.T) { 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", + cmd := fmt.Sprintf("fetch %s -d '%s' --repository-config %s --repository-cache %s --registry-config %s --plain-http", tt.args, outdir, filepath.Join(outdir, "repositories.yaml"), diff --git a/cmd/helm/registry_login.go b/cmd/helm/registry_login.go index 59b5591ba..74ad4cebe 100644 --- a/cmd/helm/registry_login.go +++ b/cmd/helm/registry_login.go @@ -43,6 +43,7 @@ type registryLoginOptions struct { keyFile string caFile string insecure bool + plainHTTP bool } func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { @@ -66,7 +67,8 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman action.WithCertFile(o.certFile), action.WithKeyFile(o.keyFile), action.WithCAFile(o.caFile), - action.WithInsecure(o.insecure)) + action.WithInsecure(o.insecure), + action.WithPlainHTTPLogin(o.plainHTTP)) }, } @@ -78,6 +80,7 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman f.StringVar(&o.certFile, "cert-file", "", "identify registry client using this SSL certificate file") f.StringVar(&o.keyFile, "key-file", "", "identify registry client using this SSL key file") f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") + f.BoolVar(&o.plainHTTP, "plain-http", false, "use insecure HTTP connections for the chart upload") return cmd } diff --git a/go.mod b/go.mod index 6db35856b..848adb3d6 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,6 @@ require ( github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/pkg/errors v0.9.1 github.com/rubenv/sql-migrate v1.7.1 - github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 @@ -45,7 +44,7 @@ require ( k8s.io/client-go v0.32.1 k8s.io/klog/v2 v2.130.1 k8s.io/kubectl v0.32.1 - oras.land/oras-go v1.2.6 + oras.land/oras-go/v2 v2.5.0 sigs.k8s.io/yaml v1.4.0 ) @@ -68,11 +67,7 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/cli v27.1.0+incompatible // indirect - github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker v27.1.1+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.2 // indirect - github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect @@ -118,7 +113,6 @@ require ( github.com/miekg/dns v1.1.57 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/moby/locker v1.0.1 // indirect github.com/moby/spdystream v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -137,6 +131,7 @@ require ( github.com/redis/go-redis/v9 v9.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/cast v1.7.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect diff --git a/go.sum b/go.sum index 266ca3add..5e7d07608 100644 --- a/go.sum +++ b/go.sum @@ -22,10 +22,6 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8 github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/Masterminds/vcs v1.13.3 h1:IIA2aBdXvfbIM+yl/eTnL4hb1XwdpvuQLglAix1gweE= github.com/Masterminds/vcs v1.13.3/go.mod h1:TiE7xuEjl1N4j016moRd6vezp6e6Lz23gypeXfzXeW8= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Microsoft/hcsshim v0.11.7 h1:vl/nj3Bar/CvJSYo7gIQPyRWc9f3c6IeSNavBTSZNZQ= -github.com/Microsoft/hcsshim v0.11.7/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= @@ -52,12 +48,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= -github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= -github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= github.com/containerd/containerd v1.7.25 h1:khEQOAXOEJalRO228yzVsuASLH42vT7DIo9Ss+9SMFQ= github.com/containerd/containerd v1.7.25/go.mod h1:tWfHzVI0azhw4CT2vaIjsb2CoV4LJ9PrMPaULAr21Ok= -github.com/containerd/continuity v0.4.4 h1:/fNVfTJ7wIl/YPMHjf+5H32uFhl63JucB34PlCpMKII= -github.com/containerd/continuity v0.4.4/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= @@ -83,22 +75,12 @@ github.com/distribution/distribution/v3 v3.0.0-rc.2 h1:tTrzntanYMbd20SyvdeR83Ya1 github.com/distribution/distribution/v3 v3.0.0-rc.2/go.mod h1:H2zIRRXS20ylnv2HTuKILAWuANjuA60GB7MLOsQag7Y= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v27.1.0+incompatible h1:P0KSYmPtNbmx59wHZvG6+rjivhKDRA1BvvWM0f5DgHc= -github.com/docker/cli v27.1.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= -github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= -github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= -github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= -github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arXfYcAtECDFgAgHklGI8CxgjHnXKJ4= -github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.9.11+incompatible h1:ixHHqfcGvxhWkniF1tWxBHA0yb4Z+d1UQi45df52xW8= @@ -148,8 +130,6 @@ github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeH github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -255,14 +235,8 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= -github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU= github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= -github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= -github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= -github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= -github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -373,8 +347,6 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 h1:UW0+QyeyBVhn+COBec3nGhfnFe5lwB0ic1JBVjzhk0w= go.opentelemetry.io/contrib/bridges/prometheus v0.57.0/go.mod h1:ppciCHRLsyCio54qbzQv0E4Jyth/fLWDTJYfvWpcSVk= go.opentelemetry.io/contrib/exporters/autoexport v0.57.0 h1:jmTVJ86dP60C01K3slFQa2NQ/Aoi7zA+wy7vMOKD9H4= @@ -547,8 +519,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= -gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc= k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k= k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw= @@ -571,8 +541,8 @@ k8s.io/kubectl v0.32.1 h1:/btLtXLQUU1rWx8AEvX9jrb9LaI6yeezt3sFALhB8M8= k8s.io/kubectl v0.32.1/go.mod h1:sezNuyWi1STk4ZNPVRIFfgjqMI6XMf+oCVLjZen/pFQ= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -oras.land/oras-go v1.2.6 h1:z8cmxQXBU8yZ4mkytWqXfo6tZcamPwjsuxYU81xJ8Lk= -oras.land/oras-go v1.2.6/go.mod h1:OVPc1PegSEe/K8YiLfosrlqlqTN9PUyFvOw5Y9gwrT8= +oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= +oras.land/oras-go/v2 v2.5.0/go.mod h1:z4eisnLP530vwIOUOJeBIj0aGI0L1C3d53atvCBqZHg= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= sigs.k8s.io/kustomize/api v0.18.0 h1:hTzp67k+3NEVInwz5BHyzc9rGxIauoXferXyjv5lWPo= diff --git a/pkg/action/registry_login.go b/pkg/action/registry_login.go index 7a981d547..fd9d4bfc6 100644 --- a/pkg/action/registry_login.go +++ b/pkg/action/registry_login.go @@ -24,11 +24,12 @@ import ( // RegistryLogin performs a registry login operation. type RegistryLogin struct { - cfg *Configuration - certFile string - keyFile string - caFile string - insecure bool + cfg *Configuration + certFile string + keyFile string + caFile string + insecure bool + plainHTTP bool } type RegistryLoginOpt func(*RegistryLogin) error @@ -41,7 +42,7 @@ func WithCertFile(certFile string) RegistryLoginOpt { } } -// WithKeyFile specifies whether to very certificates when communicating. +// WithInsecure specifies whether to verify certificates. func WithInsecure(insecure bool) RegistryLoginOpt { return func(r *RegistryLogin) error { r.insecure = insecure @@ -65,6 +66,14 @@ func WithCAFile(caFile string) RegistryLoginOpt { } } +// WithPlainHTTPLogin use http rather than https for login. +func WithPlainHTTPLogin(isPlain bool) RegistryLoginOpt { + return func(r *RegistryLogin) error { + r.plainHTTP = isPlain + return nil + } +} + // NewRegistryLogin creates a new RegistryLogin object with the given configuration. func NewRegistryLogin(cfg *Configuration) *RegistryLogin { return &RegistryLogin{ @@ -84,5 +93,7 @@ func (a *RegistryLogin) Run(_ io.Writer, hostname string, username string, passw hostname, registry.LoginOptBasicAuth(username, password), registry.LoginOptInsecure(a.insecure), - registry.LoginOptTLSClientConfig(a.certFile, a.keyFile, a.caFile)) + registry.LoginOptTLSClientConfig(a.certFile, a.keyFile, a.caFile), + registry.LoginOptPlainText(a.plainHTTP), + ) } diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index 1e989ce6f..1d28e3c22 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -56,8 +56,6 @@ func TestResolveChartRef(t *testing.T) { {name: "ref with tag", ref: "oci://example.com/helm-charts/nginx:15.4.2", expect: "oci://example.com/helm-charts/nginx:15.4.2"}, {name: "no repository", ref: "oci://", fail: true}, {name: "oci ref", ref: "oci://example.com/helm-charts/nginx", version: "15.4.2", expect: "oci://example.com/helm-charts/nginx:15.4.2"}, - {name: "oci ref with sha256", ref: "oci://example.com/install/by/sha@sha256:d234555386402a5867ef0169fefe5486858b6d8d209eaf32fd26d29b16807fd6", version: "0.1.1", expect: "oci://example.com/install/by/sha@sha256:d234555386402a5867ef0169fefe5486858b6d8d209eaf32fd26d29b16807fd6"}, - {name: "oci ref with sha256 and version", ref: "oci://example.com/install/by/sha:0.1.1@sha256:d234555386402a5867ef0169fefe5486858b6d8d209eaf32fd26d29b16807fd6", version: "0.1.1", expect: "oci://example.com/install/by/sha:0.1.1@sha256:d234555386402a5867ef0169fefe5486858b6d8d209eaf32fd26d29b16807fd6"}, {name: "oci ref with sha256 and version mismatch", ref: "oci://example.com/install/by/sha:0.1.1@sha256:d234555386402a5867ef0169fefe5486858b6d8d209eaf32fd26d29b16807fd6", version: "0.1.2", fail: true}, } diff --git a/pkg/registry/client.go b/pkg/registry/client.go index 5cb8d1bb4..01e5dff7b 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -18,26 +18,31 @@ package registry // import "helm.sh/helm/v4/pkg/registry" import ( "context" - "encoding/base64" + "crypto/tls" + "crypto/x509" "encoding/json" "fmt" "io" "net/http" "net/url" + "os" "sort" "strings" + "sync" "github.com/Masterminds/semver/v3" "github.com/containerd/containerd/remotes" + "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" - "oras.land/oras-go/pkg/auth" - dockerauth "oras.land/oras-go/pkg/auth/docker" - "oras.land/oras-go/pkg/content" - "oras.land/oras-go/pkg/oras" - "oras.land/oras-go/pkg/registry" - registryremote "oras.land/oras-go/pkg/registry/remote" - registryauth "oras.land/oras-go/pkg/registry/remote/auth" + "oras.land/oras-go/v2" + "oras.land/oras-go/v2/content" + "oras.land/oras-go/v2/content/memory" + "oras.land/oras-go/v2/registry" + "oras.land/oras-go/v2/registry/remote" + "oras.land/oras-go/v2/registry/remote/auth" + "oras.land/oras-go/v2/registry/remote/credentials" + "oras.land/oras-go/v2/registry/remote/retry" "helm.sh/helm/v4/internal/version" "helm.sh/helm/v4/pkg/chart" @@ -51,6 +56,8 @@ storing semantic versions, Helm adopts the convention of changing plus (+) to an underscore (_) in chart version tags when pushing to a registry and back to a plus (+) when pulling from a registry.` +var errDeprecatedRemote = errors.New("providing github.com/containerd/containerd/remotes.Resolver via ClientOptResolver is no longer suported") + type ( // RemoteClient shadows the ORAS remote.Client interface // (hiding the ORAS type from Helm client visibility) @@ -68,11 +75,12 @@ type ( username string password string out io.Writer - authorizer auth.Client + authorizer *auth.Client registryAuthorizer RemoteClient - resolver func(ref registry.Reference) (remotes.Resolver, error) + credentialsStore credentials.Store httpClient *http.Client plainHTTP bool + err error // pass any errors from the ClientOption functions } // ClientOption allows specifying various settings configurable by the user for overriding the defaults @@ -87,101 +95,70 @@ func NewClient(options ...ClientOption) (*Client, error) { } for _, option := range options { option(client) + if client.err != nil { + return nil, client.err + } } if client.credentialsFile == "" { client.credentialsFile = helmpath.ConfigPath(CredentialsFileBasename) } - if client.authorizer == nil { - authClient, err := dockerauth.NewClientWithDockerFallback(client.credentialsFile) - if err != nil { - return nil, err - } - client.authorizer = authClient - } - - resolverFn := client.resolver // copy for avoiding recursive call - client.resolver = func(ref registry.Reference) (remotes.Resolver, error) { - if resolverFn != nil { - // validate if the resolverFn returns a valid resolver - if resolver, err := resolverFn(ref); resolver != nil && err == nil { - return resolver, nil - } - } - headers := http.Header{} - headers.Set("User-Agent", version.GetUserAgent()) - opts := []auth.ResolverOption{auth.WithResolverHeaders(headers)} - if client.httpClient != nil { - opts = append(opts, auth.WithResolverClient(client.httpClient)) - } - if client.plainHTTP { - opts = append(opts, auth.WithResolverPlainHTTP()) + if client.httpClient == nil { + type cloner[T any] interface { + Clone() T } - // if username and password are set, use them for authentication - // by adding the basic auth Authorization header to the resolver - if client.username != "" && client.password != "" { - concat := client.username + ":" + client.password - encodedAuth := base64.StdEncoding.EncodeToString([]byte(concat)) - opts = append(opts, auth.WithResolverHeaders( - http.Header{ - "Authorization": []string{"Basic " + encodedAuth}, - }, - )) + // try to copy (clone) the http.DefaultTransport so any mutations we + // perform on it (e.g. TLS config) are not reflected globally + // follow https://github.com/golang/go/issues/39299 for a more elegant + // solution in the future + transport := http.DefaultTransport + if t, ok := transport.(cloner[*http.Transport]); ok { + transport = t.Clone() + } else if t, ok := transport.(cloner[http.RoundTripper]); ok { + // this branch will not be used with go 1.20, it was added + // optimistically to try to clone if the http.DefaultTransport + // implementation changes, still the Clone method in that case + // might not return http.RoundTripper... + transport = t.Clone() } - resolver, err := client.authorizer.ResolverWithOpts(opts...) - if err != nil { - return nil, err + client.httpClient = &http.Client{ + Transport: retry.NewTransport(transport), } - return resolver, nil } - // allocate a cache if option is set - var cache registryauth.Cache - if client.enableCache { - cache = registryauth.DefaultCache + storeOptions := credentials.StoreOptions{ + AllowPlaintextPut: true, + DetectDefaultNativeStore: true, + } + store, err := credentials.NewStore(client.credentialsFile, storeOptions) + if err != nil { + return nil, err + } + dockerStore, err := credentials.NewStoreFromDocker(storeOptions) + if err != nil { + // should only fail if user home directory can't be determined + client.credentialsStore = store + } else { + // use Helm credentials with fallback to Docker + client.credentialsStore = credentials.NewStoreWithFallbacks(store, dockerStore) } - if client.registryAuthorizer == nil { - client.registryAuthorizer = ®istryauth.Client{ - Client: client.httpClient, - Header: http.Header{ - "User-Agent": {version.GetUserAgent()}, - }, - Cache: cache, - Credential: func(_ context.Context, reg string) (registryauth.Credential, error) { - if client.username != "" && client.password != "" { - return registryauth.Credential{ - Username: client.username, - Password: client.password, - }, nil - } - - dockerClient, ok := client.authorizer.(*dockerauth.Client) - if !ok { - return registryauth.EmptyCredential, errors.New("unable to obtain docker client") - } - - username, password, err := dockerClient.Credential(reg) - if err != nil { - return registryauth.EmptyCredential, errors.New("unable to retrieve credentials") - } - // A blank returned username and password value is a bearer token - if username == "" && password != "" { - return registryauth.Credential{ - RefreshToken: password, - }, nil - } + if client.authorizer == nil { + authorizer := auth.Client{ + Client: client.httpClient, + } + authorizer.SetUserAgent(version.GetUserAgent()) - return registryauth.Credential{ - Username: username, - Password: password, - }, nil + authorizer.Credential = credentials.Credential(client.credentialsStore) - }, + if client.enableCache { + authorizer.Cache = auth.NewCache() } + client.authorizer = &authorizer } + return client, nil } @@ -220,7 +197,7 @@ func ClientOptWriter(out io.Writer) ClientOption { // Depending on the use-case you may need to set both ClientOptAuthorizer and ClientOptRegistryAuthorizer. func ClientOptAuthorizer(authorizer auth.Client) ClientOption { return func(client *Client) { - client.authorizer = authorizer + client.authorizer = &authorizer } } @@ -254,12 +231,9 @@ func ClientOptPlainHTTP() ClientOption { } } -// ClientOptResolver returns a function that sets the resolver setting on a client options set -func ClientOptResolver(resolver remotes.Resolver) ClientOption { - return func(client *Client) { - client.resolver = func(_ registry.Reference) (remotes.Resolver, error) { - return resolver, nil - } +func ClientOptResolver(_ remotes.Resolver) ClientOption { + return func(c *Client) { + c.err = errDeprecatedRemote } } @@ -268,60 +242,128 @@ type ( LoginOption func(*loginOperation) loginOperation struct { - username string - password string - insecure bool - certFile string - keyFile string - caFile string + host string + client *Client } ) // Login logs into a registry func (c *Client) Login(host string, options ...LoginOption) error { - operation := &loginOperation{} for _, option := range options { - option(operation) + option(&loginOperation{host, c}) + } + + reg, err := remote.NewRegistry(host) + if err != nil { + return err } - authorizerLoginOpts := []auth.LoginOption{ - auth.WithLoginContext(ctx(c.out, c.debug)), - auth.WithLoginHostname(host), - auth.WithLoginUsername(operation.username), - auth.WithLoginSecret(operation.password), - auth.WithLoginUserAgent(version.GetUserAgent()), - auth.WithLoginTLS(operation.certFile, operation.keyFile, operation.caFile), + reg.PlainHTTP = c.plainHTTP + reg.Client = c.authorizer + + ctx := context.Background() + cred, err := c.authorizer.Credential(ctx, host) + if err != nil { + return fmt.Errorf("fetching credentials for %q: %w", host, err) } - if operation.insecure { - authorizerLoginOpts = append(authorizerLoginOpts, auth.WithLoginInsecure()) + + if err := reg.Ping(ctx); err != nil { + return fmt.Errorf("authenticating to %q: %w", host, err) } - if err := c.authorizer.LoginWithOpts(authorizerLoginOpts...); err != nil { + + key := credentials.ServerAddressFromRegistry(host) + if err := c.credentialsStore.Put(ctx, key, cred); err != nil { return err } + fmt.Fprintln(c.out, "Login Succeeded") return nil } // LoginOptBasicAuth returns a function that sets the username/password settings on login func LoginOptBasicAuth(username string, password string) LoginOption { - return func(operation *loginOperation) { - operation.username = username - operation.password = password + return func(o *loginOperation) { + o.client.username = username + o.client.password = password + o.client.authorizer.Credential = auth.StaticCredential(o.host, auth.Credential{Username: username, Password: password}) } } +// LoginOptPlainText returns a function that allows plaintext (HTTP) login +func LoginOptPlainText(isPlainText bool) LoginOption { + return func(o *loginOperation) { + o.client.plainHTTP = isPlainText + } +} + +func ensureTLSConfig(client *auth.Client) (*tls.Config, error) { + var transport *http.Transport + + switch t := client.Client.Transport.(type) { + case *http.Transport: + transport = t + case *retry.Transport: + switch t := t.Base.(type) { + case *http.Transport: + transport = t + } + } + + if transport == nil { + // we don't know how to access the http.Transport, most likely the + // auth.Client.Client was provided by API user + return nil, fmt.Errorf("unable to access TLS client configuration, the provided HTTP Transport is not supported, given: %T", client.Client.Transport) + } + + if transport.TLSClientConfig == nil { + transport.TLSClientConfig = &tls.Config{} + } + + return transport.TLSClientConfig, nil +} + // LoginOptInsecure returns a function that sets the insecure setting on login func LoginOptInsecure(insecure bool) LoginOption { - return func(operation *loginOperation) { - operation.insecure = insecure + return func(o *loginOperation) { + tlsConfig, err := ensureTLSConfig(o.client.authorizer) + + if err != nil { + panic(err) + } + + tlsConfig.InsecureSkipVerify = insecure } } // LoginOptTLSClientConfig returns a function that sets the TLS settings on login. func LoginOptTLSClientConfig(certFile, keyFile, caFile string) LoginOption { - return func(operation *loginOperation) { - operation.certFile = certFile - operation.keyFile = keyFile - operation.caFile = caFile + return func(o *loginOperation) { + if (certFile == "" || keyFile == "") && caFile == "" { + return + } + tlsConfig, err := ensureTLSConfig(o.client.authorizer) + if err != nil { + panic(err) + } + + if certFile != "" && keyFile != "" { + authCert, err := tls.LoadX509KeyPair(certFile, keyFile) + if err != nil { + panic(err) + } + tlsConfig.Certificates = []tls.Certificate{authCert} + } + + if caFile != "" { + certPool := x509.NewCertPool() + ca, err := os.ReadFile(caFile) + if err != nil { + panic(err) + } + if !certPool.AppendCertsFromPEM(ca) { + panic(fmt.Errorf("unable to parse CA file: %q", caFile)) + } + tlsConfig.RootCAs = certPool + } } } @@ -338,7 +380,8 @@ func (c *Client) Logout(host string, opts ...LogoutOption) error { for _, opt := range opts { opt(operation) } - if err := c.authorizer.Logout(ctx(c.out, c.debug), host); err != nil { + + if err := credentials.Logout(context.Background(), c.credentialsStore, host); err != nil { return err } fmt.Fprintf(c.out, "Removing login credentials for %s\n", host) @@ -393,8 +436,9 @@ func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) { return nil, errors.New( "must specify at least one layer to pull (chart/prov)") } - memoryStore := content.NewMemory() + memoryStore := memory.New() allowedMediaTypes := []string{ + ocispec.MediaTypeImageManifest, ConfigMediaType, } minNumDescriptors := 1 // 1 for the config @@ -410,18 +454,34 @@ func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) { } var descriptors, layers []ocispec.Descriptor - remotesResolver, err := c.resolver(parsedRef.orasReference) + + repository, err := remote.NewRepository(parsedRef.String()) if err != nil { return nil, err } - registryStore := content.Registry{Resolver: remotesResolver} + repository.PlainHTTP = c.plainHTTP + repository.Client = c.authorizer - manifest, err := oras.Copy(ctx(c.out, c.debug), registryStore, parsedRef.String(), memoryStore, "", - oras.WithPullEmptyNameAllowed(), - oras.WithAllowedMediaTypes(allowedMediaTypes), - oras.WithLayerDescriptors(func(l []ocispec.Descriptor) { - layers = l - })) + ctx := context.Background() + + sort.Strings(allowedMediaTypes) + + var mu sync.Mutex + manifest, err := oras.Copy(ctx, repository, parsedRef.String(), memoryStore, "", oras.CopyOptions{ + CopyGraphOptions: oras.CopyGraphOptions{ + PreCopy: func(_ context.Context, desc ocispec.Descriptor) error { + mediaType := desc.MediaType + if i := sort.SearchStrings(allowedMediaTypes, mediaType); i >= len(allowedMediaTypes) || allowedMediaTypes[i] != mediaType { + return errors.Errorf("media type %q is not allowed, found in descriptor with digest: %q", mediaType, desc.Digest) + } + + mu.Lock() + layers = append(layers, desc) + mu.Unlock() + return nil + }, + }, + }) if err != nil { return nil, err } @@ -480,54 +540,37 @@ func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) { Prov: &DescriptorPullSummary{}, Ref: parsedRef.String(), } - var getManifestErr error - if _, manifestData, ok := memoryStore.Get(manifest); !ok { - getManifestErr = errors.Errorf("Unable to retrieve blob with digest %s", manifest.Digest) - } else { - result.Manifest.Data = manifestData - } - if getManifestErr != nil { - return nil, getManifestErr + + result.Manifest.Data, err = content.FetchAll(ctx, memoryStore, manifest) + if err != nil { + return nil, fmt.Errorf("unable to retrieve blob with digest %s: %w", manifest.Digest, err) } - var getConfigDescriptorErr error - if _, configData, ok := memoryStore.Get(*configDescriptor); !ok { - getConfigDescriptorErr = errors.Errorf("Unable to retrieve blob with digest %s", configDescriptor.Digest) - } else { - result.Config.Data = configData - var meta *chart.Metadata - if err := json.Unmarshal(configData, &meta); err != nil { - return nil, err - } - result.Chart.Meta = meta + + result.Config.Data, err = content.FetchAll(ctx, memoryStore, *configDescriptor) + if err != nil { + return nil, fmt.Errorf("unable to retrieve blob with digest %s: %w", configDescriptor.Digest, err) } - if getConfigDescriptorErr != nil { - return nil, getConfigDescriptorErr + + if err := json.Unmarshal(result.Config.Data, &result.Chart.Meta); err != nil { + return nil, err } + if operation.withChart { - var getChartDescriptorErr error - if _, chartData, ok := memoryStore.Get(*chartDescriptor); !ok { - getChartDescriptorErr = errors.Errorf("Unable to retrieve blob with digest %s", chartDescriptor.Digest) - } else { - result.Chart.Data = chartData - result.Chart.Digest = chartDescriptor.Digest.String() - result.Chart.Size = chartDescriptor.Size - } - if getChartDescriptorErr != nil { - return nil, getChartDescriptorErr + result.Chart.Data, err = content.FetchAll(ctx, memoryStore, *chartDescriptor) + if err != nil { + return nil, fmt.Errorf("unable to retrieve blob with digest %s: %w", chartDescriptor.Digest, err) } + result.Chart.Digest = chartDescriptor.Digest.String() + result.Chart.Size = chartDescriptor.Size } + if operation.withProv && !provMissing { - var getProvDescriptorErr error - if _, provData, ok := memoryStore.Get(*provDescriptor); !ok { - getProvDescriptorErr = errors.Errorf("Unable to retrieve blob with digest %s", provDescriptor.Digest) - } else { - result.Prov.Data = provData - result.Prov.Digest = provDescriptor.Digest.String() - result.Prov.Size = provDescriptor.Size - } - if getProvDescriptorErr != nil { - return nil, getProvDescriptorErr + result.Prov.Data, err = content.FetchAll(ctx, memoryStore, *provDescriptor) + if err != nil { + return nil, fmt.Errorf("unable to retrieve blob with digest %s: %w", provDescriptor.Digest, err) } + result.Prov.Digest = provDescriptor.Digest.String() + result.Prov.Size = provDescriptor.Size } fmt.Fprintf(c.out, "Pulled: %s\n", result.Ref) @@ -615,8 +658,11 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu "strict mode enabled, ref basename and tag must match the chart name and version") } } - memoryStore := content.NewMemory() - chartDescriptor, err := memoryStore.Add("", ChartLayerMediaType, data) + + ctx := context.Background() + + memoryStore := memory.New() + chartDescriptor, err := oras.PushBytes(ctx, memoryStore, ChartLayerMediaType, data) if err != nil { return nil, err } @@ -626,43 +672,57 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu return nil, err } - configDescriptor, err := memoryStore.Add("", ConfigMediaType, configData) + configDescriptor, err := oras.PushBytes(ctx, memoryStore, ConfigMediaType, configData) if err != nil { return nil, err } - descriptors := []ocispec.Descriptor{chartDescriptor} + layers := []ocispec.Descriptor{chartDescriptor} var provDescriptor ocispec.Descriptor if operation.provData != nil { - provDescriptor, err = memoryStore.Add("", ProvLayerMediaType, operation.provData) + provDescriptor, err = oras.PushBytes(ctx, memoryStore, ProvLayerMediaType, operation.provData) if err != nil { return nil, err } - descriptors = append(descriptors, provDescriptor) + layers = append(layers, provDescriptor) } + // sort layers for determinism, similar to how ORAS v1 does it + sort.Slice(layers, func(i, j int) bool { + return layers[i].Digest < layers[j].Digest + }) + ociAnnotations := generateOCIAnnotations(meta, operation.creationTime) + manifest := ocispec.Manifest{ + Versioned: specs.Versioned{SchemaVersion: 2}, + Config: configDescriptor, + Layers: layers, + Annotations: ociAnnotations, + } - manifestData, manifest, err := content.GenerateManifest(&configDescriptor, ociAnnotations, descriptors...) + manifestData, err := json.Marshal(manifest) if err != nil { return nil, err } - if err := memoryStore.StoreManifest(parsedRef.String(), manifest, manifestData); err != nil { + manifestDescriptor, err := oras.TagBytes(ctx, memoryStore, ocispec.MediaTypeImageManifest, manifestData, ref) + if err != nil { return nil, err } - remotesResolver, err := c.resolver(parsedRef.orasReference) + repository, err := remote.NewRepository(parsedRef.String()) if err != nil { return nil, err } - registryStore := content.Registry{Resolver: remotesResolver} - _, err = oras.Copy(ctx(c.out, c.debug), memoryStore, parsedRef.orasReference.String(), registryStore, "", - oras.WithNameValidation(nil)) + repository.PlainHTTP = c.plainHTTP + repository.Client = c.authorizer + + manifestDescriptor, err = oras.ExtendedCopy(ctx, memoryStore, parsedRef.String(), repository, parsedRef.String(), oras.DefaultExtendedCopyOptions) if err != nil { return nil, err } + chartSummary := &descriptorPushSummaryWithMeta{ Meta: meta, } @@ -670,8 +730,8 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu chartSummary.Size = chartDescriptor.Size result := &PushResult{ Manifest: &descriptorPushSummary{ - Digest: manifest.Digest.String(), - Size: manifest.Size, + Digest: manifestDescriptor.Digest.String(), + Size: manifestDescriptor.Size, }, Config: &descriptorPushSummary{ Digest: configDescriptor.Digest.String(), @@ -725,27 +785,29 @@ func (c *Client) Tags(ref string) ([]string, error) { return nil, err } - repository := registryremote.Repository{ - Reference: parsedReference, - Client: c.registryAuthorizer, - PlainHTTP: c.plainHTTP, - } - - var registryTags []string - - registryTags, err = registry.Tags(ctx(c.out, c.debug), &repository) + ctx := context.Background() + repository, err := remote.NewRepository(parsedReference.String()) if err != nil { return nil, err } + repository.PlainHTTP = c.plainHTTP + repository.Client = c.authorizer var tagVersions []*semver.Version - for _, tag := range registryTags { - // Change underscore (_) back to plus (+) for Helm - // See https://github.com/helm/helm/issues/10166 - tagVersion, err := semver.StrictNewVersion(strings.ReplaceAll(tag, "_", "+")) - if err == nil { - tagVersions = append(tagVersions, tagVersion) + err = repository.Tags(ctx, "", func(tags []string) error { + for _, tag := range tags { + // Change underscore (_) back to plus (+) for Helm + // See https://github.com/helm/helm/issues/10166 + tagVersion, err := semver.StrictNewVersion(strings.ReplaceAll(tag, "_", "+")) + if err == nil { + tagVersions = append(tagVersions, tagVersion) + } } + + return nil + }) + if err != nil { + return nil, err } // Sort the collection @@ -762,30 +824,28 @@ func (c *Client) Tags(ref string) ([]string, error) { } // Resolve a reference to a descriptor. -func (c *Client) Resolve(ref string) (*ocispec.Descriptor, error) { - ctx := context.Background() - parsedRef, err := newReference(ref) +func (c *Client) Resolve(ref string) (desc ocispec.Descriptor, err error) { + remoteRepository, err := remote.NewRepository(ref) if err != nil { - return nil, err - } - if parsedRef.Registry == "" { - return nil, nil + return desc, err } + remoteRepository.PlainHTTP = c.plainHTTP - remotesResolver, err := c.resolver(parsedRef.orasReference) + parsedReference, err := newReference(ref) if err != nil { - return nil, err + return desc, err } - _, desc, err := remotesResolver.Resolve(ctx, ref) - return &desc, err + ctx := context.Background() + parsedString := parsedReference.String() + return remoteRepository.Resolve(ctx, parsedString) } // ValidateReference for path and version func (c *Client) ValidateReference(ref, version string, u *url.URL) (*url.URL, error) { var tag string - registryReference, err := newReference(u.Path) + registryReference, err := newReference(u.Host + u.Path) if err != nil { return nil, err } @@ -800,19 +860,20 @@ func (c *Client) ValidateReference(ref, version string, u *url.URL) (*url.URL, e } if registryReference.Digest != "" { - if registryReference.Tag == "" { + if version == "" { // Install by digest only return u, nil } + u.Path = fmt.Sprintf("%s@%s", registryReference.Repository, registryReference.Digest) // Validate the tag if it was specified - path := registryReference.Registry + "/" + registryReference.Repository + ":" + registryReference.Tag + path := registryReference.Registry + "/" + registryReference.Repository + ":" + version desc, err := c.Resolve(path) if err != nil { // The resource does not have to be tagged when digest is specified return u, nil } - if desc != nil && desc.Digest.String() != registryReference.Digest { + if desc.Digest.String() != registryReference.Digest { return nil, errors.Errorf("chart reference digest mismatch: %s is not %s", desc.Digest.String(), registryReference.Digest) } return u, nil @@ -842,7 +903,7 @@ func (c *Client) ValidateReference(ref, version string, u *url.URL) (*url.URL, e } } - u.Path = fmt.Sprintf("%s/%s:%s", registryReference.Registry, registryReference.Repository, tag) + u.Path = fmt.Sprintf("%s:%s", registryReference.Repository, tag) return u, err } diff --git a/pkg/registry/client_http_test.go b/pkg/registry/client_http_test.go index 872d19fc9..043fd4205 100644 --- a/pkg/registry/client_http_test.go +++ b/pkg/registry/client_http_test.go @@ -17,12 +17,13 @@ limitations under the License. package registry import ( + "errors" "fmt" "os" "testing" - "github.com/containerd/containerd/errdefs" "github.com/stretchr/testify/suite" + "oras.land/oras-go/v2/content" ) type HTTPRegistryClientTestSuite struct { @@ -42,6 +43,18 @@ func (suite *HTTPRegistryClientTestSuite) TearDownSuite() { os.RemoveAll(suite.WorkspaceDir) } +func (suite *HTTPRegistryClientTestSuite) Test_0_Login() { + err := suite.RegistryClient.Login(suite.DockerRegistryHost, + LoginOptBasicAuth("badverybad", "ohsobad"), + LoginOptPlainText(true)) + suite.NotNil(err, "error logging into registry with bad credentials") + + err = suite.RegistryClient.Login(suite.DockerRegistryHost, + LoginOptBasicAuth(testUsername, testPassword), + LoginOptPlainText(true)) + suite.Nil(err, "no error logging into registry with good credentials") +} + func (suite *HTTPRegistryClientTestSuite) Test_1_Push() { testPush(&suite.TestSuite) } @@ -60,7 +73,7 @@ func (suite *HTTPRegistryClientTestSuite) Test_4_ManInTheMiddle() { // returns content that does not match the expected digest _, err := suite.RegistryClient.Pull(ref) suite.NotNil(err) - suite.True(errdefs.IsFailedPrecondition(err)) + suite.True(errors.Is(err, content.ErrMismatchedDigest)) } func TestHTTPRegistryClientTestSuite(t *testing.T) { diff --git a/pkg/registry/client_insecure_tls_test.go b/pkg/registry/client_insecure_tls_test.go index 5ba79b2ea..accbf1670 100644 --- a/pkg/registry/client_insecure_tls_test.go +++ b/pkg/registry/client_insecure_tls_test.go @@ -66,7 +66,10 @@ func (suite *InsecureTLSRegistryClientTestSuite) Test_3_Tags() { func (suite *InsecureTLSRegistryClientTestSuite) Test_4_Logout() { err := suite.RegistryClient.Logout("this-host-aint-real:5000") - suite.NotNil(err, "error logging out of registry that has no entry") + if err != nil { + // credential backend for mac generates an error + suite.NotNil(err, "failed to delete the credential for this-host-aint-real:5000") + } err = suite.RegistryClient.Logout(suite.DockerRegistryHost) suite.Nil(err, "no error logging out of registry") diff --git a/pkg/registry/client_test.go b/pkg/registry/client_test.go new file mode 100644 index 000000000..4c5a78849 --- /dev/null +++ b/pkg/registry/client_test.go @@ -0,0 +1,33 @@ +/* +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 registry + +import ( + "testing" + + "github.com/containerd/containerd/remotes" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewClientResolverNotSupported(t *testing.T) { + var r remotes.Resolver + + client, err := NewClient(ClientOptResolver(r)) + require.Equal(t, err, errDeprecatedRemote) + assert.Nil(t, client) +} diff --git a/pkg/registry/client_tls_test.go b/pkg/registry/client_tls_test.go index 518cfced4..156ae4816 100644 --- a/pkg/registry/client_tls_test.go +++ b/pkg/registry/client_tls_test.go @@ -66,7 +66,10 @@ func (suite *TLSRegistryClientTestSuite) Test_3_Tags() { func (suite *TLSRegistryClientTestSuite) Test_4_Logout() { err := suite.RegistryClient.Logout("this-host-aint-real:5000") - suite.NotNil(err, "error logging out of registry that has no entry") + if err != nil { + // credential backend for mac generates an error + suite.NotNil(err, "failed to delete the credential for this-host-aint-real:5000") + } err = suite.RegistryClient.Logout(suite.DockerRegistryHost) suite.Nil(err, "no error logging out of registry") diff --git a/pkg/registry/reference.go b/pkg/registry/reference.go index 9b99d73bf..b5677761d 100644 --- a/pkg/registry/reference.go +++ b/pkg/registry/reference.go @@ -19,11 +19,11 @@ package registry import ( "strings" - orasregistry "oras.land/oras-go/pkg/registry" + "oras.land/oras-go/v2/registry" ) type reference struct { - orasReference orasregistry.Reference + orasReference registry.Reference Registry string Repository string Tag string @@ -60,7 +60,7 @@ func newReference(raw string) (result reference, err error) { } } - result.orasReference, err = orasregistry.ParseReference(raw) + result.orasReference, err = registry.ParseReference(raw) if err != nil { return result, err } diff --git a/pkg/registry/util.go b/pkg/registry/util.go index 326d3efcd..fb6103369 100644 --- a/pkg/registry/util.go +++ b/pkg/registry/util.go @@ -18,24 +18,20 @@ package registry // import "helm.sh/helm/v4/pkg/registry" import ( "bytes" - "context" "fmt" "io" "net/http" "strings" "time" + "helm.sh/helm/v4/internal/tlsutil" + "helm.sh/helm/v4/pkg/chart" + "helm.sh/helm/v4/pkg/chart/loader" helmtime "helm.sh/helm/v4/pkg/time" "github.com/Masterminds/semver/v3" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" - "github.com/sirupsen/logrus" - orascontext "oras.land/oras-go/pkg/context" - - "helm.sh/helm/v4/internal/tlsutil" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" ) var immutableOciAnnotations = []string{ @@ -43,7 +39,7 @@ var immutableOciAnnotations = []string{ ocispec.AnnotationTitle, } -// IsOCI determines whether or not a URL is to be treated as an OCI URL +// IsOCI determines whether a URL is to be treated as an OCI URL func IsOCI(url string) bool { return strings.HasPrefix(url, fmt.Sprintf("%s://", OCIScheme)) } @@ -103,17 +99,6 @@ func extractChartMeta(chartData []byte) (*chart.Metadata, error) { return ch.Metadata, nil } -// ctx retrieves a fresh context. -// disable verbose logging coming from ORAS (unless debug is enabled) -func ctx(out io.Writer, debug bool) context.Context { - if !debug { - return orascontext.Background() - } - ctx := orascontext.WithLoggerFromWriter(context.Background(), out) - orascontext.GetLogger(ctx).Logger.SetLevel(logrus.DebugLevel) - return ctx -} - // NewRegistryClientWithTLS is a helper function to create a new registry client with TLS enabled. func NewRegistryClientWithTLS(out io.Writer, certFile, keyFile, caFile string, insecureSkipTLSverify bool, registryConfig string, debug bool) (*Client, error) { tlsConf, err := tlsutil.NewClientTLS(certFile, keyFile, caFile, insecureSkipTLSverify) diff --git a/pkg/registry/utils_test.go b/pkg/registry/utils_test.go index d064295cd..c8be02a9a 100644 --- a/pkg/registry/utils_test.go +++ b/pkg/registry/utils_test.go @@ -88,7 +88,6 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry { ClientOptEnableCache(true), ClientOptWriter(suite.Out), ClientOptCredentialsFile(credentialsFile), - ClientOptResolver(nil), ClientOptBasicAuth(testUsername, testPassword), } @@ -141,14 +140,11 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry { config.HTTP.DrainTimeout = time.Duration(10) * time.Second config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}} - // Basic auth is not possible if we are serving HTTP. - if tlsEnabled { - config.Auth = configuration.Auth{ - "htpasswd": configuration.Parameters{ - "realm": "localhost", - "path": htpasswdPath, - }, - } + config.Auth = configuration.Auth{ + "htpasswd": configuration.Parameters{ + "realm": "localhost", + "path": htpasswdPath, + }, } // config tls @@ -277,7 +273,7 @@ func testPush(suite *TestSuite) { result, err := suite.RegistryClient.Push(chartData, ref, PushOptProvData(provData), PushOptCreationTime(testingChartCreationTime)) suite.Nil(err, "no error pushing good ref with prov") - _, err = suite.RegistryClient.Pull(ref) + _, err = suite.RegistryClient.Pull(ref, PullOptWithProv(true)) suite.Nil(err, "no error pulling a simple chart") // Validate the output diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index 7a6b1e0f2..125452261 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -163,9 +163,10 @@ func (srv *OCIServer) Run(t *testing.T, opts ...OCIServerOpt) { err = registryClient.Login( srv.RegistryURL, ociRegistry.LoginOptBasicAuth(srv.TestUsername, srv.TestPassword), - ociRegistry.LoginOptInsecure(false)) + ociRegistry.LoginOptInsecure(true), + ociRegistry.LoginOptPlainText(true)) if err != nil { - t.Fatalf("error logging into registry with good credentials") + t.Fatalf("error logging into registry with good credentials: %v", err) } ref := fmt.Sprintf("%s/u/ocitestuser/oci-dependent-chart:0.1.0", srv.RegistryURL) From d6375957354becca07321781506f429309a22d81 Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Mon, 27 Jan 2025 18:40:38 -0800 Subject: [PATCH 073/271] chore: Remove unused `WaitAndGetCompletedPodPhase` Signed-off-by: George Jenkins --- pkg/kube/client.go | 32 -------------------------------- pkg/kube/fake/fake.go | 34 ++++++++++++---------------------- pkg/kube/fake/printer.go | 6 ------ pkg/kube/interface.go | 5 ----- 4 files changed, 12 insertions(+), 65 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 79aa98535..0b84f5219 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -824,35 +824,3 @@ func scrubValidationError(err error) error { } return err } - -// WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase -// and returns said phase (PodSucceeded or PodFailed qualify). -func (c *Client) WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) { - client, err := c.getKubeClient() - if err != nil { - return v1.PodUnknown, err - } - to := int64(timeout) - watcher, err := client.CoreV1().Pods(c.namespace()).Watch(context.Background(), metav1.ListOptions{ - FieldSelector: fmt.Sprintf("metadata.name=%s", name), - TimeoutSeconds: &to, - }) - if err != nil { - return v1.PodUnknown, err - } - - for event := range watcher.ResultChan() { - p, ok := event.Object.(*v1.Pod) - if !ok { - return v1.PodUnknown, fmt.Errorf("%s not a pod", name) - } - switch p.Status.Phase { - case v1.PodFailed: - return v1.PodFailed, nil - case v1.PodSucceeded: - return v1.PodSucceeded, nil - } - } - - return v1.PodUnknown, err -} diff --git a/pkg/kube/fake/fake.go b/pkg/kube/fake/fake.go index a60d9f34e..ceca3c113 100644 --- a/pkg/kube/fake/fake.go +++ b/pkg/kube/fake/fake.go @@ -21,7 +21,6 @@ import ( "io" "time" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" @@ -34,19 +33,18 @@ import ( // delegates all its calls to `PrintingKubeClient` type FailingKubeClient struct { PrintingKubeClient - CreateError error - GetError error - WaitError error - DeleteError error - DeleteWithPropagationError error - WatchUntilReadyError error - UpdateError error - BuildError error - BuildTableError error - BuildDummy bool - BuildUnstructuredError error - WaitAndGetCompletedPodPhaseError error - WaitDuration time.Duration + CreateError error + GetError error + WaitError error + DeleteError error + DeleteWithPropagationError error + WatchUntilReadyError error + UpdateError error + BuildError error + BuildTableError error + BuildDummy bool + BuildUnstructuredError error + WaitDuration time.Duration } // Create returns the configured error if set or prints @@ -133,14 +131,6 @@ func (f *FailingKubeClient) BuildTable(r io.Reader, _ bool) (kube.ResourceList, return f.PrintingKubeClient.BuildTable(r, false) } -// WaitAndGetCompletedPodPhase returns the configured error if set or prints -func (f *FailingKubeClient) WaitAndGetCompletedPodPhase(s string, d time.Duration) (v1.PodPhase, error) { - if f.WaitAndGetCompletedPodPhaseError != nil { - return v1.PodSucceeded, f.WaitAndGetCompletedPodPhaseError - } - return f.PrintingKubeClient.WaitAndGetCompletedPodPhase(s, d) -} - // DeleteWithPropagationPolicy returns the configured error if set or prints func (f *FailingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceList, policy metav1.DeletionPropagation) (*kube.Result, []error) { if f.DeleteWithPropagationError != nil { diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index b38e8c084..0b957d725 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -21,7 +21,6 @@ import ( "strings" "time" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" @@ -111,11 +110,6 @@ func (p *PrintingKubeClient) BuildTable(_ io.Reader, _ bool) (kube.ResourceList, return []*resource.Info{}, nil } -// WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase. -func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(_ string, _ time.Duration) (v1.PodPhase, error) { - return v1.PodSucceeded, nil -} - // DeleteWithPropagationPolicy implements KubeClient delete. // // It only prints out the content to be deleted. diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index ce42ed950..7dc7ad8bc 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -20,7 +20,6 @@ import ( "io" "time" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -64,10 +63,6 @@ type Interface interface { // Validates against OpenAPI schema if validate is true. Build(reader io.Reader, validate bool) (ResourceList, error) - // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase - // and returns said phase (PodSucceeded or PodFailed qualify). - WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error) - // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error } From 5f64fe666371113a9057ff9c7938e2da5ad4a0b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 21:17:19 +0000 Subject: [PATCH 074/271] build(deps): bump golangci/golangci-lint-action from 6.2.0 to 6.3.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/ec5d18412c0aeab7936cb16880d708ba2a64e1ae...e60da84bfae8c7920a47be973d75e15710aa8bd7) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index eb643fc82..99481d611 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,6 @@ jobs: go-version: '1.23' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae #pin@6.2.0 + uses: golangci/golangci-lint-action@e60da84bfae8c7920a47be973d75e15710aa8bd7 #pin@6.3.0 with: version: v1.62 From 54753d64dc26687e65884b799f4f75c92f006ceb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 21:55:15 +0000 Subject: [PATCH 075/271] build(deps): bump golang.org/x/term from 0.28.0 to 0.29.0 Bumps [golang.org/x/term](https://github.com/golang/term) from 0.28.0 to 0.29.0. - [Commits](https://github.com/golang/term/compare/v0.28.0...v0.29.0) --- updated-dependencies: - dependency-name: golang.org/x/term dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 968dc2246..ae9eab763 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/crypto v0.32.0 - golang.org/x/term v0.28.0 + golang.org/x/term v0.29.0 golang.org/x/text v0.21.0 k8s.io/api v0.32.1 k8s.io/apiextensions-apiserver v0.32.1 @@ -163,7 +163,7 @@ require ( golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.29.0 // indirect + golang.org/x/sys v0.30.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect diff --git a/go.sum b/go.sum index bd9fc6626..87037b37d 100644 --- a/go.sum +++ b/go.sum @@ -461,8 +461,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -470,8 +470,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= -golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= -golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= From 56b40ad40fb8ce82b97e83255f1fad7abb5e6147 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 20:05:52 +0000 Subject: [PATCH 076/271] build(deps): bump golang.org/x/text from 0.21.0 to 0.22.0 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.21.0 to 0.22.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ae9eab763..f89eb4ce8 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/crypto v0.32.0 golang.org/x/term v0.29.0 - golang.org/x/text v0.21.0 + golang.org/x/text v0.22.0 k8s.io/api v0.32.1 k8s.io/apiextensions-apiserver v0.32.1 k8s.io/apimachinery v0.32.1 @@ -162,7 +162,7 @@ require ( golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sync v0.10.0 // indirect + golang.org/x/sync v0.11.0 // indirect golang.org/x/sys v0.30.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect diff --git a/go.sum b/go.sum index 87037b37d..a811b14cc 100644 --- a/go.sum +++ b/go.sum @@ -438,8 +438,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -479,8 +479,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From a8f53f98ee2206dababbbc0bb8f1037c529488e7 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 6 Feb 2025 15:22:14 +0000 Subject: [PATCH 077/271] WIP custom status reader Signed-off-by: Austin Abro --- pkg/kube/client.go | 6 +- pkg/kube/job_status_reader.go | 120 +++++++++++++++++++++++++++++ pkg/kube/job_status_reader_test.go | 79 +++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 pkg/kube/job_status_reader.go create mode 100644 pkg/kube/job_status_reader_test.go diff --git a/pkg/kube/client.go b/pkg/kube/client.go index e3fdb8b3b..b4164a8ff 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -59,6 +59,7 @@ import ( watchtools "k8s.io/client-go/tools/watch" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. @@ -133,6 +134,9 @@ func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { return nil, err } sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) + newCustomJobStatusReader := NewCustomJobStatusReader(restMapper) + customSR := statusreaders.NewStatusReader(restMapper, newCustomJobStatusReader) + sw.StatusReader = customSR return &statusWaiter{ sw: sw, log: c.Log, @@ -148,7 +152,7 @@ func New(getter genericclioptions.RESTClientGetter, ws WaitStrategy) (*Client, e getter = genericclioptions.NewConfigFlags(true) } factory := cmdutil.NewFactory(getter) - c := &Client{ + c := &Client{ Factory: factory, Log: nopLogger, } diff --git a/pkg/kube/job_status_reader.go b/pkg/kube/job_status_reader.go new file mode 100644 index 000000000..f6eb8d3d9 --- /dev/null +++ b/pkg/kube/job_status_reader.go @@ -0,0 +1,120 @@ +/* +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 kube + +// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go + +import ( + "context" + "fmt" + + batchv1 "k8s.io/api/batch/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" + "sigs.k8s.io/cli-utils/pkg/kstatus/status" + "sigs.k8s.io/cli-utils/pkg/object" +) + +type customJobStatusReader struct { + genericStatusReader engine.StatusReader +} + +func NewCustomJobStatusReader(mapper meta.RESTMapper) engine.StatusReader { + genericStatusReader := statusreaders.NewGenericStatusReader(mapper, jobConditions) + return &customJobStatusReader{ + genericStatusReader: genericStatusReader, + } +} + +func (j *customJobStatusReader) Supports(gk schema.GroupKind) bool { + return gk == batchv1.SchemeGroupVersion.WithKind("Job").GroupKind() +} + +func (j *customJobStatusReader) ReadStatus(ctx context.Context, reader engine.ClusterReader, resource object.ObjMetadata) (*event.ResourceStatus, error) { + return j.genericStatusReader.ReadStatus(ctx, reader, resource) +} + +func (j *customJobStatusReader) ReadStatusForObject(ctx context.Context, reader engine.ClusterReader, resource *unstructured.Unstructured) (*event.ResourceStatus, error) { + return j.genericStatusReader.ReadStatusForObject(ctx, reader, resource) +} + +// Ref: https://github.com/kubernetes-sigs/cli-utils/blob/v0.29.4/pkg/kstatus/status/core.go +// Modified to return Current status only when the Job has completed as opposed to when it's in progress. +func jobConditions(u *unstructured.Unstructured) (*status.Result, error) { + obj := u.UnstructuredContent() + + parallelism := status.GetIntField(obj, ".spec.parallelism", 1) + completions := status.GetIntField(obj, ".spec.completions", parallelism) + succeeded := status.GetIntField(obj, ".status.succeeded", 0) + failed := status.GetIntField(obj, ".status.failed", 0) + + // Conditions + // https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/job/utils.go#L24 + objc, err := status.GetObjectWithConditions(obj) + if err != nil { + return nil, err + } + for _, c := range objc.Status.Conditions { + switch c.Type { + case "Complete": + if c.Status == corev1.ConditionTrue { + message := fmt.Sprintf("Job Completed. succeeded: %d/%d", succeeded, completions) + return &status.Result{ + Status: status.CurrentStatus, + Message: message, + Conditions: []status.Condition{}, + }, nil + } + case "Failed": + message := fmt.Sprintf("Job Failed. failed: %d/%d", failed, completions) + if c.Status == corev1.ConditionTrue { + return &status.Result{ + Status: status.FailedStatus, + Message: message, + Conditions: []status.Condition{ + { + Type: status.ConditionStalled, + Status: corev1.ConditionTrue, + Reason: "JobFailed", + Message: message, + }, + }, + }, nil + } + } + } + + message := "Job in progress" + return &status.Result{ + Status: status.InProgressStatus, + Message: message, + Conditions: []status.Condition{ + { + Type: status.ConditionReconciling, + Status: corev1.ConditionTrue, + Reason: "JobInProgress", + Message: message, + }, + }, + }, nil +} diff --git a/pkg/kube/job_status_reader_test.go b/pkg/kube/job_status_reader_test.go new file mode 100644 index 000000000..af372c8b3 --- /dev/null +++ b/pkg/kube/job_status_reader_test.go @@ -0,0 +1,79 @@ +/* +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 kube + +// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go +import ( + "testing" + + "github.com/stretchr/testify/assert" + batchv1 "k8s.io/api/batch/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + + "sigs.k8s.io/cli-utils/pkg/kstatus/status" +) + +func toUnstructured(obj runtime.Object) (*unstructured.Unstructured, error) { + // If the incoming object is already unstructured, perform a deep copy first + // otherwise DefaultUnstructuredConverter ends up returning the inner map without + // making a copy. + if _, ok := obj.(runtime.Unstructured); ok { + obj = obj.DeepCopyObject() + } + rawMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) + if err != nil { + return nil, err + } + return &unstructured.Unstructured{Object: rawMap}, nil +} + +func TestJobConditions(t *testing.T) { + job := &batchv1.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "job", + }, + Spec: batchv1.JobSpec{}, + Status: batchv1.JobStatus{}, + } + + t.Run("job without Complete condition returns InProgress status", func(t *testing.T) { + us, err := toUnstructured(job) + assert.NoError(t, err) + result, err := jobConditions(us) + assert.NoError(t, err) + assert.Equal(t, status.InProgressStatus, result) + }) + + t.Run("job with Complete condition as True returns Current status", func(t *testing.T) { + job.Status = batchv1.JobStatus{ + Conditions: []batchv1.JobCondition{ + { + Type: batchv1.JobComplete, + Status: corev1.ConditionTrue, + }, + }, + } + us, err := toUnstructured(job) + assert.NoError(t, err) + result, err := jobConditions(us) + assert.NoError(t, err) + assert.Equal(t, status.CurrentStatus, result.Status) + }) +} From a5909993231c0826a7c5c139241d0e053ce9d03e Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 6 Feb 2025 19:53:42 +0000 Subject: [PATCH 078/271] switch client Signed-off-by: Austin Abro --- pkg/kube/client.go | 11 +++-------- pkg/kube/statuswait.go | 33 +++++++++++++++++++-------------- pkg/kube/statuswait_test.go | 22 ++++++++++++---------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index b4164a8ff..3753998ff 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -37,7 +37,6 @@ import ( apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" multierror "github.com/hashicorp/go-multierror" @@ -59,7 +58,6 @@ import ( watchtools "k8s.io/client-go/tools/watch" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. @@ -133,13 +131,10 @@ func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { if err != nil { return nil, err } - sw := watcher.NewDefaultStatusWatcher(dynamicClient, restMapper) - newCustomJobStatusReader := NewCustomJobStatusReader(restMapper) - customSR := statusreaders.NewStatusReader(restMapper, newCustomJobStatusReader) - sw.StatusReader = customSR return &statusWaiter{ - sw: sw, - log: c.Log, + restMapper: restMapper, + client: dynamicClient, + log: c.Log, }, nil default: return nil, errors.New("unknown wait strategy") diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 7ac4706ee..1aa424c4c 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -23,42 +23,51 @@ import ( "time" appsv1 "k8s.io/api/apps/v1" - batchv1 "k8s.io/api/batch/v1" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/client-go/dynamic" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" "sigs.k8s.io/cli-utils/pkg/kstatus/status" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" "sigs.k8s.io/cli-utils/pkg/object" ) type statusWaiter struct { - sw watcher.StatusWatcher - log func(string, ...interface{}) + client dynamic.Interface + restMapper meta.RESTMapper + log func(string, ...interface{}) } func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) - return w.wait(ctx, resourceList, false) + sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) + return w.wait(ctx, resourceList, sw) } func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) - return w.wait(ctx, resourceList, true) + sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) + newCustomJobStatusReader := NewCustomJobStatusReader(w.restMapper) + customSR := statusreaders.NewStatusReader(w.restMapper, newCustomJobStatusReader) + sw.StatusReader = customSR + return w.wait(ctx, resourceList, sw) } func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() w.log("beginning wait for %d resources to be deleted with timeout of %s", len(resourceList), timeout) - return w.waitForDelete(ctx, resourceList) + sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) + return w.waitForDelete(ctx, resourceList, sw) } -func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error { +func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList, sw watcher.StatusWatcher) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() resources := []object.ObjMetadata{} @@ -69,7 +78,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } resources = append(resources, obj) } - eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) + eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) go logResourceStatus(ctx, resources, statusCollector, status.NotFoundStatus, w.log) done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus)) @@ -95,16 +104,12 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL return nil } -func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error { +func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw watcher.StatusWatcher) error { cancelCtx, cancel := context.WithCancel(ctx) defer cancel() resources := []object.ObjMetadata{} for _, resource := range resourceList { switch value := AsVersioned(resource).(type) { - case *batchv1.Job: - if !waitForJobs { - continue - } case *appsv1.Deployment: if value.Spec.Paused { continue @@ -117,7 +122,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, wait resources = append(resources, obj) } - eventCh := w.sw.Watch(cancelCtx, resources, watcher.Options{}) + eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) go logResourceStatus(cancelCtx, resources, statusCollector, status.CurrentStatus, w.log) done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus)) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index d853e0012..f3694953c 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -38,7 +38,6 @@ import ( "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" "sigs.k8s.io/cli-utils/pkg/kstatus/status" - "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" "sigs.k8s.io/cli-utils/pkg/object" "sigs.k8s.io/cli-utils/pkg/testutil" ) @@ -178,10 +177,10 @@ func TestStatusWaitForDelete(t *testing.T) { appsv1.SchemeGroupVersion.WithKind("Deployment"), batchv1.SchemeGroupVersion.WithKind("Job"), ) - statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) statusWaiter := statusWaiter{ - sw: statusWatcher, - log: t.Logf, + restMapper: fakeMapper, + client: fakeClient, + log: t.Logf, } createdObjs := []runtime.Object{} for _, manifest := range tt.manifestsToCreate { @@ -275,10 +274,10 @@ func TestStatusWait(t *testing.T) { appsv1.SchemeGroupVersion.WithKind("Deployment"), batchv1.SchemeGroupVersion.WithKind("Job"), ) - statusWatcher := watcher.NewDefaultStatusWatcher(fakeClient, fakeMapper) statusWaiter := statusWaiter{ - sw: statusWatcher, - log: t.Logf, + client: fakeClient, + restMapper: fakeMapper, + log: t.Logf, } objs := []runtime.Object{} @@ -299,9 +298,12 @@ func TestStatusWait(t *testing.T) { resourceList = append(resourceList, list...) } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) - defer cancel() - err := statusWaiter.wait(ctx, resourceList, tt.waitForJobs) + var err error + if tt.waitForJobs { + err = statusWaiter.Wait(resourceList, time.Second*3) + } else { + err = statusWaiter.WaitWithJobs(resourceList, time.Second*3) + } if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return From bbe3246f0ada5dab5cc9c02873e40810e40c33fe Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 6 Feb 2025 21:41:14 +0000 Subject: [PATCH 079/271] tests passing Signed-off-by: Austin Abro --- pkg/kube/job_status_reader_test.go | 14 ++--- pkg/kube/statuswait_test.go | 82 ++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 11 deletions(-) diff --git a/pkg/kube/job_status_reader_test.go b/pkg/kube/job_status_reader_test.go index af372c8b3..60760efb9 100644 --- a/pkg/kube/job_status_reader_test.go +++ b/pkg/kube/job_status_reader_test.go @@ -53,13 +53,13 @@ func TestJobConditions(t *testing.T) { Status: batchv1.JobStatus{}, } - t.Run("job without Complete condition returns InProgress status", func(t *testing.T) { - us, err := toUnstructured(job) - assert.NoError(t, err) - result, err := jobConditions(us) - assert.NoError(t, err) - assert.Equal(t, status.InProgressStatus, result) - }) + // t.Run("job without Complete condition returns InProgress status", func(t *testing.T) { + // us, err := toUnstructured(job) + // assert.NoError(t, err) + // result, err := jobConditions(us) + // assert.NoError(t, err) + // assert.Equal(t, status.InProgressStatus, result) + // }) t.Run("job with Complete condition as True returns Current status", func(t *testing.T) { job.Status = batchv1.JobStatus{ diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index f3694953c..c028f8fd0 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -72,6 +72,80 @@ metadata: generation: 1 ` +var jobReadyManifest = ` +apiVersion: batch/v1 +kind: Job +metadata: + name: sleep-job + namespace: default + uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 + resourceVersion: "568" + generation: 1 + creationTimestamp: 2025-02-06T16:34:20-05:00 + labels: + batch.kubernetes.io/controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 + batch.kubernetes.io/job-name: sleep-job + controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 + job-name: sleep-job + annotations: + kubectl.kubernetes.io/last-applied-configuration: "{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{},\"name\":\"sleep-job\",\"namespace\":\"default\"},\"spec\":{\"template\":{\"metadata\":{\"name\":\"sleep-job\"},\"spec\":{\"containers\":[{\"command\":[\"sh\",\"-c\",\"sleep 100\"],\"image\":\"busybox\",\"name\":\"sleep\"}],\"restartPolicy\":\"Never\"}}}}\n" + managedFields: + - manager: kubectl-client-side-apply + operation: Update + apiVersion: batch/v1 + time: 2025-02-06T16:34:20-05:00 + fieldsType: FieldsV1 + fieldsV1: {} + - manager: k3s + operation: Update + apiVersion: batch/v1 + time: 2025-02-06T16:34:23-05:00 + fieldsType: FieldsV1 + fieldsV1: {} + subresource: status +spec: + parallelism: 1 + completions: 1 + backoffLimit: 6 + selector: + matchLabels: + batch.kubernetes.io/controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 + manualSelector: false + template: + metadata: + name: sleep-job + labels: + batch.kubernetes.io/controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 + batch.kubernetes.io/job-name: sleep-job + controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 + job-name: sleep-job + spec: + containers: + - name: sleep + image: busybox + command: + - sh + - -c + - sleep 100 + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + imagePullPolicy: Always + restartPolicy: Never + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + securityContext: {} + schedulerName: default-scheduler + completionMode: NonIndexed + suspend: false + podReplacementPolicy: TerminatingOrFailed +status: + startTime: 2025-02-06T16:34:20-05:00 + active: 1 + terminating: 0 + uncountedTerminatedPods: {} + ready: 1 +` + var jobCompleteManifest = ` apiVersion: batch/v1 kind: Job @@ -242,8 +316,8 @@ func TestStatusWait(t *testing.T) { waitForJobs: true, }, { - name: "Job is not ready, but we pass wait anyway", - objManifests: []string{jobNoStatusManifest}, + name: "Job is not ready but we pass wait anyway", + objManifests: []string{jobReadyManifest}, expectErrs: nil, waitForJobs: false, }, @@ -300,9 +374,9 @@ func TestStatusWait(t *testing.T) { var err error if tt.waitForJobs { - err = statusWaiter.Wait(resourceList, time.Second*3) - } else { err = statusWaiter.WaitWithJobs(resourceList, time.Second*3) + } else { + err = statusWaiter.Wait(resourceList, time.Second*3) } if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) From 59ef43e399375b773c1c42fe51befacbbb62e0f3 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 6 Feb 2025 21:41:43 +0000 Subject: [PATCH 080/271] tests passing Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index c028f8fd0..06aa36c09 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -81,28 +81,6 @@ metadata: uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 resourceVersion: "568" generation: 1 - creationTimestamp: 2025-02-06T16:34:20-05:00 - labels: - batch.kubernetes.io/controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 - batch.kubernetes.io/job-name: sleep-job - controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 - job-name: sleep-job - annotations: - kubectl.kubernetes.io/last-applied-configuration: "{\"apiVersion\":\"batch/v1\",\"kind\":\"Job\",\"metadata\":{\"annotations\":{},\"name\":\"sleep-job\",\"namespace\":\"default\"},\"spec\":{\"template\":{\"metadata\":{\"name\":\"sleep-job\"},\"spec\":{\"containers\":[{\"command\":[\"sh\",\"-c\",\"sleep 100\"],\"image\":\"busybox\",\"name\":\"sleep\"}],\"restartPolicy\":\"Never\"}}}}\n" - managedFields: - - manager: kubectl-client-side-apply - operation: Update - apiVersion: batch/v1 - time: 2025-02-06T16:34:20-05:00 - fieldsType: FieldsV1 - fieldsV1: {} - - manager: k3s - operation: Update - apiVersion: batch/v1 - time: 2025-02-06T16:34:23-05:00 - fieldsType: FieldsV1 - fieldsV1: {} - subresource: status spec: parallelism: 1 completions: 1 From b9cbc93003d1d55399dccf13da396d6011a9b9cc Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 6 Feb 2025 21:45:07 +0000 Subject: [PATCH 081/271] tests passing Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 39 ------------------------------------- 1 file changed, 39 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 06aa36c09..ba4e79a58 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -78,49 +78,10 @@ kind: Job metadata: name: sleep-job namespace: default - uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 - resourceVersion: "568" generation: 1 -spec: - parallelism: 1 - completions: 1 - backoffLimit: 6 - selector: - matchLabels: - batch.kubernetes.io/controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 - manualSelector: false - template: - metadata: - name: sleep-job - labels: - batch.kubernetes.io/controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 - batch.kubernetes.io/job-name: sleep-job - controller-uid: 5e7d8814-36fc-486f-9e6d-5b0a09351682 - job-name: sleep-job - spec: - containers: - - name: sleep - image: busybox - command: - - sh - - -c - - sleep 100 - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: Always - restartPolicy: Never - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - securityContext: {} - schedulerName: default-scheduler - completionMode: NonIndexed - suspend: false - podReplacementPolicy: TerminatingOrFailed status: startTime: 2025-02-06T16:34:20-05:00 active: 1 - terminating: 0 - uncountedTerminatedPods: {} ready: 1 ` From c0744a1a8c57f0055fac98b205dc20adf46c91bb Mon Sep 17 00:00:00 2001 From: Edith Puclla <58795858+edithturn@users.noreply.github.com> Date: Fri, 7 Feb 2025 11:47:48 +0000 Subject: [PATCH 082/271] Add Percona to the list of organizations using Helm Adding Percona to the list of organizations using Helm. Percona utilizes Helm for managing its open-source database solutions. Signed-off-by: Edith Puclla <58795858+edithturn@users.noreply.github.com> --- ADOPTERS.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ADOPTERS.md b/ADOPTERS.md index e5ee1e7a2..a83519fea 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -5,19 +5,21 @@ # Organizations Using Helm -- [IBM](https://www.ibm.com) -- [InfoCert](https://www.infocert.it/) -- [Microsoft](https://microsoft.com) -- [Omnistrate](https://omnistrate.com) -- [Octopus Deploy](https://octopus.com/) -- [New Relic](https://www.newrelic.com) -- [Qovery](https://www.qovery.com/) -- [Samsung SDS](https://www.samsungsds.com/) -- [Softonic](https://hello.softonic.com/) -- [SyncTune](https://mb-consulting.dev) -- [Syself](https://syself.com) -- [Ville de Montreal](https://montreal.ca) -- [Intercept](https://Intercept.cloud) -- [Oracle](www.oracle.com) +- [IBM](https://www.ibm.com) +- [InfoCert](https://www.infocert.it/) +- [Intercept](https://Intercept.cloud) +- [Microsoft](https://microsoft.com) +- [New Relic](https://www.newrelic.com) +- [Octopus Deploy](https://octopus.com/) +- [Omnistrate](https://omnistrate.com) +- [Oracle](www.oracle.com) +- [Percona](https://www.percona.com) +- [Qovery](https://www.qovery.com/) +- [Samsung SDS](https://www.samsungsds.com/) +- [Softonic](https://hello.softonic.com/) +- [SyncTune](https://mb-consulting.dev) +- [Syself](https://syself.com) +- [Ville de Montreal](https://montreal.ca) + _This file is part of the CNCF official documentation for projects._ From 0314135290d69e35c4f3c70330cc212ae0186a7c Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Feb 2025 14:34:37 +0000 Subject: [PATCH 083/271] tests passing Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 73 ++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index ba4e79a58..9e3b696d5 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -76,7 +76,7 @@ var jobReadyManifest = ` apiVersion: batch/v1 kind: Job metadata: - name: sleep-job + name: ready-not-complete namespace: default generation: 1 status: @@ -182,8 +182,8 @@ func TestStatusWaitForDelete(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() c := newTestClient(t) - timeout := time.Second * 2 - timeUntilPodDelete := time.Second * 1 + timeout := time.Second + timeUntilPodDelete := time.Millisecond * 500 fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), @@ -232,7 +232,6 @@ func TestStatusWaitForDelete(t *testing.T) { assert.NoError(t, err) }) } - } func TestStatusWait(t *testing.T) { @@ -314,7 +313,7 @@ func TestStatusWait(t *testing.T) { var err error if tt.waitForJobs { err = statusWaiter.WaitWithJobs(resourceList, time.Second*3) - } else { + } else { err = statusWaiter.Wait(resourceList, time.Second*3) } if tt.expectErrs != nil { @@ -325,3 +324,67 @@ func TestStatusWait(t *testing.T) { }) } } + +func TestWaitForJobComplete(t *testing.T) { + t.Parallel() + tests := []struct { + name string + objManifests []string + expectErrs []error + }{ + { + name: "Job is complete", + objManifests: []string{jobCompleteManifest}, + }, + { + name: "Job is not ready", + objManifests: []string{jobNoStatusManifest}, + expectErrs: []error{errors.New("resource not ready, name: test, kind: Job, status: InProgress"), errors.New("context deadline exceeded")}, + }, + { + name: "Job is ready but not complete", + objManifests: []string{jobReadyManifest}, + expectErrs: []error{errors.New("resource not ready, name: ready-not-complete, kind: Job, status: InProgress"), errors.New("context deadline exceeded")}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + c := newTestClient(t) + fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) + fakeMapper := testutil.NewFakeRESTMapper( + batchv1.SchemeGroupVersion.WithKind("Job"), + ) + statusWaiter := statusWaiter{ + client: fakeClient, + restMapper: fakeMapper, + log: t.Logf, + } + objs := []runtime.Object{} + for _, podYaml := range tt.objManifests { + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(podYaml), &m) + assert.NoError(t, err) + resource := &unstructured.Unstructured{Object: m} + objs = append(objs, resource) + gvr := getGVR(t, fakeMapper, resource) + err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) + assert.NoError(t, err) + } + resourceList := ResourceList{} + for _, obj := range objs { + list, err := c.Build(objBody(obj), false) + assert.NoError(t, err) + resourceList = append(resourceList, list...) + } + + err := statusWaiter.WaitWithJobs(resourceList, time.Second*3) + if tt.expectErrs != nil { + assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) + return + } + assert.NoError(t, err) + }) + } +} From cc83b7c2e6b9403e7347990d11f329abd0fd4403 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Feb 2025 15:01:53 +0000 Subject: [PATCH 084/271] tests passing Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 9e3b696d5..131224e8b 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -242,11 +242,6 @@ func TestStatusWait(t *testing.T) { expectErrs []error waitForJobs bool }{ - { - name: "Job is complete", - objManifests: []string{jobCompleteManifest}, - expectErrs: nil, - }, { name: "Job is not complete", objManifests: []string{jobNoStatusManifest}, @@ -254,7 +249,7 @@ func TestStatusWait(t *testing.T) { waitForJobs: true, }, { - name: "Job is not ready but we pass wait anyway", + name: "Job is ready but not complete", objManifests: []string{jobReadyManifest}, expectErrs: nil, waitForJobs: false, @@ -310,12 +305,7 @@ func TestStatusWait(t *testing.T) { resourceList = append(resourceList, list...) } - var err error - if tt.waitForJobs { - err = statusWaiter.WaitWithJobs(resourceList, time.Second*3) - } else { - err = statusWaiter.Wait(resourceList, time.Second*3) - } + err := statusWaiter.Wait(resourceList, time.Second*3) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) return From f49a7e134a4da7967be9f65bfa1f91a159889252 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Feb 2025 15:14:25 +0000 Subject: [PATCH 085/271] start watch until ready Signed-off-by: Austin Abro --- pkg/kube/client.go | 157 ----------------------------------------- pkg/kube/interface.go | 24 +++---- pkg/kube/statuswait.go | 5 ++ pkg/kube/wait.go | 157 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+), 169 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 3753998ff..8dca1c51b 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -18,7 +18,6 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "bytes" - "context" "encoding/json" "fmt" "io" @@ -27,11 +26,9 @@ import ( "reflect" "strings" "sync" - "time" jsonpatch "github.com/evanphx/json-patch" "github.com/pkg/errors" - batch "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -39,23 +36,18 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" - multierror "github.com/hashicorp/go-multierror" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" - "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" - "k8s.io/apimachinery/pkg/watch" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - cachetools "k8s.io/client-go/tools/cache" - watchtools "k8s.io/client-go/tools/watch" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" ) @@ -524,52 +516,6 @@ func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropa return res, nil } -func (c *Client) watchTimeout(t time.Duration) func(*resource.Info) error { - return func(info *resource.Info) error { - return c.watchUntilReady(t, info) - } -} - -// WatchUntilReady watches the resources given and waits until it is ready. -// -// This method is mainly for hook implementations. It watches for a resource to -// hit a particular milestone. The milestone depends on the Kind. -// -// For most kinds, it checks to see if the resource is marked as Added or Modified -// by the Kubernetes event stream. For some kinds, it does more: -// -// - Jobs: A job is marked "Ready" when it has successfully completed. This is -// ascertained by watching the Status fields in a job's output. -// - Pods: A pod is marked "Ready" when it has successfully completed. This is -// ascertained by watching the status.phase field in a pod's output. -// -// Handling for other kinds will be added as necessary. -func (c *Client) WatchUntilReady(resources ResourceList, timeout time.Duration) error { - // For jobs, there's also the option to do poll c.Jobs(namespace).Get(): - // https://github.com/adamreese/kubernetes/blob/master/test/e2e/job.go#L291-L300 - return perform(resources, c.watchTimeout(timeout)) -} - -func perform(infos ResourceList, fn func(*resource.Info) error) error { - var result error - - if len(infos) == 0 { - return ErrNoObjectsVisited - } - - errs := make(chan error) - go batchPerform(infos, fn, errs) - - for range infos { - err := <-errs - if err != nil { - result = multierror.Append(result, err) - } - } - - return result -} - // getManagedFieldsManager returns the manager string. If one was set it will be returned. // Otherwise, one is calculated based on the name of the binary. func getManagedFieldsManager() string { @@ -721,109 +667,6 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, return nil } -func (c *Client) watchUntilReady(timeout time.Duration, info *resource.Info) error { - kind := info.Mapping.GroupVersionKind.Kind - switch kind { - case "Job", "Pod": - default: - return nil - } - - c.Log("Watching for changes to %s %s with timeout of %v", kind, info.Name, timeout) - - // Use a selector on the name of the resource. This should be unique for the - // given version and kind - selector, err := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", info.Name)) - if err != nil { - return err - } - lw := cachetools.NewListWatchFromClient(info.Client, info.Mapping.Resource.Resource, info.Namespace, selector) - - // What we watch for depends on the Kind. - // - For a Job, we watch for completion. - // - For all else, we watch until Ready. - // In the future, we might want to add some special logic for types - // like Ingress, Volume, etc. - - ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) - defer cancel() - _, err = watchtools.UntilWithSync(ctx, lw, &unstructured.Unstructured{}, nil, func(e watch.Event) (bool, error) { - // Make sure the incoming object is versioned as we use unstructured - // objects when we build manifests - obj := convertWithMapper(e.Object, info.Mapping) - switch e.Type { - case watch.Added, watch.Modified: - // For things like a secret or a config map, this is the best indicator - // we get. We care mostly about jobs, where what we want to see is - // the status go into a good state. For other types, like ReplicaSet - // we don't really do anything to support these as hooks. - c.Log("Add/Modify event for %s: %v", info.Name, e.Type) - switch kind { - case "Job": - return c.waitForJob(obj, info.Name) - case "Pod": - return c.waitForPodSuccess(obj, info.Name) - } - return true, nil - case watch.Deleted: - c.Log("Deleted event for %s", info.Name) - return true, nil - case watch.Error: - // Handle error and return with an error. - c.Log("Error event for %s", info.Name) - return true, errors.Errorf("failed to deploy %s", info.Name) - default: - return false, nil - } - }) - return err -} - -// waitForJob is a helper that waits for a job to complete. -// -// This operates on an event returned from a watcher. -func (c *Client) waitForJob(obj runtime.Object, name string) (bool, error) { - o, ok := obj.(*batch.Job) - if !ok { - return true, errors.Errorf("expected %s to be a *batch.Job, got %T", name, obj) - } - - for _, c := range o.Status.Conditions { - if c.Type == batch.JobComplete && c.Status == "True" { - return true, nil - } else if c.Type == batch.JobFailed && c.Status == "True" { - return true, errors.Errorf("job %s failed: %s", name, c.Reason) - } - } - - c.Log("%s: Jobs active: %d, jobs failed: %d, jobs succeeded: %d", name, o.Status.Active, o.Status.Failed, o.Status.Succeeded) - return false, nil -} - -// waitForPodSuccess is a helper that waits for a pod to complete. -// -// This operates on an event returned from a watcher. -func (c *Client) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { - o, ok := obj.(*v1.Pod) - if !ok { - return true, errors.Errorf("expected %s to be a *v1.Pod, got %T", name, obj) - } - - switch o.Status.Phase { - case v1.PodSucceeded: - c.Log("Pod %s succeeded", o.Name) - return true, nil - case v1.PodFailed: - return true, errors.Errorf("pod %s failed", o.Name) - case v1.PodPending: - c.Log("Pod %s pending", o.Name) - case v1.PodRunning: - c.Log("Pod %s running", o.Name) - } - - return false, nil -} - // scrubValidationError removes kubectl info from the message. func scrubValidationError(err error) error { if err == nil { diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index f8e3c2ee2..0e6da1094 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -34,18 +34,6 @@ type Interface interface { // Delete destroys one or more resources. Delete(resources ResourceList) (*Result, []error) - // WatchUntilReady watches the resources given and waits until it is ready. - // - // This method is mainly for hook implementations. It watches for a resource to - // hit a particular milestone. The milestone depends on the Kind. - // - // For Jobs, "ready" means the Job ran to completion (exited without error). - // For Pods, "ready" means the Pod phase is marked "succeeded". - // For all other kinds, it means the kind was created or modified without - // error. - // TODO: Is watch until ready really behavior we want over the resources actually being ready? - WatchUntilReady(resources ResourceList, timeout time.Duration) error - // Update updates one or more resources or creates the resource // if it doesn't exist. Update(original, target ResourceList, force bool) (*Result, error) @@ -72,6 +60,18 @@ type Waiter interface { // WaitForDelete wait up to the given timeout for the specified resources to be deleted. WaitForDelete(resources ResourceList, timeout time.Duration) error + + // WatchUntilReady watches the resources given and waits until it is ready. + // + // This method is mainly for hook implementations. It watches for a resource to + // hit a particular milestone. The milestone depends on the Kind. + // + // For Jobs, "ready" means the Job ran to completion (exited without error). + // For Pods, "ready" means the Pod phase is marked "succeeded". + // For all other kinds, it means the kind was created or modified without + // error. + // TODO: Is watch until ready really behavior we want over the resources actually being ready? + WatchUntilReady(resources ResourceList, timeout time.Duration) error } // InterfaceDeletionPropagation is introduced to avoid breaking backwards compatibility for Interface implementers. diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 1aa424c4c..2e27917bc 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -40,6 +40,11 @@ type statusWaiter struct { log func(string, ...interface{}) } +func (w *statusWaiter) WatchUntilReady(resources ResourceList, timeout time.Duration) error { + panic("todo") + return nil +} + func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 525373e4d..fdb3c9087 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -22,19 +22,27 @@ import ( "net/http" "time" + multierror "github.com/hashicorp/go-multierror" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes" + cachetools "k8s.io/client-go/tools/cache" + watchtools "k8s.io/client-go/tools/watch" + batch "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/util/wait" ) @@ -177,3 +185,152 @@ func SelectorsForObject(object runtime.Object) (selector labels.Selector, err er return selector, errors.Wrap(err, "invalid label selector") } + +func (hw *HelmWaiter) watchTimeout(t time.Duration) func(*resource.Info) error { + return func(info *resource.Info) error { + return hw.watchUntilReady(t, info) + } +} + +// WatchUntilReady watches the resources given and waits until it is ready. +// +// This method is mainly for hook implementations. It watches for a resource to +// hit a particular milestone. The milestone depends on the Kind. +// +// For most kinds, it checks to see if the resource is marked as Added or Modified +// by the Kubernetes event stream. For some kinds, it does more: +// +// - Jobs: A job is marked "Ready" when it has successfully completed. This is +// ascertained by watching the Status fields in a job's output. +// - Pods: A pod is marked "Ready" when it has successfully completed. This is +// ascertained by watching the status.phase field in a pod's output. +// +// Handling for other kinds will be added as necessary. +func (hw *HelmWaiter) WatchUntilReady(resources ResourceList, timeout time.Duration) error { + // For jobs, there's also the option to do poll c.Jobs(namespace).Get(): + // https://github.com/adamreese/kubernetes/blob/master/test/e2e/job.go#L291-L300 + return perform(resources, hw.watchTimeout(timeout)) +} + +func perform(infos ResourceList, fn func(*resource.Info) error) error { + var result error + + if len(infos) == 0 { + return ErrNoObjectsVisited + } + + errs := make(chan error) + go batchPerform(infos, fn, errs) + + for range infos { + err := <-errs + if err != nil { + result = multierror.Append(result, err) + } + } + + return result +} + +func (hw *HelmWaiter) watchUntilReady(timeout time.Duration, info *resource.Info) error { + kind := info.Mapping.GroupVersionKind.Kind + switch kind { + case "Job", "Pod": + default: + return nil + } + + hw.log("Watching for changes to %s %s with timeout of %v", kind, info.Name, timeout) + + // Use a selector on the name of the resource. This should be unique for the + // given version and kind + selector, err := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", info.Name)) + if err != nil { + return err + } + lw := cachetools.NewListWatchFromClient(info.Client, info.Mapping.Resource.Resource, info.Namespace, selector) + + // What we watch for depends on the Kind. + // - For a Job, we watch for completion. + // - For all else, we watch until Ready. + // In the future, we might want to add some special logic for types + // like Ingress, Volume, etc. + + ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) + defer cancel() + _, err = watchtools.UntilWithSync(ctx, lw, &unstructured.Unstructured{}, nil, func(e watch.Event) (bool, error) { + // Make sure the incoming object is versioned as we use unstructured + // objects when we build manifests + obj := convertWithMapper(e.Object, info.Mapping) + switch e.Type { + case watch.Added, watch.Modified: + // For things like a secret or a config map, this is the best indicator + // we get. We care mostly about jobs, where what we want to see is + // the status go into a good state. For other types, like ReplicaSet + // we don't really do anything to support these as hooks. + hw.log("Add/Modify event for %s: %v", info.Name, e.Type) + switch kind { + case "Job": + return hw.waitForJob(obj, info.Name) + case "Pod": + return hw.waitForPodSuccess(obj, info.Name) + } + return true, nil + case watch.Deleted: + hw.log("Deleted event for %s", info.Name) + return true, nil + case watch.Error: + // Handle error and return with an error. + hw.log("Error event for %s", info.Name) + return true, errors.Errorf("failed to deploy %s", info.Name) + default: + return false, nil + } + }) + return err +} + +// waitForJob is a helper that waits for a job to complete. +// +// This operates on an event returned from a watcher. +func (hw *HelmWaiter) waitForJob(obj runtime.Object, name string) (bool, error) { + o, ok := obj.(*batch.Job) + if !ok { + return true, errors.Errorf("expected %s to be a *batch.Job, got %T", name, obj) + } + + for _, c := range o.Status.Conditions { + if c.Type == batch.JobComplete && c.Status == "True" { + return true, nil + } else if c.Type == batch.JobFailed && c.Status == "True" { + return true, errors.Errorf("job %s failed: %s", name, c.Reason) + } + } + + hw.log("%s: Jobs active: %d, jobs failed: %d, jobs succeeded: %d", name, o.Status.Active, o.Status.Failed, o.Status.Succeeded) + return false, nil +} + +// waitForPodSuccess is a helper that waits for a pod to complete. +// +// This operates on an event returned from a watcher. +func (c *HelmWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { + o, ok := obj.(*v1.Pod) + if !ok { + return true, errors.Errorf("expected %s to be a *v1.Pod, got %T", name, obj) + } + + switch o.Status.Phase { + case v1.PodSucceeded: + c.log("Pod %s succeeded", o.Name) + return true, nil + case v1.PodFailed: + return true, errors.Errorf("pod %s failed", o.Name) + case v1.PodPending: + c.log("Pod %s pending", o.Name) + case v1.PodRunning: + c.log("Pod %s running", o.Name) + } + + return false, nil +} From 187e99d299817e824a5bc5e5b3e3345a87e3ee96 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Feb 2025 17:18:27 +0000 Subject: [PATCH 086/271] custom status readers look good Signed-off-by: Austin Abro --- pkg/kube/job_status_reader_test.go | 14 ++-- pkg/kube/pod_status_reader.go | 110 +++++++++++++++++++++++++++++ pkg/kube/pod_status_reader_test.go | 66 +++++++++++++++++ pkg/kube/statuswait.go | 2 +- 4 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 pkg/kube/pod_status_reader.go create mode 100644 pkg/kube/pod_status_reader_test.go diff --git a/pkg/kube/job_status_reader_test.go b/pkg/kube/job_status_reader_test.go index 60760efb9..98b994030 100644 --- a/pkg/kube/job_status_reader_test.go +++ b/pkg/kube/job_status_reader_test.go @@ -53,13 +53,13 @@ func TestJobConditions(t *testing.T) { Status: batchv1.JobStatus{}, } - // t.Run("job without Complete condition returns InProgress status", func(t *testing.T) { - // us, err := toUnstructured(job) - // assert.NoError(t, err) - // result, err := jobConditions(us) - // assert.NoError(t, err) - // assert.Equal(t, status.InProgressStatus, result) - // }) + t.Run("job without Complete condition returns InProgress status", func(t *testing.T) { + us, err := toUnstructured(job) + assert.NoError(t, err) + result, err := jobConditions(us) + assert.NoError(t, err) + assert.Equal(t, status.InProgressStatus, result.Status) + }) t.Run("job with Complete condition as True returns Current status", func(t *testing.T) { job.Status = batchv1.JobStatus{ diff --git a/pkg/kube/pod_status_reader.go b/pkg/kube/pod_status_reader.go new file mode 100644 index 000000000..25e427966 --- /dev/null +++ b/pkg/kube/pod_status_reader.go @@ -0,0 +1,110 @@ +/* +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 kube + +// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go + +import ( + "context" + "fmt" + + batchv1 "k8s.io/api/batch/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" + "sigs.k8s.io/cli-utils/pkg/kstatus/status" + "sigs.k8s.io/cli-utils/pkg/object" +) + +type customPodStatusReader struct { + genericStatusReader engine.StatusReader +} + +func NewCustomPodStatusReader(mapper meta.RESTMapper) engine.StatusReader { + genericStatusReader := statusreaders.NewGenericStatusReader(mapper, podConditions) + return &customJobStatusReader{ + genericStatusReader: genericStatusReader, + } +} + +func (j *customPodStatusReader) Supports(gk schema.GroupKind) bool { + return gk == batchv1.SchemeGroupVersion.WithKind("Job").GroupKind() +} + +func (j *customPodStatusReader) ReadStatus(ctx context.Context, reader engine.ClusterReader, resource object.ObjMetadata) (*event.ResourceStatus, error) { + return j.genericStatusReader.ReadStatus(ctx, reader, resource) +} + +func (j *customPodStatusReader) ReadStatusForObject(ctx context.Context, reader engine.ClusterReader, resource *unstructured.Unstructured) (*event.ResourceStatus, error) { + return j.genericStatusReader.ReadStatusForObject(ctx, reader, resource) +} + +func podConditions(u *unstructured.Unstructured) (*status.Result, error) { + obj := u.UnstructuredContent() + phase := status.GetStringField(obj, ".status.phase", "") + switch phase { + case string(v1.PodSucceeded): + message := fmt.Sprintf("pod %s succeeded", u.GetName()) + return &status.Result{ + Status: status.CurrentStatus, + Message: message, + Conditions: []status.Condition{ + { + Type: status.ConditionStalled, + Status: corev1.ConditionTrue, + Message: message, + }, + }, + }, nil + case string(v1.PodFailed): + message := fmt.Sprintf("pod %s failed", u.GetName()) + return &status.Result{ + Status: status.FailedStatus, + Message: message, + Conditions: []status.Condition{ + { + Type: status.ConditionStalled, + Status: corev1.ConditionTrue, + Reason: "PodFailed", + Message: message, + }, + }, + }, nil + case string(v1.PodPending): + case string(v1.PodRunning): + } + + message := "Pod in progress" + return &status.Result{ + Status: status.InProgressStatus, + Message: message, + Conditions: []status.Condition{ + { + Type: status.ConditionReconciling, + Status: corev1.ConditionTrue, + Reason: "PodInProgress", + Message: message, + }, + }, + }, nil +} diff --git a/pkg/kube/pod_status_reader_test.go b/pkg/kube/pod_status_reader_test.go new file mode 100644 index 000000000..2604ef026 --- /dev/null +++ b/pkg/kube/pod_status_reader_test.go @@ -0,0 +1,66 @@ +/* +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 kube + +// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go +import ( + "testing" + + "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "sigs.k8s.io/cli-utils/pkg/kstatus/status" +) + +func TestPodConditions(t *testing.T) { + t.Parallel() + + //TODO add some more tests here and parallelize + + t.Run("pod without status returns in progress", func(t *testing.T) { + pod := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "pod", + }, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{}, + } + us, err := toUnstructured(pod) + assert.NoError(t, err) + result, err := podConditions(us) + assert.NoError(t, err) + assert.Equal(t, status.InProgressStatus, result.Status) + }) + + t.Run("pod succeeded returns Current status", func(t *testing.T) { + pod := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "pod", + }, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{ + Phase: v1.PodSucceeded, + }, + } + us, err := toUnstructured(pod) + assert.NoError(t, err) + result, err := podConditions(us) + assert.NoError(t, err) + assert.Equal(t, status.CurrentStatus, result.Status) + }) +} diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 2e27917bc..16751abba 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -41,7 +41,7 @@ type statusWaiter struct { } func (w *statusWaiter) WatchUntilReady(resources ResourceList, timeout time.Duration) error { - panic("todo") + return nil } From c76b1c1e6a1952de9bbbdfff838128b83455b4a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Feb 2025 21:49:26 +0000 Subject: [PATCH 087/271] build(deps): bump golang.org/x/crypto from 0.32.0 to 0.33.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.32.0 to 0.33.0. - [Commits](https://github.com/golang/crypto/compare/v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f89eb4ce8..a92840897 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 - golang.org/x/crypto v0.32.0 + golang.org/x/crypto v0.33.0 golang.org/x/term v0.29.0 golang.org/x/text v0.22.0 k8s.io/api v0.32.1 diff --git a/go.sum b/go.sum index a811b14cc..0c60af24e 100644 --- a/go.sum +++ b/go.sum @@ -401,8 +401,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= -golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= From 274d43c10d1c62f921db1be9b57ce1a722196e9f Mon Sep 17 00:00:00 2001 From: Zhanwei Li Date: Sat, 8 Feb 2025 10:04:14 +0800 Subject: [PATCH 088/271] feat: Enhance JSON value parsing in Helm CLI - Add support for parsing full JSON objects with `--set-json` - Update documentation to clarify JSON value input formats - Improve test coverage for value parsing scenarios - Modify `MergeValues` to handle both key=value and JSON object formats Signed-off-by: Zhanwei Li --- cmd/helm/flags.go | 2 +- cmd/helm/install.go | 5 +- cmd/helm/upgrade.go | 2 +- pkg/cli/values/options.go | 16 +++++- pkg/cli/values/options_test.go | 96 +++++++++++++++++++++++++++++++++- 5 files changed, 115 insertions(+), 6 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 3d159babd..8d0f644d6 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -47,7 +47,7 @@ func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { 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)") + 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 or using json format: {\"key1\": jsonval1, \"key2\": \"jsonval2\"})") f.StringArrayVar(&v.LiteralValues, "set-literal", []string{}, "set a literal STRING value on the command line") } diff --git a/cmd/helm/install.go b/cmd/helm/install.go index ec651140c..fe09dfc53 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -52,7 +52,7 @@ 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. +(scalars/objects/arrays) from the command line. Additionally, you can use '--set-json' and passing json object as a string. $ helm install -f myvalues.yaml myredis ./redis @@ -72,6 +72,9 @@ or $ helm install --set-json 'master.sidecars=[{"name":"sidecar","image":"myImage","imagePullPolicy":"Always","ports":[{"name":"portname","containerPort":1234}]}]' 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 diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 7b4267894..6684f9ebf 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -53,7 +53,7 @@ or use the '--set' flag and pass configuration from the command line, to force s 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. +(scalars/objects/arrays) from the command line. Additionally, you can use '--set-json' and passing json object as a string. 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 diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index 24c47ecba..d7086e8c3 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -17,6 +17,7 @@ limitations under the License. package values import ( + "encoding/json" "io" "net/url" "os" @@ -62,8 +63,19 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er // User specified a value via --set-json for _, value := range opts.JSONValues { - if err := strvals.ParseJSON(value, base); err != nil { - return nil, errors.Errorf("failed parsing --set-json data %s", value) + trimmedValue := strings.TrimSpace(value) + if len(trimmedValue) > 0 && trimmedValue[0] == '{' { + // If value is JSON object format, parse it as map + var jsonMap map[string]interface{} + if err := json.Unmarshal([]byte(trimmedValue), &jsonMap); err != nil { + return nil, errors.Errorf("failed parsing --set-json data using JSON format: %s", value) + } + base = mergeMaps(base, jsonMap) + } else { + // Otherwise, parse it as key=value format + if err := strvals.ParseJSON(value, base); err != nil { + return nil, errors.Errorf("failed parsing --set-json data %s", value) + } } } diff --git a/pkg/cli/values/options_test.go b/pkg/cli/values/options_test.go index 9182e3cc8..5197a1b5e 100644 --- a/pkg/cli/values/options_test.go +++ b/pkg/cli/values/options_test.go @@ -23,7 +23,7 @@ import ( "helm.sh/helm/v4/pkg/getter" ) -func TestMergeValues(t *testing.T) { +func TestMergeMaps(t *testing.T) { nestedMap := map[string]interface{}{ "foo": "bar", "baz": map[string]string{ @@ -86,3 +86,97 @@ func TestReadFile(t *testing.T) { t.Errorf("Expected error when has special strings") } } + +func TestMergeValues(t *testing.T) { + tests := []struct { + name string + opts Options + expected map[string]interface{} + wantErr bool + }{ + { + name: "set-json object", + opts: Options{ + JSONValues: []string{`{"foo": {"bar": "baz"}}`}, + }, + expected: map[string]interface{}{ + "foo": map[string]interface{}{ + "bar": "baz", + }, + }, + }, + { + name: "set-json key=value", + opts: Options{ + JSONValues: []string{"foo.bar=[1,2,3]"}, + }, + expected: map[string]interface{}{ + "foo": map[string]interface{}{ + "bar": []interface{}{1.0, 2.0, 3.0}, + }, + }, + }, + { + name: "set regular value", + opts: Options{ + Values: []string{"foo=bar"}, + }, + expected: map[string]interface{}{ + "foo": "bar", + }, + }, + { + name: "set string value", + opts: Options{ + StringValues: []string{"foo=123"}, + }, + expected: map[string]interface{}{ + "foo": "123", + }, + }, + { + name: "set literal value", + opts: Options{ + LiteralValues: []string{"foo=true"}, + }, + expected: map[string]interface{}{ + "foo": "true", + }, + }, + { + name: "multiple options", + opts: Options{ + Values: []string{"a=foo"}, + StringValues: []string{"b=bar"}, + JSONValues: []string{`{"c": "foo1"}`}, + LiteralValues: []string{"d=bar1"}, + }, + expected: map[string]interface{}{ + "a": "foo", + "b": "bar", + "c": "foo1", + "d": "bar1", + }, + }, + { + name: "invalid json", + opts: Options{ + JSONValues: []string{`{invalid`}, + }, + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := tt.opts.MergeValues(getter.Providers{}) + if (err != nil) != tt.wantErr { + t.Errorf("MergeValues() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !tt.wantErr && !reflect.DeepEqual(got, tt.expected) { + t.Errorf("MergeValues() = %v, want %v", got, tt.expected) + } + }) + } +} From 234d171da510c5e140f1ad494b2498448c9432db Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Sat, 30 Nov 2024 23:46:18 -0800 Subject: [PATCH 089/271] Cleanup repotest Server constructors Signed-off-by: George Jenkins --- cmd/helm/dependency_build_test.go | 8 +- cmd/helm/dependency_update_test.go | 24 +-- cmd/helm/install_test.go | 16 +- cmd/helm/pull_test.go | 24 +-- cmd/helm/repo_add_test.go | 49 +++--- cmd/helm/repo_remove_test.go | 17 +- cmd/helm/repo_update_test.go | 32 ++-- cmd/helm/show_test.go | 8 +- pkg/downloader/chart_downloader_test.go | 33 ++-- pkg/downloader/manager_test.go | 39 ++--- pkg/repo/repotest/server.go | 222 +++++++++++------------- pkg/repo/repotest/server_test.go | 128 ++++++++++++-- pkg/repo/repotest/tlsconfig.go | 43 +++++ 13 files changed, 382 insertions(+), 261 deletions(-) create mode 100644 pkg/repo/repotest/tlsconfig.go diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index 189378ce5..1258db3f8 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -29,11 +29,11 @@ import ( ) func TestDependencyBuildCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz"), + ) defer srv.Stop() - if err != nil { - t.Fatal(err) - } rootDir := srv.Root() srv.LinkIndices() diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 82a6b875d..7cf3e8e0a 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -32,10 +32,10 @@ import ( ) func TestDependencyUpdateCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz"), + ) defer srv.Stop() t.Logf("Listening on directory %s", srv.Root()) @@ -151,10 +151,10 @@ func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { defer resetEnv()() ensure.HelmHome(t) - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz"), + ) defer srv.Stop() t.Logf("Listening on directory %s", srv.Root()) @@ -248,10 +248,10 @@ func TestDependencyUpdateCmd_WithRepoThatWasNotAdded(t *testing.T) { } func setupMockRepoServer(t *testing.T) *repotest.Server { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz"), + ) t.Logf("Listening on directory %s", srv.Root()) diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index e7b6e1dff..be8480423 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -27,19 +27,13 @@ import ( ) func TestInstall(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz*"), + repotest.WithMiddleware(repotest.BasicAuthMiddleware(t)), + ) defer srv.Stop() - srv.WithMiddleware(http.HandlerFunc(func(_ 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) })) diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index 160e95c76..1110a6bdf 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -28,10 +28,10 @@ import ( ) func TestPullCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz*"), + ) defer srv.Stop() ociSrv, err := repotest.NewOCIServer(t, srv.Root()) @@ -257,19 +257,13 @@ func TestPullCmd(t *testing.T) { } func TestPullWithCredentialsCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz*"), + repotest.WithMiddleware(repotest.BasicAuthMiddleware(t)), + ) defer srv.Stop() - srv.WithMiddleware(http.HandlerFunc(func(_ 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) })) diff --git a/cmd/helm/repo_add_test.go b/cmd/helm/repo_add_test.go index 15ad835e6..35911d5ae 100644 --- a/cmd/helm/repo_add_test.go +++ b/cmd/helm/repo_add_test.go @@ -34,22 +34,21 @@ import ( ) func TestRepoAddCmd(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) 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) - } + srv2 := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer srv2.Stop() tmpdir := filepath.Join(t.TempDir(), "path-component.yaml/data") - err = os.MkdirAll(tmpdir, 0777) - if err != nil { + if err := os.MkdirAll(tmpdir, 0777); err != nil { t.Fatal(err) } repoFile := filepath.Join(tmpdir, "repositories.yaml") @@ -81,10 +80,10 @@ func TestRepoAddCmd(t *testing.T) { } func TestRepoAdd(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() rootDir := t.TempDir() @@ -134,10 +133,10 @@ func TestRepoAdd(t *testing.T) { } func TestRepoAddCheckLegalName(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() defer resetEnv()() @@ -190,10 +189,10 @@ func TestRepoAddConcurrentHiddenFile(t *testing.T) { } func repoAddConcurrent(t *testing.T, testName, repoFile string) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() var wg sync.WaitGroup @@ -240,7 +239,11 @@ func TestRepoAddFileCompletion(t *testing.T) { } func TestRepoAddWithPasswordFromStdin(t *testing.T) { - srv := repotest.NewTempServerWithCleanupAndBasicAuth(t, "testdata/testserver/*.*") + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + repotest.WithMiddleware(repotest.BasicAuthMiddleware(t)), + ) defer srv.Stop() defer resetEnv()() diff --git a/cmd/helm/repo_remove_test.go b/cmd/helm/repo_remove_test.go index dcfbd99f8..7e6609671 100644 --- a/cmd/helm/repo_remove_test.go +++ b/cmd/helm/repo_remove_test.go @@ -30,10 +30,10 @@ import ( ) func TestRepoRemove(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() rootDir := t.TempDir() @@ -162,10 +162,11 @@ func testCacheFiles(t *testing.T, cacheIndexFile string, cacheChartsFile string, } func TestRepoRemoveCompletion(t *testing.T) { - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) + defer ts.Stop() rootDir := t.TempDir() diff --git a/cmd/helm/repo_update_test.go b/cmd/helm/repo_update_test.go index 13369c7cc..7e379da91 100644 --- a/cmd/helm/repo_update_test.go +++ b/cmd/helm/repo_update_test.go @@ -106,10 +106,11 @@ func TestUpdateCustomCacheCmd(t *testing.T) { cachePath := filepath.Join(rootDir, "updcustomcache") os.Mkdir(cachePath, os.ModePerm) - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) + defer ts.Stop() o := &repoUpdateOptions{ @@ -130,10 +131,9 @@ func TestUpdateCharts(t *testing.T) { defer resetEnv()() ensure.HelmHome(t) - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer(t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() r, err := repo.NewChartRepository(&repo.Entry{ @@ -165,10 +165,10 @@ func TestUpdateChartsFail(t *testing.T) { defer resetEnv()() ensure.HelmHome(t) - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() var invalidURL = ts.URL() + "55" @@ -198,10 +198,10 @@ func TestUpdateChartsFailWithError(t *testing.T) { defer resetEnv()() ensure.HelmHome(t) - ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") - if err != nil { - t.Fatal(err) - } + ts := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testserver/*.*"), + ) defer ts.Stop() var invalidURL = ts.URL() + "55" diff --git a/cmd/helm/show_test.go b/cmd/helm/show_test.go index 098335f09..0598095b5 100644 --- a/cmd/helm/show_test.go +++ b/cmd/helm/show_test.go @@ -26,10 +26,10 @@ import ( ) func TestShowPreReleaseChart(t *testing.T) { - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz*"), + ) defer srv.Stop() if err := srv.LinkIndices(); err != nil { diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index 1d28e3c22..26dcc58ff 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -175,7 +175,11 @@ func TestIsTar(t *testing.T) { } func TestDownloadTo(t *testing.T) { - srv := repotest.NewTempServerWithCleanupAndBasicAuth(t, "testdata/*.tgz*") + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/*.tgz*"), + repotest.WithMiddleware(repotest.BasicAuthMiddleware(t)), + ) defer srv.Stop() if err := srv.CreateIndex(); err != nil { t.Fatal(err) @@ -222,12 +226,11 @@ func TestDownloadTo(t *testing.T) { func TestDownloadTo_TLS(t *testing.T) { // Set up mock server w/ tls enabled - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*") - srv.Stop() - if err != nil { - t.Fatal(err) - } - srv.StartTLS() + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/*.tgz*"), + repotest.WithTLSConfig(repotest.MakeTestTLSConfig(t, "../../testdata")), + ) defer srv.Stop() if err := srv.CreateIndex(); err != nil { t.Fatal(err) @@ -249,7 +252,13 @@ func TestDownloadTo_TLS(t *testing.T) { RepositoryConfig: repoConfig, RepositoryCache: repoCache, }), - Options: []getter.Option{}, + Options: []getter.Option{ + getter.WithTLSClientConfig( + "", + "", + filepath.Join("../../testdata/rootca.crt"), + ), + }, } cname := "test/signtest" dest := srv.Root() @@ -278,10 +287,10 @@ func TestDownloadTo_VerifyLater(t *testing.T) { dest := t.TempDir() // Set up a fake repo - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/*.tgz*"), + ) defer srv.Stop() if err := srv.LinkIndices(); err != nil { t.Fatal(err) diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index ae4e693ba..b721c6a0d 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -292,10 +292,10 @@ version: 0.1.0` func TestUpdateBeforeBuild(t *testing.T) { // Set up a fake repo - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/*.tgz*"), + ) defer srv.Stop() if err := srv.LinkIndices(); err != nil { t.Fatal(err) @@ -347,13 +347,11 @@ func TestUpdateBeforeBuild(t *testing.T) { } // Update before Build. see issue: https://github.com/helm/helm/issues/7101 - err = m.Update() - if err != nil { + if err := m.Update(); err != nil { t.Fatal(err) } - err = m.Build() - if err != nil { + if err := m.Build(); err != nil { t.Fatal(err) } } @@ -363,10 +361,10 @@ func TestUpdateBeforeBuild(t *testing.T) { // to be fetched. func TestUpdateWithNoRepo(t *testing.T) { // Set up a fake repo - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/*.tgz*"), + ) defer srv.Stop() if err := srv.LinkIndices(); err != nil { t.Fatal(err) @@ -422,8 +420,7 @@ func TestUpdateWithNoRepo(t *testing.T) { } // Test the update - err = m.Update() - if err != nil { + if err := m.Update(); err != nil { t.Fatal(err) } } @@ -436,10 +433,10 @@ func TestUpdateWithNoRepo(t *testing.T) { // If each of these main fields (name, version, repository) is not supplied by dep param, default value will be used. func checkBuildWithOptionalFields(t *testing.T, chartName string, dep chart.Dependency) { // Set up a fake repo - srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*") - if err != nil { - t.Fatal(err) - } + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/*.tgz*"), + ) defer srv.Stop() if err := srv.LinkIndices(); err != nil { t.Fatal(err) @@ -487,14 +484,12 @@ func checkBuildWithOptionalFields(t *testing.T, chartName string, dep chart.Depe } // First build will update dependencies and create Chart.lock file. - err = m.Build() - if err != nil { + if err := m.Build(); err != nil { t.Fatal(err) } // Second build should be passed. See PR #6655. - err = m.Build() - if err != nil { + if err := m.Build(); err != nil { t.Fatal(err) } } diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index c7b674d04..0155c54d8 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -17,6 +17,7 @@ package repotest import ( "context" + "crypto/tls" "fmt" "net/http" "net/http/httptest" @@ -33,7 +34,6 @@ import ( "golang.org/x/crypto/bcrypt" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/internal/tlsutil" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" "helm.sh/helm/v4/pkg/chartutil" @@ -41,34 +41,103 @@ import ( "helm.sh/helm/v4/pkg/repo" ) -// NewTempServerWithCleanup creates a server inside of a temp dir. +func BasicAuthMiddleware(t *testing.T) http.HandlerFunc { + return http.HandlerFunc(func(_ 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) + } + }) +} + +type ServerOption func(*testing.T, *Server) + +func WithTLSConfig(tlsConfig *tls.Config) ServerOption { + return func(_ *testing.T, server *Server) { + server.tlsConfig = tlsConfig + } +} + +func WithMiddleware(middleware http.HandlerFunc) ServerOption { + return func(_ *testing.T, server *Server) { + server.middleware = middleware + } +} + +func WithChartSourceGlob(glob string) ServerOption { + return func(_ *testing.T, server *Server) { + server.chartSourceGlob = glob + } +} + +// Server is an implementation of a repository server for testing. +type Server struct { + docroot string + srv *httptest.Server + middleware http.HandlerFunc + tlsConfig *tls.Config + chartSourceGlob string +} + +// NewTempServer creates a server inside of a temp dir. // // If the passed in string is not "", it will be treated as a shell glob, and files // will be copied from that path to the server's docroot. // -// The caller is responsible for stopping the server. +// The server is started automatically. The caller is responsible for stopping +// the server. +// // The temp dir will be removed by testing package automatically when test finished. -func NewTempServerWithCleanup(t *testing.T, glob string) (*Server, error) { - srv, err := NewTempServer(glob) +func NewTempServer(t *testing.T, options ...ServerOption) *Server { + + docrootTempDir, err := os.MkdirTemp("", "helm-repotest-") + if err != nil { + t.Fatal(err) + } + + srv := newServer(t, docrootTempDir, options...) + t.Cleanup(func() { os.RemoveAll(srv.docroot) }) - return srv, err + + if srv.chartSourceGlob != "" { + if _, err := srv.CopyCharts(srv.chartSourceGlob); err != nil { + t.Fatal(err) + } + } + + return srv } -// Set up a fake repo with basic auth enabled -func NewTempServerWithCleanupAndBasicAuth(t *testing.T, glob string) *Server { - srv, err := NewTempServerWithCleanup(t, glob) - srv.Stop() +// Create the server, but don't yet start it +func newServer(t *testing.T, docroot string, options ...ServerOption) *Server { + absdocroot, err := filepath.Abs(docroot) if err != nil { t.Fatal(err) } - srv.WithMiddleware(http.HandlerFunc(func(_ 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) + + s := &Server{ + docroot: absdocroot, + } + + for _, option := range options { + option(t, s) + } + + s.srv = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if s.middleware != nil { + s.middleware.ServeHTTP(w, r) } + http.FileServer(http.Dir(s.Root())).ServeHTTP(w, r) })) - srv.Start() - return srv + + s.start() + + // Add the testing repository as the only repo. Server must be started for the server's URL to be valid + if err := setTestingRepository(s.URL(), filepath.Join(s.docroot, "repositories.yaml")); err != nil { + t.Fatal(err) + } + + return s } type OCIServer struct { @@ -239,69 +308,6 @@ func (srv *OCIServer) Run(t *testing.T, opts ...OCIServerOpt) { result.Chart.Digest, result.Chart.Size) } -// NewTempServer creates a server inside of a temp dir. -// -// If the passed in string is not "", it will be treated as a shell glob, and files -// will be copied from that path to the server's docroot. -// -// The caller is responsible for destroying the temp directory as well as stopping -// the server. -// -// Deprecated: use NewTempServerWithCleanup -func NewTempServer(glob string) (*Server, error) { - tdir, err := os.MkdirTemp("", "helm-repotest-") - if err != nil { - return nil, err - } - srv := NewServer(tdir) - - if glob != "" { - if _, err := srv.CopyCharts(glob); err != nil { - srv.Stop() - return srv, err - } - } - - return srv, nil -} - -// NewServer creates a repository server for testing. -// -// docroot should be a temp dir managed by the caller. -// -// This will start the server, serving files off of the docroot. -// -// Use CopyCharts to move charts into the repository and then index them -// for service. -func NewServer(docroot string) *Server { - root, err := filepath.Abs(docroot) - if err != nil { - panic(err) - } - srv := &Server{ - docroot: root, - } - srv.Start() - // Add the testing repository as the only repo. - if err := setTestingRepository(srv.URL(), filepath.Join(root, "repositories.yaml")); err != nil { - panic(err) - } - return srv -} - -// Server is an implementation of a repository server for testing. -type Server struct { - docroot string - srv *httptest.Server - middleware http.HandlerFunc -} - -// WithMiddleware injects middleware in front of the server. This can be used to inject -// additional functionality like layering in an authentication frontend. -func (s *Server) WithMiddleware(middleware http.HandlerFunc) { - s.middleware = middleware -} - // Root gets the docroot for the server. func (s *Server) Root() string { return s.docroot @@ -348,50 +354,12 @@ func (s *Server) CreateIndex() error { return os.WriteFile(ifile, d, 0644) } -func (s *Server) Start() { - s.srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if s.middleware != nil { - s.middleware.ServeHTTP(w, r) - } - http.FileServer(http.Dir(s.docroot)).ServeHTTP(w, r) - })) -} - -func (s *Server) StartTLS() { - cd := "../../testdata" - ca, pub, priv := filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "crt.pem"), filepath.Join(cd, "key.pem") - insecure := false - - s.srv = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if s.middleware != nil { - s.middleware.ServeHTTP(w, r) - } - http.FileServer(http.Dir(s.Root())).ServeHTTP(w, r) - })) - tlsConf, err := tlsutil.NewTLSConfig( - tlsutil.WithInsecureSkipVerify(insecure), - tlsutil.WithCertKeyPairFiles(pub, priv), - tlsutil.WithCAFile(ca), - ) - if err != nil { - panic(err) - } - tlsConf.ServerName = "helm.sh" - s.srv.TLS = tlsConf - s.srv.StartTLS() - - // Set up repositories config with ca file - repoConfig := filepath.Join(s.Root(), "repositories.yaml") - - r := repo.NewFile() - r.Add(&repo.Entry{ - Name: "test", - URL: s.URL(), - CAFile: filepath.Join("../../testdata", "rootca.crt"), - }) - - if err := r.WriteFile(repoConfig, 0600); err != nil { - panic(err) +func (s *Server) start() { + if s.tlsConfig != nil { + s.srv.TLS = s.tlsConfig + s.srv.StartTLS() + } else { + s.srv.Start() } } @@ -411,6 +379,10 @@ func (s *Server) URL() string { return s.srv.URL } +func (s *Server) Client() *http.Client { + return s.srv.Client() +} + // LinkIndices links the index created with CreateIndex and makes a symbolic link to the cache index. // // This makes it possible to simulate a local cache of a repository. @@ -422,6 +394,10 @@ func (s *Server) LinkIndices() error { // setTestingRepository sets up a testing repository.yaml with only the given URL. func setTestingRepository(url, fname string) error { + if url == "" { + panic("no url") + } + r := repo.NewFile() r.Add(&repo.Entry{ Name: "test", diff --git a/pkg/repo/repotest/server_test.go b/pkg/repo/repotest/server_test.go index 6d15925db..cf68e5110 100644 --- a/pkg/repo/repotest/server_test.go +++ b/pkg/repo/repotest/server_test.go @@ -19,6 +19,7 @@ import ( "io" "net/http" "path/filepath" + "strings" "testing" "sigs.k8s.io/yaml" @@ -34,7 +35,7 @@ func TestServer(t *testing.T) { rootDir := t.TempDir() - srv := NewServer(rootDir) + srv := newServer(t, rootDir) defer srv.Stop() c, err := srv.CopyCharts("testdata/*.tgz") @@ -99,18 +100,123 @@ func TestServer(t *testing.T) { func TestNewTempServer(t *testing.T) { ensure.HelmHome(t) - srv, err := NewTempServerWithCleanup(t, "testdata/examplechart-0.1.0.tgz") - if err != nil { - t.Fatal(err) + type testCase struct { + options []ServerOption } - defer srv.Stop() - res, err := http.Head(srv.URL() + "/examplechart-0.1.0.tgz") - res.Body.Close() - if err != nil { - t.Error(err) + testCases := map[string]testCase{ + "plainhttp": { + options: []ServerOption{ + WithChartSourceGlob("testdata/examplechart-0.1.0.tgz"), + }, + }, + "tls": { + options: []ServerOption{ + WithChartSourceGlob("testdata/examplechart-0.1.0.tgz"), + WithTLSConfig(MakeTestTLSConfig(t, "../../../testdata")), + }, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + srv := NewTempServer( + t, + tc.options..., + ) + defer srv.Stop() + + if srv.srv.URL == "" { + t.Fatal("unstarted server") + } + + client := srv.Client() + + { + res, err := client.Head(srv.URL() + "/repositories.yaml") + if err != nil { + t.Error(err) + } + + res.Body.Close() + + if res.StatusCode != 200 { + t.Errorf("Expected 200, got %d", res.StatusCode) + } + + } + + { + res, err := client.Head(srv.URL() + "/examplechart-0.1.0.tgz") + if err != nil { + t.Error(err) + } + res.Body.Close() + + if res.StatusCode != 200 { + t.Errorf("Expected 200, got %d", res.StatusCode) + } + } + + res, err := client.Get(srv.URL() + "/examplechart-0.1.0.tgz") + res.Body.Close() + if err != nil { + t.Fatal(err) + } + + if res.ContentLength < 500 { + t.Errorf("Expected at least 500 bytes of data, got %d", res.ContentLength) + } + + res, err = client.Get(srv.URL() + "/index.yaml") + if err != nil { + t.Fatal(err) + } + + data, err := io.ReadAll(res.Body) + res.Body.Close() + if err != nil { + t.Fatal(err) + } + + m := repo.NewIndexFile() + if err := yaml.Unmarshal(data, m); err != nil { + t.Fatal(err) + } + + if l := len(m.Entries); l != 1 { + t.Fatalf("Expected 1 entry, got %d", l) + } + + expect := "examplechart" + if !m.Has(expect, "0.1.0") { + t.Errorf("missing %q", expect) + } + + res, err = client.Get(srv.URL() + "/index.yaml-nosuchthing") + res.Body.Close() + if err != nil { + t.Fatal(err) + } + if res.StatusCode != 404 { + t.Fatalf("Expected 404, got %d", res.StatusCode) + } + }) } - if res.StatusCode != 200 { - t.Errorf("Expected 200, got %d", res.StatusCode) + +} + +func TestNewTempServer_TLS(t *testing.T) { + ensure.HelmHome(t) + + srv := NewTempServer( + t, + WithChartSourceGlob("testdata/examplechart-0.1.0.tgz"), + WithTLSConfig(MakeTestTLSConfig(t, "../../../testdata")), + ) + defer srv.Stop() + + if !strings.HasPrefix(srv.URL(), "https://") { + t.Fatal("non-TLS server") } } diff --git a/pkg/repo/repotest/tlsconfig.go b/pkg/repo/repotest/tlsconfig.go new file mode 100644 index 000000000..3914a4d3f --- /dev/null +++ b/pkg/repo/repotest/tlsconfig.go @@ -0,0 +1,43 @@ +/* +Copyright The Helm Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package repotest + +import ( + "crypto/tls" + "path/filepath" + "testing" + + "helm.sh/helm/v4/internal/tlsutil" + + "github.com/stretchr/testify/require" +) + +func MakeTestTLSConfig(t *testing.T, path string) *tls.Config { + ca, pub, priv := filepath.Join(path, "rootca.crt"), filepath.Join(path, "crt.pem"), filepath.Join(path, "key.pem") + + insecure := false + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithInsecureSkipVerify(insecure), + tlsutil.WithCertKeyPairFiles(pub, priv), + tlsutil.WithCAFile(ca), + ) + //require.Nil(t, err, err.Error()) + require.Nil(t, err) + + tlsConf.ServerName = "helm.sh" + + return tlsConf +} From 37020c32fa3bb7660fd61453165b9da9ee62a491 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 9 Feb 2025 11:11:00 +0800 Subject: [PATCH 090/271] Update pkg/cli/values/options.go Co-authored-by: George Jenkins Signed-off-by: Jonathan --- pkg/cli/values/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index d7086e8c3..09af69f8b 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -68,7 +68,7 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er // If value is JSON object format, parse it as map var jsonMap map[string]interface{} if err := json.Unmarshal([]byte(trimmedValue), &jsonMap); err != nil { - return nil, errors.Errorf("failed parsing --set-json data using JSON format: %s", value) + return nil, errors.Errorf("failed parsing --set-json data JSON: %s", value) } base = mergeMaps(base, jsonMap) } else { From d1cc9b39a33e335c56e68e1305d27bc036363406 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 9 Feb 2025 15:32:46 +0000 Subject: [PATCH 091/271] tests for status reader Signed-off-by: Austin Abro --- pkg/kube/job_status_reader_test.go | 93 ++++++++++++++++-------- pkg/kube/pod_status_reader.go | 8 +-- pkg/kube/pod_status_reader_test.go | 110 ++++++++++++++++++++--------- 3 files changed, 145 insertions(+), 66 deletions(-) diff --git a/pkg/kube/job_status_reader_test.go b/pkg/kube/job_status_reader_test.go index 98b994030..cd0dcedeb 100644 --- a/pkg/kube/job_status_reader_test.go +++ b/pkg/kube/job_status_reader_test.go @@ -30,7 +30,8 @@ import ( "sigs.k8s.io/cli-utils/pkg/kstatus/status" ) -func toUnstructured(obj runtime.Object) (*unstructured.Unstructured, error) { +func toUnstructured(t *testing.T, obj runtime.Object) (*unstructured.Unstructured, error) { + t.Helper() // If the incoming object is already unstructured, perform a deep copy first // otherwise DefaultUnstructuredConverter ends up returning the inner map without // making a copy. @@ -45,35 +46,69 @@ func toUnstructured(obj runtime.Object) (*unstructured.Unstructured, error) { } func TestJobConditions(t *testing.T) { - job := &batchv1.Job{ - ObjectMeta: metav1.ObjectMeta{ - Name: "job", + t.Parallel() + tests := []struct { + name string + job *batchv1.Job + expectedStatus status.Status + }{ + { + name: "job without Complete condition returns InProgress status", + job: &batchv1.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "job-no-condition", + }, + Spec: batchv1.JobSpec{}, + Status: batchv1.JobStatus{}, + }, + expectedStatus: status.InProgressStatus, }, - Spec: batchv1.JobSpec{}, - Status: batchv1.JobStatus{}, - } - - t.Run("job without Complete condition returns InProgress status", func(t *testing.T) { - us, err := toUnstructured(job) - assert.NoError(t, err) - result, err := jobConditions(us) - assert.NoError(t, err) - assert.Equal(t, status.InProgressStatus, result.Status) - }) - - t.Run("job with Complete condition as True returns Current status", func(t *testing.T) { - job.Status = batchv1.JobStatus{ - Conditions: []batchv1.JobCondition{ - { - Type: batchv1.JobComplete, - Status: corev1.ConditionTrue, + { + name: "job with Complete condition as True returns Current status", + job: &batchv1.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "job-complete", + }, + Spec: batchv1.JobSpec{}, + Status: batchv1.JobStatus{ + Conditions: []batchv1.JobCondition{ + { + Type: batchv1.JobComplete, + Status: corev1.ConditionTrue, + }, + }, + }, + }, + expectedStatus: status.CurrentStatus, + }, + { + name: "job with Failed condition as True returns Failed status", + job: &batchv1.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "job-failed", + }, + Spec: batchv1.JobSpec{}, + Status: batchv1.JobStatus{ + Conditions: []batchv1.JobCondition{ + { + Type: batchv1.JobFailed, + Status: corev1.ConditionTrue, + }, + }, }, }, - } - us, err := toUnstructured(job) - assert.NoError(t, err) - result, err := jobConditions(us) - assert.NoError(t, err) - assert.Equal(t, status.CurrentStatus, result.Status) - }) + expectedStatus: status.FailedStatus, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + us, err := toUnstructured(t, tc.job) + assert.NoError(t, err) + result, err := jobConditions(us) + assert.NoError(t, err) + assert.Equal(t, tc.expectedStatus, result.Status) + }) + } } diff --git a/pkg/kube/pod_status_reader.go b/pkg/kube/pod_status_reader.go index 25e427966..752f73ac1 100644 --- a/pkg/kube/pod_status_reader.go +++ b/pkg/kube/pod_status_reader.go @@ -62,8 +62,8 @@ func (j *customPodStatusReader) ReadStatusForObject(ctx context.Context, reader func podConditions(u *unstructured.Unstructured) (*status.Result, error) { obj := u.UnstructuredContent() phase := status.GetStringField(obj, ".status.phase", "") - switch phase { - case string(v1.PodSucceeded): + switch v1.PodPhase(phase) { + case v1.PodSucceeded: message := fmt.Sprintf("pod %s succeeded", u.GetName()) return &status.Result{ Status: status.CurrentStatus, @@ -76,7 +76,7 @@ func podConditions(u *unstructured.Unstructured) (*status.Result, error) { }, }, }, nil - case string(v1.PodFailed): + case v1.PodFailed: message := fmt.Sprintf("pod %s failed", u.GetName()) return &status.Result{ Status: status.FailedStatus, @@ -90,8 +90,6 @@ func podConditions(u *unstructured.Unstructured) (*status.Result, error) { }, }, }, nil - case string(v1.PodPending): - case string(v1.PodRunning): } message := "Pod in progress" diff --git a/pkg/kube/pod_status_reader_test.go b/pkg/kube/pod_status_reader_test.go index 2604ef026..bb08f041a 100644 --- a/pkg/kube/pod_status_reader_test.go +++ b/pkg/kube/pod_status_reader_test.go @@ -28,39 +28,85 @@ import ( ) func TestPodConditions(t *testing.T) { - t.Parallel() - - //TODO add some more tests here and parallelize - - t.Run("pod without status returns in progress", func(t *testing.T) { - pod := &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod", + tests := []struct { + name string + pod *v1.Pod + expectedStatus status.Status + }{ + { + name: "pod without status returns in progress", + pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "pod-no-status"}, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{}, }, - Spec: v1.PodSpec{}, - Status: v1.PodStatus{}, - } - us, err := toUnstructured(pod) - assert.NoError(t, err) - result, err := podConditions(us) - assert.NoError(t, err) - assert.Equal(t, status.InProgressStatus, result.Status) - }) - - t.Run("pod succeeded returns Current status", func(t *testing.T) { - pod := &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod", + expectedStatus: status.InProgressStatus, + }, + { + name: "pod succeeded returns current status", + pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "pod-succeeded"}, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{ + Phase: v1.PodSucceeded, + }, + }, + expectedStatus: status.CurrentStatus, + }, + { + name: "pod failed returns failed status", + pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "pod-failed"}, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{ + Phase: v1.PodFailed, + }, }, - Spec: v1.PodSpec{}, - Status: v1.PodStatus{ - Phase: v1.PodSucceeded, + expectedStatus: status.FailedStatus, + }, + { + name: "pod pending returns in progress status", + pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "pod-pending"}, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{ + Phase: v1.PodPending, + }, }, - } - us, err := toUnstructured(pod) - assert.NoError(t, err) - result, err := podConditions(us) - assert.NoError(t, err) - assert.Equal(t, status.CurrentStatus, result.Status) - }) + expectedStatus: status.InProgressStatus, + }, + { + name: "pod running returns in progress status", + pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "pod-running"}, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{ + Phase: v1.PodRunning, + }, + }, + expectedStatus: status.InProgressStatus, + }, + { + name: "pod with unknown phase returns in progress status", + pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "pod-unknown"}, + Spec: v1.PodSpec{}, + Status: v1.PodStatus{ + Phase: v1.PodUnknown, + }, + }, + expectedStatus: status.InProgressStatus, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + us, err := toUnstructured(t, tc.pod) + assert.NoError(t, err) + result, err := podConditions(us) + assert.NoError(t, err) + assert.Equal(t, tc.expectedStatus, result.Status) + }) + } } From 14391dea5bf98c54ca0f9d87c82a5328f4bff063 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 10 Feb 2025 15:06:16 +0000 Subject: [PATCH 092/271] pods and jobs working Signed-off-by: Austin Abro --- pkg/kube/pod_status_reader.go | 12 ++- pkg/kube/statuswait.go | 75 +++++++++++------- pkg/kube/statuswait_test.go | 141 ++++++++++++++++++++++++++-------- 3 files changed, 159 insertions(+), 69 deletions(-) diff --git a/pkg/kube/pod_status_reader.go b/pkg/kube/pod_status_reader.go index 752f73ac1..c44af542e 100644 --- a/pkg/kube/pod_status_reader.go +++ b/pkg/kube/pod_status_reader.go @@ -22,9 +22,7 @@ import ( "context" "fmt" - batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" @@ -42,13 +40,13 @@ type customPodStatusReader struct { func NewCustomPodStatusReader(mapper meta.RESTMapper) engine.StatusReader { genericStatusReader := statusreaders.NewGenericStatusReader(mapper, podConditions) - return &customJobStatusReader{ + return &customPodStatusReader{ genericStatusReader: genericStatusReader, } } func (j *customPodStatusReader) Supports(gk schema.GroupKind) bool { - return gk == batchv1.SchemeGroupVersion.WithKind("Job").GroupKind() + return gk == corev1.SchemeGroupVersion.WithKind("Pod").GroupKind() } func (j *customPodStatusReader) ReadStatus(ctx context.Context, reader engine.ClusterReader, resource object.ObjMetadata) (*event.ResourceStatus, error) { @@ -62,8 +60,8 @@ func (j *customPodStatusReader) ReadStatusForObject(ctx context.Context, reader func podConditions(u *unstructured.Unstructured) (*status.Result, error) { obj := u.UnstructuredContent() phase := status.GetStringField(obj, ".status.phase", "") - switch v1.PodPhase(phase) { - case v1.PodSucceeded: + switch corev1.PodPhase(phase) { + case corev1.PodSucceeded: message := fmt.Sprintf("pod %s succeeded", u.GetName()) return &status.Result{ Status: status.CurrentStatus, @@ -76,7 +74,7 @@ func podConditions(u *unstructured.Unstructured) (*status.Result, error) { }, }, }, nil - case v1.PodFailed: + case corev1.PodFailed: message := fmt.Sprintf("pod %s failed", u.GetName()) return &status.Result{ Status: status.FailedStatus, diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 16751abba..4aff42ff2 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -20,13 +20,16 @@ import ( "context" "errors" "fmt" + "sort" "time" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/dynamic" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" + "sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" "sigs.k8s.io/cli-utils/pkg/kstatus/status" @@ -40,9 +43,32 @@ type statusWaiter struct { log func(string, ...interface{}) } -func (w *statusWaiter) WatchUntilReady(resources ResourceList, timeout time.Duration) error { - - return nil +func alwaysReady(u *unstructured.Unstructured) (*status.Result, error) { + return &status.Result{ + Status: status.CurrentStatus, + Message: "Resource is current", + }, nil +} + +func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.Duration) error { + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + w.log("waiting for %d pods and jobs to complete with a timeout of %s", len(resourceList), timeout) + sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) + jobSR := NewCustomJobStatusReader(w.restMapper) + podSR := NewCustomPodStatusReader(w.restMapper) + // We don't want to wait on any other resources as watchUntilReady is only for Helm hooks + genericSR := statusreaders.NewGenericStatusReader(w.restMapper, alwaysReady) + + sr := &statusreaders.DelegatingStatusReader{ + StatusReaders: []engine.StatusReader{ + jobSR, + podSR, + genericSR, + }, + } + sw.StatusReader = sr + return w.wait(ctx, resourceList, sw) } func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { @@ -85,8 +111,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - go logResourceStatus(ctx, resources, statusCollector, status.NotFoundStatus, w.log) - done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus)) + done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus, w.log)) <-done if statusCollector.Error != nil { @@ -129,8 +154,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw w eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - go logResourceStatus(cancelCtx, resources, statusCollector, status.CurrentStatus, w.log) - done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus)) + done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus, w.log)) <-done if statusCollector.Error != nil { @@ -153,38 +177,33 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw w return nil } -func statusObserver(cancel context.CancelFunc, desired status.Status) collector.ObserverFunc { - return func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { - rss := []*event.ResourceStatus{} +func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func(string, ...interface{})) collector.ObserverFunc { + return func(statusCollector *collector.ResourceStatusCollector, e event.Event) { + var rss []*event.ResourceStatus + var nonDesiredResources []*event.ResourceStatus for _, rs := range statusCollector.ResourceStatuses { if rs == nil { continue } rss = append(rss, rs) + if rs.Status != desired { + nonDesiredResources = append(nonDesiredResources, rs) + } } + if aggregator.AggregateStatus(rss, desired) == desired { cancel() return } - } -} -func logResourceStatus(ctx context.Context, resources []object.ObjMetadata, sc *collector.ResourceStatusCollector, desiredStatus status.Status, log func(string, ...interface{})) { - ticker := time.NewTicker(1 * time.Second) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - for _, id := range resources { - rs := sc.ResourceStatuses[id] - if rs.Status != desiredStatus { - log("waiting for resource, name: %s, kind: %s, desired status: %s, actual status: %s", rs.Identifier.Name, rs.Identifier.GroupKind.Kind, desiredStatus, rs.Status) - // only log one resource to not overwhelm the logs - break - } - } + if len(nonDesiredResources) > 0 { + // Log only the first resource so the user knows what they're waiting for without being overwhelmed + sort.Slice(nonDesiredResources, func(i, j int) bool { + return nonDesiredResources[i].Identifier.Name < nonDesiredResources[j].Identifier.Name + }) + first := nonDesiredResources[0] + logFn("waiting for resource: name: %s, kind: %s, desired status: %s, actual status: %s", + first.Identifier.Name, first.Identifier.GroupKind.Kind, desired, first.Status) } } } diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 131224e8b..df16bf7e9 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -17,9 +17,7 @@ limitations under the License. package kube // import "helm.sh/helm/v3/pkg/kube" import ( - "context" "errors" - "fmt" "testing" "time" @@ -35,10 +33,6 @@ import ( "k8s.io/apimachinery/pkg/util/yaml" dynamicfake "k8s.io/client-go/dynamic/fake" "k8s.io/kubectl/pkg/scheme" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" - "sigs.k8s.io/cli-utils/pkg/object" "sigs.k8s.io/cli-utils/pkg/testutil" ) @@ -46,7 +40,7 @@ var podCurrentManifest = ` apiVersion: v1 kind: Pod metadata: - name: good-pod + name: current-pod namespace: ns status: conditions: @@ -100,11 +94,21 @@ status: status: "True" ` +var podCompleteManifest = ` +apiVersion: v1 +kind: Pod +metadata: + name: good-pod + namespace: ns +status: + phase: Succeeded +` + var pausedDeploymentManifest = ` apiVersion: apps/v1 kind: Deployment metadata: - name: nginx + name: paused namespace: ns-1 generation: 1 spec: @@ -125,6 +129,30 @@ spec: - containerPort: 80 ` +var notReadyDeploymentManifest = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: not-ready + namespace: ns-1 + generation: 1 +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.19.6 + ports: + - containerPort: 80 +` + func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured) schema.GroupVersionResource { gvk := obj.GroupVersionKind() mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version) @@ -132,31 +160,6 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured return mapping.Resource } -func TestStatusLogger(t *testing.T) { - t.Parallel() - ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*1500) - defer cancel() - readyPod := object.ObjMetadata{ - Name: "readyPod", - GroupKind: schema.GroupKind{Kind: "Pod"}, - } - notReadyPod := object.ObjMetadata{ - Name: "notReadyPod", - GroupKind: schema.GroupKind{Kind: "Pod"}, - } - objs := []object.ObjMetadata{readyPod, notReadyPod} - resourceStatusCollector := collector.NewResourceStatusCollector(objs) - resourceStatusCollector.ResourceStatuses[readyPod] = &event.ResourceStatus{ - Identifier: readyPod, - Status: status.CurrentStatus, - } - expectedMessage := "waiting for resource, name: notReadyPod, kind: Pod, desired status: Current, actual status: Unknown" - testLogger := func(message string, args ...interface{}) { - assert.Equal(t, expectedMessage, fmt.Sprintf(message, args...)) - } - logResourceStatus(ctx, objs, resourceStatusCollector, status.CurrentStatus, testLogger) -} - func TestStatusWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { @@ -175,7 +178,7 @@ func TestStatusWaitForDelete(t *testing.T) { name: "error when not all objects are deleted", manifestsToCreate: []string{jobCompleteManifest, podCurrentManifest}, manifestsToDelete: []string{jobCompleteManifest}, - expectErrs: []error{errors.New("resource still exists, name: good-pod, kind: Pod, status: Current"), errors.New("context deadline exceeded")}, + expectErrs: []error{errors.New("resource still exists, name: current-pod, kind: Pod, status: Current"), errors.New("context deadline exceeded")}, }, } for _, tt := range tests { @@ -378,3 +381,73 @@ func TestWaitForJobComplete(t *testing.T) { }) } } + +func TestWatchForReady(t *testing.T) { + t.Parallel() + tests := []struct { + name string + objManifests []string + expectErrs []error + }{ + { + name: "succeeds if pod and job are complete", + objManifests: []string{jobCompleteManifest, podCompleteManifest}, + }, + { + name: "succeeds even when a resource that's not a pod or job is complete", + objManifests: []string{notReadyDeploymentManifest}, + }, + { + name: "Fails if job is not complete", + objManifests: []string{jobReadyManifest}, + expectErrs: []error{errors.New("resource not ready, name: ready-not-complete, kind: Job, status: InProgress"), errors.New("context deadline exceeded")}, + }, + { + name: "Fails if pod is not complete", + objManifests: []string{podCurrentManifest}, + expectErrs: []error{errors.New("resource not ready, name: current-pod, kind: Pod, status: InProgress"), errors.New("context deadline exceeded")}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + c := newTestClient(t) + fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) + fakeMapper := testutil.NewFakeRESTMapper( + v1.SchemeGroupVersion.WithKind("Pod"), + appsv1.SchemeGroupVersion.WithKind("Deployment"), + batchv1.SchemeGroupVersion.WithKind("Job"), + ) + statusWaiter := statusWaiter{ + client: fakeClient, + restMapper: fakeMapper, + log: t.Logf, + } + objs := []runtime.Object{} + for _, podYaml := range tt.objManifests { + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(podYaml), &m) + assert.NoError(t, err) + resource := &unstructured.Unstructured{Object: m} + objs = append(objs, resource) + gvr := getGVR(t, fakeMapper, resource) + err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) + assert.NoError(t, err) + } + resourceList := ResourceList{} + for _, obj := range objs { + list, err := c.Build(objBody(obj), false) + assert.NoError(t, err) + resourceList = append(resourceList, list...) + } + + err := statusWaiter.WatchUntilReady(resourceList, time.Second*3) + if tt.expectErrs != nil { + assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) + return + } + assert.NoError(t, err) + }) + } +} From f866409c508c4b5430f0943b95f25ffbfd931c3b Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 10 Feb 2025 15:13:18 +0000 Subject: [PATCH 093/271] move statusreaders to it's own package Signed-off-by: Austin Abro --- {pkg/kube => internal/statusreaders}/job_status_reader.go | 2 +- .../statusreaders}/job_status_reader_test.go | 2 +- {pkg/kube => internal/statusreaders}/pod_status_reader.go | 4 +--- .../statusreaders}/pod_status_reader_test.go | 3 +-- pkg/kube/statuswait.go | 7 ++++--- 5 files changed, 8 insertions(+), 10 deletions(-) rename {pkg/kube => internal/statusreaders}/job_status_reader.go (99%) rename {pkg/kube => internal/statusreaders}/job_status_reader_test.go (99%) rename {pkg/kube => internal/statusreaders}/pod_status_reader.go (95%) rename {pkg/kube => internal/statusreaders}/pod_status_reader_test.go (95%) diff --git a/pkg/kube/job_status_reader.go b/internal/statusreaders/job_status_reader.go similarity index 99% rename from pkg/kube/job_status_reader.go rename to internal/statusreaders/job_status_reader.go index f6eb8d3d9..d493d9e13 100644 --- a/pkg/kube/job_status_reader.go +++ b/internal/statusreaders/job_status_reader.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package kube +package statusreaders // This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go diff --git a/pkg/kube/job_status_reader_test.go b/internal/statusreaders/job_status_reader_test.go similarity index 99% rename from pkg/kube/job_status_reader_test.go rename to internal/statusreaders/job_status_reader_test.go index cd0dcedeb..70e4ee29a 100644 --- a/pkg/kube/job_status_reader_test.go +++ b/internal/statusreaders/job_status_reader_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package kube +package statusreaders // This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go import ( diff --git a/pkg/kube/pod_status_reader.go b/internal/statusreaders/pod_status_reader.go similarity index 95% rename from pkg/kube/pod_status_reader.go rename to internal/statusreaders/pod_status_reader.go index c44af542e..d3daf7cc3 100644 --- a/pkg/kube/pod_status_reader.go +++ b/internal/statusreaders/pod_status_reader.go @@ -14,9 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package kube - -// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go +package statusreaders import ( "context" diff --git a/pkg/kube/pod_status_reader_test.go b/internal/statusreaders/pod_status_reader_test.go similarity index 95% rename from pkg/kube/pod_status_reader_test.go rename to internal/statusreaders/pod_status_reader_test.go index bb08f041a..a151f1aed 100644 --- a/pkg/kube/pod_status_reader_test.go +++ b/internal/statusreaders/pod_status_reader_test.go @@ -14,9 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -package kube +package statusreaders -// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go import ( "testing" diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 4aff42ff2..eaa473cd4 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -23,6 +23,7 @@ import ( "sort" "time" + helmStatusReaders "helm.sh/helm/v4/internal/statusreaders" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -55,8 +56,8 @@ func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.D defer cancel() w.log("waiting for %d pods and jobs to complete with a timeout of %s", len(resourceList), timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) - jobSR := NewCustomJobStatusReader(w.restMapper) - podSR := NewCustomPodStatusReader(w.restMapper) + jobSR := helmStatusReaders.NewCustomJobStatusReader(w.restMapper) + podSR := helmStatusReaders.NewCustomPodStatusReader(w.restMapper) // We don't want to wait on any other resources as watchUntilReady is only for Helm hooks genericSR := statusreaders.NewGenericStatusReader(w.restMapper, alwaysReady) @@ -84,7 +85,7 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura defer cancel() w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) - newCustomJobStatusReader := NewCustomJobStatusReader(w.restMapper) + newCustomJobStatusReader := helmStatusReaders.NewCustomJobStatusReader(w.restMapper) customSR := statusreaders.NewStatusReader(w.restMapper, newCustomJobStatusReader) sw.StatusReader = customSR return w.wait(ctx, resourceList, sw) From 7207565e1284e2b597ffad5179d67487ab9478c1 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 10 Feb 2025 15:31:43 +0000 Subject: [PATCH 094/271] lint Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 7 +++--- pkg/kube/wait.go | 50 +++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index eaa473cd4..0729d0d1b 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -23,7 +23,6 @@ import ( "sort" "time" - helmStatusReaders "helm.sh/helm/v4/internal/statusreaders" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -36,6 +35,8 @@ import ( "sigs.k8s.io/cli-utils/pkg/kstatus/status" "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" "sigs.k8s.io/cli-utils/pkg/object" + + helmStatusReaders "helm.sh/helm/v4/internal/statusreaders" ) type statusWaiter struct { @@ -44,7 +45,7 @@ type statusWaiter struct { log func(string, ...interface{}) } -func alwaysReady(u *unstructured.Unstructured) (*status.Result, error) { +func alwaysReady(_ *unstructured.Unstructured) (*status.Result, error) { return &status.Result{ Status: status.CurrentStatus, Message: "Resource is current", @@ -179,7 +180,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw w } func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func(string, ...interface{})) collector.ObserverFunc { - return func(statusCollector *collector.ResourceStatusCollector, e event.Event) { + return func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { var rss []*event.ResourceStatus var nonDesiredResources []*event.ResourceStatus for _, rs := range statusCollector.ResourceStatuses { diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index fdb3c9087..83b352201 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -27,6 +27,7 @@ import ( appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" + batch "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" @@ -42,7 +43,6 @@ import ( "k8s.io/client-go/kubernetes" cachetools "k8s.io/client-go/tools/cache" watchtools "k8s.io/client-go/tools/watch" - batch "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/util/wait" ) @@ -55,20 +55,20 @@ type HelmWaiter struct { kubeClient *kubernetes.Clientset } -func (w *HelmWaiter) Wait(resources ResourceList, timeout time.Duration) error { - w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true)) - return w.waitForResources(resources, timeout) +func (hw *HelmWaiter) Wait(resources ResourceList, timeout time.Duration) error { + hw.c = NewReadyChecker(hw.kubeClient, hw.log, PausedAsReady(true)) + return hw.waitForResources(resources, timeout) } -func (w *HelmWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { - w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true), CheckJobs(true)) - return w.waitForResources(resources, timeout) +func (hw *HelmWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { + hw.c = NewReadyChecker(hw.kubeClient, hw.log, PausedAsReady(true), CheckJobs(true)) + return hw.waitForResources(resources, timeout) } // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached -func (w *HelmWaiter) waitForResources(created ResourceList, timeout time.Duration) error { - w.log("beginning wait for %d resources with timeout of %v", len(created), timeout) +func (hw *HelmWaiter) waitForResources(created ResourceList, timeout time.Duration) error { + hw.log("beginning wait for %d resources with timeout of %v", len(created), timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() @@ -81,15 +81,15 @@ func (w *HelmWaiter) waitForResources(created ResourceList, timeout time.Duratio return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) { waitRetries := 30 for i, v := range created { - ready, err := w.c.IsReady(ctx, v) + ready, err := hw.c.IsReady(ctx, v) - if waitRetries > 0 && w.isRetryableError(err, v) { + if waitRetries > 0 && hw.isRetryableError(err, v) { numberOfErrors[i]++ if numberOfErrors[i] > waitRetries { - w.log("Max number of retries reached") + hw.log("Max number of retries reached") return false, err } - w.log("Retrying as current number of retries %d less than max number of retries %d", numberOfErrors[i]-1, waitRetries) + hw.log("Retrying as current number of retries %d less than max number of retries %d", numberOfErrors[i]-1, waitRetries) return false, nil } numberOfErrors[i] = 0 @@ -101,28 +101,28 @@ func (w *HelmWaiter) waitForResources(created ResourceList, timeout time.Duratio }) } -func (w *HelmWaiter) isRetryableError(err error, resource *resource.Info) bool { +func (hw *HelmWaiter) isRetryableError(err error, resource *resource.Info) bool { if err == nil { return false } - w.log("Error received when checking status of resource %s. Error: '%s', Resource details: '%s'", resource.Name, err, resource) + hw.log("Error received when checking status of resource %s. Error: '%s', Resource details: '%s'", resource.Name, err, resource) if ev, ok := err.(*apierrors.StatusError); ok { statusCode := ev.Status().Code - retryable := w.isRetryableHTTPStatusCode(statusCode) - w.log("Status code received: %d. Retryable error? %t", statusCode, retryable) + retryable := hw.isRetryableHTTPStatusCode(statusCode) + hw.log("Status code received: %d. Retryable error? %t", statusCode, retryable) return retryable } - w.log("Retryable error? %t", true) + hw.log("Retryable error? %t", true) return true } -func (w *HelmWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { +func (hw *HelmWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { return httpStatusCode == 0 || httpStatusCode == http.StatusTooManyRequests || (httpStatusCode >= 500 && httpStatusCode != http.StatusNotImplemented) } // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached -func (w *HelmWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { - w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), timeout) +func (hw *HelmWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { + hw.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() @@ -314,7 +314,7 @@ func (hw *HelmWaiter) waitForJob(obj runtime.Object, name string) (bool, error) // waitForPodSuccess is a helper that waits for a pod to complete. // // This operates on an event returned from a watcher. -func (c *HelmWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { +func (hw *HelmWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { o, ok := obj.(*v1.Pod) if !ok { return true, errors.Errorf("expected %s to be a *v1.Pod, got %T", name, obj) @@ -322,14 +322,14 @@ func (c *HelmWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, e switch o.Status.Phase { case v1.PodSucceeded: - c.log("Pod %s succeeded", o.Name) + hw.log("Pod %s succeeded", o.Name) return true, nil case v1.PodFailed: return true, errors.Errorf("pod %s failed", o.Name) case v1.PodPending: - c.log("Pod %s pending", o.Name) + hw.log("Pod %s pending", o.Name) case v1.PodRunning: - c.log("Pod %s running", o.Name) + hw.log("Pod %s running", o.Name) } return false, nil From bd3b5ee5d05391a63ced7c32cba05caa62c8d968 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 10 Feb 2025 15:51:14 +0000 Subject: [PATCH 095/271] comment Signed-off-by: Austin Abro --- pkg/kube/interface.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 0e6da1094..7af8ebca6 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -70,7 +70,6 @@ type Waiter interface { // For Pods, "ready" means the Pod phase is marked "succeeded". // For all other kinds, it means the kind was created or modified without // error. - // TODO: Is watch until ready really behavior we want over the resources actually being ready? WatchUntilReady(resources ResourceList, timeout time.Duration) error } From 9498994ab5ce6676bc02f0c6931cb9afcd9ba1da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 21:15:38 +0000 Subject: [PATCH 096/271] build(deps): bump golangci/golangci-lint-action from 6.3.0 to 6.3.2 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.3.0 to 6.3.2. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/e60da84bfae8c7920a47be973d75e15710aa8bd7...051d91933864810ecd5e2ea2cfd98f6a5bca5347) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 99481d611..914af6a0a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,6 @@ jobs: go-version: '1.23' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@e60da84bfae8c7920a47be973d75e15710aa8bd7 #pin@6.3.0 + uses: golangci/golangci-lint-action@051d91933864810ecd5e2ea2cfd98f6a5bca5347 #pin@6.3.2 with: version: v1.62 From 8b8cc948224875091d0939216c0bdcc337a58602 Mon Sep 17 00:00:00 2001 From: wangjingcun Date: Tue, 11 Feb 2025 23:20:27 +0800 Subject: [PATCH 097/271] Use a more direct and less error-prone return value Signed-off-by: wangjingcun --- pkg/cli/values/options.go | 2 +- pkg/kube/roundtripper.go | 8 ++++---- pkg/plugin/installer/vcs_installer.go | 2 +- pkg/provenance/sign_test.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index 24c47ecba..0710d5b86 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -143,5 +143,5 @@ func readFile(filePath string, p getter.Providers) ([]byte, error) { if err != nil { return nil, err } - return data.Bytes(), err + return data.Bytes(), nil } diff --git a/pkg/kube/roundtripper.go b/pkg/kube/roundtripper.go index fdb103529..551d3009b 100644 --- a/pkg/kube/roundtripper.go +++ b/pkg/kube/roundtripper.go @@ -49,7 +49,7 @@ func (rt *RetryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp b, err := io.ReadAll(resp.Body) resp.Body.Close() if err != nil { - return resp, rtErr + return resp, err } var ke kubernetesError @@ -58,10 +58,10 @@ func (rt *RetryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp r.Seek(0, io.SeekStart) resp.Body = io.NopCloser(r) if err != nil { - return resp, rtErr + return resp, nil } if ke.Code < 500 { - return resp, rtErr + return resp, nil } // Matches messages like "etcdserver: leader changed" if strings.HasSuffix(ke.Message, "etcdserver: leader changed") { @@ -71,7 +71,7 @@ func (rt *RetryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp if strings.HasSuffix(ke.Message, "raft proposal dropped") { return rt.roundTrip(req, retry-1, resp) } - return resp, rtErr + return resp, nil } type kubernetesError struct { diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 8153550b2..3967e46cd 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -63,7 +63,7 @@ func NewVCSInstaller(source, version string) (*VCSInstaller, error) { Version: version, base: newBase(source), } - return i, err + return i, nil } // Install clones a remote repository and installs into the plugin directory. diff --git a/pkg/provenance/sign_test.go b/pkg/provenance/sign_test.go index bf6848368..69a6dad5b 100644 --- a/pkg/provenance/sign_test.go +++ b/pkg/provenance/sign_test.go @@ -34,7 +34,7 @@ const ( // phrase. Use `gpg --export-secret-keys helm-test` to export the secret. testKeyfile = "testdata/helm-test-key.secret" - // testPasswordKeyFile is a keyfile with a password. + // testPasswordKeyfile is a keyfile with a password. testPasswordKeyfile = "testdata/helm-password-key.secret" // testPubfile is the public key file. From 9097b7eacc3b0fc7826b937612a9cd085ffcf08b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 21:42:41 +0000 Subject: [PATCH 098/271] build(deps): bump github.com/distribution/distribution/v3 Bumps [github.com/distribution/distribution/v3](https://github.com/distribution/distribution) from 3.0.0-rc.2 to 3.0.0-rc.3. - [Release notes](https://github.com/distribution/distribution/releases) - [Commits](https://github.com/distribution/distribution/compare/v3.0.0-rc.2...v3.0.0-rc.3) --- updated-dependencies: - dependency-name: github.com/distribution/distribution/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f89eb4ce8..a68148c79 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 github.com/containerd/containerd v1.7.25 github.com/cyphar/filepath-securejoin v0.4.1 - github.com/distribution/distribution/v3 v3.0.0-rc.2 + github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/evanphx/json-patch v5.9.11+incompatible github.com/foxcpp/go-mockdns v1.1.0 github.com/gobwas/glob v0.2.3 diff --git a/go.sum b/go.sum index a811b14cc..ea2d733e8 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/distribution/distribution/v3 v3.0.0-rc.2 h1:tTrzntanYMbd20SyvdeR83Ya1l/aBwDcA3NCIpmwemc= -github.com/distribution/distribution/v3 v3.0.0-rc.2/go.mod h1:H2zIRRXS20ylnv2HTuKILAWuANjuA60GB7MLOsQag7Y= +github.com/distribution/distribution/v3 v3.0.0-rc.3 h1:JRJso9IVLoooKX76oWR+DWCCdZlK5m4nRtDWvzB1ITg= +github.com/distribution/distribution/v3 v3.0.0-rc.3/go.mod h1:offoOgrnYs+CFwis8nE0hyzYZqRCZj5EFc5kgfszwiE= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= From 653eec1da31bf3bf7621a29234c2735d0ab06076 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 12 Feb 2025 15:35:10 -0500 Subject: [PATCH 099/271] adding-my-key Signed-off-by: Robert Sirchia --- KEYS | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/KEYS b/KEYS index f14c596c7..e772fff40 100644 --- a/KEYS +++ b/KEYS @@ -1037,3 +1037,24 @@ nk38BkgHg3LHjCbCNEVkSK2TMT69A58iwpY9WUQlphsiz4WBpafSPbv/jSlsm7uK TNWtbFGBRpJyEg== =w141 -----END PGP PUBLIC KEY BLOCK----- +pub ed25519 2024-07-09 [SC] + 7FEC81FACC7FFB2A010ADD13C2D40F4D8196E874 +uid [ultimate] Robert Sirchia (I like turtles.) +sig 3 C2D40F4D8196E874 2024-07-09 [self-signature] +sub cv25519 2024-07-09 [E] +sig C2D40F4D8196E874 2024-07-09 [self-signature] + +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEZo2C6xYJKwYBBAHaRw8BAQdA8kCWaI+FlCabcTw8EVeiMkokyWDalgl/Inbn +ACcGN1e0N1JvYmVydCBTaXJjaGlhIChJIGxpa2UgdHVydGxlcy4pIDxyc2lyY2hp +YUBvdXRsb29rLmNvbT6IkwQTFgoAOxYhBH/sgfrMf/sqAQrdE8LUD02Bluh0BQJm +jYLrAhsDBQsJCAcCAiICBhUKCQgLAgQWAgMBAh4HAheAAAoJEMLUD02Bluh0dyYA +/i7RB6m3MXNA8ei7GD8uQVpLfCRgEFsqSS/AzAOu8NGhAQCbw1kWL3AUll7KKtiQ +UE96nhCk+HnkQeVkWYS+MZ1tALg4BGaNgusSCisGAQQBl1UBBQEBB0CCA6Au4krL +YinQq9aAs29fFeRu/ye3PqQuz5jZ2r1ScAMBCAeIeAQYFgoAIBYhBH/sgfrMf/sq +AQrdE8LUD02Bluh0BQJmjYLrAhsMAAoJEMLUD02Bluh0KH4BAMSwEIGkoQl10LN3 +K6V08VpFmniENmCDHshXYq0gGiTDAP9FsXl2UtmFU5xuYxH4fRKIxgmxJRAFMWI8 +u3Rdu/s+DQ== +=smBO +-----END PGP PUBLIC KEY BLOCK----- From 8eb615d37604294611d2fe4a3f39aa433d6fb7e9 Mon Sep 17 00:00:00 2001 From: Eimhin Laverty Date: Thu, 13 Feb 2025 17:23:43 +0100 Subject: [PATCH 100/271] Update version option description with more accurate info Signed-off-by: Eimhin Laverty --- scripts/get-helm-3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 index 5f19bd3fa..3aa44daee 100755 --- a/scripts/get-helm-3 +++ b/scripts/get-helm-3 @@ -279,7 +279,7 @@ testVersion() { help () { echo "Accepted cli arguments are:" echo -e "\t[--help|-h ] ->> prints this help" - echo -e "\t[--version|-v ] . When not defined it fetches the latest release from GitHub" + echo -e "\t[--version|-v ] . When not defined it fetches the latest release tag from the Helm CDN" echo -e "\te.g. --version v3.0.0 or -v canary" echo -e "\t[--no-sudo] ->> install without sudo" } From 5b940c026d717aa553cf590a1c4032e01c231fad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 22:01:53 +0000 Subject: [PATCH 101/271] build(deps): bump the k8s-io group with 7 updates Bumps the k8s-io group with 7 updates: | Package | From | To | | --- | --- | --- | | [k8s.io/api](https://github.com/kubernetes/api) | `0.32.1` | `0.32.2` | | [k8s.io/apiextensions-apiserver](https://github.com/kubernetes/apiextensions-apiserver) | `0.32.1` | `0.32.2` | | [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) | `0.32.1` | `0.32.2` | | [k8s.io/apiserver](https://github.com/kubernetes/apiserver) | `0.32.1` | `0.32.2` | | [k8s.io/cli-runtime](https://github.com/kubernetes/cli-runtime) | `0.32.1` | `0.32.2` | | [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.32.1` | `0.32.2` | | [k8s.io/kubectl](https://github.com/kubernetes/kubectl) | `0.32.1` | `0.32.2` | Updates `k8s.io/api` from 0.32.1 to 0.32.2 - [Commits](https://github.com/kubernetes/api/compare/v0.32.1...v0.32.2) Updates `k8s.io/apiextensions-apiserver` from 0.32.1 to 0.32.2 - [Release notes](https://github.com/kubernetes/apiextensions-apiserver/releases) - [Commits](https://github.com/kubernetes/apiextensions-apiserver/compare/v0.32.1...v0.32.2) Updates `k8s.io/apimachinery` from 0.32.1 to 0.32.2 - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.32.1...v0.32.2) Updates `k8s.io/apiserver` from 0.32.1 to 0.32.2 - [Commits](https://github.com/kubernetes/apiserver/compare/v0.32.1...v0.32.2) Updates `k8s.io/cli-runtime` from 0.32.1 to 0.32.2 - [Commits](https://github.com/kubernetes/cli-runtime/compare/v0.32.1...v0.32.2) Updates `k8s.io/client-go` from 0.32.1 to 0.32.2 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.32.1...v0.32.2) Updates `k8s.io/kubectl` from 0.32.1 to 0.32.2 - [Commits](https://github.com/kubernetes/kubectl/compare/v0.32.1...v0.32.2) --- updated-dependencies: - dependency-name: k8s.io/api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/apiextensions-apiserver dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/apiserver dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/cli-runtime dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/kubectl dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io ... Signed-off-by: dependabot[bot] --- go.mod | 16 ++++++++-------- go.sum | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index d4bb5755d..f3a8265b6 100644 --- a/go.mod +++ b/go.mod @@ -36,14 +36,14 @@ require ( golang.org/x/crypto v0.33.0 golang.org/x/term v0.29.0 golang.org/x/text v0.22.0 - k8s.io/api v0.32.1 - k8s.io/apiextensions-apiserver v0.32.1 - k8s.io/apimachinery v0.32.1 - k8s.io/apiserver v0.32.1 - k8s.io/cli-runtime v0.32.1 - k8s.io/client-go v0.32.1 + k8s.io/api v0.32.2 + k8s.io/apiextensions-apiserver v0.32.2 + k8s.io/apimachinery v0.32.2 + k8s.io/apiserver v0.32.2 + k8s.io/cli-runtime v0.32.2 + k8s.io/client-go v0.32.2 k8s.io/klog/v2 v2.130.1 - k8s.io/kubectl v0.32.1 + k8s.io/kubectl v0.32.2 oras.land/oras-go/v2 v2.5.0 sigs.k8s.io/yaml v1.4.0 ) @@ -174,7 +174,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/component-base v0.32.1 // indirect + k8s.io/component-base v0.32.2 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect diff --git a/go.sum b/go.sum index 4eaeeaf3a..25a825e86 100644 --- a/go.sum +++ b/go.sum @@ -519,26 +519,26 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc= -k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k= -k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw= -k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto= -k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs= -k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= -k8s.io/apiserver v0.32.1 h1:oo0OozRos66WFq87Zc5tclUX2r0mymoVHRq8JmR7Aak= -k8s.io/apiserver v0.32.1/go.mod h1:UcB9tWjBY7aryeI5zAgzVJB/6k7E97bkr1RgqDz0jPw= -k8s.io/cli-runtime v0.32.1 h1:19nwZPlYGJPUDbhAxDIS2/oydCikvKMHsxroKNGA2mM= -k8s.io/cli-runtime v0.32.1/go.mod h1:NJPbeadVFnV2E7B7vF+FvU09mpwYlZCu8PqjzfuOnkY= -k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU= -k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg= -k8s.io/component-base v0.32.1 h1:/5IfJ0dHIKBWysGV0yKTFfacZ5yNV1sulPh3ilJjRZk= -k8s.io/component-base v0.32.1/go.mod h1:j1iMMHi/sqAHeG5z+O9BFNCF698a1u0186zkjMZQ28w= +k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw= +k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y= +k8s.io/apiextensions-apiserver v0.32.2 h1:2YMk285jWMk2188V2AERy5yDwBYrjgWYggscghPCvV4= +k8s.io/apiextensions-apiserver v0.32.2/go.mod h1:GPwf8sph7YlJT3H6aKUWtd0E+oyShk/YHWQHf/OOgCA= +k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ= +k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= +k8s.io/apiserver v0.32.2 h1:WzyxAu4mvLkQxwD9hGa4ZfExo3yZZaYzoYvvVDlM6vw= +k8s.io/apiserver v0.32.2/go.mod h1:PEwREHiHNU2oFdte7BjzA1ZyjWjuckORLIK/wLV5goM= +k8s.io/cli-runtime v0.32.2 h1:aKQR4foh9qeyckKRkNXUccP9moxzffyndZAvr+IXMks= +k8s.io/cli-runtime v0.32.2/go.mod h1:a/JpeMztz3xDa7GCyyShcwe55p8pbcCVQxvqZnIwXN8= +k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA= +k8s.io/client-go v0.32.2/go.mod h1:fpZ4oJXclZ3r2nDOv+Ux3XcJutfrwjKTCHz2H3sww94= +k8s.io/component-base v0.32.2 h1:1aUL5Vdmu7qNo4ZsE+569PV5zFatM9hl+lb3dEea2zU= +k8s.io/component-base v0.32.2/go.mod h1:PXJ61Vx9Lg+P5mS8TLd7bCIr+eMJRQTyXe8KvkrvJq0= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= -k8s.io/kubectl v0.32.1 h1:/btLtXLQUU1rWx8AEvX9jrb9LaI6yeezt3sFALhB8M8= -k8s.io/kubectl v0.32.1/go.mod h1:sezNuyWi1STk4ZNPVRIFfgjqMI6XMf+oCVLjZen/pFQ= +k8s.io/kubectl v0.32.2 h1:TAkag6+XfSBgkqK9I7ZvwtF0WVtUAvK8ZqTt+5zi1Us= +k8s.io/kubectl v0.32.2/go.mod h1:+h/NQFSPxiDZYX/WZaWw9fwYezGLISP0ud8nQKg+3g8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= From 2b03c527f19f47039116143417d0e58422b3e789 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 16 Feb 2025 20:38:28 +0000 Subject: [PATCH 102/271] set command line flags Signed-off-by: Austin Abro --- cmd/helm/flags.go | 44 ++++++++++++++++++++++++++++++++++++++ cmd/helm/install.go | 4 ++-- cmd/helm/rollback.go | 2 +- cmd/helm/upgrade.go | 2 +- pkg/action/action.go | 2 +- pkg/action/install.go | 14 +++++++++--- pkg/action/install_test.go | 7 +++--- pkg/action/rollback.go | 9 ++++++-- pkg/action/upgrade.go | 20 ++++++++++++----- pkg/action/upgrade_test.go | 11 +++++----- pkg/kube/client.go | 8 +++---- pkg/kube/client_test.go | 4 ++-- 12 files changed, 98 insertions(+), 29 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 3d159babd..c2e5e295d 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -32,6 +32,7 @@ import ( "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/helmpath" + "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/repo" ) @@ -51,6 +52,49 @@ func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { f.StringArrayVar(&v.LiteralValues, "set-literal", []string{}, "set a literal STRING value on the command line") } +func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) { + cmd.Flags().Var( + newWaitValue(wait), + "wait", + "if set, will wait until all resources are in the expected state before marking the operation as successful. It will wait for as long as --timeout. Options are (true, false, watcher, and legacy)", + ) + // Sets the strategy to use the watcher strategy if `--wait` is used without an argument + cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy) +} + +type waitValue kube.WaitStrategy + +func newWaitValue(ws *kube.WaitStrategy) *waitValue { + return (*waitValue)(ws) +} + +func (ws *waitValue) String() string { + if ws == nil { + return "" + } + return string(*ws) +} + +func (ws *waitValue) Set(s string) error { + switch s { + case string(kube.StatusWatcherStrategy), string(kube.LegacyWaiterStrategy): + *ws = waitValue(s) + return nil + case "true": + *ws = waitValue(kube.StatusWatcherStrategy) + return nil + case "false": + *ws = "" + return nil + default: + return fmt.Errorf("invalid wait input %q. Valid inputs are true, false, %s, and %s", s, kube.StatusWatcherStrategy, kube.LegacyWaiterStrategy) + } +} + +func (ws *waitValue) Type() string { + return "WaitStrategy" +} + 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") diff --git a/cmd/helm/install.go b/cmd/helm/install.go index ec651140c..16545b6ae 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -190,8 +190,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&client.Replace, "replace", false, "reuse 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.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") 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") @@ -209,6 +208,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal f.BoolVar(&client.TakeOwnership, "take-ownership", false, "if set, install will ignore the check for helm annotations and take ownership of the existing resources") addValueOptionsFlags(f, valueOpts) addChartPathOptionsFlags(f, &client.ChartPathOptions) + AddWaitFlag(cmd, &client.Wait) err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { requiredArgs := 2 diff --git a/cmd/helm/rollback.go b/cmd/helm/rollback.go index a65f30a1f..83d3089e2 100644 --- a/cmd/helm/rollback.go +++ b/cmd/helm/rollback.go @@ -81,10 +81,10 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 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") + AddWaitFlag(cmd, &client.Wait) return cmd } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 7b4267894..e5e485eae 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -278,7 +278,6 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 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.ResetThenReuseValues, "reset-then-reuse-values", false, "when upgrading, reset the values to the ones built into the chart, apply the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' or '--reuse-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") @@ -295,6 +294,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { addValueOptionsFlags(f, valueOpts) bindOutputFlag(cmd, &outfmt) bindPostRenderFlag(cmd, &client.PostRenderer) + AddWaitFlag(cmd, &client.Wait) err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { if len(args) != 2 { diff --git a/pkg/action/action.go b/pkg/action/action.go index 0157ce1cc..a2d7523a5 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -371,7 +371,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - kc, err := kube.New(getter, kube.StatusWaiterStrategy) + kc, err := kube.New(getter, kube.StatusWatcherStrategy) if err != nil { return err } diff --git a/pkg/action/install.go b/pkg/action/install.go index ef3f0fdc7..61b5ebd33 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -79,7 +79,7 @@ type Install struct { HideSecret bool DisableHooks bool Replace bool - Wait bool + Wait kube.WaitStrategy WaitForJobs bool Devel bool DependencyUpdate bool @@ -157,6 +157,10 @@ func (i *Install) GetRegistryClient() *registry.Client { return i.ChartPathOptions.registryClient } +func (i *Install) shouldWait() bool { + return i.Wait != "" +} + func (i *Install) installCRDs(crds []chart.CRD) error { // We do these one file at a time in the order they were read. totalItems := []*resource.Info{} @@ -289,7 +293,11 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - i.Wait = i.Wait || i.Atomic + if !i.shouldWait() { + if i.Atomic { + i.Wait = "watcher" + } + } caps, err := i.cfg.getCapabilities() if err != nil { @@ -465,7 +473,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource return rel, err } - if i.Wait { + if i.shouldWait() { if i.WaitForJobs { err = i.cfg.KubeClient.WaitWithJobs(resources, i.Timeout) } else { diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 9f738f0bc..6377cfda5 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -34,6 +34,7 @@ import ( "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chartutil" + "helm.sh/helm/v4/pkg/kube" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" "helm.sh/helm/v4/pkg/storage/driver" @@ -407,7 +408,7 @@ func TestInstallRelease_Wait(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") instAction.cfg.KubeClient = failer - instAction.Wait = true + instAction.Wait = kube.StatusWatcherStrategy vals := map[string]interface{}{} goroutines := runtime.NumGoroutine() @@ -426,7 +427,7 @@ func TestInstallRelease_Wait_Interrupted(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitDuration = 10 * time.Second instAction.cfg.KubeClient = failer - instAction.Wait = true + instAction.Wait = kube.StatusWatcherStrategy vals := map[string]interface{}{} ctx, cancel := context.WithCancel(context.Background()) @@ -449,7 +450,7 @@ func TestInstallRelease_WaitForJobs(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") instAction.cfg.KubeClient = failer - instAction.Wait = true + instAction.Wait = kube.StatusWatcherStrategy instAction.WaitForJobs = true vals := map[string]interface{}{} diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 12dee35ce..8ec134832 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "helm.sh/helm/v4/pkg/chartutil" + "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) @@ -37,7 +38,7 @@ type Rollback struct { Version int Timeout time.Duration - Wait bool + Wait kube.WaitStrategy WaitForJobs bool DisableHooks bool DryRun bool @@ -89,6 +90,10 @@ func (r *Rollback) Run(name string) error { return nil } +func (r *Rollback) shouldWait() bool { + return !(r.Wait == "") +} + // prepareRollback finds the previous release and prepares a new release object with // the previous release's configuration func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Release, error) { @@ -223,7 +228,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas } } - if r.Wait { + if r.shouldWait() { if r.WaitForJobs { if err := r.cfg.KubeClient.WaitWithJobs(target, r.Timeout); err != nil { targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index f3e9a33bc..8d103ab6b 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -64,8 +64,8 @@ type Upgrade struct { SkipCRDs bool // Timeout is the timeout for this operation Timeout time.Duration - // Wait determines whether the wait operation should be performed after the upgrade is requested. - Wait bool + // Wait determines whether the wait operation should be performed and what type of wait. + Wait kube.WaitStrategy // WaitForJobs determines whether the wait operation for the Jobs should be performed after the upgrade is requested. WaitForJobs bool // DisableHooks disables hook processing if set to true. @@ -155,7 +155,11 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - u.Wait = u.Wait || u.Atomic + if !u.shouldWait() { + if u.Atomic { + u.Wait = kube.StatusWatcherStrategy + } + } if err := chartutil.ValidateReleaseName(name); err != nil { return nil, errors.Errorf("release name is invalid: %s", name) @@ -186,6 +190,10 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. return res, nil } +func (u *Upgrade) shouldWait() bool { + return u.Wait != "" +} + // isDryRun returns true if Upgrade is set to run as a DryRun func (u *Upgrade) isDryRun() bool { if u.DryRun || u.DryRunOption == "client" || u.DryRunOption == "server" || u.DryRunOption == "true" { @@ -443,7 +451,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele } } - if u.Wait { + if u.shouldWait() { u.cfg.Log( "waiting for release %s resources (created: %d updated: %d deleted: %d)", upgradedRelease.Name, len(results.Created), len(results.Updated), len(results.Deleted)) @@ -526,7 +534,9 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e rollin := NewRollback(u.cfg) rollin.Version = filteredHistory[0].Version - rollin.Wait = true + if !u.shouldWait() { + rollin.Wait = kube.StatusWatcherStrategy + } rollin.WaitForJobs = u.WaitForJobs rollin.DisableHooks = u.DisableHooks rollin.Recreate = u.Recreate diff --git a/pkg/action/upgrade_test.go b/pkg/action/upgrade_test.go index 5437490cb..93c54560a 100644 --- a/pkg/action/upgrade_test.go +++ b/pkg/action/upgrade_test.go @@ -24,6 +24,7 @@ import ( "time" "helm.sh/helm/v4/pkg/chart" + "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/storage/driver" "github.com/stretchr/testify/assert" @@ -52,7 +53,7 @@ func TestUpgradeRelease_Success(t *testing.T) { rel.Info.Status = release.StatusDeployed req.NoError(upAction.cfg.Releases.Create(rel)) - upAction.Wait = true + upAction.Wait = kube.StatusWatcherStrategy vals := map[string]interface{}{} ctx, done := context.WithCancel(context.Background()) @@ -82,7 +83,7 @@ func TestUpgradeRelease_Wait(t *testing.T) { failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") upAction.cfg.KubeClient = failer - upAction.Wait = true + upAction.Wait = kube.StatusWatcherStrategy vals := map[string]interface{}{} res, err := upAction.Run(rel.Name, buildChart(), vals) @@ -104,7 +105,7 @@ func TestUpgradeRelease_WaitForJobs(t *testing.T) { failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") upAction.cfg.KubeClient = failer - upAction.Wait = true + upAction.Wait = kube.StatusWatcherStrategy upAction.WaitForJobs = true vals := map[string]interface{}{} @@ -128,7 +129,7 @@ func TestUpgradeRelease_CleanupOnFail(t *testing.T) { failer.WaitError = fmt.Errorf("I timed out") failer.DeleteError = fmt.Errorf("I tried to delete nil") upAction.cfg.KubeClient = failer - upAction.Wait = true + upAction.Wait = kube.StatusWatcherStrategy upAction.CleanupOnFail = true vals := map[string]interface{}{} @@ -395,7 +396,7 @@ func TestUpgradeRelease_Interrupted_Wait(t *testing.T) { failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitDuration = 10 * time.Second upAction.cfg.KubeClient = failer - upAction.Wait = true + upAction.Wait = kube.StatusWatcherStrategy vals := map[string]interface{}{} ctx := context.Background() diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 8dca1c51b..ba7794ac4 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -80,11 +80,11 @@ type Client struct { Waiter } -type WaitStrategy int +type WaitStrategy string const ( - StatusWaiterStrategy WaitStrategy = iota - LegacyWaiterStrategy + StatusWatcherStrategy WaitStrategy = "watcher" + LegacyWaiterStrategy WaitStrategy = "legacy" ) func init() { @@ -106,7 +106,7 @@ func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { return nil, err } return &HelmWaiter{kubeClient: kc, log: c.Log}, nil - case StatusWaiterStrategy: + case StatusWatcherStrategy: cfg, err := c.Factory.ToRESTConfig() if err != nil { return nil, err diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index cdf75938e..4c8719f98 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -659,7 +659,7 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c, err := New(nil, StatusWaiterStrategy) + c, err := New(nil, StatusWatcherStrategy) if err != nil { t.Fatal(err) } @@ -672,7 +672,7 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c, err = New(nil, StatusWaiterStrategy) + c, err = New(nil, StatusWatcherStrategy) if err != nil { t.Fatal(err) } From f2dd2c91093eeecff6747f9c85a9757ccb6d4b80 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 16 Feb 2025 21:10:06 +0000 Subject: [PATCH 103/271] add hook only waiter Signed-off-by: Austin Abro --- cmd/helm/flags.go | 9 ++++--- cmd/helm/install.go | 2 +- cmd/helm/uninstall.go | 2 +- cmd/helm/upgrade.go | 2 +- pkg/action/install.go | 20 +++++++------- pkg/action/rollback.go | 28 +++++++++----------- pkg/action/uninstall.go | 8 +++--- pkg/action/uninstall_test.go | 5 ++-- pkg/action/upgrade.go | 35 +++++++++---------------- pkg/kube/client.go | 51 ++++++++++++++++++++++-------------- pkg/kube/client_test.go | 6 ++--- pkg/kube/statuswait.go | 20 ++++++++++++++ 12 files changed, 103 insertions(+), 85 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index c2e5e295d..d1f0fec58 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -54,7 +54,7 @@ func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) { cmd.Flags().Var( - newWaitValue(wait), + newWaitValue(kube.HookOnlyStrategy, wait), "wait", "if set, will wait until all resources are in the expected state before marking the operation as successful. It will wait for as long as --timeout. Options are (true, false, watcher, and legacy)", ) @@ -64,7 +64,8 @@ func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) { type waitValue kube.WaitStrategy -func newWaitValue(ws *kube.WaitStrategy) *waitValue { +func newWaitValue(defaultValue kube.WaitStrategy, ws *kube.WaitStrategy) *waitValue { + *ws = defaultValue return (*waitValue)(ws) } @@ -77,7 +78,7 @@ func (ws *waitValue) String() string { func (ws *waitValue) Set(s string) error { switch s { - case string(kube.StatusWatcherStrategy), string(kube.LegacyWaiterStrategy): + case string(kube.StatusWatcherStrategy), string(kube.LegacyStrategy): *ws = waitValue(s) return nil case "true": @@ -87,7 +88,7 @@ func (ws *waitValue) Set(s string) error { *ws = "" return nil default: - return fmt.Errorf("invalid wait input %q. Valid inputs are true, false, %s, and %s", s, kube.StatusWatcherStrategy, kube.LegacyWaiterStrategy) + return fmt.Errorf("invalid wait input %q. Valid inputs are true, false, %s, and %s", s, kube.StatusWatcherStrategy, kube.LegacyStrategy) } } diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 16545b6ae..649c5c8b8 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -198,7 +198,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal 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.Atomic, "atomic", false, "if set, the installation process deletes the installation on failure. The --wait flag will be set automatically to \"watcher\" if --atomic is used") f.BoolVar(&client.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed. By default, CRDs are installed if not already present") f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent") f.BoolVar(&client.SkipSchemaValidation, "skip-schema-validation", false, "if set, disables JSON schema validation") diff --git a/cmd/helm/uninstall.go b/cmd/helm/uninstall.go index 9c5e25c87..3504fd322 100644 --- a/cmd/helm/uninstall.go +++ b/cmd/helm/uninstall.go @@ -76,10 +76,10 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") f.BoolVar(&client.IgnoreNotFound, "ignore-not-found", false, `Treat "release not found" as a successful uninstall`) 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.StringVar(&client.DeletionPropagation, "cascade", "background", "Must be \"background\", \"orphan\", or \"foreground\". Selects the deletion cascading strategy for the dependents. Defaults to background.") 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") + AddWaitFlag(cmd, &client.Wait) return cmd } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index e5e485eae..092f6bdcc 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -279,7 +279,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 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.ResetThenReuseValues, "reset-then-reuse-values", false, "when upgrading, reset the values to the ones built into the chart, apply the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' or '--reuse-values' is specified, this is ignored") 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.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 to \"watcher\" 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") diff --git a/pkg/action/install.go b/pkg/action/install.go index 61b5ebd33..a12dee11d 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -293,9 +293,9 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - if !i.shouldWait() { + if i.Wait == kube.HookOnlyStrategy { if i.Atomic { - i.Wait = "watcher" + i.Wait = kube.StatusWatcherStrategy } } @@ -473,15 +473,13 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource return rel, err } - if i.shouldWait() { - if i.WaitForJobs { - err = i.cfg.KubeClient.WaitWithJobs(resources, i.Timeout) - } else { - err = i.cfg.KubeClient.Wait(resources, i.Timeout) - } - if err != nil { - return rel, err - } + if i.WaitForJobs { + err = i.cfg.KubeClient.WaitWithJobs(resources, i.Timeout) + } else { + err = i.cfg.KubeClient.Wait(resources, i.Timeout) + } + if err != nil { + return rel, err } if !i.DisableHooks { diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 8ec134832..8cb8b4ed4 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -228,21 +228,19 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas } } - if r.shouldWait() { - if r.WaitForJobs { - if err := r.cfg.KubeClient.WaitWithJobs(target, r.Timeout); err != nil { - targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) - r.cfg.recordRelease(currentRelease) - r.cfg.recordRelease(targetRelease) - return targetRelease, errors.Wrapf(err, "release %s failed", targetRelease.Name) - } - } else { - if err := r.cfg.KubeClient.Wait(target, r.Timeout); err != nil { - targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) - r.cfg.recordRelease(currentRelease) - r.cfg.recordRelease(targetRelease) - return targetRelease, errors.Wrapf(err, "release %s failed", targetRelease.Name) - } + if r.WaitForJobs { + if err := r.cfg.KubeClient.WaitWithJobs(target, r.Timeout); err != nil { + targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) + r.cfg.recordRelease(currentRelease) + r.cfg.recordRelease(targetRelease) + return targetRelease, errors.Wrapf(err, "release %s failed", targetRelease.Name) + } + } else { + if err := r.cfg.KubeClient.Wait(target, r.Timeout); err != nil { + targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) + r.cfg.recordRelease(currentRelease) + r.cfg.recordRelease(targetRelease) + return targetRelease, errors.Wrapf(err, "release %s failed", targetRelease.Name) } } diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 75d999976..0a03f2180 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -41,7 +41,7 @@ type Uninstall struct { DryRun bool IgnoreNotFound bool KeepHistory bool - Wait bool + Wait kube.WaitStrategy DeletionPropagation string Timeout time.Duration Description string @@ -130,10 +130,8 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } res.Info = kept - if u.Wait { - if err := u.cfg.KubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil { - errs = append(errs, err) - } + if err := u.cfg.KubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil { + errs = append(errs, err) } if !u.DisableHooks { diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go index eca9e6ad8..1c67cab7f 100644 --- a/pkg/action/uninstall_test.go +++ b/pkg/action/uninstall_test.go @@ -22,6 +22,7 @@ import ( "github.com/stretchr/testify/assert" + "helm.sh/helm/v4/pkg/kube" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" ) @@ -82,7 +83,7 @@ func TestUninstallRelease_Wait(t *testing.T) { unAction := uninstallAction(t) unAction.DisableHooks = true unAction.DryRun = false - unAction.Wait = true + unAction.Wait = kube.StatusWatcherStrategy rel := releaseStub() rel.Name = "come-fail-away" @@ -113,7 +114,7 @@ func TestUninstallRelease_Cascade(t *testing.T) { unAction := uninstallAction(t) unAction.DisableHooks = true unAction.DryRun = false - unAction.Wait = false + unAction.Wait = kube.HookOnlyStrategy unAction.DeletionPropagation = "foreground" rel := releaseStub() diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 8d103ab6b..671426a27 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -155,7 +155,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - if !u.shouldWait() { + if u.Wait == kube.HookOnlyStrategy { if u.Atomic { u.Wait = kube.StatusWatcherStrategy } @@ -190,10 +190,6 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. return res, nil } -func (u *Upgrade) shouldWait() bool { - return u.Wait != "" -} - // isDryRun returns true if Upgrade is set to run as a DryRun func (u *Upgrade) isDryRun() bool { if u.DryRun || u.DryRunOption == "client" || u.DryRunOption == "server" || u.DryRunOption == "true" { @@ -451,22 +447,17 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele } } - if u.shouldWait() { - u.cfg.Log( - "waiting for release %s resources (created: %d updated: %d deleted: %d)", - upgradedRelease.Name, len(results.Created), len(results.Updated), len(results.Deleted)) - if u.WaitForJobs { - if err := u.cfg.KubeClient.WaitWithJobs(target, u.Timeout); err != nil { - u.cfg.recordRelease(originalRelease) - u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) - return - } - } else { - if err := u.cfg.KubeClient.Wait(target, u.Timeout); err != nil { - u.cfg.recordRelease(originalRelease) - u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) - return - } + if u.WaitForJobs { + if err := u.cfg.KubeClient.WaitWithJobs(target, u.Timeout); err != nil { + u.cfg.recordRelease(originalRelease) + u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) + return + } + } else { + if err := u.cfg.KubeClient.Wait(target, u.Timeout); err != nil { + u.cfg.recordRelease(originalRelease) + u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) + return } } @@ -534,7 +525,7 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e rollin := NewRollback(u.cfg) rollin.Version = filteredHistory[0].Version - if !u.shouldWait() { + if u.Wait == kube.HookOnlyStrategy { rollin.Wait = kube.StatusWatcherStrategy } rollin.WaitForJobs = u.WaitForJobs diff --git a/pkg/kube/client.go b/pkg/kube/client.go index ba7794ac4..de28c3421 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -84,7 +84,8 @@ type WaitStrategy string const ( StatusWatcherStrategy WaitStrategy = "watcher" - LegacyWaiterStrategy WaitStrategy = "legacy" + LegacyStrategy WaitStrategy = "legacy" + HookOnlyStrategy WaitStrategy = "noop" ) func init() { @@ -98,36 +99,46 @@ func init() { } } +func (c *Client) newStatusWatcher() (*statusWaiter, error) { + cfg, err := c.Factory.ToRESTConfig() + if err != nil { + return nil, err + } + dynamicClient, err := c.Factory.DynamicClient() + if err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(cfg) + if err != nil { + return nil, err + } + restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) + if err != nil { + return nil, err + } + return &statusWaiter{ + restMapper: restMapper, + client: dynamicClient, + log: c.Log, + }, nil +} + func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { switch strategy { - case LegacyWaiterStrategy: + case LegacyStrategy: kc, err := c.Factory.KubernetesClientSet() if err != nil { return nil, err } return &HelmWaiter{kubeClient: kc, log: c.Log}, nil case StatusWatcherStrategy: - cfg, err := c.Factory.ToRESTConfig() - if err != nil { - return nil, err - } - dynamicClient, err := c.Factory.DynamicClient() - if err != nil { - return nil, err - } - httpClient, err := rest.HTTPClientFor(cfg) - if err != nil { - return nil, err - } - restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) + return c.newStatusWatcher() + case HookOnlyStrategy: + sw, err := c.newStatusWatcher() if err != nil { return nil, err } - return &statusWaiter{ - restMapper: restMapper, - client: dynamicClient, - log: c.Log, - }, nil + return &hookOnlyWaiter{sw: sw}, nil default: return nil, errors.New("unknown wait strategy") } diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 4c8719f98..8c8f89cdb 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -513,7 +513,7 @@ func TestWait(t *testing.T) { }), } var err error - c.Waiter, err = c.newWaiter(LegacyWaiterStrategy) + c.Waiter, err = c.newWaiter(LegacyStrategy) if err != nil { t.Fatal(err) } @@ -570,7 +570,7 @@ func TestWaitJob(t *testing.T) { }), } var err error - c.Waiter, err = c.newWaiter(LegacyWaiterStrategy) + c.Waiter, err = c.newWaiter(LegacyStrategy) if err != nil { t.Fatal(err) } @@ -629,7 +629,7 @@ func TestWaitDelete(t *testing.T) { }), } var err error - c.Waiter, err = c.newWaiter(LegacyWaiterStrategy) + c.Waiter, err = c.newWaiter(LegacyStrategy) if err != nil { t.Fatal(err) } diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 0729d0d1b..4a0dcd0d2 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -209,3 +209,23 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func } } } + +type hookOnlyWaiter struct { + sw *statusWaiter +} + +func (w *hookOnlyWaiter) WatchUntilReady(resourceList ResourceList, timeout time.Duration) error { + return w.sw.WatchUntilReady(resourceList, timeout) +} + +func (w *hookOnlyWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { + return nil +} + +func (w *hookOnlyWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { + return nil +} + +func (w *hookOnlyWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { + return nil +} From 978d5a33181c5f102a2d70e5b1a9f756e9e3dc61 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 16 Feb 2025 21:11:48 +0000 Subject: [PATCH 104/271] lint Signed-off-by: Austin Abro --- pkg/kube/wait.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 83b352201..a7e3a1c7e 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -27,10 +27,8 @@ import ( appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" - batch "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -294,15 +292,15 @@ func (hw *HelmWaiter) watchUntilReady(timeout time.Duration, info *resource.Info // // This operates on an event returned from a watcher. func (hw *HelmWaiter) waitForJob(obj runtime.Object, name string) (bool, error) { - o, ok := obj.(*batch.Job) + o, ok := obj.(*batchv1.Job) if !ok { return true, errors.Errorf("expected %s to be a *batch.Job, got %T", name, obj) } for _, c := range o.Status.Conditions { - if c.Type == batch.JobComplete && c.Status == "True" { + if c.Type == batchv1.JobComplete && c.Status == "True" { return true, nil - } else if c.Type == batch.JobFailed && c.Status == "True" { + } else if c.Type == batchv1.JobFailed && c.Status == "True" { return true, errors.Errorf("job %s failed: %s", name, c.Reason) } } @@ -315,20 +313,20 @@ func (hw *HelmWaiter) waitForJob(obj runtime.Object, name string) (bool, error) // // This operates on an event returned from a watcher. func (hw *HelmWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { - o, ok := obj.(*v1.Pod) + o, ok := obj.(*corev1.Pod) if !ok { return true, errors.Errorf("expected %s to be a *v1.Pod, got %T", name, obj) } switch o.Status.Phase { - case v1.PodSucceeded: + case corev1.PodSucceeded: hw.log("Pod %s succeeded", o.Name) return true, nil - case v1.PodFailed: + case corev1.PodFailed: return true, errors.Errorf("pod %s failed", o.Name) - case v1.PodPending: + case corev1.PodPending: hw.log("Pod %s pending", o.Name) - case v1.PodRunning: + case corev1.PodRunning: hw.log("Pod %s running", o.Name) } From 7fde4962a85fb58c09e5412a7114592ca27a3d6a Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Sun, 16 Feb 2025 21:33:15 +0000 Subject: [PATCH 105/271] set waiter in functions Signed-off-by: Austin Abro --- pkg/action/action.go | 2 +- pkg/action/install.go | 7 +++---- pkg/action/rollback.go | 8 ++++---- pkg/action/uninstall.go | 5 +++++ pkg/action/upgrade.go | 8 ++++++++ pkg/kube/client.go | 13 +++++++++++-- pkg/kube/client_test.go | 4 ++-- pkg/kube/fake/fake.go | 4 ++++ pkg/kube/fake/printer.go | 4 ++++ pkg/kube/interface.go | 2 ++ 10 files changed, 44 insertions(+), 13 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index a2d7523a5..d067c67ea 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -371,7 +371,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - kc, err := kube.New(getter, kube.StatusWatcherStrategy) + kc, err := kube.New(getter) if err != nil { return err } diff --git a/pkg/action/install.go b/pkg/action/install.go index a12dee11d..a589aaf04 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -157,10 +157,6 @@ func (i *Install) GetRegistryClient() *registry.Client { return i.ChartPathOptions.registryClient } -func (i *Install) shouldWait() bool { - return i.Wait != "" -} - func (i *Install) installCRDs(crds []chart.CRD) error { // We do these one file at a time in the order they were read. totalItems := []*resource.Info{} @@ -298,6 +294,9 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma i.Wait = kube.StatusWatcherStrategy } } + if err := i.cfg.KubeClient.SetWaiter(i.Wait); err != nil { + return nil, fmt.Errorf("failed to set kube client waiter: %w", err) + } caps, err := i.cfg.getCapabilities() if err != nil { diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 8cb8b4ed4..804bdbd58 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -61,6 +61,10 @@ func (r *Rollback) Run(name string) error { return err } + if err := r.cfg.KubeClient.SetWaiter(r.Wait); err != nil { + return fmt.Errorf("failed to set kube client waiter: %w", err) + } + r.cfg.Releases.MaxHistory = r.MaxHistory r.cfg.Log("preparing rollback of %s", name) @@ -90,10 +94,6 @@ func (r *Rollback) Run(name string) error { return nil } -func (r *Rollback) shouldWait() bool { - return !(r.Wait == "") -} - // prepareRollback finds the previous release and prepares a new release object with // the previous release's configuration func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Release, error) { diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 0a03f2180..f21551bbf 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -17,6 +17,7 @@ limitations under the License. package action import ( + "fmt" "strings" "time" @@ -60,6 +61,10 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) return nil, err } + if err := u.cfg.KubeClient.SetWaiter(u.Wait); err != nil { + return nil, fmt.Errorf("failed to set kube client waiter: %w", err) + } + if u.DryRun { // In the dry run case, just see if the release exists r, err := u.cfg.releaseContent(name, 0) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 671426a27..626c1e6ad 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -160,6 +160,9 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. u.Wait = kube.StatusWatcherStrategy } } + if err := u.cfg.KubeClient.SetWaiter(u.Wait); err != nil { + return nil, fmt.Errorf("failed to set kube client waiter: %w", err) + } if err := chartutil.ValidateReleaseName(name); err != nil { return nil, errors.Errorf("release name is invalid: %s", name) @@ -528,6 +531,11 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e if u.Wait == kube.HookOnlyStrategy { rollin.Wait = kube.StatusWatcherStrategy } + // TODO pretty sure this is unnecessary as the waiter is already set if atomic at the start of upgrade + werr := u.cfg.KubeClient.SetWaiter(u.Wait) + if werr != nil { + return rel, errors.Wrapf(herr, "an error occurred while creating the waiter. original upgrade error: %s", err) + } rollin.WaitForJobs = u.WaitForJobs rollin.DisableHooks = u.DisableHooks rollin.Recreate = u.Recreate diff --git a/pkg/kube/client.go b/pkg/kube/client.go index de28c3421..425152006 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -144,8 +144,17 @@ func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { } } +func (c *Client) SetWaiter(ws WaitStrategy) error { + var err error + c.Waiter, err = c.newWaiter(ws) + if err != nil { + return err + } + return nil +} + // New creates a new Client. -func New(getter genericclioptions.RESTClientGetter, ws WaitStrategy) (*Client, error) { +func New(getter genericclioptions.RESTClientGetter) (*Client, error) { if getter == nil { getter = genericclioptions.NewConfigFlags(true) } @@ -155,7 +164,7 @@ func New(getter genericclioptions.RESTClientGetter, ws WaitStrategy) (*Client, e Log: nopLogger, } var err error - c.Waiter, err = c.newWaiter(ws) + c.Waiter, err = c.newWaiter(HookOnlyStrategy) if err != nil { return nil, err } diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 8c8f89cdb..a5ad2b1eb 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -659,7 +659,7 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c, err := New(nil, StatusWatcherStrategy) + c, err := New(nil) if err != nil { t.Fatal(err) } @@ -672,7 +672,7 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c, err = New(nil, StatusWatcherStrategy) + c, err = New(nil) if err != nil { t.Fatal(err) } diff --git a/pkg/kube/fake/fake.go b/pkg/kube/fake/fake.go index ceca3c113..d722320f8 100644 --- a/pkg/kube/fake/fake.go +++ b/pkg/kube/fake/fake.go @@ -139,6 +139,10 @@ func (f *FailingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceL return f.PrintingKubeClient.DeleteWithPropagationPolicy(resources, policy) } +func (f *FailingKubeClient) SetWaiter(ws kube.WaitStrategy) error { + return nil +} + func createDummyResourceList() kube.ResourceList { var resInfo resource.Info resInfo.Name = "dummyName" diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index 0b957d725..3c0430aa1 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -121,6 +121,10 @@ func (p *PrintingKubeClient) DeleteWithPropagationPolicy(resources kube.Resource return &kube.Result{Deleted: resources}, nil } +func (f *PrintingKubeClient) SetWaiter(ws kube.WaitStrategy) error { + return nil +} + func bufferize(resources kube.ResourceList) io.Reader { var builder strings.Builder for _, info := range resources { diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 7af8ebca6..fc74a9833 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -47,6 +47,8 @@ type Interface interface { Build(reader io.Reader, validate bool) (ResourceList, error) // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error + // Set Waiter sets the Kube.Waiter + SetWaiter(ws WaitStrategy) error Waiter } From 165654426d9edeaadc5352e54e2ac4c72f408c1d Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 17 Feb 2025 10:27:11 +0000 Subject: [PATCH 106/271] chore: update profiling doc in CONTRIBUTING.md Signed-off-by: Evans Mungai --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc225d218..8ab93403d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -284,7 +284,7 @@ Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which wou ### Profiling PRs -If your contribution requires profiling to check memory and/or CPU usage, you can set `HELM_PPROF_CPU_PROFILE=/path/to/cpu.prof HELM_PPROF_MEM_PROFILE=/path/to/mem.prof helm show all bitnami/nginx` environment variable to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. +If your contribution requires profiling to check memory and/or CPU usage, you can set `HELM_PPROF_CPU_PROFILE=/path/to/cpu.prof` and/or `HELM_PPROF_MEM_PROFILE=/path/to/mem.prof` environment variables to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. Example analysing collected profiling data ``` From 5d1225549755832468972e4491991014441946f7 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 17 Feb 2025 14:53:34 +0000 Subject: [PATCH 107/271] wait for delete Signed-off-by: Austin Abro --- pkg/action/uninstall_test.go | 2 +- pkg/kube/fake/fake.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go index 1c67cab7f..5d2b33bdf 100644 --- a/pkg/action/uninstall_test.go +++ b/pkg/action/uninstall_test.go @@ -100,7 +100,7 @@ func TestUninstallRelease_Wait(t *testing.T) { }` unAction.cfg.Releases.Create(rel) failer := unAction.cfg.KubeClient.(*kubefake.FailingKubeClient) - failer.WaitError = fmt.Errorf("U timed out") + failer.WaitForDeleteError = fmt.Errorf("U timed out") unAction.cfg.KubeClient = failer res, err := unAction.Run(rel.Name) is.Error(err) diff --git a/pkg/kube/fake/fake.go b/pkg/kube/fake/fake.go index d722320f8..087fa89cb 100644 --- a/pkg/kube/fake/fake.go +++ b/pkg/kube/fake/fake.go @@ -36,6 +36,7 @@ type FailingKubeClient struct { CreateError error GetError error WaitError error + WaitForDeleteError error DeleteError error DeleteWithPropagationError error WatchUntilReadyError error @@ -82,8 +83,8 @@ func (f *FailingKubeClient) WaitWithJobs(resources kube.ResourceList, d time.Dur // WaitForDelete returns the configured error if set or prints func (f *FailingKubeClient) WaitForDelete(resources kube.ResourceList, d time.Duration) error { - if f.WaitError != nil { - return f.WaitError + if f.WaitForDeleteError != nil { + return f.WaitForDeleteError } return f.PrintingKubeClient.WaitForDelete(resources, d) } From fdf448497137d8c9358d5ccc481e535cfbc6523b Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 17 Feb 2025 18:31:17 +0000 Subject: [PATCH 108/271] Update cmd/helm/profiling.go Co-authored-by: George Jenkins Signed-off-by: Evans Mungai --- cmd/helm/profiling.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go index e48441512..9bcdb850e 100644 --- a/cmd/helm/profiling.go +++ b/cmd/helm/profiling.go @@ -83,8 +83,8 @@ func stopProfiling() error { } } - if len(errs) > 0 { - return fmt.Errorf("errors while stopping profiling: [%s]", strings.Join(errs, ", ")) + if err := errors.Join(errs...); err != nil { + return fmt.Errorf("error(s) while stopping profiling: %w", err) } return nil From 62576db2fcabd40bb9801f81a0de9e8fcc36d154 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Mon, 17 Feb 2025 18:36:04 +0000 Subject: [PATCH 109/271] chore: use []error instead of []string Signed-off-by: Evans Mungai --- cmd/helm/profiling.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go index 9bcdb850e..950ad15da 100644 --- a/cmd/helm/profiling.go +++ b/cmd/helm/profiling.go @@ -17,11 +17,11 @@ limitations under the License. package main import ( + "errors" "fmt" "os" "runtime" "runtime/pprof" - "strings" ) var ( @@ -58,14 +58,14 @@ func startProfiling() error { // It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE // environment variable. func stopProfiling() error { - errs := []string{} + errs := []error{} // Stop CPU profiling if it was started if cpuProfileFile != nil { pprof.StopCPUProfile() err := cpuProfileFile.Close() if err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) } cpuProfileFile = nil } @@ -73,13 +73,13 @@ func stopProfiling() error { if memProfilePath != "" { f, err := os.Create(memProfilePath) if err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) } defer f.Close() runtime.GC() // get up-to-date statistics if err := pprof.WriteHeapProfile(f); err != nil { - errs = append(errs, err.Error()) + errs = append(errs, err) } } From 50be8ae64b7756597f72d451b0ffd5951b82ee61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 21:08:38 +0000 Subject: [PATCH 110/271] build(deps): bump golangci/golangci-lint-action from 6.3.2 to 6.5.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.3.2 to 6.5.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/051d91933864810ecd5e2ea2cfd98f6a5bca5347...2226d7cb06a077cd73e56eedd38eecad18e5d837) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 914af6a0a..5971ada24 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,6 @@ jobs: go-version: '1.23' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@051d91933864810ecd5e2ea2cfd98f6a5bca5347 #pin@6.3.2 + uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 #pin@6.5.0 with: version: v1.62 From 001d2978b6dc4df0a3d0a4b5c76f8f34b9e1beca Mon Sep 17 00:00:00 2001 From: hugehope Date: Tue, 18 Feb 2025 15:20:46 +0800 Subject: [PATCH 111/271] refactor: using slices.Contains to simplify the code Signed-off-by: hugehope --- pkg/action/release_testing.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index 2539a7f65..1568b0683 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "io" + "slices" "sort" "time" @@ -75,7 +76,7 @@ func (r *ReleaseTesting) Run(name string) (*release.Release, error) { executingHooks := []*release.Hook{} if len(r.Filters[ExcludeNameFilter]) != 0 { for _, h := range rel.Hooks { - if contains(r.Filters[ExcludeNameFilter], h.Name) { + if slices.Contains(r.Filters[ExcludeNameFilter], h.Name) { skippedHooks = append(skippedHooks, h) } else { executingHooks = append(executingHooks, h) @@ -86,7 +87,7 @@ func (r *ReleaseTesting) Run(name string) (*release.Release, error) { if len(r.Filters[IncludeNameFilter]) != 0 { executingHooks = nil for _, h := range rel.Hooks { - if contains(r.Filters[IncludeNameFilter], h.Name) { + if slices.Contains(r.Filters[IncludeNameFilter], h.Name) { executingHooks = append(executingHooks, h) } else { skippedHooks = append(skippedHooks, h) @@ -119,10 +120,10 @@ func (r *ReleaseTesting) GetPodLogs(out io.Writer, rel *release.Release) error { for _, h := range hooksByWight { for _, e := range h.Events { if e == release.HookTest { - if contains(r.Filters[ExcludeNameFilter], h.Name) { + if slices.Contains(r.Filters[ExcludeNameFilter], h.Name) { continue } - if len(r.Filters[IncludeNameFilter]) > 0 && !contains(r.Filters[IncludeNameFilter], h.Name) { + if len(r.Filters[IncludeNameFilter]) > 0 && !slices.Contains(r.Filters[IncludeNameFilter], h.Name) { continue } req := client.CoreV1().Pods(r.Namespace).GetLogs(h.Name, &v1.PodLogOptions{}) @@ -142,12 +143,3 @@ func (r *ReleaseTesting) GetPodLogs(out io.Writer, rel *release.Release) error { } return nil } - -func contains(arr []string, value string) bool { - for _, item := range arr { - if item == value { - return true - } - } - return false -} From ecd531657778daf3fde3777e39fbf628fa9eb4a6 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 18 Feb 2025 13:50:04 +0000 Subject: [PATCH 112/271] lint Signed-off-by: Austin Abro --- cmd/helm/install.go | 2 +- pkg/kube/fake/fake.go | 2 +- pkg/kube/statuswait.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 649c5c8b8..4d72be966 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -190,7 +190,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&client.Replace, "replace", false, "reuse 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.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") 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") diff --git a/pkg/kube/fake/fake.go b/pkg/kube/fake/fake.go index 087fa89cb..c4322733a 100644 --- a/pkg/kube/fake/fake.go +++ b/pkg/kube/fake/fake.go @@ -140,7 +140,7 @@ func (f *FailingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceL return f.PrintingKubeClient.DeleteWithPropagationPolicy(resources, policy) } -func (f *FailingKubeClient) SetWaiter(ws kube.WaitStrategy) error { +func (f *FailingKubeClient) SetWaiter(_ kube.WaitStrategy) error { return nil } diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 4a0dcd0d2..3c1e90a36 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -218,14 +218,14 @@ func (w *hookOnlyWaiter) WatchUntilReady(resourceList ResourceList, timeout time return w.sw.WatchUntilReady(resourceList, timeout) } -func (w *hookOnlyWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { +func (w *hookOnlyWaiter) Wait(_ ResourceList, _ time.Duration) error { return nil } -func (w *hookOnlyWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { +func (w *hookOnlyWaiter) WaitWithJobs(_ ResourceList, _ time.Duration) error { return nil } -func (w *hookOnlyWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { +func (w *hookOnlyWaiter) WaitForDelete(_ ResourceList, _ time.Duration) error { return nil } From efde8304059b791ef48afaf602d5cc4c7a537f3d Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 18 Feb 2025 13:53:06 +0000 Subject: [PATCH 113/271] better name Signed-off-by: Austin Abro --- pkg/kube/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 425152006..ff062a172 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -85,7 +85,7 @@ type WaitStrategy string const ( StatusWatcherStrategy WaitStrategy = "watcher" LegacyStrategy WaitStrategy = "legacy" - HookOnlyStrategy WaitStrategy = "noop" + HookOnlyStrategy WaitStrategy = "hookOnly" ) func init() { From ea87c49d1b6ef516d95226ce7fffd610d99ca16c Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 18 Feb 2025 13:53:47 +0000 Subject: [PATCH 114/271] print Signed-off-by: Austin Abro --- pkg/kube/fake/printer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index 3c0430aa1..82649b202 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -121,7 +121,7 @@ func (p *PrintingKubeClient) DeleteWithPropagationPolicy(resources kube.Resource return &kube.Result{Deleted: resources}, nil } -func (f *PrintingKubeClient) SetWaiter(ws kube.WaitStrategy) error { +func (p *PrintingKubeClient) SetWaiter(_ kube.WaitStrategy) error { return nil } From 5d31fb09d2110242dd91ff64e9b8e161f38e15d4 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 18 Feb 2025 13:55:13 +0000 Subject: [PATCH 115/271] better help text Signed-off-by: Austin Abro --- cmd/helm/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index d1f0fec58..c73bab63f 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -56,7 +56,7 @@ func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) { cmd.Flags().Var( newWaitValue(kube.HookOnlyStrategy, wait), "wait", - "if set, will wait until all resources are in the expected state before marking the operation as successful. It will wait for as long as --timeout. Options are (true, false, watcher, and legacy)", + "if set, will wait until all resources are in the expected state before marking the operation as successful. It will wait for as long as --timeout. Valid inputs are true, false, watcher, and legacy", ) // Sets the strategy to use the watcher strategy if `--wait` is used without an argument cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy) From b689ff203e76cf009f931dcec49910c6054c06b3 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 19 Feb 2025 14:58:10 -0500 Subject: [PATCH 116/271] Moving to SetOut and SetErr for Cobra SetOutput is deprecated. This causes it to fail linting. Signed-off-by: Matt Farina --- cmd/helm/require/args_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/helm/require/args_test.go b/cmd/helm/require/args_test.go index 5a84a42d0..cd5850650 100644 --- a/cmd/helm/require/args_test.go +++ b/cmd/helm/require/args_test.go @@ -71,7 +71,8 @@ func runTestCases(t *testing.T, testCases []testCase) { Args: tc.validateFunc, } cmd.SetArgs(tc.args) - cmd.SetOutput(io.Discard) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) err := cmd.Execute() if tc.wantError == "" { From 3d2c914a6d38000c8d9f68efdf7538adab567d4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Feb 2025 20:12:17 +0000 Subject: [PATCH 117/271] build(deps): bump github.com/spf13/cobra from 1.8.1 to 1.9.1 Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.8.1 to 1.9.1. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](https://github.com/spf13/cobra/compare/v1.8.1...v1.9.1) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index f3a8265b6..c84140350 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/pkg/errors v0.9.1 github.com/rubenv/sql-migrate v1.7.1 - github.com/spf13/cobra v1.8.1 + github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 @@ -63,7 +63,7 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/containerd/platforms v0.2.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/distribution/reference v0.6.0 // indirect diff --git a/go.sum b/go.sum index 25a825e86..995e14598 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpS github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -313,9 +313,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= +github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From 0d36cb664a30826ad3f1b811e5ad942144e85336 Mon Sep 17 00:00:00 2001 From: lubingtan Date: Fri, 24 Jan 2025 16:21:02 +0800 Subject: [PATCH 118/271] feat: support multi-document values files Signed-off-by: lubingtan --- pkg/cli/values/options.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index add2f72d5..e1f1988c8 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -17,6 +17,7 @@ limitations under the License. package values import ( + "bytes" "encoding/json" "io" "net/url" @@ -24,7 +25,7 @@ import ( "strings" "github.com/pkg/errors" - "sigs.k8s.io/yaml" + utilyaml "k8s.io/apimachinery/pkg/util/yaml" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/strvals" @@ -47,18 +48,23 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er // User specified a values files via -f/--values for _, filePath := range opts.ValueFiles { - currentMap := map[string]interface{}{} - - bytes, err := readFile(filePath, p) + raw, err := readFile(filePath, p) if err != nil { return nil, err } - if err := yaml.Unmarshal(bytes, ¤tMap); err != nil { - return nil, errors.Wrapf(err, "failed to parse %s", filePath) + decoder := utilyaml.NewYAMLOrJSONDecoder(bytes.NewReader(raw), 4096) + for { + currentMap := map[string]interface{}{} + if err := decoder.Decode(¤tMap); err != nil { + if err == io.EOF { + break + } + return nil, errors.Wrapf(err, "failed to parse %s", filePath) + } + // Merge with the previous map + base = mergeMaps(base, currentMap) } - // Merge with the previous map - base = mergeMaps(base, currentMap) } // User specified a value via --set-json From 92087f6e33d6a5d8333e6afda7d68a4d15a2cec9 Mon Sep 17 00:00:00 2001 From: lubingtan Date: Mon, 3 Feb 2025 20:53:07 +0800 Subject: [PATCH 119/271] feat: support multi-document values files for default chart values Signed-off-by: lubingtan --- pkg/chart/loader/load.go | 53 ++++++++++++++-- pkg/chart/loader/load_test.go | 113 +++++++++++++++++++++++++++++++++ pkg/cli/values/options.go | 41 ++---------- pkg/cli/values/options_test.go | 55 ---------------- 4 files changed, 168 insertions(+), 94 deletions(-) diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index 7645ba96c..c40a1aaf5 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -17,14 +17,17 @@ limitations under the License. package loader import ( + "bufio" "bytes" "encoding/json" + "io" "log" "os" "path/filepath" "strings" "github.com/pkg/errors" + utilyaml "k8s.io/apimachinery/pkg/util/yaml" "sigs.k8s.io/yaml" "helm.sh/helm/v4/pkg/chart" @@ -104,13 +107,11 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { return c, errors.Wrap(err, "cannot load Chart.lock") } case f.Name == "values.yaml": - c.Values = make(map[string]interface{}) - if err := yaml.Unmarshal(f.Data, &c.Values, func(d *json.Decoder) *json.Decoder { - d.UseNumber() - return d - }); err != nil { + values, err := LoadValues(f.Data) + if err != nil { return c, errors.Wrap(err, "cannot load values.yaml") } + c.Values = values case f.Name == "values.schema.json": c.Schema = f.Data @@ -205,3 +206,45 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { return c, nil } + +func LoadValues(data []byte) (map[string]interface{}, error) { + values := map[string]interface{}{} + reader := utilyaml.NewYAMLReader(bufio.NewReader(bytes.NewReader(data))) + for { + currentMap := map[string]interface{}{} + raw, err := reader.Read() + if err != nil { + if err == io.EOF { + break + } + return nil, errors.Wrap(err, "error reading yaml document") + } + if err := yaml.Unmarshal(raw, ¤tMap, func(d *json.Decoder) *json.Decoder { + d.UseNumber() + return d + }); err != nil { + return nil, errors.Wrap(err, "cannot unmarshal yaml document") + } + values = MergeMaps(values, currentMap) + } + return values, nil +} + +func MergeMaps(a, b map[string]interface{}) map[string]interface{} { + out := make(map[string]interface{}, len(a)) + for k, v := range a { + out[k] = v + } + for k, v := range b { + if v, ok := v.(map[string]interface{}); ok { + if bv, ok := out[k]; ok { + if bv, ok := bv.(map[string]interface{}); ok { + out[k] = MergeMaps(bv, v) + continue + } + } + } + out[k] = v + } + return out +} diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index 25e000835..92ffa002b 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -24,6 +24,7 @@ import ( "log" "os" "path/filepath" + "reflect" "runtime" "strings" "testing" @@ -488,6 +489,118 @@ func TestLoadInvalidArchive(t *testing.T) { } } +func TestLoadValues(t *testing.T) { + testDatas := []struct { + name string + data []byte + expctedValues map[string]interface{} + }{ + { + name: "It should load values correctly", + data: []byte(` +foo: + image: foo:v1 +bar: + version: v2 +`), + expctedValues: map[string]interface{}{ + "foo": map[string]interface{}{ + "image": "foo:v1", + }, + "bar": map[string]interface{}{ + "version": "v2", + }, + }, + }, + { + name: "It should load values correctly with multiple documents in one file", + data: []byte(` +foo: + image: foo:v1 +bar: + version: v2 +--- +foo: + image: foo:v2 +`), + expctedValues: map[string]interface{}{ + "foo": map[string]interface{}{ + "image": "foo:v2", + }, + "bar": map[string]interface{}{ + "version": "v2", + }, + }, + }, + } + for _, testData := range testDatas { + t.Run(testData.name, func(tt *testing.T) { + values, err := LoadValues(testData.data) + if err != nil { + tt.Fatal(err) + } + if !reflect.DeepEqual(values, testData.expctedValues) { + tt.Errorf("Expected values: %v, got %v", testData.expctedValues, values) + } + }) + } +} + +func TestMergeValues(t *testing.T) { + nestedMap := map[string]interface{}{ + "foo": "bar", + "baz": map[string]string{ + "cool": "stuff", + }, + } + anotherNestedMap := map[string]interface{}{ + "foo": "bar", + "baz": map[string]string{ + "cool": "things", + "awesome": "stuff", + }, + } + flatMap := map[string]interface{}{ + "foo": "bar", + "baz": "stuff", + } + anotherFlatMap := map[string]interface{}{ + "testing": "fun", + } + + testMap := MergeMaps(flatMap, nestedMap) + equal := reflect.DeepEqual(testMap, nestedMap) + if !equal { + t.Errorf("Expected a nested map to overwrite a flat value. Expected: %v, got %v", nestedMap, testMap) + } + + testMap = MergeMaps(nestedMap, flatMap) + equal = reflect.DeepEqual(testMap, flatMap) + if !equal { + t.Errorf("Expected a flat value to overwrite a map. Expected: %v, got %v", flatMap, testMap) + } + + testMap = MergeMaps(nestedMap, anotherNestedMap) + equal = reflect.DeepEqual(testMap, anotherNestedMap) + if !equal { + t.Errorf("Expected a nested map to overwrite another nested map. Expected: %v, got %v", anotherNestedMap, testMap) + } + + testMap = MergeMaps(anotherFlatMap, anotherNestedMap) + expectedMap := map[string]interface{}{ + "testing": "fun", + "foo": "bar", + "baz": map[string]string{ + "cool": "things", + "awesome": "stuff", + }, + } + equal = reflect.DeepEqual(testMap, expectedMap) + if !equal { + t.Errorf("Expected a map with different keys to merge properly with another map. Expected: %v, got %v", expectedMap, testMap) + } +} + func verifyChart(t *testing.T, c *chart.Chart) { t.Helper() if c.Name() == "" { diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index e1f1988c8..70390f12a 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -17,7 +17,6 @@ limitations under the License. package values import ( - "bytes" "encoding/json" "io" "net/url" @@ -25,8 +24,8 @@ import ( "strings" "github.com/pkg/errors" - utilyaml "k8s.io/apimachinery/pkg/util/yaml" + "helm.sh/helm/v4/pkg/chart/loader" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/strvals" ) @@ -48,23 +47,16 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er // User specified a values files via -f/--values for _, filePath := range opts.ValueFiles { - raw, err := readFile(filePath, p) + bytes, err := readFile(filePath, p) if err != nil { return nil, err } - - decoder := utilyaml.NewYAMLOrJSONDecoder(bytes.NewReader(raw), 4096) - for { - currentMap := map[string]interface{}{} - if err := decoder.Decode(¤tMap); err != nil { - if err == io.EOF { - break - } - return nil, errors.Wrapf(err, "failed to parse %s", filePath) - } - // Merge with the previous map - base = mergeMaps(base, currentMap) + currentMap, err := loader.LoadValues(bytes) + if err != nil { + return nil, errors.Wrapf(err, "failed to parse %s", filePath) } + // Merge with the previous map + base = loader.MergeMaps(base, currentMap) } // User specified a value via --set-json @@ -123,25 +115,6 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er return base, nil } -func mergeMaps(a, b map[string]interface{}) map[string]interface{} { - out := make(map[string]interface{}, len(a)) - for k, v := range a { - out[k] = v - } - for k, v := range b { - if v, ok := v.(map[string]interface{}); ok { - if bv, ok := out[k]; ok { - if bv, ok := bv.(map[string]interface{}); ok { - out[k] = mergeMaps(bv, v) - continue - } - } - } - out[k] = v - } - return out -} - // readFile load a file from stdin, the local directory, or a remote file with a url. func readFile(filePath string, p getter.Providers) ([]byte, error) { if strings.TrimSpace(filePath) == "-" { diff --git a/pkg/cli/values/options_test.go b/pkg/cli/values/options_test.go index 5197a1b5e..c3bb0af33 100644 --- a/pkg/cli/values/options_test.go +++ b/pkg/cli/values/options_test.go @@ -23,61 +23,6 @@ import ( "helm.sh/helm/v4/pkg/getter" ) -func TestMergeMaps(t *testing.T) { - nestedMap := map[string]interface{}{ - "foo": "bar", - "baz": map[string]string{ - "cool": "stuff", - }, - } - anotherNestedMap := map[string]interface{}{ - "foo": "bar", - "baz": map[string]string{ - "cool": "things", - "awesome": "stuff", - }, - } - flatMap := map[string]interface{}{ - "foo": "bar", - "baz": "stuff", - } - anotherFlatMap := map[string]interface{}{ - "testing": "fun", - } - - testMap := mergeMaps(flatMap, nestedMap) - equal := reflect.DeepEqual(testMap, nestedMap) - if !equal { - t.Errorf("Expected a nested map to overwrite a flat value. Expected: %v, got %v", nestedMap, testMap) - } - - testMap = mergeMaps(nestedMap, flatMap) - equal = reflect.DeepEqual(testMap, flatMap) - if !equal { - t.Errorf("Expected a flat value to overwrite a map. Expected: %v, got %v", flatMap, testMap) - } - - testMap = mergeMaps(nestedMap, anotherNestedMap) - equal = reflect.DeepEqual(testMap, anotherNestedMap) - if !equal { - t.Errorf("Expected a nested map to overwrite another nested map. Expected: %v, got %v", anotherNestedMap, testMap) - } - - testMap = mergeMaps(anotherFlatMap, anotherNestedMap) - expectedMap := map[string]interface{}{ - "testing": "fun", - "foo": "bar", - "baz": map[string]string{ - "cool": "things", - "awesome": "stuff", - }, - } - equal = reflect.DeepEqual(testMap, expectedMap) - if !equal { - t.Errorf("Expected a map with different keys to merge properly with another map. Expected: %v, got %v", expectedMap, testMap) - } -} - func TestReadFile(t *testing.T) { var p getter.Providers filePath := "%a.txt" From 3d84e00ce756f34f8d3cf41c1489548696edd8a7 Mon Sep 17 00:00:00 2001 From: lubingtan Date: Sun, 9 Feb 2025 16:16:08 +0800 Subject: [PATCH 120/271] fix: use Reader interface as the input of LoadValues and enhance UT of LoadValues Signed-off-by: lubingtan --- pkg/chart/loader/load.go | 7 ++++--- pkg/chart/loader/load_test.go | 19 ++++++++----------- pkg/cli/values/options.go | 5 +++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index c40a1aaf5..84a040c0f 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -107,7 +107,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { return c, errors.Wrap(err, "cannot load Chart.lock") } case f.Name == "values.yaml": - values, err := LoadValues(f.Data) + values, err := LoadValues(bytes.NewReader(f.Data)) if err != nil { return c, errors.Wrap(err, "cannot load values.yaml") } @@ -207,9 +207,10 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { return c, nil } -func LoadValues(data []byte) (map[string]interface{}, error) { +// LoadValues loads chat values from a reader. +func LoadValues(data io.Reader) (map[string]interface{}, error) { values := map[string]interface{}{} - reader := utilyaml.NewYAMLReader(bufio.NewReader(bytes.NewReader(data))) + reader := utilyaml.NewYAMLReader(bufio.NewReader(data)) for { currentMap := map[string]interface{}{} raw, err := reader.Read() diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index 92ffa002b..e34124829 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -490,13 +490,11 @@ func TestLoadInvalidArchive(t *testing.T) { } func TestLoadValues(t *testing.T) { - testDatas := []struct { - name string + testCases := map[string]struct { data []byte expctedValues map[string]interface{} }{ - { - name: "It should load values correctly", + "It should load values correctly": { data: []byte(` foo: image: foo:v1 @@ -512,8 +510,7 @@ bar: }, }, }, - { - name: "It should load values correctly with multiple documents in one file", + "It should load values correctly with multiple documents in one file": { data: []byte(` foo: image: foo:v1 @@ -533,14 +530,14 @@ foo: }, }, } - for _, testData := range testDatas { - t.Run(testData.name, func(tt *testing.T) { - values, err := LoadValues(testData.data) + for testName, testCase := range testCases { + t.Run(testName, func(tt *testing.T) { + values, err := LoadValues(bytes.NewReader(testCase.data)) if err != nil { tt.Fatal(err) } - if !reflect.DeepEqual(values, testData.expctedValues) { - tt.Errorf("Expected values: %v, got %v", testData.expctedValues, values) + if !reflect.DeepEqual(values, testCase.expctedValues) { + tt.Errorf("Expected values: %v, got %v", testCase.expctedValues, values) } }) } diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index 70390f12a..54dd288bc 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -17,6 +17,7 @@ limitations under the License. package values import ( + "bytes" "encoding/json" "io" "net/url" @@ -47,11 +48,11 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er // User specified a values files via -f/--values for _, filePath := range opts.ValueFiles { - bytes, err := readFile(filePath, p) + raw, err := readFile(filePath, p) if err != nil { return nil, err } - currentMap, err := loader.LoadValues(bytes) + currentMap, err := loader.LoadValues(bytes.NewReader(raw)) if err != nil { return nil, errors.Wrapf(err, "failed to parse %s", filePath) } From fb7221bc9aa8f7747d7f31bffa1181886b7de6ec Mon Sep 17 00:00:00 2001 From: lubingtan Date: Sun, 9 Feb 2025 22:13:26 +0800 Subject: [PATCH 121/271] fix: add doc for func MergeMaps Signed-off-by: lubingtan --- pkg/chart/loader/load.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index 84a040c0f..c957c398d 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -231,6 +231,8 @@ func LoadValues(data io.Reader) (map[string]interface{}, error) { return values, nil } +// MergeMaps merges two maps. If a key exists in both maps, the value from b will be used. +// If the value is a map, the maps will be merged recursively. func MergeMaps(a, b map[string]interface{}) map[string]interface{} { out := make(map[string]interface{}, len(a)) for k, v := range a { From 91cd72d0e47cd5a45871037894927c62956b0f98 Mon Sep 17 00:00:00 2001 From: lubingtan Date: Mon, 10 Feb 2025 08:25:23 +0800 Subject: [PATCH 122/271] fix: improve LoadValues function documentation Signed-off-by: lubingtan --- pkg/chart/loader/load.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index c957c398d..e32094ef5 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -207,7 +207,10 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { return c, nil } -// LoadValues loads chat values from a reader. +// LoadValues loads values from a reader. +// +// The reader is expected to contain one or more YAML documents, the values of which are merged. +// And the values can be either a chart's default values or a user-supplied values. func LoadValues(data io.Reader) (map[string]interface{}, error) { values := map[string]interface{}{} reader := utilyaml.NewYAMLReader(bufio.NewReader(data)) From ef5614364bb174df3126fbb7d0d89b39c2af5c8f Mon Sep 17 00:00:00 2001 From: lubingtan Date: Thu, 20 Feb 2025 08:13:54 +0800 Subject: [PATCH 123/271] fix: replace mergeMaps call with loader.MergeMaps in MergeValues function Signed-off-by: lubingtan --- pkg/cli/values/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index 54dd288bc..2c3706b84 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -69,7 +69,7 @@ func (opts *Options) MergeValues(p getter.Providers) (map[string]interface{}, er if err := json.Unmarshal([]byte(trimmedValue), &jsonMap); err != nil { return nil, errors.Errorf("failed parsing --set-json data JSON: %s", value) } - base = mergeMaps(base, jsonMap) + base = loader.MergeMaps(base, jsonMap) } else { // Otherwise, parse it as key=value format if err := strvals.ParseJSON(value, base); err != nil { From 8207fafe130feb0540c53acb6c0cb95f242d6e3c Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 20 Feb 2025 12:13:59 -0500 Subject: [PATCH 124/271] fixing error handling from a previous PR Signed-off-by: Robert Sirchia --- pkg/kube/roundtripper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/roundtripper.go b/pkg/kube/roundtripper.go index 551d3009b..52cb5bad2 100644 --- a/pkg/kube/roundtripper.go +++ b/pkg/kube/roundtripper.go @@ -58,7 +58,7 @@ func (rt *RetryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp r.Seek(0, io.SeekStart) resp.Body = io.NopCloser(r) if err != nil { - return resp, nil + return resp, err } if ke.Code < 500 { return resp, nil From bb6314adefd2020cf8adb45a3109e1957446b741 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 20 Feb 2025 14:42:48 -0300 Subject: [PATCH 125/271] Do not reassign repos variable Signed-off-by: Felipe Santos --- pkg/downloader/manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 2e284ab73..dfff0ddd4 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -678,9 +678,9 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error { var wg sync.WaitGroup - repos = dedupeRepos(repos) + localRepos := dedupeRepos(repos) - for _, c := range repos { + for _, c := range localRepos { r, err := repo.NewChartRepository(c, m.Getters) if err != nil { return err From 281ccb083543beeac21b9b72be9a07dbdd18f21f Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 20 Feb 2025 15:33:52 -0300 Subject: [PATCH 126/271] Do not store the normalized chart url Signed-off-by: Felipe Santos --- pkg/downloader/manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index dfff0ddd4..c430eddaf 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -664,8 +664,8 @@ func dedupeRepos(repos []*repo.Entry) []*repo.Entry { seen := make(map[string]*repo.Entry) for _, r := range repos { // Normalize URL by removing trailing slashes. - r.URL = strings.TrimSuffix(r.URL, "/") - seen[r.URL] = r + seenUrl := strings.TrimRight(r.URL, "/") + seen[seenUrl] = r } var unique []*repo.Entry for _, r := range seen { From ecb5a2c9dd3f6363c7b153e7b3527db4444ff54f Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 20 Feb 2025 15:45:57 -0300 Subject: [PATCH 127/271] Fix variable name for linter And restore trimSuffix instead of trimRight, which was a mistake. Signed-off-by: Felipe Santos --- pkg/downloader/manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index c430eddaf..52f7d5a92 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -664,8 +664,8 @@ func dedupeRepos(repos []*repo.Entry) []*repo.Entry { seen := make(map[string]*repo.Entry) for _, r := range repos { // Normalize URL by removing trailing slashes. - seenUrl := strings.TrimRight(r.URL, "/") - seen[seenUrl] = r + seenURL := strings.TrimSuffix(r.URL, "/") + seen[seenURL] = r } var unique []*repo.Entry for _, r := range seen { From b1fd2391679258afeb06bf6ad540c51eeb18f4ea Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 20 Feb 2025 16:58:55 -0300 Subject: [PATCH 128/271] Fix tests failing after removing repo normalization Signed-off-by: Felipe Santos --- pkg/downloader/manager_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index 6a963f603..1c45ee011 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -649,7 +649,8 @@ func TestDedupeRepos(t *testing.T) { }, want: []*repo.Entry{ { - URL: "https://example.com/charts", + // the last one wins + URL: "https://example.com/charts/", }, }, }, From cde407b7d10a2ba2b2ba72466d90ce25fd953ee5 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Fri, 7 Jan 2022 13:37:19 +0000 Subject: [PATCH 129/271] Add hook annotations to output pod logs to client on success and fail Signed-off-by: Chris Berry --- pkg/action/action_test.go | 15 ++- pkg/action/hooks.go | 88 +++++++++++- pkg/action/hooks_test.go | 208 +++++++++++++++++++++++++++++ pkg/action/install_test.go | 4 + pkg/kube/client.go | 50 ++++++- pkg/kube/client_test.go | 35 +++++ pkg/kube/fake/printer.go | 20 ++- pkg/kube/interface.go | 7 + pkg/release/hook.go | 16 +++ pkg/releaseutil/manifest_sorter.go | 36 +++-- 10 files changed, 452 insertions(+), 27 deletions(-) create mode 100644 pkg/action/hooks_test.go diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 71ea83789..47cff6ec1 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -111,6 +111,14 @@ type chartOptions struct { type chartOption func(*chartOptions) func buildChart(opts ...chartOption) *chart.Chart { + defaultTemplates := []*chart.File{ + {Name: "templates/hello", Data: []byte("hello: world")}, + {Name: "templates/hooks", Data: []byte(manifestWithHook)}, + } + return buildChartWithTemplates(defaultTemplates, opts...) +} + +func buildChartWithTemplates(templates []*chart.File, opts ...chartOption) *chart.Chart { c := &chartOptions{ Chart: &chart.Chart{ // TODO: This should be more complete. @@ -119,18 +127,13 @@ func buildChart(opts ...chartOption) *chart.Chart { Name: "hello", Version: "0.1.0", }, - // This adds a basic template and hooks. - Templates: []*chart.File{ - {Name: "templates/hello", Data: []byte("hello: world")}, - {Name: "templates/hooks", Data: []byte(manifestWithHook)}, - }, + Templates: templates, }, } for _, opt := range opts { opt(c) } - return c.Chart } diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index ecca1d997..95d843ce0 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -17,12 +17,19 @@ package action import ( "bytes" + "fmt" + "log" "sort" "time" + "helm.sh/helm/v4/pkg/kube" + + "helm.sh/helm/v4/pkg/chartutil" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) @@ -44,7 +51,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, for _, h := range executingHooks { // Set default delete policy to before-hook-creation - if len(h.DeletePolicies) == 0 { + if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 { // TODO(jlegrone): Only apply before-hook-creation delete policy to run to completion // resources. For all other resource types update in place if a // resource with the same name already exists and is owned by the @@ -87,10 +94,18 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // Mark hook as succeeded or failed if err != nil { h.LastRun.Phase = release.HookPhaseFailed + // If a hook is failed, check the annotation of the hook to determine if we should copy the logs client side + if errOutputting := cfg.outputLogsByPolicy(h, rl.Namespace, release.HookOutputOnFailed); errOutputting != nil { + // We log the error here as we want to propagate the hook failure upwards to the release object. + log.Printf("error outputting logs for hook failure: %v", errOutputting) + } // If a hook is failed, check the annotation of the hook to determine whether the hook should be deleted // under failed condition. If so, then clear the corresponding resource object in the hook - if err := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); err != nil { - return err + if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); err != nil { + // We log the error here as we want to propagate the hook failure upwards to the release object. + // This is a change in behaviour as the edge case previously would lose the hook error and only + // raise the delete hook error. + log.Printf("error the hook resource on hook failure: %v", errDeleting) } return err } @@ -98,9 +113,13 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, } // If all hooks are successful, check the annotation of each hook to determine whether the hook should be deleted - // under succeeded condition. If so, then clear the corresponding resource object in each hook + // or output should be logged under succeeded condition. If so, then clear the corresponding resource object in each hook for i := len(executingHooks) - 1; i >= 0; i-- { h := executingHooks[i] + if err := cfg.outputLogsByPolicy(h, rl.Namespace, release.HookOutputOnSucceeded); err != nil { + // We log here as we still want to attempt hook resource deletion even if output logging fails. + log.Printf("error outputting logs for hook failure: %v", err) + } if err := cfg.deleteHookByPolicy(h, release.HookSucceeded, timeout); err != nil { return err } @@ -158,3 +177,62 @@ func hookHasDeletePolicy(h *release.Hook, policy release.HookDeletePolicy) bool } return false } + +// outputLogsByPolicy outputs a pods logs if the hook policy instructs it to +func (cfg *Configuration) outputLogsByPolicy(h *release.Hook, releaseNamespace string, policy release.HookOutputLogPolicy) error { + if hookHasOutputLogPolicy(h, policy) { + namespace, err := cfg.deriveNamespace(h, releaseNamespace) + if err != nil { + return err + } + switch h.Kind { + case "Job": + return cfg.outputContainerLogsForListOptions(namespace, metav1.ListOptions{LabelSelector: fmt.Sprintf("job-name=%s", h.Name)}) + case "Pod": + return cfg.outputContainerLogsForListOptions(namespace, metav1.ListOptions{FieldSelector: fmt.Sprintf("metadata.name=%s", h.Name)}) + default: + return nil + } + } + return nil +} + +func (cfg *Configuration) outputContainerLogsForListOptions(namespace string, listOptions metav1.ListOptions) error { + //TODO Helm 4: Remove this check when GetPodList and OutputContainerLogsForPodList are moved from InterfaceExt to Interface + if kubeClient, ok := cfg.KubeClient.(kube.InterfaceExt); ok { + podList, err := kubeClient.GetPodList(namespace, listOptions) + if err != nil { + return err + } + err = kubeClient.OutputContainerLogsForPodList(podList, namespace, log.Writer()) + return err + } + return nil +} + +func (cfg *Configuration) deriveNamespace(h *release.Hook, namespace string) (string, error) { + values, err := chartutil.ReadValues([]byte(h.Manifest)) + if err != nil { + return "", errors.Wrapf(err, "unable to parse kubernetes manifest for output logs hook %s", h.Path) + } + value, err := values.PathValue("metadata.namespace") + switch err.(type) { + case nil: + return value.(string), nil + case chartutil.ErrNoValue: + return namespace, nil + default: + return "", errors.Wrapf(err, "unable to parse path of metadata.namespace in yaml for output logs hook %s", h.Path) + } +} + +// hookHasOutputLogPolicy determines whether the defined hook output log policy matches the hook output log policies +// supported by helm. +func hookHasOutputLogPolicy(h *release.Hook, policy release.HookOutputLogPolicy) bool { + for _, v := range h.OutputLogPolicies { + if policy == v { + return true + } + } + return false +} diff --git a/pkg/action/hooks_test.go b/pkg/action/hooks_test.go new file mode 100644 index 000000000..25a28f60f --- /dev/null +++ b/pkg/action/hooks_test.go @@ -0,0 +1,208 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package action + +import ( + "bytes" + "fmt" + "io/ioutil" + "testing" + + "github.com/stretchr/testify/assert" + + "helm.sh/helm/v3/pkg/chart" + kubefake "helm.sh/helm/v3/pkg/kube/fake" + "helm.sh/helm/v3/pkg/release" +) + +func podManifestWithOutputLogs(hookDefinitions []release.HookOutputLogPolicy) string { + hookDefinitionString := convertHooksToCommaSeparated(hookDefinitions) + return fmt.Sprintf(`kind: Pod +metadata: + name: finding-sharky, + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-output-log-policy": %s +spec: + containers: + - name: sharky-test + image: fake-image + cmd: fake-command`, hookDefinitionString) +} + +func podManifestWithOutputLogWithNamespace(hookDefinitions []release.HookOutputLogPolicy) string { + hookDefinitionString := convertHooksToCommaSeparated(hookDefinitions) + return fmt.Sprintf(`kind: Pod +metadata: + name: finding-george + namespace: sneaky-namespace + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-output-log-policy": %s +spec: + containers: + - name: george-test + image: fake-image + cmd: fake-command`, hookDefinitionString) +} + +func jobManifestWithOutputLog(hookDefinitions []release.HookOutputLogPolicy) string { + hookDefinitionString := convertHooksToCommaSeparated(hookDefinitions) + return fmt.Sprintf(`kind: Job +apiVersion: batch/v1 +metadata: + name: losing-religion + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-output-log-policy": %s +spec: + completions: 1 + parallelism: 1 + activeDeadlineSeconds: 30 + template: + spec: + containers: + - name: religion-container + image: religion-image + cmd: religion-command`, hookDefinitionString) +} + +func jobManifestWithOutputLogWithNamespace(hookDefinitions []release.HookOutputLogPolicy) string { + hookDefinitionString := convertHooksToCommaSeparated(hookDefinitions) + return fmt.Sprintf(`kind: Job +apiVersion: batch/v1 +metadata: + name: losing-religion + namespace: rem-namespace + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-output-log-policy": %s +spec: + completions: 1 + parallelism: 1 + activeDeadlineSeconds: 30 + template: + spec: + containers: + - name: religion-container + image: religion-image + cmd: religion-command`, hookDefinitionString) +} + +func convertHooksToCommaSeparated(hookDefinitions []release.HookOutputLogPolicy) string { + var commaSeparated string + for i, policy := range hookDefinitions { + if i+1 == len(hookDefinitions) { + commaSeparated += policy.String() + } else { + commaSeparated += policy.String() + "," + } + } + return commaSeparated +} + +func TestInstallRelease_HookOutputLogsOnFailure(t *testing.T) { + // Should output on failure with expected namespace if hook-failed is set + runInstallForHooksWithFailure(t, podManifestWithOutputLogs([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "spaced", true) + runInstallForHooksWithFailure(t, podManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "sneaky-namespace", true) + runInstallForHooksWithFailure(t, jobManifestWithOutputLog([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "spaced", true) + runInstallForHooksWithFailure(t, jobManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "rem-namespace", true) + + // Should not output on failure with expected namespace if hook-succeed is set + runInstallForHooksWithFailure(t, podManifestWithOutputLogs([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "", false) + runInstallForHooksWithFailure(t, podManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "", false) + runInstallForHooksWithFailure(t, jobManifestWithOutputLog([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "", false) + runInstallForHooksWithFailure(t, jobManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "", false) +} + +func TestInstallRelease_HookOutputLogsOnSuccess(t *testing.T) { + // Should output on success with expected namespace if hook-succeeded is set + runInstallForHooksWithSuccess(t, podManifestWithOutputLogs([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "spaced", true) + runInstallForHooksWithSuccess(t, podManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "sneaky-namespace", true) + runInstallForHooksWithSuccess(t, jobManifestWithOutputLog([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "spaced", true) + runInstallForHooksWithSuccess(t, jobManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded}), "rem-namespace", true) + + // Should not output on success if hook-failed is set + runInstallForHooksWithSuccess(t, podManifestWithOutputLogs([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "", false) + runInstallForHooksWithSuccess(t, podManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "", false) + runInstallForHooksWithSuccess(t, jobManifestWithOutputLog([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "", false) + runInstallForHooksWithSuccess(t, jobManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnFailed}), "", false) +} + +func TestInstallRelease_HooksOutputLogsOnSuccessAndFailure(t *testing.T) { + // Should output on success with expected namespace if hook-succeeded and hook-failed is set + runInstallForHooksWithSuccess(t, podManifestWithOutputLogs([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "spaced", true) + runInstallForHooksWithSuccess(t, podManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "sneaky-namespace", true) + runInstallForHooksWithSuccess(t, jobManifestWithOutputLog([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "spaced", true) + runInstallForHooksWithSuccess(t, jobManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "rem-namespace", true) + + // Should output on failure if hook-succeeded and hook-failed is set + runInstallForHooksWithFailure(t, podManifestWithOutputLogs([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "spaced", true) + runInstallForHooksWithFailure(t, podManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "sneaky-namespace", true) + runInstallForHooksWithFailure(t, jobManifestWithOutputLog([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "spaced", true) + runInstallForHooksWithFailure(t, jobManifestWithOutputLogWithNamespace([]release.HookOutputLogPolicy{release.HookOutputOnSucceeded, release.HookOutputOnFailed}), "rem-namespace", true) +} + +func runInstallForHooksWithSuccess(t *testing.T, manifest, expectedNamespace string, shouldOutput bool) { + var expectedOutput string + if shouldOutput { + expectedOutput = fmt.Sprintf("attempted to output logs for namespace: %s", expectedNamespace) + } + is := assert.New(t) + instAction := installAction(t) + instAction.ReleaseName = "failed-hooks" + outBuffer := &bytes.Buffer{} + instAction.cfg.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard, LogOutput: outBuffer} + + templates := []*chart.File{ + {Name: "templates/hello", Data: []byte("hello: world")}, + {Name: "templates/hooks", Data: []byte(manifest)}, + } + vals := map[string]interface{}{} + + res, err := instAction.Run(buildChartWithTemplates(templates), vals) + is.NoError(err) + is.Equal(expectedOutput, outBuffer.String()) + is.Equal(release.StatusDeployed, res.Info.Status) +} + +func runInstallForHooksWithFailure(t *testing.T, manifest, expectedNamespace string, shouldOutput bool) { + var expectedOutput string + if shouldOutput { + expectedOutput = fmt.Sprintf("attempted to output logs for namespace: %s", expectedNamespace) + } + is := assert.New(t) + instAction := installAction(t) + instAction.ReleaseName = "failed-hooks" + failingClient := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) + failingClient.WatchUntilReadyError = fmt.Errorf("failed watch") + instAction.cfg.KubeClient = failingClient + outBuffer := &bytes.Buffer{} + failingClient.PrintingKubeClient = kubefake.PrintingKubeClient{Out: ioutil.Discard, LogOutput: outBuffer} + + templates := []*chart.File{ + {Name: "templates/hello", Data: []byte("hello: world")}, + {Name: "templates/hooks", Data: []byte(manifest)}, + } + vals := map[string]interface{}{} + + res, err := instAction.Run(buildChartWithTemplates(templates), vals) + is.Error(err) + is.Contains(res.Info.Description, "failed pre-install") + is.Equal(expectedOutput, outBuffer.String()) + is.Equal(release.StatusFailed, res.Info.Status) +} diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 9f738f0bc..a1eadf693 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -17,6 +17,7 @@ limitations under the License. package action import ( + "bytes" "context" "fmt" "io" @@ -354,11 +355,14 @@ func TestInstallRelease_FailedHooks(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WatchUntilReadyError = fmt.Errorf("Failed watch") instAction.cfg.KubeClient = failer + outBuffer := &bytes.Buffer{} + failer.PrintingKubeClient = kubefake.PrintingKubeClient{Out: ioutil.Discard, LogOutput: outBuffer} vals := map[string]interface{}{} res, err := instAction.Run(buildChart(), vals) is.Error(err) is.Contains(res.Info.Description, "failed post-install") + is.Equal("", outBuffer.String()) is.Equal(release.StatusFailed, res.Info.Status) } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 0b84f5219..bf7e77c5a 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -29,6 +29,8 @@ import ( "sync" "time" + "k8s.io/client-go/rest" + jsonpatch "github.com/evanphx/json-patch" "github.com/pkg/errors" batch "k8s.io/api/batch/v1" @@ -83,7 +85,7 @@ type Client struct { // Namespace allows to bypass the kubeconfig file for the choice of the namespace Namespace string - kubeClient *kubernetes.Clientset + kubeClient kubernetes.Interface } func init() { @@ -111,7 +113,7 @@ func New(getter genericclioptions.RESTClientGetter) *Client { var nopLogger = func(_ string, _ ...interface{}) {} // getKubeClient get or create a new KubernetesClientSet -func (c *Client) getKubeClient() (*kubernetes.Clientset, error) { +func (c *Client) getKubeClient() (kubernetes.Interface, error) { var err error if c.kubeClient == nil { c.kubeClient, err = c.Factory.KubernetesClientSet() @@ -131,7 +133,7 @@ func (c *Client) IsReachable() error { if err != nil { return errors.Wrap(err, "Kubernetes cluster unreachable") } - if _, err := client.ServerVersion(); err != nil { + if _, err := client.Discovery().ServerVersion(); err != nil { return errors.Wrap(err, "Kubernetes cluster unreachable") } return nil @@ -812,6 +814,48 @@ func (c *Client) waitForPodSuccess(obj runtime.Object, name string) (bool, error return false, nil } +// GetPodList uses the kubernetes interface to get the list of pods filtered by listOptions +func (c *Client) GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) { + podList, err := c.kubeClient.CoreV1().Pods(namespace).List(context.Background(), listOptions) + if err != nil { + return nil, fmt.Errorf("failed to get pod list with options: %+v with error: %v", listOptions, err) + } + return podList, nil +} + +// OutputContainerLogsForPodList is a helper that outputs logs for a list of pods +func (c *Client) OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writer io.Writer) error { + for _, pod := range podList.Items { + for _, container := range pod.Spec.Containers { + options := &v1.PodLogOptions{ + Container: container.Name, + } + request := c.kubeClient.CoreV1().Pods(namespace).GetLogs(pod.Name, options) + err2 := copyRequestStreamToWriter(request, pod.Name, container.Name, writer) + if err2 != nil { + return err2 + } + } + } + return nil +} + +func copyRequestStreamToWriter(request *rest.Request, podName, containerName string, writer io.Writer) error { + readCloser, err := request.Stream(context.Background()) + if err != nil { + return errors.Errorf("Failed to stream pod logs for pod: %s, container: %s", podName, containerName) + } + defer readCloser.Close() + _, err = io.Copy(writer, readCloser) + if err != nil { + return errors.Errorf("Failed to copy IO from logs for pod: %s, container: %s", podName, containerName) + } + if err != nil { + return errors.Errorf("Failed to close reader for pod: %s, container: %s", podName, containerName) + } + return nil +} + // scrubValidationError removes kubectl info from the message. func scrubValidationError(err error) error { if err == nil { diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index f2d6bcb59..d9bd72783 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -24,10 +24,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" + k8sfake "k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest/fake" cmdtesting "k8s.io/kubectl/pkg/cmd/testing" @@ -682,6 +685,38 @@ func TestReal(t *testing.T) { } } +func TestGetPodList(t *testing.T) { + + namespace := "some-namespace" + names := []string{"dave", "jimmy"} + var responsePodList v1.PodList + for _, name := range names { + responsePodList.Items = append(responsePodList.Items, newPodWithStatus(name, v1.PodStatus{}, namespace)) + } + + kubeClient := k8sfake.NewSimpleClientset(&responsePodList) + c := Client{Namespace: namespace, kubeClient: kubeClient} + + podList, err := c.GetPodList(namespace, metav1.ListOptions{}) + clientAssertions := assert.New(t) + clientAssertions.NoError(err) + clientAssertions.Equal(&responsePodList, podList) + +} + +func TestOutputContainerLogsForPodList(t *testing.T) { + namespace := "some-namespace" + somePodList := newPodList("jimmy", "three", "structs") + + kubeClient := k8sfake.NewSimpleClientset(&somePodList) + c := Client{Namespace: namespace, kubeClient: kubeClient} + outBuffer := &bytes.Buffer{} + err := c.OutputContainerLogsForPodList(&somePodList, namespace, outBuffer) + clientAssertions := assert.New(t) + clientAssertions.NoError(err) + clientAssertions.Equal("fake logsfake logsfake logs", outBuffer.String()) +} + const testServiceManifest = ` kind: Service apiVersion: v1 diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index 0b957d725..4b9a6d523 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -17,6 +17,7 @@ limitations under the License. package fake import ( + "fmt" "io" "strings" "time" @@ -31,7 +32,8 @@ import ( // PrintingKubeClient implements KubeClient, but simply prints the reader to // the given output. type PrintingKubeClient struct { - Out io.Writer + Out io.Writer + LogOutput io.Writer } // IsReachable checks if the cluster is reachable @@ -110,6 +112,22 @@ func (p *PrintingKubeClient) BuildTable(_ io.Reader, _ bool) (kube.ResourceList, return []*resource.Info{}, nil } +// WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase. +func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(_ string, _ time.Duration) (v1.PodPhase, error) { + return v1.PodSucceeded, nil +} + +// GetPodList implements KubeClient GetPodList. +func (p *PrintingKubeClient) GetPodList(_ string, _ metav1.ListOptions) (*v1.PodList, error) { + return &v1.PodList{}, nil +} + +// OutputContainerLogsForPodList implements KubeClient OutputContainerLogsForPodList. +func (p *PrintingKubeClient) OutputContainerLogsForPodList(_ *v1.PodList, someNamespace string, _ io.Writer) error { + _, err := io.Copy(p.LogOutput, strings.NewReader(fmt.Sprintf("attempted to output logs for namespace: %s", someNamespace))) + return err +} + // DeleteWithPropagationPolicy implements KubeClient delete. // // It only prints out the content to be deleted. diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 7dc7ad8bc..4d295f560 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -20,6 +20,7 @@ import ( "io" "time" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -73,6 +74,12 @@ type Interface interface { type InterfaceExt interface { // WaitForDelete wait up to the given timeout for the specified resources to be deleted. WaitForDelete(resources ResourceList, timeout time.Duration) error + + // GetPodList list all pods that match the specified listOptions + GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) + + // OutputContainerLogsForPodList output the logs for a pod list + OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writer io.Writer) error } // InterfaceDeletionPropagation is introduced to avoid breaking backwards compatibility for Interface implementers. diff --git a/pkg/release/hook.go b/pkg/release/hook.go index e2cdc0eb8..5ff61fdaa 100644 --- a/pkg/release/hook.go +++ b/pkg/release/hook.go @@ -50,6 +50,17 @@ const ( func (x HookDeletePolicy) String() string { return string(x) } +// HookOutputLogPolicy specifies the hook output log policy +type HookOutputLogPolicy string + +// Hook output log policy types +const ( + HookOutputOnSucceeded HookOutputLogPolicy = "hook-succeeded" + HookOutputOnFailed HookOutputLogPolicy = "hook-failed" +) + +func (x HookOutputLogPolicy) String() string { return string(x) } + // HookAnnotation is the label name for a hook const HookAnnotation = "helm.sh/hook" @@ -59,6 +70,9 @@ const HookWeightAnnotation = "helm.sh/hook-weight" // HookDeleteAnnotation is the label name for the delete policy for a hook const HookDeleteAnnotation = "helm.sh/hook-delete-policy" +// HookOutputLogAnnotation is the label name for the output log policy for a hook +const HookOutputLogAnnotation = "helm.sh/hook-output-log-policy" + // Hook defines a hook object. type Hook struct { Name string `json:"name,omitempty"` @@ -76,6 +90,8 @@ type Hook struct { Weight int `json:"weight,omitempty"` // DeletePolicies are the policies that indicate when to delete the hook DeletePolicies []HookDeletePolicy `json:"delete_policies,omitempty"` + // OutputLogPolicies defines whether we should copy hook logs back to main process + OutputLogPolicies []HookOutputLogPolicy `json:"output_log_policies,omitempty"` } // A HookExecution records the result for the last execution of a hook for a given release. diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/releaseutil/manifest_sorter.go index b2db2ff9f..4aaae2d8c 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/releaseutil/manifest_sorter.go @@ -123,11 +123,18 @@ func SortManifests(files map[string]string, _ chartutil.VersionSet, ordering Kin // // To determine the policy to delete the hook, it looks for a YAML structure like this: // -// kind: SomeKind -// apiVersion: v1 -// metadata: -// annotations: -// helm.sh/hook-delete-policy: hook-succeeded +// kind: SomeKind +// apiVersion: v1 +// metadata: +// annotations: +// helm.sh/hook-delete-policy: hook-succeeded +// To determine the policy to output logs of the hook (for Pod and Job only), it looks for a YAML structure like this: +// +// kind: Pod +// apiVersion: v1 +// metadata: +// annotations: +// helm.sh/hook-output-log-policy: hook-succeeded,hook-failed func (file *manifestFile) sort(result *result) error { // Go through manifests in order found in file (function `SplitManifests` creates integer-sortable keys) var sortedEntryKeys []string @@ -166,13 +173,14 @@ func (file *manifestFile) sort(result *result) error { hw := calculateHookWeight(entry) h := &release.Hook{ - Name: entry.Metadata.Name, - Kind: entry.Kind, - Path: file.path, - Manifest: m, - Events: []release.HookEvent{}, - Weight: hw, - DeletePolicies: []release.HookDeletePolicy{}, + Name: entry.Metadata.Name, + Kind: entry.Kind, + Path: file.path, + Manifest: m, + Events: []release.HookEvent{}, + Weight: hw, + DeletePolicies: []release.HookDeletePolicy{}, + OutputLogPolicies: []release.HookOutputLogPolicy{}, } isUnknownHook := false @@ -196,6 +204,10 @@ func (file *manifestFile) sort(result *result) error { operateAnnotationValues(entry, release.HookDeleteAnnotation, func(value string) { h.DeletePolicies = append(h.DeletePolicies, release.HookDeletePolicy(value)) }) + + operateAnnotationValues(entry, release.HookOutputLogAnnotation, func(value string) { + h.OutputLogPolicies = append(h.OutputLogPolicies, release.HookOutputLogPolicy(value)) + }) } return nil From 3964f84ac86a190b8e163554a056f67f09555cfe Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 3 May 2023 10:35:25 +0100 Subject: [PATCH 130/271] Tidy up imports Signed-off-by: Chris --- pkg/action/hooks_test.go | 6 +++--- pkg/action/install_test.go | 2 +- pkg/kube/client.go | 2 -- pkg/kube/fake/printer.go | 1 + 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/action/hooks_test.go b/pkg/action/hooks_test.go index 25a28f60f..76de9e505 100644 --- a/pkg/action/hooks_test.go +++ b/pkg/action/hooks_test.go @@ -19,7 +19,7 @@ package action import ( "bytes" "fmt" - "io/ioutil" + "io" "testing" "github.com/stretchr/testify/assert" @@ -166,7 +166,7 @@ func runInstallForHooksWithSuccess(t *testing.T, manifest, expectedNamespace str instAction := installAction(t) instAction.ReleaseName = "failed-hooks" outBuffer := &bytes.Buffer{} - instAction.cfg.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard, LogOutput: outBuffer} + instAction.cfg.KubeClient = &kubefake.PrintingKubeClient{Out: io.Discard, LogOutput: outBuffer} templates := []*chart.File{ {Name: "templates/hello", Data: []byte("hello: world")}, @@ -192,7 +192,7 @@ func runInstallForHooksWithFailure(t *testing.T, manifest, expectedNamespace str failingClient.WatchUntilReadyError = fmt.Errorf("failed watch") instAction.cfg.KubeClient = failingClient outBuffer := &bytes.Buffer{} - failingClient.PrintingKubeClient = kubefake.PrintingKubeClient{Out: ioutil.Discard, LogOutput: outBuffer} + failingClient.PrintingKubeClient = kubefake.PrintingKubeClient{Out: io.Discard, LogOutput: outBuffer} templates := []*chart.File{ {Name: "templates/hello", Data: []byte("hello: world")}, diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index a1eadf693..f78fa40d2 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -356,7 +356,7 @@ func TestInstallRelease_FailedHooks(t *testing.T) { failer.WatchUntilReadyError = fmt.Errorf("Failed watch") instAction.cfg.KubeClient = failer outBuffer := &bytes.Buffer{} - failer.PrintingKubeClient = kubefake.PrintingKubeClient{Out: ioutil.Discard, LogOutput: outBuffer} + failer.PrintingKubeClient = kubefake.PrintingKubeClient{Out: io.Discard, LogOutput: outBuffer} vals := map[string]interface{}{} res, err := instAction.Run(buildChart(), vals) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index bf7e77c5a..361111fed 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -29,8 +29,6 @@ import ( "sync" "time" - "k8s.io/client-go/rest" - jsonpatch "github.com/evanphx/json-patch" "github.com/pkg/errors" batch "k8s.io/api/batch/v1" diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index 4b9a6d523..65515812e 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -22,6 +22,7 @@ import ( "strings" "time" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" From a55a4770691fb7d98b2db8c8f66e20159396053d Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Wed, 28 Aug 2024 21:14:17 +0100 Subject: [PATCH 131/271] Fix lint Signed-off-by: Chris Berry --- pkg/action/hooks.go | 6 +++--- pkg/releaseutil/manifest_sorter.go | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 95d843ce0..b1e8e1d66 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -51,7 +51,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, for _, h := range executingHooks { // Set default delete policy to before-hook-creation - if h.DeletePolicies == nil || len(h.DeletePolicies) == 0 { + if len(h.DeletePolicies) == 0 { // TODO(jlegrone): Only apply before-hook-creation delete policy to run to completion // resources. For all other resource types update in place if a // resource with the same name already exists and is owned by the @@ -157,7 +157,7 @@ func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.Hoo return errors.New(joinErrors(errs)) } - //wait for resources until they are deleted to avoid conflicts + // wait for resources until they are deleted to avoid conflicts if kubeClient, ok := cfg.KubeClient.(kube.InterfaceExt); ok { if err := kubeClient.WaitForDelete(resources, timeout); err != nil { return err @@ -198,7 +198,7 @@ func (cfg *Configuration) outputLogsByPolicy(h *release.Hook, releaseNamespace s } func (cfg *Configuration) outputContainerLogsForListOptions(namespace string, listOptions metav1.ListOptions) error { - //TODO Helm 4: Remove this check when GetPodList and OutputContainerLogsForPodList are moved from InterfaceExt to Interface + // TODO Helm 4: Remove this check when GetPodList and OutputContainerLogsForPodList are moved from InterfaceExt to Interface if kubeClient, ok := cfg.KubeClient.(kube.InterfaceExt); ok { podList, err := kubeClient.GetPodList(namespace, listOptions) if err != nil { diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/releaseutil/manifest_sorter.go index 4aaae2d8c..844ce161b 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/releaseutil/manifest_sorter.go @@ -123,18 +123,19 @@ func SortManifests(files map[string]string, _ chartutil.VersionSet, ordering Kin // // To determine the policy to delete the hook, it looks for a YAML structure like this: // -// kind: SomeKind -// apiVersion: v1 -// metadata: -// annotations: -// helm.sh/hook-delete-policy: hook-succeeded +// kind: SomeKind +// apiVersion: v1 +// metadata: +// annotations: +// helm.sh/hook-delete-policy: hook-succeeded +// // To determine the policy to output logs of the hook (for Pod and Job only), it looks for a YAML structure like this: // -// kind: Pod -// apiVersion: v1 -// metadata: -// annotations: -// helm.sh/hook-output-log-policy: hook-succeeded,hook-failed +// kind: Pod +// apiVersion: v1 +// metadata: +// annotations: +// helm.sh/hook-output-log-policy: hook-succeeded,hook-failed func (file *manifestFile) sort(result *result) error { // Go through manifests in order found in file (function `SplitManifests` creates integer-sortable keys) var sortedEntryKeys []string From 3d4e679d9faad8167aeb99f4d02eed2ed99723de Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Tue, 14 Jan 2025 10:49:28 +0000 Subject: [PATCH 132/271] Update based on review comments Signed-off-by: Chris Berry --- pkg/action/hooks.go | 2 +- pkg/action/hooks_test.go | 6 +++--- pkg/kube/interface.go | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index b1e8e1d66..021a563c3 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -199,7 +199,7 @@ func (cfg *Configuration) outputLogsByPolicy(h *release.Hook, releaseNamespace s func (cfg *Configuration) outputContainerLogsForListOptions(namespace string, listOptions metav1.ListOptions) error { // TODO Helm 4: Remove this check when GetPodList and OutputContainerLogsForPodList are moved from InterfaceExt to Interface - if kubeClient, ok := cfg.KubeClient.(kube.InterfaceExt); ok { + if kubeClient, ok := cfg.KubeClient.(kube.InterfaceLogs); ok { podList, err := kubeClient.GetPodList(namespace, listOptions) if err != nil { return err diff --git a/pkg/action/hooks_test.go b/pkg/action/hooks_test.go index 76de9e505..0f4a9be34 100644 --- a/pkg/action/hooks_test.go +++ b/pkg/action/hooks_test.go @@ -24,9 +24,9 @@ import ( "github.com/stretchr/testify/assert" - "helm.sh/helm/v3/pkg/chart" - kubefake "helm.sh/helm/v3/pkg/kube/fake" - "helm.sh/helm/v3/pkg/release" + "helm.sh/helm/v4/pkg/chart" + kubefake "helm.sh/helm/v4/pkg/kube/fake" + "helm.sh/helm/v4/pkg/release" ) func podManifestWithOutputLogs(hookDefinitions []release.HookOutputLogPolicy) string { diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 4d295f560..f701690e3 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -68,13 +68,18 @@ type Interface interface { IsReachable() error } -// InterfaceExt is introduced to avoid breaking backwards compatibility for Interface implementers. +// InterfaceExt was introduced to avoid breaking backwards compatibility for Interface implementers. // // TODO Helm 4: Remove InterfaceExt and integrate its method(s) into the Interface. type InterfaceExt interface { // WaitForDelete wait up to the given timeout for the specified resources to be deleted. WaitForDelete(resources ResourceList, timeout time.Duration) error +} +// InterfaceLogs was introduced to avoid breaking backwards compatibility for Interface implementers. +// +// TODO Helm 4: Remove InterfaceLogs and integrate its method(s) into the Interface. +type InterfaceLogs interface { // GetPodList list all pods that match the specified listOptions GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) @@ -86,7 +91,7 @@ type InterfaceExt interface { // // TODO Helm 4: Remove InterfaceDeletionPropagation and integrate its method(s) into the Interface. type InterfaceDeletionPropagation interface { - // Delete destroys one or more resources. The deletion propagation is handled as per the given deletion propagation value. + // DeleteWithPropagationPolicy destroys one or more resources. The deletion propagation is handled as per the given deletion propagation value. DeleteWithPropagationPolicy(resources ResourceList, policy metav1.DeletionPropagation) (*Result, []error) } @@ -114,5 +119,6 @@ type InterfaceResources interface { var _ Interface = (*Client)(nil) var _ InterfaceExt = (*Client)(nil) +var _ InterfaceLogs = (*Client)(nil) var _ InterfaceDeletionPropagation = (*Client)(nil) var _ InterfaceResources = (*Client)(nil) From 243cb2e21f38767314e2dcd5b827b5aa4adc94fb Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Tue, 14 Jan 2025 11:09:40 +0000 Subject: [PATCH 133/271] Update based on review comments Signed-off-by: Chris Berry --- pkg/action/hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 021a563c3..539f8e7c1 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -198,7 +198,7 @@ func (cfg *Configuration) outputLogsByPolicy(h *release.Hook, releaseNamespace s } func (cfg *Configuration) outputContainerLogsForListOptions(namespace string, listOptions metav1.ListOptions) error { - // TODO Helm 4: Remove this check when GetPodList and OutputContainerLogsForPodList are moved from InterfaceExt to Interface + // TODO Helm 4: Remove this check when GetPodList and OutputContainerLogsForPodList are moved from InterfaceLogs to Interface if kubeClient, ok := cfg.KubeClient.(kube.InterfaceLogs); ok { podList, err := kubeClient.GetPodList(namespace, listOptions) if err != nil { From f729b9ade059579ee53182bafcb399a8b7d86f5a Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Thu, 20 Feb 2025 12:36:11 -0500 Subject: [PATCH 134/271] add short circuit return Co-authored-by: George Jenkins Signed-off-by: Scott Rigby --- pkg/action/hooks.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 539f8e7c1..310e6d372 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -180,7 +180,9 @@ func hookHasDeletePolicy(h *release.Hook, policy release.HookDeletePolicy) bool // outputLogsByPolicy outputs a pods logs if the hook policy instructs it to func (cfg *Configuration) outputLogsByPolicy(h *release.Hook, releaseNamespace string, policy release.HookOutputLogPolicy) error { - if hookHasOutputLogPolicy(h, policy) { + if !hookHasOutputLogPolicy(h, policy) { + return nil + } namespace, err := cfg.deriveNamespace(h, releaseNamespace) if err != nil { return err From 3796c1f4a171d33b6622e118ae812435574fdadb Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Thu, 20 Feb 2025 12:37:41 -0500 Subject: [PATCH 135/271] remove comments about previous functionality Signed-off-by: Scott Rigby --- pkg/action/hooks.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 310e6d372..370aa9a67 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -103,8 +103,6 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // under failed condition. If so, then clear the corresponding resource object in the hook if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); err != nil { // We log the error here as we want to propagate the hook failure upwards to the release object. - // This is a change in behaviour as the edge case previously would lose the hook error and only - // raise the delete hook error. log.Printf("error the hook resource on hook failure: %v", errDeleting) } return err From e8a76bc3eb2a9e1ce9a246164d9d555031eb055e Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Thu, 20 Feb 2025 13:34:09 -0500 Subject: [PATCH 136/271] fix err check Co-authored-by: George Jenkins Signed-off-by: Scott Rigby --- pkg/action/hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 370aa9a67..ebe8be6ba 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -101,7 +101,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, } // If a hook is failed, check the annotation of the hook to determine whether the hook should be deleted // under failed condition. If so, then clear the corresponding resource object in the hook - if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); err != nil { + if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); errDeleting != nil { // We log the error here as we want to propagate the hook failure upwards to the release object. log.Printf("error the hook resource on hook failure: %v", errDeleting) } From 52ac92fb690bb6c4f8d09900330608b88f745ab2 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Thu, 20 Feb 2025 13:34:54 -0500 Subject: [PATCH 137/271] clarify fix error message Signed-off-by: Scott Rigby --- pkg/action/hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index ebe8be6ba..dadcb27f6 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -103,7 +103,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // under failed condition. If so, then clear the corresponding resource object in the hook if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); errDeleting != nil { // We log the error here as we want to propagate the hook failure upwards to the release object. - log.Printf("error the hook resource on hook failure: %v", errDeleting) + log.Printf("error deleting the hook resource on hook failure: %v", errDeleting) } return err } From 6d30fa59904f1936613e0882d3e3c2608351da0b Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Fri, 21 Feb 2025 12:33:12 +0000 Subject: [PATCH 138/271] Add HookOutputFunc and generic yaml unmarshaller Signed-off-by: Chris Berry --- pkg/action/action.go | 13 ++++++++- pkg/action/hooks.go | 57 ++++++++++++++++++---------------------- pkg/kube/client.go | 4 +-- pkg/kube/client_test.go | 3 ++- pkg/kube/fake/printer.go | 2 +- pkg/kube/interface.go | 2 +- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 8418a4c27..0d81a63cb 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -19,6 +19,8 @@ package action import ( "bytes" "fmt" + "io" + "log" "os" "path" "path/filepath" @@ -95,6 +97,9 @@ type Configuration struct { Capabilities *chartutil.Capabilities Log func(string, ...interface{}) + + // HookOutputFunc Called with container name and returns and expects writer that will receive the log output + HookOutputFunc func(namespace, pod, container string) io.Writer } // renderResources renders the templates in a chart @@ -122,7 +127,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu var err2 error // A `helm template` should not talk to the remote cluster. However, commands with the flag - //`--dry-run` with the value of `false`, `none`, or `server` should try to interact with the cluster. + // `--dry-run` with the value of `false`, `none`, or `server` should try to interact with the cluster. // It may break in interesting and exotic ways because other data (e.g. discovery) is mocked. if interactWithRemote && cfg.RESTClientGetter != nil { restConfig, err := cfg.RESTClientGetter.ToRESTConfig() @@ -422,6 +427,12 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp cfg.KubeClient = kc cfg.Releases = store cfg.Log = log + cfg.HookOutputFunc = defaultHookOutputWriter return nil } + +// defaultHookOutputWriter will write the Hook logs to log.Writer(). +func defaultHookOutputWriter(_, _, _ string) io.Writer { + return log.Writer() +} diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index dadcb27f6..b6c505807 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -19,16 +19,16 @@ import ( "bytes" "fmt" "log" + "slices" "sort" "time" "helm.sh/helm/v4/pkg/kube" - "helm.sh/helm/v4/pkg/chartutil" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/pkg/errors" + "gopkg.in/yaml.v3" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" @@ -179,22 +179,20 @@ func hookHasDeletePolicy(h *release.Hook, policy release.HookDeletePolicy) bool // outputLogsByPolicy outputs a pods logs if the hook policy instructs it to func (cfg *Configuration) outputLogsByPolicy(h *release.Hook, releaseNamespace string, policy release.HookOutputLogPolicy) error { if !hookHasOutputLogPolicy(h, policy) { - return nil + return nil } - namespace, err := cfg.deriveNamespace(h, releaseNamespace) - if err != nil { - return err - } - switch h.Kind { - case "Job": - return cfg.outputContainerLogsForListOptions(namespace, metav1.ListOptions{LabelSelector: fmt.Sprintf("job-name=%s", h.Name)}) - case "Pod": - return cfg.outputContainerLogsForListOptions(namespace, metav1.ListOptions{FieldSelector: fmt.Sprintf("metadata.name=%s", h.Name)}) - default: - return nil - } + namespace, err := cfg.deriveNamespace(h, releaseNamespace) + if err != nil { + return err + } + switch h.Kind { + case "Job": + return cfg.outputContainerLogsForListOptions(namespace, metav1.ListOptions{LabelSelector: fmt.Sprintf("job-name=%s", h.Name)}) + case "Pod": + return cfg.outputContainerLogsForListOptions(namespace, metav1.ListOptions{FieldSelector: fmt.Sprintf("metadata.name=%s", h.Name)}) + default: + return nil } - return nil } func (cfg *Configuration) outputContainerLogsForListOptions(namespace string, listOptions metav1.ListOptions) error { @@ -204,35 +202,30 @@ func (cfg *Configuration) outputContainerLogsForListOptions(namespace string, li if err != nil { return err } - err = kubeClient.OutputContainerLogsForPodList(podList, namespace, log.Writer()) + err = kubeClient.OutputContainerLogsForPodList(podList, namespace, cfg.HookOutputFunc) return err } return nil } func (cfg *Configuration) deriveNamespace(h *release.Hook, namespace string) (string, error) { - values, err := chartutil.ReadValues([]byte(h.Manifest)) + tmp := struct { + Metadata struct { + Namespace string + } + }{} + err := yaml.Unmarshal([]byte(h.Manifest), &tmp) if err != nil { - return "", errors.Wrapf(err, "unable to parse kubernetes manifest for output logs hook %s", h.Path) + return "", errors.Wrapf(err, "unable to parse metadata.namespace from kubernetes manifest for output logs hook %s", h.Path) } - value, err := values.PathValue("metadata.namespace") - switch err.(type) { - case nil: - return value.(string), nil - case chartutil.ErrNoValue: + if tmp.Metadata.Namespace == "" { return namespace, nil - default: - return "", errors.Wrapf(err, "unable to parse path of metadata.namespace in yaml for output logs hook %s", h.Path) } + return tmp.Metadata.Namespace, nil } // hookHasOutputLogPolicy determines whether the defined hook output log policy matches the hook output log policies // supported by helm. func hookHasOutputLogPolicy(h *release.Hook, policy release.HookOutputLogPolicy) bool { - for _, v := range h.OutputLogPolicies { - if policy == v { - return true - } - } - return false + return slices.Contains(h.OutputLogPolicies, policy) } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 361111fed..fd111c647 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -822,14 +822,14 @@ func (c *Client) GetPodList(namespace string, listOptions metav1.ListOptions) (* } // OutputContainerLogsForPodList is a helper that outputs logs for a list of pods -func (c *Client) OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writer io.Writer) error { +func (c *Client) OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writerFunc func(namespace, pod, container string) io.Writer) error { for _, pod := range podList.Items { for _, container := range pod.Spec.Containers { options := &v1.PodLogOptions{ Container: container.Name, } request := c.kubeClient.CoreV1().Pods(namespace).GetLogs(pod.Name, options) - err2 := copyRequestStreamToWriter(request, pod.Name, container.Name, writer) + err2 := copyRequestStreamToWriter(request, pod.Name, container.Name, writerFunc(namespace, pod.Name, container.Name)) if err2 != nil { return err2 } diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index d9bd72783..ff1335f0f 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -711,7 +711,8 @@ func TestOutputContainerLogsForPodList(t *testing.T) { kubeClient := k8sfake.NewSimpleClientset(&somePodList) c := Client{Namespace: namespace, kubeClient: kubeClient} outBuffer := &bytes.Buffer{} - err := c.OutputContainerLogsForPodList(&somePodList, namespace, outBuffer) + outBufferFunc := func(_, _, _ string) io.Writer { return outBuffer } + err := c.OutputContainerLogsForPodList(&somePodList, namespace, outBufferFunc) clientAssertions := assert.New(t) clientAssertions.NoError(err) clientAssertions.Equal("fake logsfake logsfake logs", outBuffer.String()) diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index 65515812e..dcce9a3be 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -124,7 +124,7 @@ func (p *PrintingKubeClient) GetPodList(_ string, _ metav1.ListOptions) (*v1.Pod } // OutputContainerLogsForPodList implements KubeClient OutputContainerLogsForPodList. -func (p *PrintingKubeClient) OutputContainerLogsForPodList(_ *v1.PodList, someNamespace string, _ io.Writer) error { +func (p *PrintingKubeClient) OutputContainerLogsForPodList(_ *v1.PodList, someNamespace string, _ func(namespace, pod, container string) io.Writer) error { _, err := io.Copy(p.LogOutput, strings.NewReader(fmt.Sprintf("attempted to output logs for namespace: %s", someNamespace))) return err } diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index f701690e3..c9776cacd 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -84,7 +84,7 @@ type InterfaceLogs interface { GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) // OutputContainerLogsForPodList output the logs for a pod list - OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writer io.Writer) error + OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writerFunc func(namespace, pod, container string) io.Writer) error } // InterfaceDeletionPropagation is introduced to avoid breaking backwards compatibility for Interface implementers. From 9791767baa9d3e4d460c25e921f06172b2cec53f Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Fri, 21 Feb 2025 16:16:26 +0000 Subject: [PATCH 139/271] Refactor based on review comment Signed-off-by: Chris Berry --- cmd/helm/helm.go | 7 ++++++- cmd/helm/list.go | 2 +- pkg/action/action.go | 19 ++++++++++--------- pkg/action/action_test.go | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index aa981740f..3d5c17030 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -57,6 +57,11 @@ func warning(format string, v ...interface{}) { fmt.Fprintf(os.Stderr, format, v...) } +// hookOutputWriter provides the writer for writing hook logs. +func hookOutputWriter(_, _, _ string) io.Writer { + return log.Writer() +} + 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 @@ -74,7 +79,7 @@ func main() { // 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 { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, debug, hookOutputWriter); err != nil { log.Fatal(err) } if helmDriver == "memory" { diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 67da22cdf..f9bf336d4 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -71,7 +71,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(cmd *cobra.Command, _ []string) error { if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug, nil); err != nil { return err } } diff --git a/pkg/action/action.go b/pkg/action/action.go index 0d81a63cb..dfb263269 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -20,7 +20,6 @@ import ( "bytes" "fmt" "io" - "log" "os" "path" "path/filepath" @@ -98,7 +97,7 @@ type Configuration struct { Log func(string, ...interface{}) - // HookOutputFunc Called with container name and returns and expects writer that will receive the log output + // HookOutputFunc called with container name and returns and expects writer that will receive the log output. HookOutputFunc func(namespace, pod, container string) io.Writer } @@ -247,6 +246,9 @@ type RESTClientGetter interface { // DebugLog sets the logger that writes debug strings type DebugLog func(format string, v ...interface{}) +// HookOutputFunc returns the io.Writer for outputting hook logs. +type HookOutputFunc func(namespace, pod, container string) io.Writer + // capabilities builds a Capabilities from discovery information. func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { if cfg.Capabilities != nil { @@ -375,7 +377,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { } // Init initializes the action configuration -func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog, outputFunc HookOutputFunc) error { kc := kube.New(getter) kc.Log = log @@ -427,12 +429,11 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp cfg.KubeClient = kc cfg.Releases = store cfg.Log = log - cfg.HookOutputFunc = defaultHookOutputWriter + if outputFunc != nil { + cfg.HookOutputFunc = outputFunc + } else { + cfg.HookOutputFunc = func(_, _, _ string) io.Writer { return io.Discard } + } return nil } - -// defaultHookOutputWriter will write the Hook logs to log.Writer(). -func defaultHookOutputWriter(_, _, _ string) io.Writer { - return log.Writer() -} diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 47cff6ec1..2d1516edb 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -334,7 +334,7 @@ func TestConfiguration_Init(t *testing.T) { t.Run(tt.name, func(t *testing.T) { cfg := &Configuration{} - actualErr := cfg.Init(nil, "default", tt.helmDriver, nil) + actualErr := cfg.Init(nil, "default", tt.helmDriver, nil, nil) if tt.expectErr { assert.Error(t, actualErr) assert.Contains(t, actualErr.Error(), tt.errMsg) From e5bc21c56b5b384acf77dbc3589694d03477cb27 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Fri, 21 Feb 2025 16:33:31 +0000 Subject: [PATCH 140/271] Refactor based on review comment Signed-off-by: Chris Berry --- cmd/helm/helm.go | 3 ++- cmd/helm/list.go | 2 +- pkg/action/action.go | 16 +++++++--------- pkg/action/action_test.go | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 3d5c17030..c8de18796 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -79,12 +79,13 @@ func main() { // 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, hookOutputWriter); err != nil { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, debug); err != nil { log.Fatal(err) } if helmDriver == "memory" { loadReleasesInMemory(actionConfig) } + actionConfig.SetHookOutputFunc(hookOutputWriter) }) if err := cmd.Execute(); err != nil { diff --git a/cmd/helm/list.go b/cmd/helm/list.go index f9bf336d4..67da22cdf 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -71,7 +71,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(cmd *cobra.Command, _ []string) error { if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug, nil); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil { return err } } diff --git a/pkg/action/action.go b/pkg/action/action.go index dfb263269..745f02138 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -246,9 +246,6 @@ type RESTClientGetter interface { // DebugLog sets the logger that writes debug strings type DebugLog func(format string, v ...interface{}) -// HookOutputFunc returns the io.Writer for outputting hook logs. -type HookOutputFunc func(namespace, pod, container string) io.Writer - // capabilities builds a Capabilities from discovery information. func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { if cfg.Capabilities != nil { @@ -377,7 +374,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { } // Init initializes the action configuration -func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog, outputFunc HookOutputFunc) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { kc := kube.New(getter) kc.Log = log @@ -429,11 +426,12 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp cfg.KubeClient = kc cfg.Releases = store cfg.Log = log - if outputFunc != nil { - cfg.HookOutputFunc = outputFunc - } else { - cfg.HookOutputFunc = func(_, _, _ string) io.Writer { return io.Discard } - } + cfg.HookOutputFunc = func(_, _, _ string) io.Writer { return io.Discard } return nil } + +// SetHookOutputFunc sets the HookOutputFunc on the Configuration. +func (cfg *Configuration) SetHookOutputFunc(hookOutputFunc func(_, _, _ string) io.Writer) { + cfg.HookOutputFunc = hookOutputFunc +} diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 2d1516edb..47cff6ec1 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -334,7 +334,7 @@ func TestConfiguration_Init(t *testing.T) { t.Run(tt.name, func(t *testing.T) { cfg := &Configuration{} - actualErr := cfg.Init(nil, "default", tt.helmDriver, nil, nil) + actualErr := cfg.Init(nil, "default", tt.helmDriver, nil) if tt.expectErr { assert.Error(t, actualErr) assert.Contains(t, actualErr.Error(), tt.errMsg) From 5c0deec32792d32c052883b73ee03be3381cabab Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 21 Feb 2025 15:25:55 -0500 Subject: [PATCH 141/271] Moving chartutil to chart/util chartutil was originally created to operate on protobufs which are no longer part of Helm. The util package makes more sense to be part of the chart package. This change is part of the HIP 20 to create v3 charts and explicitly call out v2 charts. The changes for this are in smaller bite size changes. Signed-off-by: Matt Farina --- Makefile | 4 ++-- cmd/helm/create.go | 2 +- cmd/helm/create_test.go | 2 +- cmd/helm/dependency_build_test.go | 2 +- cmd/helm/dependency_update_test.go | 2 +- cmd/helm/helm_test.go | 2 +- cmd/helm/lint.go | 2 +- cmd/helm/status.go | 2 +- cmd/helm/template.go | 2 +- cmd/helm/upgrade_test.go | 2 +- pkg/action/action.go | 2 +- pkg/action/action_test.go | 2 +- pkg/action/dependency_test.go | 2 +- pkg/action/get_values.go | 2 +- pkg/action/history.go | 2 +- pkg/action/install.go | 2 +- pkg/action/install_test.go | 2 +- pkg/action/lint.go | 2 +- pkg/action/package.go | 2 +- pkg/action/pull.go | 2 +- pkg/action/release_testing.go | 2 +- pkg/action/rollback.go | 2 +- pkg/action/show.go | 2 +- pkg/action/uninstall.go | 2 +- pkg/action/upgrade.go | 2 +- pkg/{chartutil => chart/util}/capabilities.go | 2 +- pkg/{chartutil => chart/util}/capabilities_test.go | 2 +- pkg/{chartutil => chart/util}/chartfile.go | 2 +- pkg/{chartutil => chart/util}/chartfile_test.go | 2 +- pkg/{chartutil => chart/util}/coalesce.go | 2 +- pkg/{chartutil => chart/util}/coalesce_test.go | 2 +- pkg/{chartutil => chart/util}/compatible.go | 2 +- pkg/{chartutil => chart/util}/compatible_test.go | 2 +- pkg/{chartutil => chart/util}/create.go | 2 +- pkg/{chartutil => chart/util}/create_test.go | 2 +- pkg/{chartutil => chart/util}/dependencies.go | 2 +- pkg/{chartutil => chart/util}/dependencies_test.go | 2 +- pkg/{chartutil => chart/util}/doc.go | 4 ++-- pkg/{chartutil => chart/util}/errors.go | 2 +- pkg/{chartutil => chart/util}/errors_test.go | 2 +- pkg/{chartutil => chart/util}/expand.go | 2 +- pkg/{chartutil => chart/util}/expand_test.go | 2 +- pkg/{chartutil => chart/util}/jsonschema.go | 2 +- pkg/{chartutil => chart/util}/jsonschema_test.go | 2 +- pkg/{chartutil => chart/util}/save.go | 2 +- pkg/{chartutil => chart/util}/save_test.go | 2 +- .../util}/testdata/chartfiletest.yaml | 0 .../util}/testdata/coleridge.yaml | 0 .../testdata/dependent-chart-alias/.helmignore | 0 .../util}/testdata/dependent-chart-alias/Chart.lock | 0 .../util}/testdata/dependent-chart-alias/Chart.yaml | 0 .../testdata/dependent-chart-alias/INSTALL.txt | 0 .../util}/testdata/dependent-chart-alias/LICENSE | 0 .../util}/testdata/dependent-chart-alias/README.md | 0 .../dependent-chart-alias/charts/_ignore_me | 0 .../dependent-chart-alias/charts/alpine/Chart.yaml | 0 .../dependent-chart-alias/charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../dependent-chart-alias/charts/alpine/values.yaml | 0 .../dependent-chart-alias/charts/mariner-4.3.2.tgz | Bin .../testdata/dependent-chart-alias/docs/README.md | 0 .../util}/testdata/dependent-chart-alias/icon.svg | 0 .../testdata/dependent-chart-alias/ignore/me.txt | 0 .../dependent-chart-alias/templates/template.tpl | 0 .../testdata/dependent-chart-alias/values.yaml | 0 .../testdata/dependent-chart-helmignore/.helmignore | 0 .../testdata/dependent-chart-helmignore/Chart.yaml | 0 .../dependent-chart-helmignore/charts/.ignore_me | 0 .../dependent-chart-helmignore/charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../templates/template.tpl | 0 .../testdata/dependent-chart-helmignore/values.yaml | 0 .../.helmignore | 0 .../dependent-chart-no-requirements-yaml/Chart.yaml | 0 .../INSTALL.txt | 0 .../dependent-chart-no-requirements-yaml/LICENSE | 0 .../dependent-chart-no-requirements-yaml/README.md | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../docs/README.md | 0 .../dependent-chart-no-requirements-yaml/icon.svg | 0 .../ignore/me.txt | 0 .../templates/template.tpl | 0 .../values.yaml | 0 .../.helmignore | 0 .../Chart.yaml | 0 .../INSTALL.txt | 0 .../LICENSE | 0 .../README.md | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../docs/README.md | 0 .../icon.svg | 0 .../ignore/me.txt | 0 .../templates/template.tpl | 0 .../values.yaml | 0 .../.helmignore | 0 .../Chart.yaml | 0 .../INSTALL.txt | 0 .../LICENSE | 0 .../README.md | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../docs/README.md | 0 .../icon.svg | 0 .../ignore/me.txt | 0 .../templates/template.tpl | 0 .../values.yaml | 0 .../util}/testdata/frobnitz-1.2.3.tgz | Bin .../util}/testdata/frobnitz/.helmignore | 0 .../util}/testdata/frobnitz/Chart.lock | 0 .../util}/testdata/frobnitz/Chart.yaml | 0 .../util}/testdata/frobnitz/INSTALL.txt | 0 .../util}/testdata/frobnitz/LICENSE | 0 .../util}/testdata/frobnitz/README.md | 0 .../util}/testdata/frobnitz/charts/_ignore_me | 0 .../testdata/frobnitz/charts/alpine/Chart.yaml | 0 .../util}/testdata/frobnitz/charts/alpine/README.md | 0 .../frobnitz/charts/alpine/charts/mast1/Chart.yaml | 0 .../frobnitz/charts/alpine/charts/mast1/values.yaml | 0 .../frobnitz/charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../testdata/frobnitz/charts/alpine/values.yaml | 0 .../testdata/frobnitz/charts/mariner/Chart.yaml | 0 .../charts/mariner/charts/albatross/Chart.yaml | 0 .../charts/mariner/charts/albatross/values.yaml | 0 .../charts/mariner/templates/placeholder.tpl | 0 .../testdata/frobnitz/charts/mariner/values.yaml | 0 .../util}/testdata/frobnitz/docs/README.md | 0 .../util}/testdata/frobnitz/icon.svg | 0 .../util}/testdata/frobnitz/ignore/me.txt | 0 .../util}/testdata/frobnitz/templates/template.tpl | 0 .../util}/testdata/frobnitz/values.yaml | 0 .../util}/testdata/frobnitz_backslash-1.2.3.tgz | Bin pkg/{chartutil => chart/util}/testdata/genfrob.sh | 0 .../parent-chart/Chart.lock | 0 .../parent-chart/Chart.yaml | 0 .../parent-chart/charts/dev-v0.1.0.tgz | Bin .../parent-chart/charts/prod-v0.1.0.tgz | Bin .../parent-chart/envs/dev/Chart.yaml | 0 .../parent-chart/envs/dev/values.yaml | 0 .../parent-chart/envs/prod/Chart.yaml | 0 .../parent-chart/envs/prod/values.yaml | 0 .../parent-chart/templates/autoscaler.yaml | 0 .../parent-chart/values.yaml | 0 .../util}/testdata/joonix/Chart.yaml | 0 .../util}/testdata/joonix/charts/.gitkeep | 0 .../util}/testdata/subpop/Chart.yaml | 0 .../util}/testdata/subpop/README.md | 0 .../testdata/subpop/charts/subchart1/Chart.yaml | 0 .../charts/subchart1/charts/subchartA/Chart.yaml | 0 .../charts/subchartA/templates/service.yaml | 0 .../charts/subchart1/charts/subchartA/values.yaml | 0 .../charts/subchart1/charts/subchartB/Chart.yaml | 0 .../charts/subchartB/templates/service.yaml | 0 .../charts/subchart1/charts/subchartB/values.yaml | 0 .../testdata/subpop/charts/subchart1/crds/crdA.yaml | 0 .../subpop/charts/subchart1/templates/NOTES.txt | 0 .../subpop/charts/subchart1/templates/service.yaml | 0 .../charts/subchart1/templates/subdir/role.yaml | 0 .../subchart1/templates/subdir/rolebinding.yaml | 0 .../subchart1/templates/subdir/serviceaccount.yaml | 0 .../testdata/subpop/charts/subchart1/values.yaml | 0 .../testdata/subpop/charts/subchart2/Chart.yaml | 0 .../charts/subchart2/charts/subchartB/Chart.yaml | 0 .../charts/subchartB/templates/service.yaml | 0 .../charts/subchart2/charts/subchartB/values.yaml | 0 .../charts/subchart2/charts/subchartC/Chart.yaml | 0 .../charts/subchartC/templates/service.yaml | 0 .../charts/subchart2/charts/subchartC/values.yaml | 0 .../subpop/charts/subchart2/templates/service.yaml | 0 .../testdata/subpop/charts/subchart2/values.yaml | 0 .../util}/testdata/subpop/noreqs/Chart.yaml | 0 .../testdata/subpop/noreqs/templates/service.yaml | 0 .../util}/testdata/subpop/noreqs/values.yaml | 0 .../util}/testdata/subpop/values.yaml | 0 .../util}/testdata/test-values-invalid.schema.json | 0 .../util}/testdata/test-values-negative.yaml | 0 .../util}/testdata/test-values.schema.json | 0 .../util}/testdata/test-values.yaml | 0 .../testdata/three-level-dependent-chart/README.md | 0 .../three-level-dependent-chart/umbrella/Chart.yaml | 0 .../umbrella/charts/app1/Chart.yaml | 0 .../umbrella/charts/app1/charts/library/Chart.yaml | 0 .../app1/charts/library/templates/service.yaml | 0 .../umbrella/charts/app1/charts/library/values.yaml | 0 .../umbrella/charts/app1/templates/service.yaml | 0 .../umbrella/charts/app1/values.yaml | 0 .../umbrella/charts/app2/Chart.yaml | 0 .../umbrella/charts/app2/charts/library/Chart.yaml | 0 .../app2/charts/library/templates/service.yaml | 0 .../umbrella/charts/app2/charts/library/values.yaml | 0 .../umbrella/charts/app2/templates/service.yaml | 0 .../umbrella/charts/app2/values.yaml | 0 .../umbrella/charts/app3/Chart.yaml | 0 .../umbrella/charts/app3/charts/library/Chart.yaml | 0 .../app3/charts/library/templates/service.yaml | 0 .../umbrella/charts/app3/charts/library/values.yaml | 0 .../umbrella/charts/app3/templates/service.yaml | 0 .../umbrella/charts/app3/values.yaml | 0 .../umbrella/charts/app4/Chart.yaml | 0 .../umbrella/charts/app4/charts/library/Chart.yaml | 0 .../app4/charts/library/templates/service.yaml | 0 .../umbrella/charts/app4/charts/library/values.yaml | 0 .../umbrella/charts/app4/templates/service.yaml | 0 .../umbrella/charts/app4/values.yaml | 0 .../umbrella/values.yaml | 0 pkg/{chartutil => chart/util}/validate_name.go | 2 +- pkg/{chartutil => chart/util}/validate_name_test.go | 2 +- pkg/{chartutil => chart/util}/values.go | 2 +- pkg/{chartutil => chart/util}/values_test.go | 2 +- pkg/downloader/manager.go | 2 +- pkg/downloader/manager_test.go | 2 +- pkg/engine/engine.go | 2 +- pkg/engine/engine_test.go | 2 +- pkg/lint/lint.go | 2 +- pkg/lint/lint_test.go | 2 +- pkg/lint/rules/chartfile.go | 2 +- pkg/lint/rules/chartfile_test.go | 2 +- pkg/lint/rules/dependencies_test.go | 2 +- pkg/lint/rules/deprecations.go | 2 +- pkg/lint/rules/template.go | 2 +- pkg/lint/rules/template_test.go | 2 +- pkg/lint/rules/values.go | 2 +- pkg/releaseutil/manifest_sorter.go | 2 +- pkg/repo/repotest/server.go | 2 +- 256 files changed, 67 insertions(+), 67 deletions(-) rename pkg/{chartutil => chart/util}/capabilities.go (99%) rename pkg/{chartutil => chart/util}/capabilities_test.go (99%) rename pkg/{chartutil => chart/util}/chartfile.go (99%) rename pkg/{chartutil => chart/util}/chartfile_test.go (99%) rename pkg/{chartutil => chart/util}/coalesce.go (99%) rename pkg/{chartutil => chart/util}/coalesce_test.go (99%) rename pkg/{chartutil => chart/util}/compatible.go (98%) rename pkg/{chartutil => chart/util}/compatible_test.go (98%) rename pkg/{chartutil => chart/util}/create.go (99%) rename pkg/{chartutil => chart/util}/create_test.go (99%) rename pkg/{chartutil => chart/util}/dependencies.go (99%) rename pkg/{chartutil => chart/util}/dependencies_test.go (99%) rename pkg/{chartutil => chart/util}/doc.go (92%) rename pkg/{chartutil => chart/util}/errors.go (98%) rename pkg/{chartutil => chart/util}/errors_test.go (97%) rename pkg/{chartutil => chart/util}/expand.go (99%) rename pkg/{chartutil => chart/util}/expand_test.go (99%) rename pkg/{chartutil => chart/util}/jsonschema.go (99%) rename pkg/{chartutil => chart/util}/jsonschema_test.go (99%) rename pkg/{chartutil => chart/util}/save.go (99%) rename pkg/{chartutil => chart/util}/save_test.go (99%) rename pkg/{chartutil => chart/util}/testdata/chartfiletest.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/coleridge.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/.helmignore (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/Chart.lock (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/INSTALL.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/LICENSE (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/_ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/alpine/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/docs/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/icon.svg (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/ignore/me.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/templates/template.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-alias/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/.helmignore (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/.ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/_ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/charts/alpine/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/templates/template.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-helmignore/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/.helmignore (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/LICENSE (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/docs/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/icon.svg (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-no-requirements-yaml/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz-1.2.3.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/.helmignore (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/Chart.lock (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/INSTALL.txt (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/LICENSE (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/_ignore_me (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/alpine/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/mariner/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/mariner/templates/placeholder.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/charts/mariner/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/docs/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/icon.svg (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/ignore/me.txt (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/templates/template.tpl (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/frobnitz_backslash-1.2.3.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/genfrob.sh (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/joonix/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/joonix/charts/.gitkeep (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/crds/crdA.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/templates/NOTES.txt (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/templates/subdir/role.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/charts/subchart2/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/noreqs/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/noreqs/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/noreqs/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/subpop/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/test-values-invalid.schema.json (100%) rename pkg/{chartutil => chart/util}/testdata/test-values-negative.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/test-values.schema.json (100%) rename pkg/{chartutil => chart/util}/testdata/test-values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/README.md (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml (100%) rename pkg/{chartutil => chart/util}/testdata/three-level-dependent-chart/umbrella/values.yaml (100%) rename pkg/{chartutil => chart/util}/validate_name.go (99%) rename pkg/{chartutil => chart/util}/validate_name_test.go (99%) rename pkg/{chartutil => chart/util}/values.go (99%) rename pkg/{chartutil => chart/util}/values_test.go (99%) diff --git a/Makefile b/Makefile index f1fcbfb08..d2c82b033 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,8 @@ K8S_MODULES_MINOR_VER=$(word 2,$(K8S_MODULES_VER)) LDFLAGS += -X helm.sh/helm/v4/pkg/lint/rules.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER) LDFLAGS += -X helm.sh/helm/v4/pkg/lint/rules.k8sVersionMinor=$(K8S_MODULES_MINOR_VER) -LDFLAGS += -X helm.sh/helm/v4/pkg/chartutil.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER) -LDFLAGS += -X helm.sh/helm/v4/pkg/chartutil.k8sVersionMinor=$(K8S_MODULES_MINOR_VER) +LDFLAGS += -X helm.sh/helm/v4/pkg/chart/util.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER) +LDFLAGS += -X helm.sh/helm/v4/pkg/chart/util.k8sVersionMinor=$(K8S_MODULES_MINOR_VER) .PHONY: all all: build diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 29beca303..a18f2c915 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -25,7 +25,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/helmpath" ) diff --git a/cmd/helm/create_test.go b/cmd/helm/create_test.go index 88d9c315a..76fce804c 100644 --- a/cmd/helm/create_test.go +++ b/cmd/helm/create_test.go @@ -25,7 +25,7 @@ import ( "helm.sh/helm/v4/internal/test/ensure" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/helmpath" ) diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index 1258db3f8..76c01d911 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/provenance" "helm.sh/helm/v4/pkg/repo" "helm.sh/helm/v4/pkg/repo/repotest" diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 7cf3e8e0a..0732ba7b5 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -24,7 +24,7 @@ import ( "helm.sh/helm/v4/internal/test/ensure" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/provenance" "helm.sh/helm/v4/pkg/repo" diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index a20928b37..e7a05aecf 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -30,7 +30,7 @@ import ( "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 9a3f7a2fc..3e37922b2 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -27,7 +27,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/lint/support" diff --git a/cmd/helm/status.go b/cmd/helm/status.go index c56ff1f29..fd3e4ce14 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -30,7 +30,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/release" ) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 8cd91df32..1a6265eba 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -34,7 +34,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/releaseutil" ) diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index e3d41d7fa..f97a4a26b 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -26,7 +26,7 @@ import ( "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/action/action.go b/pkg/action/action.go index 8418a4c27..fef4a91f5 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -33,7 +33,7 @@ import ( "k8s.io/client-go/rest" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/engine" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 71ea83789..8545b1edc 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -25,7 +25,7 @@ import ( fakeclientset "k8s.io/client-go/kubernetes/fake" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/release" diff --git a/pkg/action/dependency_test.go b/pkg/action/dependency_test.go index aee8c240f..38f2668ae 100644 --- a/pkg/action/dependency_test.go +++ b/pkg/action/dependency_test.go @@ -26,7 +26,7 @@ import ( "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" ) func TestList(t *testing.T) { diff --git a/pkg/action/get_values.go b/pkg/action/get_values.go index aa399f76c..21253b7aa 100644 --- a/pkg/action/get_values.go +++ b/pkg/action/get_values.go @@ -17,7 +17,7 @@ limitations under the License. package action import ( - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" ) // GetValues is the action for checking a given release's values. diff --git a/pkg/action/history.go b/pkg/action/history.go index 5f514a14a..1c5cfa86f 100644 --- a/pkg/action/history.go +++ b/pkg/action/history.go @@ -19,7 +19,7 @@ package action import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/action/install.go b/pkg/action/install.go index ef3f0fdc7..6ad77a509 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -40,7 +40,7 @@ import ( "sigs.k8s.io/yaml" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 9f738f0bc..171622e46 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -33,7 +33,7 @@ import ( "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" "helm.sh/helm/v4/pkg/storage/driver" diff --git a/pkg/action/lint.go b/pkg/action/lint.go index 06fc48612..a6fd7c71c 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/action/package.go b/pkg/action/package.go index 2e792a65c..8343ba109 100644 --- a/pkg/action/package.go +++ b/pkg/action/package.go @@ -27,7 +27,7 @@ import ( "golang.org/x/term" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/provenance" ) diff --git a/pkg/action/pull.go b/pkg/action/pull.go index 7fc1a9fdb..fa85fe242 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index 1568b0683..a2c68ad64 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -27,7 +27,7 @@ import ( "github.com/pkg/errors" v1 "k8s.io/api/core/v1" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 12dee35ce..961ef8377 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/show.go b/pkg/action/show.go index 1aa9bf1d0..3b2722eef 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -27,7 +27,7 @@ import ( "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/registry" ) diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index dda7d6978..b786c37f7 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -24,7 +24,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/release" "helm.sh/helm/v4/pkg/releaseutil" diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index f3e9a33bc..c5397c984 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -29,7 +29,7 @@ import ( "k8s.io/cli-runtime/pkg/resource" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" diff --git a/pkg/chartutil/capabilities.go b/pkg/chart/util/capabilities.go similarity index 99% rename from pkg/chartutil/capabilities.go rename to pkg/chart/util/capabilities.go index 6c1ebf24c..d4b420b2f 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chart/util/capabilities.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "fmt" diff --git a/pkg/chartutil/capabilities_test.go b/pkg/chart/util/capabilities_test.go similarity index 99% rename from pkg/chartutil/capabilities_test.go rename to pkg/chart/util/capabilities_test.go index 502b0c7d5..aa9be9db8 100644 --- a/pkg/chartutil/capabilities_test.go +++ b/pkg/chart/util/capabilities_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "testing" diff --git a/pkg/chartutil/chartfile.go b/pkg/chart/util/chartfile.go similarity index 99% rename from pkg/chartutil/chartfile.go rename to pkg/chart/util/chartfile.go index 596011ba3..acab80d0a 100644 --- a/pkg/chartutil/chartfile.go +++ b/pkg/chart/util/chartfile.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "os" diff --git a/pkg/chartutil/chartfile_test.go b/pkg/chart/util/chartfile_test.go similarity index 99% rename from pkg/chartutil/chartfile_test.go rename to pkg/chart/util/chartfile_test.go index 595aee517..6eb599680 100644 --- a/pkg/chartutil/chartfile_test.go +++ b/pkg/chart/util/chartfile_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "testing" diff --git a/pkg/chartutil/coalesce.go b/pkg/chart/util/coalesce.go similarity index 99% rename from pkg/chartutil/coalesce.go rename to pkg/chart/util/coalesce.go index a46936cc6..9ab5c1015 100644 --- a/pkg/chartutil/coalesce.go +++ b/pkg/chart/util/coalesce.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "fmt" diff --git a/pkg/chartutil/coalesce_test.go b/pkg/chart/util/coalesce_test.go similarity index 99% rename from pkg/chartutil/coalesce_test.go rename to pkg/chart/util/coalesce_test.go index e207274d7..5a8dfe94a 100644 --- a/pkg/chartutil/coalesce_test.go +++ b/pkg/chart/util/coalesce_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "encoding/json" diff --git a/pkg/chartutil/compatible.go b/pkg/chart/util/compatible.go similarity index 98% rename from pkg/chartutil/compatible.go rename to pkg/chart/util/compatible.go index f4656c913..d384d2d45 100644 --- a/pkg/chartutil/compatible.go +++ b/pkg/chart/util/compatible.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import "github.com/Masterminds/semver/v3" diff --git a/pkg/chartutil/compatible_test.go b/pkg/chart/util/compatible_test.go similarity index 98% rename from pkg/chartutil/compatible_test.go rename to pkg/chart/util/compatible_test.go index df7be6161..e17d33e35 100644 --- a/pkg/chartutil/compatible_test.go +++ b/pkg/chart/util/compatible_test.go @@ -15,7 +15,7 @@ limitations under the License. */ // Package version represents the current version of the project. -package chartutil +package util import "testing" diff --git a/pkg/chartutil/create.go b/pkg/chart/util/create.go similarity index 99% rename from pkg/chartutil/create.go rename to pkg/chart/util/create.go index 4f59b9f83..dfb5099f2 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chart/util/create.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "fmt" diff --git a/pkg/chartutil/create_test.go b/pkg/chart/util/create_test.go similarity index 99% rename from pkg/chartutil/create_test.go rename to pkg/chart/util/create_test.go index 8f8122f6f..e67ce3e1f 100644 --- a/pkg/chartutil/create_test.go +++ b/pkg/chart/util/create_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "bytes" diff --git a/pkg/chartutil/dependencies.go b/pkg/chart/util/dependencies.go similarity index 99% rename from pkg/chartutil/dependencies.go rename to pkg/chart/util/dependencies.go index f0ba166d9..fb9052d71 100644 --- a/pkg/chartutil/dependencies.go +++ b/pkg/chart/util/dependencies.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "log" diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chart/util/dependencies_test.go similarity index 99% rename from pkg/chartutil/dependencies_test.go rename to pkg/chart/util/dependencies_test.go index ac8e4d76e..10fca265e 100644 --- a/pkg/chartutil/dependencies_test.go +++ b/pkg/chart/util/dependencies_test.go @@ -12,7 +12,7 @@ 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 chartutil +package util import ( "encoding/json" diff --git a/pkg/chartutil/doc.go b/pkg/chart/util/doc.go similarity index 92% rename from pkg/chartutil/doc.go rename to pkg/chart/util/doc.go index 6c0b1582b..587fcaeb1 100644 --- a/pkg/chartutil/doc.go +++ b/pkg/chart/util/doc.go @@ -15,7 +15,7 @@ limitations under the License. */ /* -Package chartutil contains tools for working with charts. +package util contains tools for working with charts. Charts are described in the chart package (pkg/chart). This package provides utilities for serializing and deserializing charts. @@ -42,4 +42,4 @@ into a Chart. When creating charts in memory, use the 'helm.sh/helm/pkg/chart' package directly. */ -package chartutil // import "helm.sh/helm/v4/pkg/chartutil" +package util // import chartutil "helm.sh/helm/v4/pkg/chart/util" diff --git a/pkg/chartutil/errors.go b/pkg/chart/util/errors.go similarity index 98% rename from pkg/chartutil/errors.go rename to pkg/chart/util/errors.go index 0a4046d2e..a175b9758 100644 --- a/pkg/chartutil/errors.go +++ b/pkg/chart/util/errors.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "fmt" diff --git a/pkg/chartutil/errors_test.go b/pkg/chart/util/errors_test.go similarity index 97% rename from pkg/chartutil/errors_test.go rename to pkg/chart/util/errors_test.go index 3f63e3733..b8ae86384 100644 --- a/pkg/chartutil/errors_test.go +++ b/pkg/chart/util/errors_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "testing" diff --git a/pkg/chartutil/expand.go b/pkg/chart/util/expand.go similarity index 99% rename from pkg/chartutil/expand.go rename to pkg/chart/util/expand.go index a9943252d..4b83bf584 100644 --- a/pkg/chartutil/expand.go +++ b/pkg/chart/util/expand.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "io" diff --git a/pkg/chartutil/expand_test.go b/pkg/chart/util/expand_test.go similarity index 99% rename from pkg/chartutil/expand_test.go rename to pkg/chart/util/expand_test.go index b46ace01f..280995f7e 100644 --- a/pkg/chartutil/expand_test.go +++ b/pkg/chart/util/expand_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "os" diff --git a/pkg/chartutil/jsonschema.go b/pkg/chart/util/jsonschema.go similarity index 99% rename from pkg/chartutil/jsonschema.go rename to pkg/chart/util/jsonschema.go index f1c8dcdf4..616c6d444 100644 --- a/pkg/chartutil/jsonschema.go +++ b/pkg/chart/util/jsonschema.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "bytes" diff --git a/pkg/chartutil/jsonschema_test.go b/pkg/chart/util/jsonschema_test.go similarity index 99% rename from pkg/chartutil/jsonschema_test.go rename to pkg/chart/util/jsonschema_test.go index 098cf70db..c5600044a 100644 --- a/pkg/chartutil/jsonschema_test.go +++ b/pkg/chart/util/jsonschema_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "os" diff --git a/pkg/chartutil/save.go b/pkg/chart/util/save.go similarity index 99% rename from pkg/chartutil/save.go rename to pkg/chart/util/save.go index 0dddad912..635ff7944 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chart/util/save.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "archive/tar" diff --git a/pkg/chartutil/save_test.go b/pkg/chart/util/save_test.go similarity index 99% rename from pkg/chartutil/save_test.go rename to pkg/chart/util/save_test.go index 3789b6617..a7338c8d7 100644 --- a/pkg/chartutil/save_test.go +++ b/pkg/chart/util/save_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "archive/tar" diff --git a/pkg/chartutil/testdata/chartfiletest.yaml b/pkg/chart/util/testdata/chartfiletest.yaml similarity index 100% rename from pkg/chartutil/testdata/chartfiletest.yaml rename to pkg/chart/util/testdata/chartfiletest.yaml diff --git a/pkg/chartutil/testdata/coleridge.yaml b/pkg/chart/util/testdata/coleridge.yaml similarity index 100% rename from pkg/chartutil/testdata/coleridge.yaml rename to pkg/chart/util/testdata/coleridge.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/.helmignore b/pkg/chart/util/testdata/dependent-chart-alias/.helmignore similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/.helmignore rename to pkg/chart/util/testdata/dependent-chart-alias/.helmignore diff --git a/pkg/chartutil/testdata/dependent-chart-alias/Chart.lock b/pkg/chart/util/testdata/dependent-chart-alias/Chart.lock similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/Chart.lock rename to pkg/chart/util/testdata/dependent-chart-alias/Chart.lock diff --git a/pkg/chartutil/testdata/dependent-chart-alias/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-alias/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/INSTALL.txt b/pkg/chart/util/testdata/dependent-chart-alias/INSTALL.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/INSTALL.txt rename to pkg/chart/util/testdata/dependent-chart-alias/INSTALL.txt diff --git a/pkg/chartutil/testdata/dependent-chart-alias/LICENSE b/pkg/chart/util/testdata/dependent-chart-alias/LICENSE similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/LICENSE rename to pkg/chart/util/testdata/dependent-chart-alias/LICENSE diff --git a/pkg/chartutil/testdata/dependent-chart-alias/README.md b/pkg/chart/util/testdata/dependent-chart-alias/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/README.md rename to pkg/chart/util/testdata/dependent-chart-alias/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/_ignore_me b/pkg/chart/util/testdata/dependent-chart-alias/charts/_ignore_me similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/_ignore_me rename to pkg/chart/util/testdata/dependent-chart-alias/charts/_ignore_me diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/README.md b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/README.md rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/values.yaml b/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/alpine/values.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz b/pkg/chart/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz rename to pkg/chart/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-alias/docs/README.md b/pkg/chart/util/testdata/dependent-chart-alias/docs/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/docs/README.md rename to pkg/chart/util/testdata/dependent-chart-alias/docs/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-alias/icon.svg b/pkg/chart/util/testdata/dependent-chart-alias/icon.svg similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/icon.svg rename to pkg/chart/util/testdata/dependent-chart-alias/icon.svg diff --git a/pkg/chartutil/testdata/dependent-chart-alias/ignore/me.txt b/pkg/chart/util/testdata/dependent-chart-alias/ignore/me.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/ignore/me.txt rename to pkg/chart/util/testdata/dependent-chart-alias/ignore/me.txt diff --git a/pkg/chartutil/testdata/dependent-chart-alias/templates/template.tpl b/pkg/chart/util/testdata/dependent-chart-alias/templates/template.tpl similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/templates/template.tpl rename to pkg/chart/util/testdata/dependent-chart-alias/templates/template.tpl diff --git a/pkg/chartutil/testdata/dependent-chart-alias/values.yaml b/pkg/chart/util/testdata/dependent-chart-alias/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-alias/values.yaml rename to pkg/chart/util/testdata/dependent-chart-alias/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/.helmignore b/pkg/chart/util/testdata/dependent-chart-helmignore/.helmignore similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/.helmignore rename to pkg/chart/util/testdata/dependent-chart-helmignore/.helmignore diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/.ignore_me b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/.ignore_me similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/.ignore_me rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/.ignore_me diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/_ignore_me b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/_ignore_me similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/_ignore_me rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/_ignore_me diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/README.md b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/README.md rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/values.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/values.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/templates/template.tpl b/pkg/chart/util/testdata/dependent-chart-helmignore/templates/template.tpl similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/templates/template.tpl rename to pkg/chart/util/testdata/dependent-chart-helmignore/templates/template.tpl diff --git a/pkg/chartutil/testdata/dependent-chart-helmignore/values.yaml b/pkg/chart/util/testdata/dependent-chart-helmignore/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-helmignore/values.yaml rename to pkg/chart/util/testdata/dependent-chart-helmignore/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/.helmignore b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/.helmignore similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/.helmignore rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/.helmignore diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/LICENSE b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/LICENSE similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/LICENSE rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/LICENSE diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/README.md b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/README.md rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/docs/README.md b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/docs/README.md rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/icon.svg b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/icon.svg similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/icon.svg rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/icon.svg diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl diff --git a/pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/values.yaml b/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-no-requirements-yaml/values.yaml rename to pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/README.md b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/README.md rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml b/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml rename to pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/README.md b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/README.md rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml b/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml similarity index 100% rename from pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml rename to pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml diff --git a/pkg/chartutil/testdata/frobnitz-1.2.3.tgz b/pkg/chart/util/testdata/frobnitz-1.2.3.tgz similarity index 100% rename from pkg/chartutil/testdata/frobnitz-1.2.3.tgz rename to pkg/chart/util/testdata/frobnitz-1.2.3.tgz diff --git a/pkg/chartutil/testdata/frobnitz/.helmignore b/pkg/chart/util/testdata/frobnitz/.helmignore similarity index 100% rename from pkg/chartutil/testdata/frobnitz/.helmignore rename to pkg/chart/util/testdata/frobnitz/.helmignore diff --git a/pkg/chartutil/testdata/frobnitz/Chart.lock b/pkg/chart/util/testdata/frobnitz/Chart.lock similarity index 100% rename from pkg/chartutil/testdata/frobnitz/Chart.lock rename to pkg/chart/util/testdata/frobnitz/Chart.lock diff --git a/pkg/chartutil/testdata/frobnitz/Chart.yaml b/pkg/chart/util/testdata/frobnitz/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/Chart.yaml rename to pkg/chart/util/testdata/frobnitz/Chart.yaml diff --git a/pkg/chartutil/testdata/frobnitz/INSTALL.txt b/pkg/chart/util/testdata/frobnitz/INSTALL.txt similarity index 100% rename from pkg/chartutil/testdata/frobnitz/INSTALL.txt rename to pkg/chart/util/testdata/frobnitz/INSTALL.txt diff --git a/pkg/chartutil/testdata/frobnitz/LICENSE b/pkg/chart/util/testdata/frobnitz/LICENSE similarity index 100% rename from pkg/chartutil/testdata/frobnitz/LICENSE rename to pkg/chart/util/testdata/frobnitz/LICENSE diff --git a/pkg/chartutil/testdata/frobnitz/README.md b/pkg/chart/util/testdata/frobnitz/README.md similarity index 100% rename from pkg/chartutil/testdata/frobnitz/README.md rename to pkg/chart/util/testdata/frobnitz/README.md diff --git a/pkg/chartutil/testdata/frobnitz/charts/_ignore_me b/pkg/chart/util/testdata/frobnitz/charts/_ignore_me similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/_ignore_me rename to pkg/chart/util/testdata/frobnitz/charts/_ignore_me diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/Chart.yaml b/pkg/chart/util/testdata/frobnitz/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/Chart.yaml rename to pkg/chart/util/testdata/frobnitz/charts/alpine/Chart.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/README.md b/pkg/chart/util/testdata/frobnitz/charts/alpine/README.md similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/README.md rename to pkg/chart/util/testdata/frobnitz/charts/alpine/README.md diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml b/pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/alpine/values.yaml b/pkg/chart/util/testdata/frobnitz/charts/alpine/values.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/alpine/values.yaml rename to pkg/chart/util/testdata/frobnitz/charts/alpine/values.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/mariner/Chart.yaml b/pkg/chart/util/testdata/frobnitz/charts/mariner/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/mariner/Chart.yaml rename to pkg/chart/util/testdata/frobnitz/charts/mariner/Chart.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml b/pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml rename to pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml b/pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml rename to pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml diff --git a/pkg/chartutil/testdata/frobnitz/charts/mariner/templates/placeholder.tpl b/pkg/chart/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/mariner/templates/placeholder.tpl rename to pkg/chart/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl diff --git a/pkg/chartutil/testdata/frobnitz/charts/mariner/values.yaml b/pkg/chart/util/testdata/frobnitz/charts/mariner/values.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/charts/mariner/values.yaml rename to pkg/chart/util/testdata/frobnitz/charts/mariner/values.yaml diff --git a/pkg/chartutil/testdata/frobnitz/docs/README.md b/pkg/chart/util/testdata/frobnitz/docs/README.md similarity index 100% rename from pkg/chartutil/testdata/frobnitz/docs/README.md rename to pkg/chart/util/testdata/frobnitz/docs/README.md diff --git a/pkg/chartutil/testdata/frobnitz/icon.svg b/pkg/chart/util/testdata/frobnitz/icon.svg similarity index 100% rename from pkg/chartutil/testdata/frobnitz/icon.svg rename to pkg/chart/util/testdata/frobnitz/icon.svg diff --git a/pkg/chartutil/testdata/frobnitz/ignore/me.txt b/pkg/chart/util/testdata/frobnitz/ignore/me.txt similarity index 100% rename from pkg/chartutil/testdata/frobnitz/ignore/me.txt rename to pkg/chart/util/testdata/frobnitz/ignore/me.txt diff --git a/pkg/chartutil/testdata/frobnitz/templates/template.tpl b/pkg/chart/util/testdata/frobnitz/templates/template.tpl similarity index 100% rename from pkg/chartutil/testdata/frobnitz/templates/template.tpl rename to pkg/chart/util/testdata/frobnitz/templates/template.tpl diff --git a/pkg/chartutil/testdata/frobnitz/values.yaml b/pkg/chart/util/testdata/frobnitz/values.yaml similarity index 100% rename from pkg/chartutil/testdata/frobnitz/values.yaml rename to pkg/chart/util/testdata/frobnitz/values.yaml diff --git a/pkg/chartutil/testdata/frobnitz_backslash-1.2.3.tgz b/pkg/chart/util/testdata/frobnitz_backslash-1.2.3.tgz similarity index 100% rename from pkg/chartutil/testdata/frobnitz_backslash-1.2.3.tgz rename to pkg/chart/util/testdata/frobnitz_backslash-1.2.3.tgz diff --git a/pkg/chartutil/testdata/genfrob.sh b/pkg/chart/util/testdata/genfrob.sh similarity index 100% rename from pkg/chartutil/testdata/genfrob.sh rename to pkg/chart/util/testdata/genfrob.sh diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml b/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml similarity index 100% rename from pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml rename to pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml diff --git a/pkg/chartutil/testdata/joonix/Chart.yaml b/pkg/chart/util/testdata/joonix/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/joonix/Chart.yaml rename to pkg/chart/util/testdata/joonix/Chart.yaml diff --git a/pkg/chartutil/testdata/joonix/charts/.gitkeep b/pkg/chart/util/testdata/joonix/charts/.gitkeep similarity index 100% rename from pkg/chartutil/testdata/joonix/charts/.gitkeep rename to pkg/chart/util/testdata/joonix/charts/.gitkeep diff --git a/pkg/chartutil/testdata/subpop/Chart.yaml b/pkg/chart/util/testdata/subpop/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/Chart.yaml rename to pkg/chart/util/testdata/subpop/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/README.md b/pkg/chart/util/testdata/subpop/README.md similarity index 100% rename from pkg/chartutil/testdata/subpop/README.md rename to pkg/chart/util/testdata/subpop/README.md diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/Chart.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/Chart.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/crds/crdA.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/crds/crdA.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/crds/crdA.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/crds/crdA.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/NOTES.txt b/pkg/chart/util/testdata/subpop/charts/subchart1/templates/NOTES.txt similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/templates/NOTES.txt rename to pkg/chart/util/testdata/subpop/charts/subchart1/templates/NOTES.txt diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/service.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/templates/service.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/subdir/role.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/templates/subdir/role.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/values.yaml b/pkg/chart/util/testdata/subpop/charts/subchart1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart1/values.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart1/values.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/Chart.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/Chart.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/templates/service.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/templates/service.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/values.yaml b/pkg/chart/util/testdata/subpop/charts/subchart2/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/charts/subchart2/values.yaml rename to pkg/chart/util/testdata/subpop/charts/subchart2/values.yaml diff --git a/pkg/chartutil/testdata/subpop/noreqs/Chart.yaml b/pkg/chart/util/testdata/subpop/noreqs/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/noreqs/Chart.yaml rename to pkg/chart/util/testdata/subpop/noreqs/Chart.yaml diff --git a/pkg/chartutil/testdata/subpop/noreqs/templates/service.yaml b/pkg/chart/util/testdata/subpop/noreqs/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/noreqs/templates/service.yaml rename to pkg/chart/util/testdata/subpop/noreqs/templates/service.yaml diff --git a/pkg/chartutil/testdata/subpop/noreqs/values.yaml b/pkg/chart/util/testdata/subpop/noreqs/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/noreqs/values.yaml rename to pkg/chart/util/testdata/subpop/noreqs/values.yaml diff --git a/pkg/chartutil/testdata/subpop/values.yaml b/pkg/chart/util/testdata/subpop/values.yaml similarity index 100% rename from pkg/chartutil/testdata/subpop/values.yaml rename to pkg/chart/util/testdata/subpop/values.yaml diff --git a/pkg/chartutil/testdata/test-values-invalid.schema.json b/pkg/chart/util/testdata/test-values-invalid.schema.json similarity index 100% rename from pkg/chartutil/testdata/test-values-invalid.schema.json rename to pkg/chart/util/testdata/test-values-invalid.schema.json diff --git a/pkg/chartutil/testdata/test-values-negative.yaml b/pkg/chart/util/testdata/test-values-negative.yaml similarity index 100% rename from pkg/chartutil/testdata/test-values-negative.yaml rename to pkg/chart/util/testdata/test-values-negative.yaml diff --git a/pkg/chartutil/testdata/test-values.schema.json b/pkg/chart/util/testdata/test-values.schema.json similarity index 100% rename from pkg/chartutil/testdata/test-values.schema.json rename to pkg/chart/util/testdata/test-values.schema.json diff --git a/pkg/chartutil/testdata/test-values.yaml b/pkg/chart/util/testdata/test-values.yaml similarity index 100% rename from pkg/chartutil/testdata/test-values.yaml rename to pkg/chart/util/testdata/test-values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/README.md b/pkg/chart/util/testdata/three-level-dependent-chart/README.md similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/README.md rename to pkg/chart/util/testdata/three-level-dependent-chart/README.md diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml diff --git a/pkg/chartutil/testdata/three-level-dependent-chart/umbrella/values.yaml b/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/values.yaml similarity index 100% rename from pkg/chartutil/testdata/three-level-dependent-chart/umbrella/values.yaml rename to pkg/chart/util/testdata/three-level-dependent-chart/umbrella/values.yaml diff --git a/pkg/chartutil/validate_name.go b/pkg/chart/util/validate_name.go similarity index 99% rename from pkg/chartutil/validate_name.go rename to pkg/chart/util/validate_name.go index 05c090cb6..73be43303 100644 --- a/pkg/chartutil/validate_name.go +++ b/pkg/chart/util/validate_name.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "fmt" diff --git a/pkg/chartutil/validate_name_test.go b/pkg/chart/util/validate_name_test.go similarity index 99% rename from pkg/chartutil/validate_name_test.go rename to pkg/chart/util/validate_name_test.go index 09dec9fbb..cfc62a0f7 100644 --- a/pkg/chartutil/validate_name_test.go +++ b/pkg/chart/util/validate_name_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import "testing" diff --git a/pkg/chartutil/values.go b/pkg/chart/util/values.go similarity index 99% rename from pkg/chartutil/values.go rename to pkg/chart/util/values.go index 706c44d48..46952c079 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chart/util/values.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "encoding/json" diff --git a/pkg/chartutil/values_test.go b/pkg/chart/util/values_test.go similarity index 99% rename from pkg/chartutil/values_test.go rename to pkg/chart/util/values_test.go index 56167c8a1..660b7e4ed 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chart/util/values_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chartutil +package util import ( "bytes" diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index f10cbfb8d..361cd6109 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -38,7 +38,7 @@ import ( "helm.sh/helm/v4/internal/urlutil" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/registry" diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index b721c6a0d..c9947e341 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -24,7 +24,7 @@ import ( "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/repo/repotest" ) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 8f69505f6..0229b1833 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -30,7 +30,7 @@ import ( "k8s.io/client-go/rest" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" ) // Engine is an implementation of the Helm rendering implementation for templates. diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index f6a96bd6a..4c28c2965 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/client-go/dynamic/fake" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" ) func TestSortTemplates(t *testing.T) { diff --git a/pkg/lint/lint.go b/pkg/lint/lint.go index 70a49ee90..b53400c87 100644 --- a/pkg/lint/lint.go +++ b/pkg/lint/lint.go @@ -19,7 +19,7 @@ package lint // import "helm.sh/helm/v4/pkg/lint" import ( "path/filepath" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/rules" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/lint_test.go b/pkg/lint/lint_test.go index 9246b64f2..bba024d59 100644 --- a/pkg/lint/lint_test.go +++ b/pkg/lint/lint_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/chartfile.go b/pkg/lint/rules/chartfile.go index 2e718067b..a1e08b58d 100644 --- a/pkg/lint/rules/chartfile.go +++ b/pkg/lint/rules/chartfile.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/yaml" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index eb9b19cb7..6d709790a 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -25,7 +25,7 @@ import ( "github.com/pkg/errors" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/dependencies_test.go b/pkg/lint/rules/dependencies_test.go index e167b4479..e946b1c01 100644 --- a/pkg/lint/rules/dependencies_test.go +++ b/pkg/lint/rules/dependencies_test.go @@ -20,7 +20,7 @@ import ( "testing" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/deprecations.go b/pkg/lint/rules/deprecations.go index 6eae06802..0a8e642c9 100644 --- a/pkg/lint/rules/deprecations.go +++ b/pkg/lint/rules/deprecations.go @@ -25,7 +25,7 @@ import ( "k8s.io/apiserver/pkg/endpoints/deprecation" kscheme "k8s.io/client-go/kubernetes/scheme" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" ) var ( diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index a50485a50..ec434aba5 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -34,7 +34,7 @@ import ( "k8s.io/apimachinery/pkg/util/yaml" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/engine" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/template_test.go b/pkg/lint/rules/template_test.go index 9e6dc4004..d3185d8c8 100644 --- a/pkg/lint/rules/template_test.go +++ b/pkg/lint/rules/template_test.go @@ -24,7 +24,7 @@ import ( "testing" "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/values.go b/pkg/lint/rules/values.go index 82278522d..f430178c3 100644 --- a/pkg/lint/rules/values.go +++ b/pkg/lint/rules/values.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/releaseutil/manifest_sorter.go index b2db2ff9f..c7d92b184 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/releaseutil/manifest_sorter.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index 0155c54d8..7b004dbc3 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -36,7 +36,7 @@ import ( "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" - "helm.sh/helm/v4/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/util" ociRegistry "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/repo" ) From 8dd279271e5a18613aa33655c0bd990e6979cf47 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 21 Feb 2025 15:33:24 -0500 Subject: [PATCH 142/271] remove unused config.go Signed-off-by: Robert Sirchia --- pkg/kube/config.go | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 pkg/kube/config.go diff --git a/pkg/kube/config.go b/pkg/kube/config.go deleted file mode 100644 index 0ef94453f..000000000 --- a/pkg/kube/config.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 kube // import "helm.sh/helm/v4/pkg/kube" - -import "k8s.io/cli-runtime/pkg/genericclioptions" - -// GetConfig returns a Kubernetes client config. -// -// Deprecated -func GetConfig(kubeconfig, context, namespace string) *genericclioptions.ConfigFlags { - cf := genericclioptions.NewConfigFlags(true) - cf.Namespace = &namespace - cf.Context = &context - cf.KubeConfig = &kubeconfig - return cf -} From 5c648151d59f0f88bd9e5d878f5909f75bde6ed7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:59:40 +0000 Subject: [PATCH 143/271] build(deps): bump ossf/scorecard-action from 2.4.0 to 2.4.1 Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits](https://github.com/ossf/scorecard-action/compare/62b2cac7ed8198b15735ed49ab1e5cf35480ba46...f49aabe0b5af0936a0987cfb85d86b75731b0186) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 7f568cf9d..a31084c72 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -33,7 +33,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 with: results_file: results.sarif results_format: sarif From 3d35e786c75493120833523da97c390f7c9b024e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:59:44 +0000 Subject: [PATCH 144/271] build(deps): bump actions/upload-artifact from 4.6.0 to 4.6.1 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.0 to 4.6.1. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08...4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 7f568cf9d..55b5581c1 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -55,7 +55,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: SARIF file path: results.sarif From f475f3e1fd8c4eb04dd07b78c68967bba39cedb8 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 22 Feb 2025 13:05:21 +0200 Subject: [PATCH 145/271] feat: error out when post-renderer produces no output When the templating post-renderer produces no output, something went wrong so we error out. Signed-off-by: Yarden Shoham --- pkg/postrender/exec.go | 6 ++++++ pkg/postrender/exec_test.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/pkg/postrender/exec.go b/pkg/postrender/exec.go index 167e737d6..30f3983cf 100644 --- a/pkg/postrender/exec.go +++ b/pkg/postrender/exec.go @@ -64,6 +64,12 @@ func (p *execRender) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error) return nil, errors.Wrapf(err, "error while running command %s. error output:\n%s", p.binaryPath, stderr.String()) } + // If the binary returned almost nothing, it's likely that it didn't + // successfully render anything + if len(bytes.TrimSpace(postRendered.Bytes())) == 0 { + return nil, errors.Errorf("post render binary %s did not produce any output %s", p.binaryPath, postRendered.String()) + } + return postRendered, nil } diff --git a/pkg/postrender/exec_test.go b/pkg/postrender/exec_test.go index 19a6ec6c4..2b091cc12 100644 --- a/pkg/postrender/exec_test.go +++ b/pkg/postrender/exec_test.go @@ -121,6 +121,21 @@ func TestExecRun(t *testing.T) { is.Contains(output.String(), "BARTEST") } +func TestExecRunWithNoOutput(t *testing.T) { + if runtime.GOOS == "windows" { + // the actual Run test uses a basic sed example, so skip this test on windows + t.Skip("skipping on windows") + } + is := assert.New(t) + testpath := setupTestingScript(t) + + renderer, err := NewExec(testpath) + require.NoError(t, err) + + _, err = renderer.Run(bytes.NewBufferString("")) + is.Error(err) +} + func TestNewExecWithOneArgsRun(t *testing.T) { if runtime.GOOS == "windows" { // the actual Run test uses a basic sed example, so skip this test on windows From 9e17871afbb3e71fc8846fafd2b4aa6b7ccb0cd4 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 22 Feb 2025 14:25:26 +0200 Subject: [PATCH 146/271] fix: error when more than one post-renderer is specified We now make sure the post-renderer flag can be passed at most once instead of silently taking the last one passed. Example: ```bash $ helm template test ... --post-renderer=true --post-renderer=cat Error: invalid argument "cat" for "--post-renderer" flag: cannot set post-renderer more than once, given: cat, previous: true ``` Signed-off-by: Yarden Shoham --- cmd/helm/flags.go | 4 ++++ cmd/helm/flags_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 8d0f644d6..b92e7cf0b 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -24,6 +24,7 @@ import ( "sort" "strings" + "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" "k8s.io/klog/v2" @@ -143,6 +144,9 @@ func (p *postRendererString) Set(val string) error { if val == "" { return nil } + if p.options.binaryPath != "" && p.options.binaryPath != val { + return errors.Errorf("cannot set post-renderer more than once, given: %s, previous: %s", val, p.options.binaryPath) + } p.options.binaryPath = val pr, err := postrender.NewExec(p.options.binaryPath, p.options.args...) if err != nil { diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go index 295f55022..bea916c34 100644 --- a/cmd/helm/flags_test.go +++ b/cmd/helm/flags_test.go @@ -20,6 +20,9 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/require" + + "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" @@ -93,3 +96,24 @@ func outputFlagCompletionTest(t *testing.T, cmdName string) { }} runTestCmd(t, tests) } + +func TestPostRendererFlagSetOnce(t *testing.T) { + cfg := action.Configuration{} + client := action.NewInstall(&cfg) + str := postRendererString{ + options: &postRendererOptions{ + renderer: &client.PostRenderer, + }, + } + // Set the binary once + err := str.Set("echo") + require.NoError(t, err) + + // Set the binary again to the same value is ok + err = str.Set("echo") + require.NoError(t, err) + + // Set the binary again to a different value is not ok + err = str.Set("cat") + require.Error(t, err) +} From 392ff9391657840d00c825030d68bef6c5181cc7 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sun, 23 Feb 2025 16:51:33 -0300 Subject: [PATCH 147/271] Fix flaky TestDedupeRepos (#30576) Signed-off-by: Felipe Santos --- pkg/downloader/manager_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index 481a9e038..8731fb003 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -22,6 +22,8 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/assert" + "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" chartutil "helm.sh/helm/v4/pkg/chart/util" @@ -657,9 +659,8 @@ func TestDedupeRepos(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := dedupeRepos(tt.repos); !reflect.DeepEqual(got, tt.want) { - t.Errorf("received:\n%v\nwant:\n%v", got, tt.want) - } + got := dedupeRepos(tt.repos) + assert.ElementsMatch(t, tt.want, got) }) } } From 326fdc3e5fa89f62dd1584dd46236f2bb8ecdbdb Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 24 Feb 2025 07:23:18 +0200 Subject: [PATCH 148/271] Apply suggestions from code review Co-authored-by: George Jenkins Signed-off-by: Yarden Shoham --- cmd/helm/flags.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index b92e7cf0b..d8e0107fd 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -144,8 +144,8 @@ func (p *postRendererString) Set(val string) error { if val == "" { return nil } - if p.options.binaryPath != "" && p.options.binaryPath != val { - return errors.Errorf("cannot set post-renderer more than once, given: %s, previous: %s", val, p.options.binaryPath) + if p.options.binaryPath != "" { + return fmt.Errorf("cannot specify --post-renderer flag more than once") } p.options.binaryPath = val pr, err := postrender.NewExec(p.options.binaryPath, p.options.args...) From dd728861a9a4353273ad77b7e16cba69144e42e6 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 24 Feb 2025 07:24:15 +0200 Subject: [PATCH 149/271] Fix tests Signed-off-by: Yarden Shoham --- cmd/helm/flags.go | 1 - cmd/helm/flags_test.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index d8e0107fd..379b2140d 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -24,7 +24,6 @@ import ( "sort" "strings" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" "k8s.io/klog/v2" diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go index bea916c34..3b43b1f47 100644 --- a/cmd/helm/flags_test.go +++ b/cmd/helm/flags_test.go @@ -109,9 +109,9 @@ func TestPostRendererFlagSetOnce(t *testing.T) { err := str.Set("echo") require.NoError(t, err) - // Set the binary again to the same value is ok + // Set the binary again to the same value is not ok err = str.Set("echo") - require.NoError(t, err) + require.Error(t, err) // Set the binary again to a different value is not ok err = str.Set("cat") From ab926212d9f14db74f3ead30d00a0a6fa4587f8c Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 24 Feb 2025 07:26:12 +0200 Subject: [PATCH 150/271] Apply suggestions from code review Co-authored-by: George Jenkins Signed-off-by: Yarden Shoham --- pkg/postrender/exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/postrender/exec.go b/pkg/postrender/exec.go index 30f3983cf..84357c656 100644 --- a/pkg/postrender/exec.go +++ b/pkg/postrender/exec.go @@ -67,7 +67,7 @@ func (p *execRender) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error) // If the binary returned almost nothing, it's likely that it didn't // successfully render anything if len(bytes.TrimSpace(postRendered.Bytes())) == 0 { - return nil, errors.Errorf("post render binary %s did not produce any output %s", p.binaryPath, postRendered.String()) + return nil, errors.Errorf("post-renderer %q produced empty output", p.binaryPath) } return postRendered, nil From 297f7b9acb5203967edc19c90b2719d48084c531 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 24 Feb 2025 15:11:54 +0000 Subject: [PATCH 151/271] squash Signed-off-by: Austin Abro --- cmd/helm/helm.go | 29 +--- cmd/helm/helm_test.go | 147 +--------------- {cmd/helm => pkg/cmd}/completion.go | 4 +- {cmd/helm => pkg/cmd}/completion_test.go | 2 +- {cmd/helm => pkg/cmd}/create.go | 4 +- {cmd/helm => pkg/cmd}/create_test.go | 2 +- {cmd/helm => pkg/cmd}/dependency.go | 4 +- {cmd/helm => pkg/cmd}/dependency_build.go | 4 +- .../helm => pkg/cmd}/dependency_build_test.go | 2 +- {cmd/helm => pkg/cmd}/dependency_test.go | 2 +- {cmd/helm => pkg/cmd}/dependency_update.go | 4 +- .../cmd}/dependency_update_test.go | 2 +- {cmd/helm => pkg/cmd}/docs.go | 4 +- {cmd/helm => pkg/cmd}/docs_test.go | 2 +- {cmd/helm => pkg/cmd}/env.go | 4 +- {cmd/helm => pkg/cmd}/env_test.go | 2 +- {cmd/helm => pkg/cmd}/flags.go | 2 +- {cmd/helm => pkg/cmd}/flags_test.go | 2 +- {cmd/helm => pkg/cmd}/get.go | 4 +- {cmd/helm => pkg/cmd}/get_all.go | 4 +- {cmd/helm => pkg/cmd}/get_all_test.go | 2 +- {cmd/helm => pkg/cmd}/get_hooks.go | 4 +- {cmd/helm => pkg/cmd}/get_hooks_test.go | 2 +- {cmd/helm => pkg/cmd}/get_manifest.go | 4 +- {cmd/helm => pkg/cmd}/get_manifest_test.go | 2 +- {cmd/helm => pkg/cmd}/get_metadata.go | 4 +- {cmd/helm => pkg/cmd}/get_metadata_test.go | 2 +- {cmd/helm => pkg/cmd}/get_notes.go | 4 +- {cmd/helm => pkg/cmd}/get_notes_test.go | 2 +- {cmd/helm => pkg/cmd}/get_test.go | 2 +- {cmd/helm => pkg/cmd}/get_values.go | 4 +- {cmd/helm => pkg/cmd}/get_values_test.go | 2 +- pkg/cmd/helpers_test.go | 164 ++++++++++++++++++ {cmd/helm => pkg/cmd}/history.go | 4 +- {cmd/helm => pkg/cmd}/history_test.go | 2 +- {cmd/helm => pkg/cmd}/install.go | 12 +- {cmd/helm => pkg/cmd}/install_test.go | 2 +- {cmd/helm => pkg/cmd}/lint.go | 2 +- {cmd/helm => pkg/cmd}/lint_test.go | 2 +- {cmd/helm => pkg/cmd}/list.go | 6 +- {cmd/helm => pkg/cmd}/list_test.go | 2 +- {cmd/helm => pkg/cmd}/load_plugins.go | 10 +- {cmd/helm => pkg/cmd}/package.go | 2 +- {cmd/helm => pkg/cmd}/package_test.go | 2 +- {cmd/helm => pkg/cmd}/plugin.go | 4 +- {cmd/helm => pkg/cmd}/plugin_install.go | 6 +- {cmd/helm => pkg/cmd}/plugin_list.go | 4 +- {cmd/helm => pkg/cmd}/plugin_test.go | 14 +- {cmd/helm => pkg/cmd}/plugin_uninstall.go | 4 +- {cmd/helm => pkg/cmd}/plugin_update.go | 6 +- {cmd/helm => pkg/cmd}/printer.go | 2 +- {cmd/helm => pkg/cmd}/profiling.go | 2 +- {cmd/helm => pkg/cmd}/pull.go | 6 +- {cmd/helm => pkg/cmd}/pull_test.go | 2 +- {cmd/helm => pkg/cmd}/push.go | 4 +- {cmd/helm => pkg/cmd}/push_test.go | 2 +- {cmd/helm => pkg/cmd}/registry.go | 2 +- {cmd/helm => pkg/cmd}/registry_login.go | 6 +- {cmd/helm => pkg/cmd}/registry_login_test.go | 2 +- {cmd/helm => pkg/cmd}/registry_logout.go | 4 +- {cmd/helm => pkg/cmd}/registry_logout_test.go | 2 +- {cmd/helm => pkg/cmd}/release_testing.go | 4 +- {cmd/helm => pkg/cmd}/release_testing_test.go | 2 +- {cmd/helm => pkg/cmd}/repo.go | 4 +- {cmd/helm => pkg/cmd}/repo_add.go | 4 +- {cmd/helm => pkg/cmd}/repo_add_test.go | 2 +- {cmd/helm => pkg/cmd}/repo_index.go | 4 +- {cmd/helm => pkg/cmd}/repo_index_test.go | 2 +- {cmd/helm => pkg/cmd}/repo_list.go | 4 +- {cmd/helm => pkg/cmd}/repo_list_test.go | 2 +- {cmd/helm => pkg/cmd}/repo_remove.go | 4 +- {cmd/helm => pkg/cmd}/repo_remove_test.go | 2 +- {cmd/helm => pkg/cmd}/repo_test.go | 2 +- {cmd/helm => pkg/cmd}/repo_update.go | 4 +- {cmd/helm => pkg/cmd}/repo_update_test.go | 2 +- {cmd/helm => pkg/cmd}/require/args.go | 0 {cmd/helm => pkg/cmd}/require/args_test.go | 0 {cmd/helm => pkg/cmd}/rollback.go | 4 +- {cmd/helm => pkg/cmd}/rollback_test.go | 2 +- {cmd/helm => pkg/cmd}/root.go | 17 +- {cmd/helm => pkg/cmd}/root_test.go | 2 +- {cmd/helm => pkg/cmd}/search.go | 2 +- {cmd/helm => pkg/cmd}/search/search.go | 0 {cmd/helm => pkg/cmd}/search/search_test.go | 0 {cmd/helm => pkg/cmd}/search_hub.go | 4 +- {cmd/helm => pkg/cmd}/search_hub_test.go | 2 +- {cmd/helm => pkg/cmd}/search_repo.go | 14 +- {cmd/helm => pkg/cmd}/search_repo_test.go | 2 +- {cmd/helm => pkg/cmd}/search_test.go | 2 +- {cmd/helm => pkg/cmd}/show.go | 8 +- {cmd/helm => pkg/cmd}/show_test.go | 2 +- {cmd/helm => pkg/cmd}/status.go | 4 +- {cmd/helm => pkg/cmd}/status_test.go | 2 +- {cmd/helm => pkg/cmd}/template.go | 4 +- {cmd/helm => pkg/cmd}/template_test.go | 2 +- .../helm/plugins/fullenv/completion.yaml | 0 .../helm/plugins/fullenv/fullenv.sh | 0 .../helm/plugins/fullenv/plugin.yaml | 0 .../helm/repositories.yaml | 0 .../helm/repository/test-name-charts.txt | 0 .../helm/repository/test-name-index.yaml | 0 .../helm/repository/testing-index.yaml | 0 .../cmd}/testdata/helm-test-key.pub | Bin .../cmd}/testdata/helm-test-key.secret | Bin .../helmhome/helm/plugins/args/args.sh | 0 .../helm/plugins/args/plugin.complete | 0 .../helmhome/helm/plugins/args/plugin.yaml | 0 .../helm/plugins/echo/completion.yaml | 0 .../helm/plugins/echo/plugin.complete | 0 .../helmhome/helm/plugins/echo/plugin.yaml | 0 .../helmhome/helm/plugins/env/completion.yaml | 0 .../helmhome/helm/plugins/env/plugin.yaml | 0 .../helm/plugins/exitwith/completion.yaml | 0 .../helm/plugins/exitwith/exitwith.sh | 0 .../helm/plugins/exitwith/plugin.yaml | 0 .../helm/plugins/fullenv/completion.yaml | 0 .../helmhome/helm/plugins/fullenv/fullenv.sh | 0 .../helmhome/helm/plugins/fullenv/plugin.yaml | 0 .../testdata/helmhome/helm/repositories.yaml | 0 .../helm/repository/test-name-charts.txt | 0 .../helm/repository/test-name-index.yaml | 0 .../helm/repository/testing-index.yaml | 0 .../output/chart-with-subchart-update.txt | 0 .../output/dependency-list-archive.txt | 0 .../output/dependency-list-no-chart-linux.txt | 0 .../dependency-list-no-requirements-linux.txt | 0 .../cmd}/testdata/output/dependency-list.txt | 0 .../cmd}/testdata/output/deprecated-chart.txt | 0 .../cmd}/testdata/output/docs-type-comp.txt | 0 .../testdata/output/empty_default_comp.txt | 0 .../testdata/output/empty_nofile_comp.txt | 0 .../cmd}/testdata/output/env-comp.txt | 0 .../cmd}/testdata/output/get-all-no-args.txt | 0 .../testdata/output/get-hooks-no-args.txt | 0 .../cmd}/testdata/output/get-hooks.txt | 0 .../testdata/output/get-manifest-no-args.txt | 0 .../cmd}/testdata/output/get-manifest.txt | 0 .../testdata/output/get-metadata-args.txt | 0 .../cmd}/testdata/output/get-metadata.json | 0 .../cmd}/testdata/output/get-metadata.txt | 0 .../cmd}/testdata/output/get-metadata.yaml | 0 .../testdata/output/get-notes-no-args.txt | 0 .../cmd}/testdata/output/get-notes.txt | 0 .../testdata/output/get-release-template.txt | 0 .../cmd}/testdata/output/get-release.txt | 0 .../cmd}/testdata/output/get-values-all.txt | 0 .../cmd}/testdata/output/get-values-args.txt | 0 .../cmd}/testdata/output/get-values.txt | 0 .../cmd}/testdata/output/history-limit.txt | 0 .../cmd}/testdata/output/history.json | 0 .../cmd}/testdata/output/history.txt | 0 .../cmd}/testdata/output/history.yaml | 0 .../testdata/output/install-and-replace.txt | 0 .../output/install-and-take-ownership.txt | 0 .../output/install-chart-bad-type.txt | 0 .../install-dry-run-with-secret-hidden.txt | 0 .../output/install-dry-run-with-secret.txt | 0 .../testdata/output/install-hide-secret.txt | 0 .../testdata/output/install-lib-chart.txt | 0 .../testdata/output/install-name-template.txt | 0 .../cmd}/testdata/output/install-no-args.txt | 0 .../cmd}/testdata/output/install-no-hooks.txt | 0 .../install-with-multiple-values-files.txt | 0 .../output/install-with-multiple-values.txt | 0 .../testdata/output/install-with-timeout.txt | 0 .../output/install-with-values-file.txt | 0 .../testdata/output/install-with-values.txt | 0 .../output/install-with-wait-for-jobs.txt | 0 .../testdata/output/install-with-wait.txt | 0 .../cmd}/testdata/output/install.txt | 0 .../cmd}/testdata/output/issue-9027.txt | 0 .../cmd}/testdata/output/issue-totoml.txt | 0 ...hart-with-bad-subcharts-with-subcharts.txt | 0 .../output/lint-chart-with-bad-subcharts.txt | 0 ...lint-chart-with-deprecated-api-old-k8s.txt | 0 .../lint-chart-with-deprecated-api-strict.txt | 0 .../output/lint-chart-with-deprecated-api.txt | 0 .../testdata/output/lint-quiet-with-error.txt | 0 .../output/lint-quiet-with-warning.txt | 0 .../cmd}/testdata/output/lint-quiet.txt | 0 .../cmd}/testdata/output/list-all.txt | 0 .../testdata/output/list-date-reversed.txt | 0 .../cmd}/testdata/output/list-date.txt | 0 .../cmd}/testdata/output/list-failed.txt | 0 .../cmd}/testdata/output/list-filter.txt | 0 .../cmd}/testdata/output/list-max.txt | 0 .../cmd}/testdata/output/list-namespace.txt | 0 .../cmd}/testdata/output/list-no-headers.txt | 0 .../cmd}/testdata/output/list-offset.txt | 0 .../cmd}/testdata/output/list-pending.txt | 0 .../cmd}/testdata/output/list-reverse.txt | 0 .../cmd}/testdata/output/list-short-json.txt | 0 .../cmd}/testdata/output/list-short-yaml.txt | 0 .../cmd}/testdata/output/list-short.txt | 0 .../cmd}/testdata/output/list-superseded.txt | 0 .../cmd}/testdata/output/list-uninstalled.txt | 0 .../testdata/output/list-uninstalling.txt | 0 .../helm => pkg/cmd}/testdata/output/list.txt | 0 .../cmd}/testdata/output/object-order.txt | 0 .../cmd}/testdata/output/output-comp.txt | 0 .../cmd}/testdata/output/plugin_args_comp.txt | 0 .../testdata/output/plugin_args_flag_comp.txt | 0 .../output/plugin_args_many_args_comp.txt | 0 .../testdata/output/plugin_args_ns_comp.txt | 0 .../output/plugin_echo_no_directive.txt | 0 .../cmd}/testdata/output/plugin_list_comp.txt | 0 .../testdata/output/plugin_repeat_comp.txt | 0 .../testdata/output/release_list_comp.txt | 0 .../output/release_list_repeat_comp.txt | 0 .../cmd}/testdata/output/repo-add.txt | 0 .../cmd}/testdata/output/repo-add2.txt | 0 .../cmd}/testdata/output/repo_list_comp.txt | 0 .../cmd}/testdata/output/repo_repeat_comp.txt | 0 .../cmd}/testdata/output/revision-comp.txt | 0 .../output/revision-wrong-args-comp.txt | 0 .../cmd}/testdata/output/rollback-comp.txt | 0 .../cmd}/testdata/output/rollback-no-args.txt | 0 .../testdata/output/rollback-no-revision.txt | 0 .../output/rollback-non-existent-version.txt | 0 .../cmd}/testdata/output/rollback-timeout.txt | 0 .../output/rollback-wait-for-jobs.txt | 0 .../cmd}/testdata/output/rollback-wait.txt | 0 .../output/rollback-wrong-args-comp.txt | 0 .../cmd}/testdata/output/rollback.txt | 0 .../testdata/output/schema-negative-cli.txt | 0 .../cmd}/testdata/output/schema-negative.txt | 0 .../cmd}/testdata/output/schema.txt | 0 .../output/search-constraint-single.txt | 0 .../testdata/output/search-constraint.txt | 0 .../output/search-multiple-devel-release.txt | 0 .../output/search-multiple-stable-release.txt | 0 .../search-multiple-versions-constraints.txt | 0 .../output/search-multiple-versions.txt | 0 .../output/search-not-found-error.txt | 0 .../cmd}/testdata/output/search-not-found.txt | 0 .../testdata/output/search-output-json.txt | 0 .../testdata/output/search-output-yaml.txt | 0 .../cmd}/testdata/output/search-regex.txt | 0 .../output/search-versions-constraint.txt | 0 .../cmd}/testdata/output/status-comp.txt | 0 .../cmd}/testdata/output/status-with-desc.txt | 0 .../testdata/output/status-with-notes.txt | 0 .../output/status-with-resources.json | 0 .../testdata/output/status-with-resources.txt | 0 .../output/status-with-test-suite.txt | 0 .../output/status-wrong-args-comp.txt | 0 .../cmd}/testdata/output/status.json | 0 .../cmd}/testdata/output/status.txt | 0 .../output/subchart-schema-cli-negative.txt | 0 .../testdata/output/subchart-schema-cli.txt | 0 .../output/subchart-schema-negative.txt | 0 .../output/template-chart-bad-type.txt | 0 ...te-chart-with-template-lib-archive-dep.txt | 0 .../template-chart-with-template-lib-dep.txt | 0 .../testdata/output/template-lib-chart.txt | 0 .../output/template-name-template.txt | 0 .../cmd}/testdata/output/template-no-args.txt | 0 .../cmd}/testdata/output/template-set.txt | 0 .../output/template-show-only-glob.txt | 0 .../output/template-show-only-multiple.txt | 0 .../output/template-show-only-one.txt | 0 .../testdata/output/template-skip-tests.txt | 0 .../output/template-subchart-cm-set-file.txt | 0 .../output/template-subchart-cm-set.txt | 0 .../testdata/output/template-subchart-cm.txt | 0 .../testdata/output/template-values-files.txt | 0 .../output/template-with-api-version.txt | 0 .../testdata/output/template-with-crds.txt | 0 .../template-with-invalid-yaml-debug.txt | 0 .../output/template-with-invalid-yaml.txt | 0 .../output/template-with-kube-version.txt | 0 .../cmd}/testdata/output/template.txt | 0 .../output/uninstall-keep-history.txt | 0 .../testdata/output/uninstall-multiple.txt | 0 .../testdata/output/uninstall-no-args.txt | 0 .../testdata/output/uninstall-no-hooks.txt | 0 .../testdata/output/uninstall-timeout.txt | 0 .../cmd}/testdata/output/uninstall-wait.txt | 0 .../cmd}/testdata/output/uninstall.txt | 0 .../output/upgrade-and-take-ownership.txt | 0 .../upgrade-uninstalled-with-keep-history.txt | 0 .../output/upgrade-with-bad-dependencies.txt | 0 ...e-with-bad-or-missing-existing-release.txt | 0 .../output/upgrade-with-dependency-update.txt | 0 .../output/upgrade-with-install-timeout.txt | 0 .../testdata/output/upgrade-with-install.txt | 0 .../upgrade-with-missing-dependencies.txt | 0 .../output/upgrade-with-pending-install.txt | 0 .../output/upgrade-with-reset-values.txt | 0 .../output/upgrade-with-reset-values2.txt | 0 .../testdata/output/upgrade-with-timeout.txt | 0 .../output/upgrade-with-wait-for-jobs.txt | 0 .../testdata/output/upgrade-with-wait.txt | 0 .../cmd}/testdata/output/upgrade.txt | 0 .../cmd}/testdata/output/values.json | 0 .../cmd}/testdata/output/values.yaml | 0 .../output/version-client-shorthand.txt | 0 .../cmd}/testdata/output/version-client.txt | 0 .../cmd}/testdata/output/version-comp.txt | 0 .../testdata/output/version-invalid-comp.txt | 0 .../cmd}/testdata/output/version-short.txt | 0 .../cmd}/testdata/output/version-template.txt | 0 .../cmd}/testdata/output/version.txt | 0 {cmd/helm => pkg/cmd}/testdata/password | 0 {cmd/helm => pkg/cmd}/testdata/plugins.yaml | 0 .../cmd}/testdata/repositories.yaml | 0 .../testdata/testcharts/alpine/Chart.yaml | 0 .../cmd}/testdata/testcharts/alpine/README.md | 0 .../testcharts/alpine/extra_values.yaml | 0 .../testcharts/alpine/more_values.yaml | 0 .../alpine/templates/alpine-pod.yaml | 0 .../testdata/testcharts/alpine/values.yaml | 0 .../chart-bad-requirements/.helmignore | 0 .../chart-bad-requirements/Chart.yaml | 0 .../charts/reqsubchart/.helmignore | 0 .../charts/reqsubchart/Chart.yaml | 0 .../charts/reqsubchart/values.yaml | 0 .../chart-bad-requirements/values.yaml | 0 .../testcharts/chart-bad-type/Chart.yaml | 0 .../testcharts/chart-bad-type/README.md | 0 .../chart-bad-type/extra_values.yaml | 0 .../chart-bad-type/more_values.yaml | 0 .../chart-bad-type/templates/alpine-pod.yaml | 0 .../testcharts/chart-bad-type/values.yaml | 0 .../testcharts/chart-missing-deps/.helmignore | 0 .../testcharts/chart-missing-deps/Chart.yaml | 0 .../charts/reqsubchart/.helmignore | 0 .../charts/reqsubchart/Chart.yaml | 0 .../charts/reqsubchart/values.yaml | 0 .../testcharts/chart-missing-deps/values.yaml | 0 .../chart-with-bad-subcharts/Chart.yaml | 0 .../charts/bad-subchart/Chart.yaml | 0 .../charts/bad-subchart/values.yaml | 0 .../charts/good-subchart/Chart.yaml | 0 .../charts/good-subchart/values.yaml | 0 .../requirements.yaml | 0 .../chart-with-bad-subcharts/values.yaml | 0 .../chart-with-deprecated-api/Chart.yaml | 0 .../templates/horizontalpodautoscaler.yaml | 0 .../chart-with-deprecated-api/values.yaml | 0 .../testcharts/chart-with-lib-dep/.helmignore | 0 .../testcharts/chart-with-lib-dep/Chart.yaml | 0 .../charts/common-0.0.5.tgz | Bin .../chart-with-lib-dep/templates/NOTES.txt | 0 .../chart-with-lib-dep/templates/_helpers.tpl | 0 .../templates/deployment.yaml | 0 .../chart-with-lib-dep/templates/ingress.yaml | 0 .../chart-with-lib-dep/templates/service.yaml | 0 .../testcharts/chart-with-lib-dep/values.yaml | 0 .../chart-with-only-crds/.helmignore | 0 .../chart-with-only-crds/Chart.yaml | 0 .../chart-with-only-crds/crds/test-crd.yaml | 0 .../chart-with-schema-and-subchart/Chart.yaml | 0 .../charts/subchart-with-schema/Chart.yaml | 0 .../subchart-with-schema/templates/empty.yaml | 0 .../subchart-with-schema/values.schema.json | 0 .../charts/subchart-with-schema/values.yaml | 0 .../templates/empty.yaml | 0 .../values.schema.json | 0 .../values.yaml | 0 .../Chart.yaml | 0 .../templates/empty.yaml | 0 .../values.schema.json | 0 .../values.yaml | 0 .../chart-with-schema-negative/Chart.yaml | 0 .../templates/empty.yaml | 0 .../values.schema.json | 0 .../chart-with-schema-negative/values.yaml | 0 .../testcharts/chart-with-schema/Chart.yaml | 0 .../chart-with-schema/extra-values.yaml | 0 .../chart-with-schema/templates/empty.yaml | 0 .../chart-with-schema/values.schema.json | 0 .../testcharts/chart-with-schema/values.yaml | 0 .../testcharts/chart-with-secret/Chart.yaml | 0 .../templates/configmap.yaml | 0 .../chart-with-secret/templates/secret.yaml | 0 .../chart-with-subchart-notes/Chart.yaml | 0 .../charts/subchart-with-notes/Chart.yaml | 0 .../subchart-with-notes/templates/NOTES.txt | 0 .../templates/NOTES.txt | 0 .../chart-with-subchart-update/Chart.lock | 0 .../chart-with-subchart-update/Chart.yaml | 0 .../charts/subchart-with-notes/Chart.yaml | 0 .../subchart-with-notes/templates/NOTES.txt | 0 .../templates/NOTES.txt | 0 .../.helmignore | 0 .../Chart.yaml | 0 .../charts/common-0.0.5.tgz | Bin .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/deployment.yaml | 0 .../templates/ingress.yaml | 0 .../templates/service.yaml | 0 .../values.yaml | 0 .../chart-with-template-lib-dep/.helmignore | 0 .../chart-with-template-lib-dep/Chart.yaml | 0 .../charts/common/.helmignore | 0 .../charts/common/Chart.yaml | 0 .../charts/common/README.md | 0 .../charts/common/templates/_chartref.tpl | 0 .../charts/common/templates/_configmap.yaml | 0 .../charts/common/templates/_container.yaml | 0 .../charts/common/templates/_deployment.yaml | 0 .../charts/common/templates/_envvar.tpl | 0 .../charts/common/templates/_fullname.tpl | 0 .../charts/common/templates/_ingress.yaml | 0 .../charts/common/templates/_metadata.yaml | 0 .../templates/_metadata_annotations.tpl | 0 .../common/templates/_metadata_labels.tpl | 0 .../charts/common/templates/_name.tpl | 0 .../templates/_persistentvolumeclaim.yaml | 0 .../charts/common/templates/_secret.yaml | 0 .../charts/common/templates/_service.yaml | 0 .../charts/common/templates/_util.tpl | 0 .../charts/common/templates/_volume.tpl | 0 .../charts/common/templates/configmap.yaml | 0 .../charts/common/values.yaml | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/deployment.yaml | 0 .../templates/ingress.yaml | 0 .../templates/service.yaml | 0 .../chart-with-template-lib-dep/values.yaml | 0 .../Chart.yaml | 0 .../README.md | 0 .../templates/alpine-pod.yaml | 0 .../values.yaml | 0 .../testcharts/compressedchart-0.1.0.tar.gz | Bin .../testcharts/compressedchart-0.1.0.tgz | Bin .../testcharts/compressedchart-0.2.0.tgz | Bin .../testcharts/compressedchart-0.3.0.tgz | Bin .../compressedchart-with-hyphens-0.1.0.tgz | Bin .../testdata/testcharts/deprecated/Chart.yaml | 0 .../testdata/testcharts/deprecated/README.md | 0 .../cmd}/testdata/testcharts/empty/Chart.yaml | 0 .../cmd}/testdata/testcharts/empty/README.md | 0 .../testcharts/empty/templates/empty.yaml | 0 .../testdata/testcharts/empty/values.yaml | 0 .../testcharts/issue-7233/.helmignore | 0 .../testdata/testcharts/issue-7233/Chart.yaml | 0 .../testcharts/issue-7233/requirements.lock | 0 .../testcharts/issue-7233/requirements.yaml | 0 .../issue-7233/templates/configmap.yaml | 0 .../testcharts/issue-7233/values.yaml | 0 .../testdata/testcharts/issue-9027/Chart.yaml | 0 .../issue-9027/charts/subchart/Chart.yaml | 0 .../charts/subchart/templates/values.yaml | 0 .../issue-9027/charts/subchart/values.yaml | 0 .../issue-9027/templates/values.yaml | 0 .../testcharts/issue-9027/values.yaml | 0 .../testcharts/issue-totoml/Chart.yaml | 0 .../issue-totoml/templates/configmap.yaml | 0 .../testcharts/issue-totoml/values.yaml | 0 .../testdata/testcharts/issue1979/Chart.yaml | 0 .../testdata/testcharts/issue1979/README.md | 0 .../testcharts/issue1979/extra_values.yaml | 0 .../testcharts/issue1979/more_values.yaml | 0 .../issue1979/templates/alpine-pod.yaml | 0 .../testdata/testcharts/issue1979/values.yaml | 0 .../testdata/testcharts/lib-chart/.helmignore | 0 .../testdata/testcharts/lib-chart/Chart.yaml | 0 .../testdata/testcharts/lib-chart/README.md | 0 .../lib-chart/templates/_chartref.tpl | 0 .../lib-chart/templates/_configmap.yaml | 0 .../lib-chart/templates/_container.yaml | 0 .../lib-chart/templates/_deployment.yaml | 0 .../lib-chart/templates/_envvar.tpl | 0 .../lib-chart/templates/_fullname.tpl | 0 .../lib-chart/templates/_ingress.yaml | 0 .../lib-chart/templates/_metadata.yaml | 0 .../templates/_metadata_annotations.tpl | 0 .../lib-chart/templates/_metadata_labels.tpl | 0 .../testcharts/lib-chart/templates/_name.tpl | 0 .../templates/_persistentvolumeclaim.yaml | 0 .../lib-chart/templates/_secret.yaml | 0 .../lib-chart/templates/_service.yaml | 0 .../testcharts/lib-chart/templates/_util.tpl | 0 .../lib-chart/templates/_volume.tpl | 0 .../testdata/testcharts/lib-chart/values.yaml | 0 .../testcharts/object-order/Chart.yaml | 0 .../object-order/templates/01-a.yml | 0 .../object-order/templates/02-b.yml | 0 .../testcharts/object-order/values.yaml | 0 .../testcharts/oci-dependent-chart-0.1.0.tgz | Bin .../pre-release-chart-0.1.0-alpha.tgz | Bin .../testdata/testcharts/reqtest-0.1.0.tgz | Bin .../testdata/testcharts/reqtest/.helmignore | 0 .../testdata/testcharts/reqtest/Chart.lock | 0 .../testdata/testcharts/reqtest/Chart.yaml | 0 .../reqtest/charts/reqsubchart/.helmignore | 0 .../reqtest/charts/reqsubchart/Chart.yaml | 0 .../reqtest/charts/reqsubchart/values.yaml | 0 .../reqtest/charts/reqsubchart2/.helmignore | 0 .../reqtest/charts/reqsubchart2/Chart.yaml | 0 .../reqtest/charts/reqsubchart2/values.yaml | 0 .../reqtest/charts/reqsubchart3-0.2.0.tgz | Bin .../testdata/testcharts/reqtest/values.yaml | 0 .../testdata/testcharts/signtest-0.1.0.tgz | Bin .../testcharts/signtest-0.1.0.tgz.prov | 0 .../testdata/testcharts/signtest/.helmignore | 0 .../testdata/testcharts/signtest/Chart.yaml | 0 .../testcharts/signtest/alpine/Chart.yaml | 0 .../testcharts/signtest/alpine/README.md | 0 .../signtest/alpine/templates/alpine-pod.yaml | 0 .../testcharts/signtest/alpine/values.yaml | 0 .../testcharts/signtest/templates/pod.yaml | 0 .../testdata/testcharts/signtest/values.yaml | 0 .../testdata/testcharts/subchart/Chart.yaml | 0 .../subchart/charts/subchartA/Chart.yaml | 0 .../charts/subchartA/templates/service.yaml | 0 .../subchart/charts/subchartA/values.yaml | 0 .../subchart/charts/subchartB/Chart.yaml | 0 .../charts/subchartB/templates/service.yaml | 0 .../subchart/charts/subchartB/values.yaml | 0 .../testcharts/subchart/crds/crdA.yaml | 0 .../testcharts/subchart/extra_values.yaml | 0 .../testcharts/subchart/templates/NOTES.txt | 0 .../subchart/templates/service.yaml | 0 .../subchart/templates/subdir/configmap.yaml | 0 .../subchart/templates/subdir/role.yaml | 0 .../templates/subdir/rolebinding.yaml | 0 .../templates/subdir/serviceaccount.yaml | 0 .../subchart/templates/tests/test-config.yaml | 0 .../templates/tests/test-nothing.yaml | 0 .../testdata/testcharts/subchart/values.yaml | 0 .../upgradetest/templates/configmap.yaml | 0 .../testcharts/upgradetest/values.yaml | 0 .../cmd}/testdata/testplugin/plugin.yaml | 0 .../cmd}/testdata/testserver/index.yaml | 0 .../testserver/repository/repositories.yaml | 0 {cmd/helm => pkg/cmd}/uninstall.go | 4 +- {cmd/helm => pkg/cmd}/uninstall_test.go | 2 +- {cmd/helm => pkg/cmd}/upgrade.go | 8 +- {cmd/helm => pkg/cmd}/upgrade_test.go | 2 +- {cmd/helm => pkg/cmd}/verify.go | 4 +- {cmd/helm => pkg/cmd}/verify_test.go | 2 +- {cmd/helm => pkg/cmd}/version.go | 4 +- {cmd/helm => pkg/cmd}/version_test.go | 2 +- 538 files changed, 354 insertions(+), 335 deletions(-) rename {cmd/helm => pkg/cmd}/completion.go (99%) rename {cmd/helm => pkg/cmd}/completion_test.go (99%) rename {cmd/helm => pkg/cmd}/create.go (98%) rename {cmd/helm => pkg/cmd}/create_test.go (99%) rename {cmd/helm => pkg/cmd}/dependency.go (98%) rename {cmd/helm => pkg/cmd}/dependency_build.go (98%) rename {cmd/helm => pkg/cmd}/dependency_build_test.go (99%) rename {cmd/helm => pkg/cmd}/dependency_test.go (99%) rename {cmd/helm => pkg/cmd}/dependency_update.go (98%) rename {cmd/helm => pkg/cmd}/dependency_update_test.go (99%) rename {cmd/helm => pkg/cmd}/docs.go (98%) rename {cmd/helm => pkg/cmd}/docs_test.go (98%) rename {cmd/helm => pkg/cmd}/env.go (97%) rename {cmd/helm => pkg/cmd}/env_test.go (98%) rename {cmd/helm => pkg/cmd}/flags.go (99%) rename {cmd/helm => pkg/cmd}/flags_test.go (99%) rename {cmd/helm => pkg/cmd}/get.go (96%) rename {cmd/helm => pkg/cmd}/get_all.go (97%) rename {cmd/helm => pkg/cmd}/get_all_test.go (99%) rename {cmd/helm => pkg/cmd}/get_hooks.go (97%) rename {cmd/helm => pkg/cmd}/get_hooks_test.go (99%) rename {cmd/helm => pkg/cmd}/get_manifest.go (97%) rename {cmd/helm => pkg/cmd}/get_manifest_test.go (99%) rename {cmd/helm => pkg/cmd}/get_metadata.go (98%) rename {cmd/helm => pkg/cmd}/get_metadata_test.go (99%) rename {cmd/helm => pkg/cmd}/get_notes.go (97%) rename {cmd/helm => pkg/cmd}/get_notes_test.go (99%) rename {cmd/helm => pkg/cmd}/get_test.go (98%) rename {cmd/helm => pkg/cmd}/get_values.go (98%) rename {cmd/helm => pkg/cmd}/get_values_test.go (99%) create mode 100644 pkg/cmd/helpers_test.go rename {cmd/helm => pkg/cmd}/history.go (99%) rename {cmd/helm => pkg/cmd}/history_test.go (99%) rename {cmd/helm => pkg/cmd}/install.go (98%) rename {cmd/helm => pkg/cmd}/install_test.go (99%) rename {cmd/helm => pkg/cmd}/lint.go (99%) rename {cmd/helm => pkg/cmd}/lint_test.go (99%) rename {cmd/helm => pkg/cmd}/list.go (98%) rename {cmd/helm => pkg/cmd}/list_test.go (99%) rename {cmd/helm => pkg/cmd}/load_plugins.go (99%) rename {cmd/helm => pkg/cmd}/package.go (99%) rename {cmd/helm => pkg/cmd}/package_test.go (99%) rename {cmd/helm => pkg/cmd}/plugin.go (97%) rename {cmd/helm => pkg/cmd}/plugin_install.go (96%) rename {cmd/helm => pkg/cmd}/plugin_list.go (97%) rename {cmd/helm => pkg/cmd}/plugin_test.go (98%) rename {cmd/helm => pkg/cmd}/plugin_uninstall.go (97%) rename {cmd/helm => pkg/cmd}/plugin_update.go (95%) rename {cmd/helm => pkg/cmd}/printer.go (98%) rename {cmd/helm => pkg/cmd}/profiling.go (99%) rename {cmd/helm => pkg/cmd}/pull.go (97%) rename {cmd/helm => pkg/cmd}/pull_test.go (99%) rename {cmd/helm => pkg/cmd}/push.go (98%) rename {cmd/helm => pkg/cmd}/push_test.go (98%) rename {cmd/helm => pkg/cmd}/registry.go (98%) rename {cmd/helm => pkg/cmd}/registry_login.go (97%) rename {cmd/helm => pkg/cmd}/registry_login_test.go (98%) rename {cmd/helm => pkg/cmd}/registry_logout.go (96%) rename {cmd/helm => pkg/cmd}/registry_logout_test.go (98%) rename {cmd/helm => pkg/cmd}/release_testing.go (98%) rename {cmd/helm => pkg/cmd}/release_testing_test.go (98%) rename {cmd/helm => pkg/cmd}/repo.go (96%) rename {cmd/helm => pkg/cmd}/repo_add.go (99%) rename {cmd/helm => pkg/cmd}/repo_add_test.go (99%) rename {cmd/helm => pkg/cmd}/repo_index.go (98%) rename {cmd/helm => pkg/cmd}/repo_index_test.go (99%) rename {cmd/helm => pkg/cmd}/repo_list.go (98%) rename {cmd/helm => pkg/cmd}/repo_list_test.go (98%) rename {cmd/helm => pkg/cmd}/repo_remove.go (98%) rename {cmd/helm => pkg/cmd}/repo_remove_test.go (99%) rename {cmd/helm => pkg/cmd}/repo_test.go (98%) rename {cmd/helm => pkg/cmd}/repo_update.go (98%) rename {cmd/helm => pkg/cmd}/repo_update_test.go (99%) rename {cmd/helm => pkg/cmd}/require/args.go (100%) rename {cmd/helm => pkg/cmd}/require/args_test.go (100%) rename {cmd/helm => pkg/cmd}/rollback.go (98%) rename {cmd/helm => pkg/cmd}/rollback_test.go (99%) rename {cmd/helm => pkg/cmd}/root.go (97%) rename {cmd/helm => pkg/cmd}/root_test.go (99%) rename {cmd/helm => pkg/cmd}/search.go (98%) rename {cmd/helm => pkg/cmd}/search/search.go (100%) rename {cmd/helm => pkg/cmd}/search/search_test.go (100%) rename {cmd/helm => pkg/cmd}/search_hub.go (99%) rename {cmd/helm => pkg/cmd}/search_hub_test.go (99%) rename {cmd/helm => pkg/cmd}/search_repo.go (97%) rename {cmd/helm => pkg/cmd}/search_repo_test.go (99%) rename {cmd/helm => pkg/cmd}/search_test.go (98%) rename {cmd/helm => pkg/cmd}/show.go (97%) rename {cmd/helm => pkg/cmd}/show_test.go (99%) rename {cmd/helm => pkg/cmd}/status.go (99%) rename {cmd/helm => pkg/cmd}/status_test.go (99%) rename {cmd/helm => pkg/cmd}/template.go (99%) rename {cmd/helm => pkg/cmd}/template_test.go (99%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/plugins/fullenv/completion.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/plugins/fullenv/fullenv.sh (100%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/plugins/fullenv/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/repositories.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/repository/test-name-charts.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/repository/test-name-index.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helm home with space/helm/repository/testing-index.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helm-test-key.pub (100%) rename {cmd/helm => pkg/cmd}/testdata/helm-test-key.secret (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/args/args.sh (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/args/plugin.complete (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/args/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/echo/completion.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/echo/plugin.complete (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/echo/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/env/completion.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/env/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/exitwith/completion.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/exitwith/exitwith.sh (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/exitwith/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/fullenv/completion.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/fullenv/fullenv.sh (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/plugins/fullenv/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/repositories.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/repository/test-name-charts.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/repository/test-name-index.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/helmhome/helm/repository/testing-index.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/output/chart-with-subchart-update.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/dependency-list-archive.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/dependency-list-no-chart-linux.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/dependency-list-no-requirements-linux.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/dependency-list.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/deprecated-chart.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/docs-type-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/empty_default_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/empty_nofile_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/env-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-all-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-hooks-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-hooks.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-manifest-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-manifest.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-metadata-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-metadata.json (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-metadata.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-metadata.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-notes-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-notes.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-release-template.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-release.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-values-all.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-values-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/get-values.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/history-limit.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/history.json (100%) rename {cmd/helm => pkg/cmd}/testdata/output/history.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/history.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-and-replace.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-and-take-ownership.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-chart-bad-type.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-dry-run-with-secret-hidden.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-dry-run-with-secret.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-hide-secret.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-lib-chart.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-name-template.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-no-hooks.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-multiple-values-files.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-multiple-values.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-timeout.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-values-file.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-values.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-wait-for-jobs.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install-with-wait.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/install.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/issue-9027.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/issue-totoml.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-chart-with-bad-subcharts.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-chart-with-deprecated-api-old-k8s.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-chart-with-deprecated-api-strict.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-chart-with-deprecated-api.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-quiet-with-error.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-quiet-with-warning.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/lint-quiet.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-all.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-date-reversed.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-date.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-failed.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-filter.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-max.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-namespace.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-no-headers.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-offset.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-pending.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-reverse.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-short-json.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-short-yaml.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-short.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-superseded.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-uninstalled.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list-uninstalling.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/list.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/object-order.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/output-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_args_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_args_flag_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_args_many_args_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_args_ns_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_echo_no_directive.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_list_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/plugin_repeat_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/release_list_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/release_list_repeat_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/repo-add.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/repo-add2.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/repo_list_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/repo_repeat_comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/revision-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/revision-wrong-args-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-no-revision.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-non-existent-version.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-timeout.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-wait-for-jobs.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-wait.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback-wrong-args-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/rollback.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/schema-negative-cli.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/schema-negative.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/schema.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-constraint-single.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-constraint.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-multiple-devel-release.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-multiple-stable-release.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-multiple-versions-constraints.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-multiple-versions.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-not-found-error.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-not-found.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-output-json.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-output-yaml.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-regex.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/search-versions-constraint.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-with-desc.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-with-notes.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-with-resources.json (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-with-resources.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-with-test-suite.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status-wrong-args-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status.json (100%) rename {cmd/helm => pkg/cmd}/testdata/output/status.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/subchart-schema-cli-negative.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/subchart-schema-cli.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/subchart-schema-negative.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-chart-bad-type.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-chart-with-template-lib-archive-dep.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-chart-with-template-lib-dep.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-lib-chart.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-name-template.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-set.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-show-only-glob.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-show-only-multiple.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-show-only-one.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-skip-tests.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-subchart-cm-set-file.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-subchart-cm-set.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-subchart-cm.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-values-files.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-with-api-version.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-with-crds.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-with-invalid-yaml-debug.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-with-invalid-yaml.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template-with-kube-version.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/template.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall-keep-history.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall-multiple.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall-no-args.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall-no-hooks.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall-timeout.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall-wait.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/uninstall.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-and-take-ownership.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-uninstalled-with-keep-history.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-bad-dependencies.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-bad-or-missing-existing-release.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-dependency-update.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-install-timeout.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-install.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-missing-dependencies.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-pending-install.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-reset-values.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-reset-values2.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-timeout.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-wait-for-jobs.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade-with-wait.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/upgrade.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/values.json (100%) rename {cmd/helm => pkg/cmd}/testdata/output/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version-client-shorthand.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version-client.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version-invalid-comp.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version-short.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version-template.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/output/version.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/password (100%) rename {cmd/helm => pkg/cmd}/testdata/plugins.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/repositories.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/alpine/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/alpine/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/alpine/extra_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/alpine/more_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/alpine/templates/alpine-pod.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/alpine/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-requirements/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-requirements/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-requirements/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-type/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-type/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-type/extra_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-type/more_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-bad-type/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-missing-deps/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-missing-deps/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-missing-deps/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-bad-subcharts/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-deprecated-api/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-deprecated-api/templates/horizontalpodautoscaler.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-deprecated-api/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/templates/service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-lib-dep/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-only-crds/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-only-crds/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-and-subchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative-skip-validation/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative-skip-validation/templates/empty.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative-skip-validation/values.schema.json (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative-skip-validation/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative/values.schema.json (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema-negative/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema/extra-values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema/templates/empty.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema/values.schema.json (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-schema/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-secret/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-secret/templates/configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-secret/templates/secret.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-notes/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-update/Chart.lock (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-update/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-lib-dep/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/compressedchart-0.1.0.tar.gz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/compressedchart-0.1.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/compressedchart-0.2.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/compressedchart-0.3.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/deprecated/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/deprecated/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/empty/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/empty/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/empty/templates/empty.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/empty/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-7233/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-7233/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-7233/requirements.lock (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-7233/requirements.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-7233/templates/configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-7233/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-9027/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-9027/charts/subchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-9027/charts/subchart/templates/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-9027/charts/subchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-9027/templates/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-9027/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-totoml/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-totoml/templates/configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue-totoml/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue1979/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue1979/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue1979/extra_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue1979/more_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue1979/templates/alpine-pod.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/issue1979/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_chartref.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_container.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_deployment.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_envvar.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_fullname.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_ingress.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_metadata.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_name.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_secret.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_util.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/templates/_volume.tpl (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/lib-chart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/object-order/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/object-order/templates/01-a.yml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/object-order/templates/02-b.yml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/object-order/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/oci-dependent-chart-0.1.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest-0.1.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/Chart.lock (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/reqtest/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest-0.1.0.tgz (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest-0.1.0.tgz.prov (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/.helmignore (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/alpine/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/alpine/README.md (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/alpine/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/templates/pod.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/signtest/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/charts/subchartA/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/charts/subchartA/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/charts/subchartB/Chart.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/charts/subchartB/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/crds/crdA.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/extra_values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/NOTES.txt (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/service.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/subdir/configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/subdir/role.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/tests/test-config.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/templates/tests/test-nothing.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/subchart/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/upgradetest/templates/configmap.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testcharts/upgradetest/values.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testplugin/plugin.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testserver/index.yaml (100%) rename {cmd/helm => pkg/cmd}/testdata/testserver/repository/repositories.yaml (100%) rename {cmd/helm => pkg/cmd}/uninstall.go (98%) rename {cmd/helm => pkg/cmd}/uninstall_test.go (99%) rename {cmd/helm => pkg/cmd}/upgrade.go (99%) rename {cmd/helm => pkg/cmd}/upgrade_test.go (99%) rename {cmd/helm => pkg/cmd}/verify.go (97%) rename {cmd/helm => pkg/cmd}/verify_test.go (99%) rename {cmd/helm => pkg/cmd}/version.go (98%) rename {cmd/helm => pkg/cmd}/version_test.go (98%) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index c8de18796..78b2c6cd3 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -17,12 +17,10 @@ limitations under the License. package main // import "helm.sh/helm/v4/cmd/helm" import ( - "fmt" "io" "log" "os" "strings" - "time" "github.com/spf13/cobra" "sigs.k8s.io/yaml" @@ -32,6 +30,7 @@ import ( "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli" + helmcmd "helm.sh/helm/v4/pkg/cmd" "helm.sh/helm/v4/pkg/kube" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" @@ -44,19 +43,6 @@ func init() { log.SetFlags(log.Lshortfile) } -func debug(format string, v ...interface{}) { - if settings.Debug { - timeNow := time.Now().String() - format = fmt.Sprintf("%s [debug] %s\n", timeNow, 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...) -} - // hookOutputWriter provides the writer for writing hook logs. func hookOutputWriter(_, _, _ string) io.Writer { return log.Writer() @@ -70,16 +56,15 @@ func main() { kube.ManagedFieldsManager = "helm" actionConfig := new(action.Configuration) - cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) + cmd, err := helmcmd.NewRootCmd(actionConfig, os.Stdout, os.Args[1:]) if err != nil { - warning("%+v", err) + helmcmd.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 { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, helmcmd.Debug); err != nil { log.Fatal(err) } if helmDriver == "memory" { @@ -89,10 +74,10 @@ func main() { }) if err := cmd.Execute(); err != nil { - debug("%+v", err) + helmcmd.Debug("%+v", err) switch e := err.(type) { - case pluginError: - os.Exit(e.code) + case helmcmd.PluginError: + os.Exit(e.Code) default: os.Exit(1) } diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index e7a05aecf..5431daad0 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -18,153 +18,12 @@ package main import ( "bytes" - "io" "os" "os/exec" "runtime" - "strings" "testing" - - shellwords "github.com/mattn/go-shellwords" - "github.com/spf13/cobra" - - "helm.sh/helm/v4/internal/test" - "helm.sh/helm/v4/pkg/action" - chartutil "helm.sh/helm/v4/pkg/chart/util" - "helm.sh/helm/v4/pkg/cli" - kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/storage" - "helm.sh/helm/v4/pkg/storage/driver" - "helm.sh/helm/v4/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: io.Discard}, - Capabilities: chartutil.DefaultCapabilities, - Log: func(_ string, _ ...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"} @@ -190,10 +49,8 @@ func TestPluginExitCode(t *testing.T) { "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", + // This mimics the "exitwith" test case in TestLoadPlugins using envvars + "HELM_PLUGINS=../../pkg/cmd/testdata/helmhome/helm/plugins", ) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} diff --git a/cmd/helm/completion.go b/pkg/cmd/completion.go similarity index 99% rename from cmd/helm/completion.go rename to pkg/cmd/completion.go index 5d2186939..6f6dbd25d 100644 --- a/cmd/helm/completion.go +++ b/pkg/cmd/completion.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" ) const completionDesc = ` diff --git a/cmd/helm/completion_test.go b/pkg/cmd/completion_test.go similarity index 99% rename from cmd/helm/completion_test.go rename to pkg/cmd/completion_test.go index 4dd427232..0618a7f64 100644 --- a/cmd/helm/completion_test.go +++ b/pkg/cmd/completion_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/create.go b/pkg/cmd/create.go similarity index 98% rename from cmd/helm/create.go rename to pkg/cmd/create.go index a18f2c915..d1e7ef4c6 100644 --- a/cmd/helm/create.go +++ b/pkg/cmd/create.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,9 +23,9 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/chart" chartutil "helm.sh/helm/v4/pkg/chart/util" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/helmpath" ) diff --git a/cmd/helm/create_test.go b/pkg/cmd/create_test.go similarity index 99% rename from cmd/helm/create_test.go rename to pkg/cmd/create_test.go index 76fce804c..8f40bfc57 100644 --- a/cmd/helm/create_test.go +++ b/pkg/cmd/create_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/dependency.go b/pkg/cmd/dependency.go similarity index 98% rename from cmd/helm/dependency.go rename to pkg/cmd/dependency.go index 5e108b6fd..34bbff6be 100644 --- a/cmd/helm/dependency.go +++ b/pkg/cmd/dependency.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" @@ -22,8 +22,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const dependencyDesc = ` diff --git a/cmd/helm/dependency_build.go b/pkg/cmd/dependency_build.go similarity index 98% rename from cmd/helm/dependency_build.go rename to pkg/cmd/dependency_build.go index 719c720a7..16907facf 100644 --- a/cmd/helm/dependency_build.go +++ b/pkg/cmd/dependency_build.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -24,8 +24,8 @@ import ( "github.com/spf13/cobra" "k8s.io/client-go/util/homedir" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" ) diff --git a/cmd/helm/dependency_build_test.go b/pkg/cmd/dependency_build_test.go similarity index 99% rename from cmd/helm/dependency_build_test.go rename to pkg/cmd/dependency_build_test.go index 76c01d911..8d0191e3f 100644 --- a/cmd/helm/dependency_build_test.go +++ b/pkg/cmd/dependency_build_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/dependency_test.go b/pkg/cmd/dependency_test.go similarity index 99% rename from cmd/helm/dependency_test.go rename to pkg/cmd/dependency_test.go index 34c6a25e1..d6bcebf1b 100644 --- a/cmd/helm/dependency_test.go +++ b/pkg/cmd/dependency_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "runtime" diff --git a/cmd/helm/dependency_update.go b/pkg/cmd/dependency_update.go similarity index 98% rename from cmd/helm/dependency_update.go rename to pkg/cmd/dependency_update.go index 563d7eba5..921e5ef49 100644 --- a/cmd/helm/dependency_update.go +++ b/pkg/cmd/dependency_update.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -22,8 +22,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" ) diff --git a/cmd/helm/dependency_update_test.go b/pkg/cmd/dependency_update_test.go similarity index 99% rename from cmd/helm/dependency_update_test.go rename to pkg/cmd/dependency_update_test.go index 0732ba7b5..3246f9c54 100644 --- a/cmd/helm/dependency_update_test.go +++ b/pkg/cmd/dependency_update_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/docs.go b/pkg/cmd/docs.go similarity index 98% rename from cmd/helm/docs.go rename to pkg/cmd/docs.go index 571840b5f..b3fd773f9 100644 --- a/cmd/helm/docs.go +++ b/pkg/cmd/docs.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -28,7 +28,7 @@ import ( "golang.org/x/text/cases" "golang.org/x/text/language" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" ) const docsDesc = ` diff --git a/cmd/helm/docs_test.go b/pkg/cmd/docs_test.go similarity index 98% rename from cmd/helm/docs_test.go rename to pkg/cmd/docs_test.go index fe5864d5e..4a8a8c687 100644 --- a/cmd/helm/docs_test.go +++ b/pkg/cmd/docs_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/env.go b/pkg/cmd/env.go similarity index 97% rename from cmd/helm/env.go rename to pkg/cmd/env.go index c7305434b..8da201031 100644 --- a/cmd/helm/env.go +++ b/pkg/cmd/env.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" ) var envHelp = ` diff --git a/cmd/helm/env_test.go b/pkg/cmd/env_test.go similarity index 98% rename from cmd/helm/env_test.go rename to pkg/cmd/env_test.go index 01ef25933..c5d7af1b7 100644 --- a/cmd/helm/env_test.go +++ b/pkg/cmd/env_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/flags.go b/pkg/cmd/flags.go similarity index 99% rename from cmd/helm/flags.go rename to pkg/cmd/flags.go index 8d0f644d6..7c69385b4 100644 --- a/cmd/helm/flags.go +++ b/pkg/cmd/flags.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "flag" diff --git a/cmd/helm/flags_test.go b/pkg/cmd/flags_test.go similarity index 99% rename from cmd/helm/flags_test.go rename to pkg/cmd/flags_test.go index 295f55022..da026ea8c 100644 --- a/cmd/helm/flags_test.go +++ b/pkg/cmd/flags_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/get.go b/pkg/cmd/get.go similarity index 96% rename from cmd/helm/get.go rename to pkg/cmd/get.go index 27d536f8b..1e672beea 100644 --- a/cmd/helm/get.go +++ b/pkg/cmd/get.go @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) var getHelp = ` diff --git a/cmd/helm/get_all.go b/pkg/cmd/get_all.go similarity index 97% rename from cmd/helm/get_all.go rename to pkg/cmd/get_all.go index 522327b67..aee92df51 100644 --- a/cmd/helm/get_all.go +++ b/pkg/cmd/get_all.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" @@ -22,9 +22,9 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" ) var getAllHelp = ` diff --git a/cmd/helm/get_all_test.go b/pkg/cmd/get_all_test.go similarity index 99% rename from cmd/helm/get_all_test.go rename to pkg/cmd/get_all_test.go index 60ea1161d..163400d22 100644 --- a/cmd/helm/get_all_test.go +++ b/pkg/cmd/get_all_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/get_hooks.go b/pkg/cmd/get_hooks.go similarity index 97% rename from cmd/helm/get_hooks.go rename to pkg/cmd/get_hooks.go index 25c6eb4e3..7ffefd93c 100644 --- a/cmd/helm/get_hooks.go +++ b/pkg/cmd/get_hooks.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const getHooksHelp = ` diff --git a/cmd/helm/get_hooks_test.go b/pkg/cmd/get_hooks_test.go similarity index 99% rename from cmd/helm/get_hooks_test.go rename to pkg/cmd/get_hooks_test.go index 75cf448cc..62eaefd1b 100644 --- a/cmd/helm/get_hooks_test.go +++ b/pkg/cmd/get_hooks_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/get_manifest.go b/pkg/cmd/get_manifest.go similarity index 97% rename from cmd/helm/get_manifest.go rename to pkg/cmd/get_manifest.go index d2a4bbe96..021495d8d 100644 --- a/cmd/helm/get_manifest.go +++ b/pkg/cmd/get_manifest.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) var getManifestHelp = ` diff --git a/cmd/helm/get_manifest_test.go b/pkg/cmd/get_manifest_test.go similarity index 99% rename from cmd/helm/get_manifest_test.go rename to pkg/cmd/get_manifest_test.go index b266620e7..004cd9ad2 100644 --- a/cmd/helm/get_manifest_test.go +++ b/pkg/cmd/get_manifest_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/get_metadata.go b/pkg/cmd/get_metadata.go similarity index 98% rename from cmd/helm/get_metadata.go rename to pkg/cmd/get_metadata.go index 4ab0c8cab..9f58e0f4e 100644 --- a/cmd/helm/get_metadata.go +++ b/pkg/cmd/get_metadata.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -24,9 +24,9 @@ import ( "github.com/spf13/cobra" k8sLabels "k8s.io/apimachinery/pkg/labels" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" ) type metadataWriter struct { diff --git a/cmd/helm/get_metadata_test.go b/pkg/cmd/get_metadata_test.go similarity index 99% rename from cmd/helm/get_metadata_test.go rename to pkg/cmd/get_metadata_test.go index 28c3c3649..213fe705d 100644 --- a/cmd/helm/get_metadata_test.go +++ b/pkg/cmd/get_metadata_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/get_notes.go b/pkg/cmd/get_notes.go similarity index 97% rename from cmd/helm/get_notes.go rename to pkg/cmd/get_notes.go index 8a8e67079..ae79d8bcc 100644 --- a/cmd/helm/get_notes.go +++ b/pkg/cmd/get_notes.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) var getNotesHelp = ` diff --git a/cmd/helm/get_notes_test.go b/pkg/cmd/get_notes_test.go similarity index 99% rename from cmd/helm/get_notes_test.go rename to pkg/cmd/get_notes_test.go index 4ddd4c7a8..0071cdcc2 100644 --- a/cmd/helm/get_notes_test.go +++ b/pkg/cmd/get_notes_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/get_test.go b/pkg/cmd/get_test.go similarity index 98% rename from cmd/helm/get_test.go rename to pkg/cmd/get_test.go index 79f914bea..cf81e4df7 100644 --- a/cmd/helm/get_test.go +++ b/pkg/cmd/get_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/get_values.go b/pkg/cmd/get_values.go similarity index 98% rename from cmd/helm/get_values.go rename to pkg/cmd/get_values.go index 8244fbaaa..02b195551 100644 --- a/cmd/helm/get_values.go +++ b/pkg/cmd/get_values.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,9 +23,9 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" ) var getValuesHelp = ` diff --git a/cmd/helm/get_values_test.go b/pkg/cmd/get_values_test.go similarity index 99% rename from cmd/helm/get_values_test.go rename to pkg/cmd/get_values_test.go index 44610c103..7f82531e3 100644 --- a/cmd/helm/get_values_test.go +++ b/pkg/cmd/get_values_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go new file mode 100644 index 000000000..8002cb0d1 --- /dev/null +++ b/pkg/cmd/helpers_test.go @@ -0,0 +1,164 @@ +/* +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 cmd + +import ( + "bytes" + "io" + "os" + "strings" + "testing" + + shellwords "github.com/mattn/go-shellwords" + "github.com/spf13/cobra" + + "helm.sh/helm/v4/internal/test" + "helm.sh/helm/v4/pkg/action" + chartutil "helm.sh/helm/v4/pkg/chart/util" + "helm.sh/helm/v4/pkg/cli" + kubefake "helm.sh/helm/v4/pkg/kube/fake" + "helm.sh/helm/v4/pkg/release" + "helm.sh/helm/v4/pkg/storage" + "helm.sh/helm/v4/pkg/storage/driver" + "helm.sh/helm/v4/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: io.Discard}, + Capabilities: chartutil.DefaultCapabilities, + Log: func(_ string, _ ...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) } +} diff --git a/cmd/helm/history.go b/pkg/cmd/history.go similarity index 99% rename from cmd/helm/history.go rename to pkg/cmd/history.go index 91d005e7a..87ba97714 100644 --- a/cmd/helm/history.go +++ b/pkg/cmd/history.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -25,10 +25,10 @@ import ( "github.com/gosuri/uitable" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/release" "helm.sh/helm/v4/pkg/releaseutil" helmtime "helm.sh/helm/v4/pkg/time" diff --git a/cmd/helm/history_test.go b/pkg/cmd/history_test.go similarity index 99% rename from cmd/helm/history_test.go rename to pkg/cmd/history_test.go index 07f5134c6..52e742334 100644 --- a/cmd/helm/history_test.go +++ b/pkg/cmd/history_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/install.go b/pkg/cmd/install.go similarity index 98% rename from cmd/helm/install.go rename to pkg/cmd/install.go index fe09dfc53..ee94b3489 100644 --- a/cmd/helm/install.go +++ b/pkg/cmd/install.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "context" @@ -30,12 +30,12 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/chart/loader" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/values" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/release" @@ -229,9 +229,9 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal } func runInstall(args []string, client *action.Install, valueOpts *values.Options, out io.Writer) (*release.Release, error) { - debug("Original chart version: %q", client.Version) + Debug("Original chart version: %q", client.Version) if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") + Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -246,7 +246,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options return nil, err } - debug("CHART PATH: %s\n", cp) + Debug("CHART PATH: %s\n", cp) p := getter.All(settings) vals, err := valueOpts.MergeValues(p) @@ -265,7 +265,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options } if chartRequested.Metadata.Deprecated { - warning("This chart is deprecated") + Warning("This chart is deprecated") } if req := chartRequested.Metadata.Dependencies; req != nil { diff --git a/cmd/helm/install_test.go b/pkg/cmd/install_test.go similarity index 99% rename from cmd/helm/install_test.go rename to pkg/cmd/install_test.go index be8480423..9cd244e84 100644 --- a/cmd/helm/install_test.go +++ b/pkg/cmd/install_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/lint.go b/pkg/cmd/lint.go similarity index 99% rename from cmd/helm/lint.go rename to pkg/cmd/lint.go index 3e37922b2..ba154d1e6 100644 --- a/cmd/helm/lint.go +++ b/pkg/cmd/lint.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/lint_test.go b/pkg/cmd/lint_test.go similarity index 99% rename from cmd/helm/lint_test.go rename to pkg/cmd/lint_test.go index 166b69ba0..401c84d74 100644 --- a/cmd/helm/lint_test.go +++ b/pkg/cmd/lint_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/list.go b/pkg/cmd/list.go similarity index 98% rename from cmd/helm/list.go rename to pkg/cmd/list.go index 67da22cdf..2e1a7737b 100644 --- a/cmd/helm/list.go +++ b/pkg/cmd/list.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -25,9 +25,9 @@ import ( "github.com/gosuri/uitable" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/release" ) @@ -71,7 +71,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(cmd *cobra.Command, _ []string) error { if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), Debug); err != nil { return err } } diff --git a/cmd/helm/list_test.go b/pkg/cmd/list_test.go similarity index 99% rename from cmd/helm/list_test.go rename to pkg/cmd/list_test.go index 01b6d7490..866c6a151 100644 --- a/cmd/helm/list_test.go +++ b/pkg/cmd/list_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/load_plugins.go b/pkg/cmd/load_plugins.go similarity index 99% rename from cmd/helm/load_plugins.go rename to pkg/cmd/load_plugins.go index 23b1b7ff4..3cf701242 100644 --- a/cmd/helm/load_plugins.go +++ b/pkg/cmd/load_plugins.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" @@ -39,9 +39,9 @@ const ( pluginDynamicCompletionExecutable = "plugin.complete" ) -type pluginError struct { +type PluginError struct { error - code int + Code int } // loadPlugins loads plugins into the command list. @@ -138,9 +138,9 @@ func callPluginExecutable(pluginName string, main string, argv []string, out io. if eerr, ok := err.(*exec.ExitError); ok { os.Stderr.Write(eerr.Stderr) status := eerr.Sys().(syscall.WaitStatus) - return pluginError{ + return PluginError{ error: errors.Errorf("plugin %q exited with error", pluginName), - code: status.ExitStatus(), + Code: status.ExitStatus(), } } return err diff --git a/cmd/helm/package.go b/pkg/cmd/package.go similarity index 99% rename from cmd/helm/package.go rename to pkg/cmd/package.go index 185442b20..7bc22dfb4 100644 --- a/cmd/helm/package.go +++ b/pkg/cmd/package.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/package_test.go b/pkg/cmd/package_test.go similarity index 99% rename from cmd/helm/package_test.go rename to pkg/cmd/package_test.go index 107928765..4a7a143bf 100644 --- a/cmd/helm/package_test.go +++ b/pkg/cmd/package_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/plugin.go b/pkg/cmd/plugin.go similarity index 97% rename from cmd/helm/plugin.go rename to pkg/cmd/plugin.go index 82fd34b72..3340e76e6 100644 --- a/cmd/helm/plugin.go +++ b/pkg/cmd/plugin.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" @@ -66,7 +66,7 @@ func runHook(p *plugin.Plugin, event string) error { prog := exec.Command(main, argv...) - debug("running %s hook: %s", event, prog) + Debug("running %s hook: %s", event, prog) prog.Stdout, prog.Stderr = os.Stdout, os.Stderr if err := prog.Run(); err != nil { diff --git a/cmd/helm/plugin_install.go b/pkg/cmd/plugin_install.go similarity index 96% rename from cmd/helm/plugin_install.go rename to pkg/cmd/plugin_install.go index d8dff6316..e17744cbb 100644 --- a/cmd/helm/plugin_install.go +++ b/pkg/cmd/plugin_install.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/plugin" "helm.sh/helm/v4/pkg/plugin/installer" ) @@ -79,7 +79,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error { return err } - debug("loading plugin from %s", i.Path()) + 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") diff --git a/cmd/helm/plugin_list.go b/pkg/cmd/plugin_list.go similarity index 97% rename from cmd/helm/plugin_list.go rename to pkg/cmd/plugin_list.go index 27ce3c973..9cca790ae 100644 --- a/cmd/helm/plugin_list.go +++ b/pkg/cmd/plugin_list.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -32,7 +32,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command { Short: "list installed Helm plugins", ValidArgsFunction: noMoreArgsCompFunc, RunE: func(_ *cobra.Command, _ []string) error { - debug("pluginDirs: %s", settings.PluginsDirectory) + Debug("pluginDirs: %s", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/cmd/helm/plugin_test.go b/pkg/cmd/plugin_test.go similarity index 98% rename from cmd/helm/plugin_test.go rename to pkg/cmd/plugin_test.go index 4d2aa1a59..c5d3728b9 100644 --- a/cmd/helm/plugin_test.go +++ b/pkg/cmd/plugin_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" @@ -143,12 +143,12 @@ func TestLoadPlugins(t *testing.T) { if runtime.GOOS != "windows" { if err := pp.RunE(pp, tt.args); err != nil { if tt.code > 0 { - perr, ok := err.(pluginError) + 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) + 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) @@ -218,12 +218,12 @@ func TestLoadPluginsWithSpace(t *testing.T) { if runtime.GOOS != "windows" { if err := pp.RunE(pp, tt.args); err != nil { if tt.code > 0 { - perr, ok := err.(pluginError) + 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) + 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) diff --git a/cmd/helm/plugin_uninstall.go b/pkg/cmd/plugin_uninstall.go similarity index 97% rename from cmd/helm/plugin_uninstall.go rename to pkg/cmd/plugin_uninstall.go index 6ef4e4f59..c1f90ca49 100644 --- a/cmd/helm/plugin_uninstall.go +++ b/pkg/cmd/plugin_uninstall.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -60,7 +60,7 @@ func (o *pluginUninstallOptions) complete(args []string) error { } func (o *pluginUninstallOptions) run(out io.Writer) error { - debug("loading installed plugins from %s", settings.PluginsDirectory) + Debug("loading installed plugins from %s", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/cmd/helm/plugin_update.go b/pkg/cmd/plugin_update.go similarity index 95% rename from cmd/helm/plugin_update.go rename to pkg/cmd/plugin_update.go index 5d0465274..cbbd8994c 100644 --- a/cmd/helm/plugin_update.go +++ b/pkg/cmd/plugin_update.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -62,7 +62,7 @@ func (o *pluginUpdateOptions) complete(args []string) error { func (o *pluginUpdateOptions) run(out io.Writer) error { installer.Debug = settings.Debug - debug("loading installed plugins from %s", settings.PluginsDirectory) + Debug("loading installed plugins from %s", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err @@ -104,7 +104,7 @@ func updatePlugin(p *plugin.Plugin) error { return err } - debug("loading plugin from %s", i.Path()) + Debug("loading plugin from %s", i.Path()) updatedPlugin, err := plugin.LoadDir(i.Path()) if err != nil { return err diff --git a/cmd/helm/printer.go b/pkg/cmd/printer.go similarity index 98% rename from cmd/helm/printer.go rename to pkg/cmd/printer.go index 7cf7bf994..30238f5bb 100644 --- a/cmd/helm/printer.go +++ b/pkg/cmd/printer.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" diff --git a/cmd/helm/profiling.go b/pkg/cmd/profiling.go similarity index 99% rename from cmd/helm/profiling.go rename to pkg/cmd/profiling.go index 950ad15da..45e7b9342 100644 --- a/cmd/helm/profiling.go +++ b/pkg/cmd/profiling.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/cmd/helm/pull.go b/pkg/cmd/pull.go similarity index 97% rename from cmd/helm/pull.go rename to pkg/cmd/pull.go index 231db30bc..5d188ee4f 100644 --- a/cmd/helm/pull.go +++ b/pkg/cmd/pull.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const pullDesc = ` @@ -60,7 +60,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { RunE: func(_ *cobra.Command, args []string) error { client.Settings = settings if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") + Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/cmd/helm/pull_test.go b/pkg/cmd/pull_test.go similarity index 99% rename from cmd/helm/pull_test.go rename to pkg/cmd/pull_test.go index 1110a6bdf..c30c94b49 100644 --- a/cmd/helm/pull_test.go +++ b/pkg/cmd/pull_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/push.go b/pkg/cmd/push.go similarity index 98% rename from cmd/helm/push.go rename to pkg/cmd/push.go index f5b275b9d..94d322b9d 100644 --- a/cmd/helm/push.go +++ b/pkg/cmd/push.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -22,8 +22,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/pusher" ) diff --git a/cmd/helm/push_test.go b/pkg/cmd/push_test.go similarity index 98% rename from cmd/helm/push_test.go rename to pkg/cmd/push_test.go index 8e56d99dc..80d08b48f 100644 --- a/cmd/helm/push_test.go +++ b/pkg/cmd/push_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/registry.go b/pkg/cmd/registry.go similarity index 98% rename from cmd/helm/registry.go rename to pkg/cmd/registry.go index f771dcb9c..fcd06f13b 100644 --- a/cmd/helm/registry.go +++ b/pkg/cmd/registry.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" diff --git a/cmd/helm/registry_login.go b/pkg/cmd/registry_login.go similarity index 97% rename from cmd/helm/registry_login.go rename to pkg/cmd/registry_login.go index 74ad4cebe..1dfb3c798 100644 --- a/cmd/helm/registry_login.go +++ b/pkg/cmd/registry_login.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bufio" @@ -27,8 +27,8 @@ import ( "github.com/moby/term" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const registryLoginDesc = ` @@ -122,7 +122,7 @@ func getUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStd } } } else { - warning("Using --password via the CLI is insecure. Use --password-stdin.") + Warning("Using --password via the CLI is insecure. Use --password-stdin.") } return username, password, nil diff --git a/cmd/helm/registry_login_test.go b/pkg/cmd/registry_login_test.go similarity index 98% rename from cmd/helm/registry_login_test.go rename to pkg/cmd/registry_login_test.go index 517fe08e1..6e4f2116e 100644 --- a/cmd/helm/registry_login_test.go +++ b/pkg/cmd/registry_login_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/registry_logout.go b/pkg/cmd/registry_logout.go similarity index 96% rename from cmd/helm/registry_logout.go rename to pkg/cmd/registry_logout.go index 13190c8cf..300453705 100644 --- a/cmd/helm/registry_logout.go +++ b/pkg/cmd/registry_logout.go @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const registryLogoutDesc = ` diff --git a/cmd/helm/registry_logout_test.go b/pkg/cmd/registry_logout_test.go similarity index 98% rename from cmd/helm/registry_logout_test.go rename to pkg/cmd/registry_logout_test.go index 31f716725..31a21b277 100644 --- a/cmd/helm/registry_logout_test.go +++ b/pkg/cmd/registry_logout_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/release_testing.go b/pkg/cmd/release_testing.go similarity index 98% rename from cmd/helm/release_testing.go rename to pkg/cmd/release_testing.go index a8c57f5d9..4904aa9f1 100644 --- a/cmd/helm/release_testing.go +++ b/pkg/cmd/release_testing.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -25,9 +25,9 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" ) const releaseTestHelp = ` diff --git a/cmd/helm/release_testing_test.go b/pkg/cmd/release_testing_test.go similarity index 98% rename from cmd/helm/release_testing_test.go rename to pkg/cmd/release_testing_test.go index 680a9bd3e..43599ad0d 100644 --- a/cmd/helm/release_testing_test.go +++ b/pkg/cmd/release_testing_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/repo.go b/pkg/cmd/repo.go similarity index 96% rename from cmd/helm/repo.go rename to pkg/cmd/repo.go index 291f0bb10..925669e13 100644 --- a/cmd/helm/repo.go +++ b/pkg/cmd/repo.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" ) var repoHelm = ` diff --git a/cmd/helm/repo_add.go b/pkg/cmd/repo_add.go similarity index 99% rename from cmd/helm/repo_add.go rename to pkg/cmd/repo_add.go index cd3dc8a62..f6c0c11c0 100644 --- a/cmd/helm/repo_add.go +++ b/pkg/cmd/repo_add.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "context" @@ -31,7 +31,7 @@ import ( "golang.org/x/term" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/repo" ) diff --git a/cmd/helm/repo_add_test.go b/pkg/cmd/repo_add_test.go similarity index 99% rename from cmd/helm/repo_add_test.go rename to pkg/cmd/repo_add_test.go index 35911d5ae..0f3a3de4f 100644 --- a/cmd/helm/repo_add_test.go +++ b/pkg/cmd/repo_add_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/repo_index.go b/pkg/cmd/repo_index.go similarity index 98% rename from cmd/helm/repo_index.go rename to pkg/cmd/repo_index.go index c84a3f1ab..13a0a9439 100644 --- a/cmd/helm/repo_index.go +++ b/pkg/cmd/repo_index.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/repo" ) diff --git a/cmd/helm/repo_index_test.go b/pkg/cmd/repo_index_test.go similarity index 99% rename from cmd/helm/repo_index_test.go rename to pkg/cmd/repo_index_test.go index e63a7bf63..c865c8a5d 100644 --- a/cmd/helm/repo_index_test.go +++ b/pkg/cmd/repo_index_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/cmd/helm/repo_list.go b/pkg/cmd/repo_list.go similarity index 98% rename from cmd/helm/repo_list.go rename to pkg/cmd/repo_list.go index e0ad10147..5b6113a13 100644 --- a/cmd/helm/repo_list.go +++ b/pkg/cmd/repo_list.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -24,8 +24,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/repo" ) diff --git a/cmd/helm/repo_list_test.go b/pkg/cmd/repo_list_test.go similarity index 98% rename from cmd/helm/repo_list_test.go rename to pkg/cmd/repo_list_test.go index 90149ebda..1da5484cc 100644 --- a/cmd/helm/repo_list_test.go +++ b/pkg/cmd/repo_list_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/repo_remove.go b/pkg/cmd/repo_remove.go similarity index 98% rename from cmd/helm/repo_remove.go rename to pkg/cmd/repo_remove.go index 6b72b0710..97630810a 100644 --- a/cmd/helm/repo_remove.go +++ b/pkg/cmd/repo_remove.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -25,7 +25,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/repo" ) diff --git a/cmd/helm/repo_remove_test.go b/pkg/cmd/repo_remove_test.go similarity index 99% rename from cmd/helm/repo_remove_test.go rename to pkg/cmd/repo_remove_test.go index 7e6609671..b8bc7179a 100644 --- a/cmd/helm/repo_remove_test.go +++ b/pkg/cmd/repo_remove_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/cmd/helm/repo_test.go b/pkg/cmd/repo_test.go similarity index 98% rename from cmd/helm/repo_test.go rename to pkg/cmd/repo_test.go index 2b0df7c4c..6b89a66c3 100644 --- a/cmd/helm/repo_test.go +++ b/pkg/cmd/repo_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/repo_update.go b/pkg/cmd/repo_update.go similarity index 98% rename from cmd/helm/repo_update.go rename to pkg/cmd/repo_update.go index 1379385c1..25071377b 100644 --- a/cmd/helm/repo_update.go +++ b/pkg/cmd/repo_update.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -25,7 +25,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/repo" ) diff --git a/cmd/helm/repo_update_test.go b/pkg/cmd/repo_update_test.go similarity index 99% rename from cmd/helm/repo_update_test.go rename to pkg/cmd/repo_update_test.go index 7e379da91..5b27a6dfb 100644 --- a/cmd/helm/repo_update_test.go +++ b/pkg/cmd/repo_update_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/cmd/helm/require/args.go b/pkg/cmd/require/args.go similarity index 100% rename from cmd/helm/require/args.go rename to pkg/cmd/require/args.go diff --git a/cmd/helm/require/args_test.go b/pkg/cmd/require/args_test.go similarity index 100% rename from cmd/helm/require/args_test.go rename to pkg/cmd/require/args_test.go diff --git a/cmd/helm/rollback.go b/pkg/cmd/rollback.go similarity index 98% rename from cmd/helm/rollback.go rename to pkg/cmd/rollback.go index a65f30a1f..155c9fb01 100644 --- a/cmd/helm/rollback.go +++ b/pkg/cmd/rollback.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -24,8 +24,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const rollbackDesc = ` diff --git a/cmd/helm/rollback_test.go b/pkg/cmd/rollback_test.go similarity index 99% rename from cmd/helm/rollback_test.go rename to pkg/cmd/rollback_test.go index a94327e07..400726d6c 100644 --- a/cmd/helm/rollback_test.go +++ b/pkg/cmd/rollback_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/root.go b/pkg/cmd/root.go similarity index 97% rename from cmd/helm/root.go rename to pkg/cmd/root.go index dd3ddeab7..ff4dcecbc 100644 --- a/cmd/helm/root.go +++ b/pkg/cmd/root.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main // import "helm.sh/helm/v4/cmd/helm" +package cmd // import "helm.sh/helm/v4/pkg/cmd" import ( "context" @@ -32,6 +32,7 @@ import ( "helm.sh/helm/v4/internal/tlsutil" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/repo" ) @@ -89,7 +90,19 @@ By default, the default directories depend on the Operating System. The defaults | Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm | ` -func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) { +var settings = cli.New() + +func Debug(format string, v ...interface{}) { + if settings.Debug { + log.Output(2, fmt.Sprintf("[debug] "+format+"\n", v...)) + } +} + +func Warning(format string, v ...interface{}) { + fmt.Fprintf(os.Stderr, "WARNING: "+format+"\n", v...) +} + +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.", diff --git a/cmd/helm/root_test.go b/pkg/cmd/root_test.go similarity index 99% rename from cmd/helm/root_test.go rename to pkg/cmd/root_test.go index e30850900..9521a5aa2 100644 --- a/cmd/helm/root_test.go +++ b/pkg/cmd/root_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "os" diff --git a/cmd/helm/search.go b/pkg/cmd/search.go similarity index 98% rename from cmd/helm/search.go rename to pkg/cmd/search.go index 6c62d5d2e..4d110286d 100644 --- a/cmd/helm/search.go +++ b/pkg/cmd/search.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "io" diff --git a/cmd/helm/search/search.go b/pkg/cmd/search/search.go similarity index 100% rename from cmd/helm/search/search.go rename to pkg/cmd/search/search.go diff --git a/cmd/helm/search/search_test.go b/pkg/cmd/search/search_test.go similarity index 100% rename from cmd/helm/search/search_test.go rename to pkg/cmd/search/search_test.go diff --git a/cmd/helm/search_hub.go b/pkg/cmd/search_hub.go similarity index 99% rename from cmd/helm/search_hub.go rename to pkg/cmd/search_hub.go index 5bdb1092d..b7f25444e 100644 --- a/cmd/helm/search_hub.go +++ b/pkg/cmd/search_hub.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -89,7 +89,7 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error { q := strings.Join(args, " ") results, err := c.Search(q) if err != nil { - debug("%s", err) + Debug("%s", err) return fmt.Errorf("unable to perform search against %q", o.searchEndpoint) } diff --git a/cmd/helm/search_hub_test.go b/pkg/cmd/search_hub_test.go similarity index 99% rename from cmd/helm/search_hub_test.go rename to pkg/cmd/search_hub_test.go index f3730275a..8e056f771 100644 --- a/cmd/helm/search_hub_test.go +++ b/pkg/cmd/search_hub_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/search_repo.go b/pkg/cmd/search_repo.go similarity index 97% rename from cmd/helm/search_repo.go rename to pkg/cmd/search_repo.go index 36e8a8c58..bc73e52b2 100644 --- a/cmd/helm/search_repo.go +++ b/pkg/cmd/search_repo.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bufio" @@ -30,8 +30,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/search" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/search" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/repo" ) @@ -130,17 +130,17 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error { } func (o *searchRepoOptions) setupSearchedVersion() { - debug("Original chart version: %q", o.version) + 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") + Debug("setting version to >0.0.0-0") o.version = ">0.0.0-0" } else { // search only for stable releases, prerelease versions will be skipped - debug("setting version to >0.0.0") + Debug("setting version to >0.0.0") o.version = ">0.0.0" } } @@ -189,8 +189,8 @@ func (o *searchRepoOptions) buildIndex() (*search.Index, error) { 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) + Warning("Repo %q is corrupt or missing. Try 'helm repo update'.", n) + Warning("%s", err) continue } diff --git a/cmd/helm/search_repo_test.go b/pkg/cmd/search_repo_test.go similarity index 99% rename from cmd/helm/search_repo_test.go rename to pkg/cmd/search_repo_test.go index 9039842f0..e7f104e05 100644 --- a/cmd/helm/search_repo_test.go +++ b/pkg/cmd/search_repo_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/search_test.go b/pkg/cmd/search_test.go similarity index 98% rename from cmd/helm/search_test.go rename to pkg/cmd/search_test.go index 6cf845b06..a0e5d84cb 100644 --- a/cmd/helm/search_test.go +++ b/pkg/cmd/search_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import "testing" diff --git a/cmd/helm/show.go b/pkg/cmd/show.go similarity index 97% rename from cmd/helm/show.go rename to pkg/cmd/show.go index 492de94f6..a02af6f18 100644 --- a/cmd/helm/show.go +++ b/pkg/cmd/show.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const showDesc = ` @@ -211,9 +211,9 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) { } func runShow(args []string, client *action.Show) (string, error) { - debug("Original chart version: %q", client.Version) + Debug("Original chart version: %q", client.Version) if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") + Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/cmd/helm/show_test.go b/pkg/cmd/show_test.go similarity index 99% rename from cmd/helm/show_test.go rename to pkg/cmd/show_test.go index 0598095b5..ab8cafc37 100644 --- a/cmd/helm/show_test.go +++ b/pkg/cmd/show_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/status.go b/pkg/cmd/status.go similarity index 99% rename from cmd/helm/status.go rename to pkg/cmd/status.go index fd3e4ce14..7a97bde3f 100644 --- a/cmd/helm/status.go +++ b/pkg/cmd/status.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" @@ -28,10 +28,10 @@ import ( "k8s.io/kubectl/pkg/cmd/get" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli/output" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/release" ) diff --git a/cmd/helm/status_test.go b/pkg/cmd/status_test.go similarity index 99% rename from cmd/helm/status_test.go rename to pkg/cmd/status_test.go index 1973fe068..8603f416b 100644 --- a/cmd/helm/status_test.go +++ b/pkg/cmd/status_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/template.go b/pkg/cmd/template.go similarity index 99% rename from cmd/helm/template.go rename to pkg/cmd/template.go index 1a6265eba..4b4a0bc8d 100644 --- a/cmd/helm/template.go +++ b/pkg/cmd/template.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "bytes" @@ -32,10 +32,10 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli/values" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/releaseutil" ) diff --git a/cmd/helm/template_test.go b/pkg/cmd/template_test.go similarity index 99% rename from cmd/helm/template_test.go rename to pkg/cmd/template_test.go index 28e24ce63..c478fced4 100644 --- a/cmd/helm/template_test.go +++ b/pkg/cmd/template_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/testdata/helm home with space/helm/plugins/fullenv/completion.yaml b/pkg/cmd/testdata/helm home with space/helm/plugins/fullenv/completion.yaml similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/plugins/fullenv/completion.yaml rename to pkg/cmd/testdata/helm home with space/helm/plugins/fullenv/completion.yaml diff --git a/cmd/helm/testdata/helm home with space/helm/plugins/fullenv/fullenv.sh b/pkg/cmd/testdata/helm home with space/helm/plugins/fullenv/fullenv.sh similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/plugins/fullenv/fullenv.sh rename to pkg/cmd/testdata/helm home with space/helm/plugins/fullenv/fullenv.sh diff --git a/cmd/helm/testdata/helm home with space/helm/plugins/fullenv/plugin.yaml b/pkg/cmd/testdata/helm home with space/helm/plugins/fullenv/plugin.yaml similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/plugins/fullenv/plugin.yaml rename to pkg/cmd/testdata/helm home with space/helm/plugins/fullenv/plugin.yaml diff --git a/cmd/helm/testdata/helm home with space/helm/repositories.yaml b/pkg/cmd/testdata/helm home with space/helm/repositories.yaml similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/repositories.yaml rename to pkg/cmd/testdata/helm home with space/helm/repositories.yaml diff --git a/cmd/helm/testdata/helm home with space/helm/repository/test-name-charts.txt b/pkg/cmd/testdata/helm home with space/helm/repository/test-name-charts.txt similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/repository/test-name-charts.txt rename to pkg/cmd/testdata/helm home with space/helm/repository/test-name-charts.txt diff --git a/cmd/helm/testdata/helm home with space/helm/repository/test-name-index.yaml b/pkg/cmd/testdata/helm home with space/helm/repository/test-name-index.yaml similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/repository/test-name-index.yaml rename to pkg/cmd/testdata/helm home with space/helm/repository/test-name-index.yaml diff --git a/cmd/helm/testdata/helm home with space/helm/repository/testing-index.yaml b/pkg/cmd/testdata/helm home with space/helm/repository/testing-index.yaml similarity index 100% rename from cmd/helm/testdata/helm home with space/helm/repository/testing-index.yaml rename to pkg/cmd/testdata/helm home with space/helm/repository/testing-index.yaml diff --git a/cmd/helm/testdata/helm-test-key.pub b/pkg/cmd/testdata/helm-test-key.pub similarity index 100% rename from cmd/helm/testdata/helm-test-key.pub rename to pkg/cmd/testdata/helm-test-key.pub diff --git a/cmd/helm/testdata/helm-test-key.secret b/pkg/cmd/testdata/helm-test-key.secret similarity index 100% rename from cmd/helm/testdata/helm-test-key.secret rename to pkg/cmd/testdata/helm-test-key.secret diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/args.sh b/pkg/cmd/testdata/helmhome/helm/plugins/args/args.sh similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/args/args.sh rename to pkg/cmd/testdata/helmhome/helm/plugins/args/args.sh diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete b/pkg/cmd/testdata/helmhome/helm/plugins/args/plugin.complete similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete rename to pkg/cmd/testdata/helmhome/helm/plugins/args/plugin.complete diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/args/plugin.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/args/plugin.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/args/plugin.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/echo/completion.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/echo/completion.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete b/pkg/cmd/testdata/helmhome/helm/plugins/echo/plugin.complete similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete rename to pkg/cmd/testdata/helmhome/helm/plugins/echo/plugin.complete diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/echo/plugin.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/echo/plugin.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/env/completion.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/env/completion.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/env/plugin.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/env/plugin.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/env/plugin.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/env/plugin.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/exitwith/completion.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/exitwith/completion.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh b/pkg/cmd/testdata/helmhome/helm/plugins/exitwith/exitwith.sh similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh rename to pkg/cmd/testdata/helmhome/helm/plugins/exitwith/exitwith.sh diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/exitwith/plugin.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/exitwith/plugin.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/fullenv/completion.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/fullenv/completion.yaml diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh b/pkg/cmd/testdata/helmhome/helm/plugins/fullenv/fullenv.sh similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh rename to pkg/cmd/testdata/helmhome/helm/plugins/fullenv/fullenv.sh diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/plugin.yaml b/pkg/cmd/testdata/helmhome/helm/plugins/fullenv/plugin.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/plugins/fullenv/plugin.yaml rename to pkg/cmd/testdata/helmhome/helm/plugins/fullenv/plugin.yaml diff --git a/cmd/helm/testdata/helmhome/helm/repositories.yaml b/pkg/cmd/testdata/helmhome/helm/repositories.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/repositories.yaml rename to pkg/cmd/testdata/helmhome/helm/repositories.yaml diff --git a/cmd/helm/testdata/helmhome/helm/repository/test-name-charts.txt b/pkg/cmd/testdata/helmhome/helm/repository/test-name-charts.txt similarity index 100% rename from cmd/helm/testdata/helmhome/helm/repository/test-name-charts.txt rename to pkg/cmd/testdata/helmhome/helm/repository/test-name-charts.txt diff --git a/cmd/helm/testdata/helmhome/helm/repository/test-name-index.yaml b/pkg/cmd/testdata/helmhome/helm/repository/test-name-index.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/repository/test-name-index.yaml rename to pkg/cmd/testdata/helmhome/helm/repository/test-name-index.yaml diff --git a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml b/pkg/cmd/testdata/helmhome/helm/repository/testing-index.yaml similarity index 100% rename from cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml rename to pkg/cmd/testdata/helmhome/helm/repository/testing-index.yaml diff --git a/cmd/helm/testdata/output/chart-with-subchart-update.txt b/pkg/cmd/testdata/output/chart-with-subchart-update.txt similarity index 100% rename from cmd/helm/testdata/output/chart-with-subchart-update.txt rename to pkg/cmd/testdata/output/chart-with-subchart-update.txt diff --git a/cmd/helm/testdata/output/dependency-list-archive.txt b/pkg/cmd/testdata/output/dependency-list-archive.txt similarity index 100% rename from cmd/helm/testdata/output/dependency-list-archive.txt rename to pkg/cmd/testdata/output/dependency-list-archive.txt diff --git a/cmd/helm/testdata/output/dependency-list-no-chart-linux.txt b/pkg/cmd/testdata/output/dependency-list-no-chart-linux.txt similarity index 100% rename from cmd/helm/testdata/output/dependency-list-no-chart-linux.txt rename to pkg/cmd/testdata/output/dependency-list-no-chart-linux.txt diff --git a/cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt b/pkg/cmd/testdata/output/dependency-list-no-requirements-linux.txt similarity index 100% rename from cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt rename to pkg/cmd/testdata/output/dependency-list-no-requirements-linux.txt diff --git a/cmd/helm/testdata/output/dependency-list.txt b/pkg/cmd/testdata/output/dependency-list.txt similarity index 100% rename from cmd/helm/testdata/output/dependency-list.txt rename to pkg/cmd/testdata/output/dependency-list.txt diff --git a/cmd/helm/testdata/output/deprecated-chart.txt b/pkg/cmd/testdata/output/deprecated-chart.txt similarity index 100% rename from cmd/helm/testdata/output/deprecated-chart.txt rename to pkg/cmd/testdata/output/deprecated-chart.txt diff --git a/cmd/helm/testdata/output/docs-type-comp.txt b/pkg/cmd/testdata/output/docs-type-comp.txt similarity index 100% rename from cmd/helm/testdata/output/docs-type-comp.txt rename to pkg/cmd/testdata/output/docs-type-comp.txt diff --git a/cmd/helm/testdata/output/empty_default_comp.txt b/pkg/cmd/testdata/output/empty_default_comp.txt similarity index 100% rename from cmd/helm/testdata/output/empty_default_comp.txt rename to pkg/cmd/testdata/output/empty_default_comp.txt diff --git a/cmd/helm/testdata/output/empty_nofile_comp.txt b/pkg/cmd/testdata/output/empty_nofile_comp.txt similarity index 100% rename from cmd/helm/testdata/output/empty_nofile_comp.txt rename to pkg/cmd/testdata/output/empty_nofile_comp.txt diff --git a/cmd/helm/testdata/output/env-comp.txt b/pkg/cmd/testdata/output/env-comp.txt similarity index 100% rename from cmd/helm/testdata/output/env-comp.txt rename to pkg/cmd/testdata/output/env-comp.txt diff --git a/cmd/helm/testdata/output/get-all-no-args.txt b/pkg/cmd/testdata/output/get-all-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/get-all-no-args.txt rename to pkg/cmd/testdata/output/get-all-no-args.txt diff --git a/cmd/helm/testdata/output/get-hooks-no-args.txt b/pkg/cmd/testdata/output/get-hooks-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/get-hooks-no-args.txt rename to pkg/cmd/testdata/output/get-hooks-no-args.txt diff --git a/cmd/helm/testdata/output/get-hooks.txt b/pkg/cmd/testdata/output/get-hooks.txt similarity index 100% rename from cmd/helm/testdata/output/get-hooks.txt rename to pkg/cmd/testdata/output/get-hooks.txt diff --git a/cmd/helm/testdata/output/get-manifest-no-args.txt b/pkg/cmd/testdata/output/get-manifest-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/get-manifest-no-args.txt rename to pkg/cmd/testdata/output/get-manifest-no-args.txt diff --git a/cmd/helm/testdata/output/get-manifest.txt b/pkg/cmd/testdata/output/get-manifest.txt similarity index 100% rename from cmd/helm/testdata/output/get-manifest.txt rename to pkg/cmd/testdata/output/get-manifest.txt diff --git a/cmd/helm/testdata/output/get-metadata-args.txt b/pkg/cmd/testdata/output/get-metadata-args.txt similarity index 100% rename from cmd/helm/testdata/output/get-metadata-args.txt rename to pkg/cmd/testdata/output/get-metadata-args.txt diff --git a/cmd/helm/testdata/output/get-metadata.json b/pkg/cmd/testdata/output/get-metadata.json similarity index 100% rename from cmd/helm/testdata/output/get-metadata.json rename to pkg/cmd/testdata/output/get-metadata.json diff --git a/cmd/helm/testdata/output/get-metadata.txt b/pkg/cmd/testdata/output/get-metadata.txt similarity index 100% rename from cmd/helm/testdata/output/get-metadata.txt rename to pkg/cmd/testdata/output/get-metadata.txt diff --git a/cmd/helm/testdata/output/get-metadata.yaml b/pkg/cmd/testdata/output/get-metadata.yaml similarity index 100% rename from cmd/helm/testdata/output/get-metadata.yaml rename to pkg/cmd/testdata/output/get-metadata.yaml diff --git a/cmd/helm/testdata/output/get-notes-no-args.txt b/pkg/cmd/testdata/output/get-notes-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/get-notes-no-args.txt rename to pkg/cmd/testdata/output/get-notes-no-args.txt diff --git a/cmd/helm/testdata/output/get-notes.txt b/pkg/cmd/testdata/output/get-notes.txt similarity index 100% rename from cmd/helm/testdata/output/get-notes.txt rename to pkg/cmd/testdata/output/get-notes.txt diff --git a/cmd/helm/testdata/output/get-release-template.txt b/pkg/cmd/testdata/output/get-release-template.txt similarity index 100% rename from cmd/helm/testdata/output/get-release-template.txt rename to pkg/cmd/testdata/output/get-release-template.txt diff --git a/cmd/helm/testdata/output/get-release.txt b/pkg/cmd/testdata/output/get-release.txt similarity index 100% rename from cmd/helm/testdata/output/get-release.txt rename to pkg/cmd/testdata/output/get-release.txt diff --git a/cmd/helm/testdata/output/get-values-all.txt b/pkg/cmd/testdata/output/get-values-all.txt similarity index 100% rename from cmd/helm/testdata/output/get-values-all.txt rename to pkg/cmd/testdata/output/get-values-all.txt diff --git a/cmd/helm/testdata/output/get-values-args.txt b/pkg/cmd/testdata/output/get-values-args.txt similarity index 100% rename from cmd/helm/testdata/output/get-values-args.txt rename to pkg/cmd/testdata/output/get-values-args.txt diff --git a/cmd/helm/testdata/output/get-values.txt b/pkg/cmd/testdata/output/get-values.txt similarity index 100% rename from cmd/helm/testdata/output/get-values.txt rename to pkg/cmd/testdata/output/get-values.txt diff --git a/cmd/helm/testdata/output/history-limit.txt b/pkg/cmd/testdata/output/history-limit.txt similarity index 100% rename from cmd/helm/testdata/output/history-limit.txt rename to pkg/cmd/testdata/output/history-limit.txt diff --git a/cmd/helm/testdata/output/history.json b/pkg/cmd/testdata/output/history.json similarity index 100% rename from cmd/helm/testdata/output/history.json rename to pkg/cmd/testdata/output/history.json diff --git a/cmd/helm/testdata/output/history.txt b/pkg/cmd/testdata/output/history.txt similarity index 100% rename from cmd/helm/testdata/output/history.txt rename to pkg/cmd/testdata/output/history.txt diff --git a/cmd/helm/testdata/output/history.yaml b/pkg/cmd/testdata/output/history.yaml similarity index 100% rename from cmd/helm/testdata/output/history.yaml rename to pkg/cmd/testdata/output/history.yaml diff --git a/cmd/helm/testdata/output/install-and-replace.txt b/pkg/cmd/testdata/output/install-and-replace.txt similarity index 100% rename from cmd/helm/testdata/output/install-and-replace.txt rename to pkg/cmd/testdata/output/install-and-replace.txt diff --git a/cmd/helm/testdata/output/install-and-take-ownership.txt b/pkg/cmd/testdata/output/install-and-take-ownership.txt similarity index 100% rename from cmd/helm/testdata/output/install-and-take-ownership.txt rename to pkg/cmd/testdata/output/install-and-take-ownership.txt diff --git a/cmd/helm/testdata/output/install-chart-bad-type.txt b/pkg/cmd/testdata/output/install-chart-bad-type.txt similarity index 100% rename from cmd/helm/testdata/output/install-chart-bad-type.txt rename to pkg/cmd/testdata/output/install-chart-bad-type.txt diff --git a/cmd/helm/testdata/output/install-dry-run-with-secret-hidden.txt b/pkg/cmd/testdata/output/install-dry-run-with-secret-hidden.txt similarity index 100% rename from cmd/helm/testdata/output/install-dry-run-with-secret-hidden.txt rename to pkg/cmd/testdata/output/install-dry-run-with-secret-hidden.txt diff --git a/cmd/helm/testdata/output/install-dry-run-with-secret.txt b/pkg/cmd/testdata/output/install-dry-run-with-secret.txt similarity index 100% rename from cmd/helm/testdata/output/install-dry-run-with-secret.txt rename to pkg/cmd/testdata/output/install-dry-run-with-secret.txt diff --git a/cmd/helm/testdata/output/install-hide-secret.txt b/pkg/cmd/testdata/output/install-hide-secret.txt similarity index 100% rename from cmd/helm/testdata/output/install-hide-secret.txt rename to pkg/cmd/testdata/output/install-hide-secret.txt diff --git a/cmd/helm/testdata/output/install-lib-chart.txt b/pkg/cmd/testdata/output/install-lib-chart.txt similarity index 100% rename from cmd/helm/testdata/output/install-lib-chart.txt rename to pkg/cmd/testdata/output/install-lib-chart.txt diff --git a/cmd/helm/testdata/output/install-name-template.txt b/pkg/cmd/testdata/output/install-name-template.txt similarity index 100% rename from cmd/helm/testdata/output/install-name-template.txt rename to pkg/cmd/testdata/output/install-name-template.txt diff --git a/cmd/helm/testdata/output/install-no-args.txt b/pkg/cmd/testdata/output/install-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/install-no-args.txt rename to pkg/cmd/testdata/output/install-no-args.txt diff --git a/cmd/helm/testdata/output/install-no-hooks.txt b/pkg/cmd/testdata/output/install-no-hooks.txt similarity index 100% rename from cmd/helm/testdata/output/install-no-hooks.txt rename to pkg/cmd/testdata/output/install-no-hooks.txt diff --git a/cmd/helm/testdata/output/install-with-multiple-values-files.txt b/pkg/cmd/testdata/output/install-with-multiple-values-files.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-multiple-values-files.txt rename to pkg/cmd/testdata/output/install-with-multiple-values-files.txt diff --git a/cmd/helm/testdata/output/install-with-multiple-values.txt b/pkg/cmd/testdata/output/install-with-multiple-values.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-multiple-values.txt rename to pkg/cmd/testdata/output/install-with-multiple-values.txt diff --git a/cmd/helm/testdata/output/install-with-timeout.txt b/pkg/cmd/testdata/output/install-with-timeout.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-timeout.txt rename to pkg/cmd/testdata/output/install-with-timeout.txt diff --git a/cmd/helm/testdata/output/install-with-values-file.txt b/pkg/cmd/testdata/output/install-with-values-file.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-values-file.txt rename to pkg/cmd/testdata/output/install-with-values-file.txt diff --git a/cmd/helm/testdata/output/install-with-values.txt b/pkg/cmd/testdata/output/install-with-values.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-values.txt rename to pkg/cmd/testdata/output/install-with-values.txt diff --git a/cmd/helm/testdata/output/install-with-wait-for-jobs.txt b/pkg/cmd/testdata/output/install-with-wait-for-jobs.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-wait-for-jobs.txt rename to pkg/cmd/testdata/output/install-with-wait-for-jobs.txt diff --git a/cmd/helm/testdata/output/install-with-wait.txt b/pkg/cmd/testdata/output/install-with-wait.txt similarity index 100% rename from cmd/helm/testdata/output/install-with-wait.txt rename to pkg/cmd/testdata/output/install-with-wait.txt diff --git a/cmd/helm/testdata/output/install.txt b/pkg/cmd/testdata/output/install.txt similarity index 100% rename from cmd/helm/testdata/output/install.txt rename to pkg/cmd/testdata/output/install.txt diff --git a/cmd/helm/testdata/output/issue-9027.txt b/pkg/cmd/testdata/output/issue-9027.txt similarity index 100% rename from cmd/helm/testdata/output/issue-9027.txt rename to pkg/cmd/testdata/output/issue-9027.txt diff --git a/cmd/helm/testdata/output/issue-totoml.txt b/pkg/cmd/testdata/output/issue-totoml.txt similarity index 100% rename from cmd/helm/testdata/output/issue-totoml.txt rename to pkg/cmd/testdata/output/issue-totoml.txt diff --git a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt b/pkg/cmd/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt similarity index 100% rename from cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt rename to pkg/cmd/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt diff --git a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt b/pkg/cmd/testdata/output/lint-chart-with-bad-subcharts.txt similarity index 100% rename from cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt rename to pkg/cmd/testdata/output/lint-chart-with-bad-subcharts.txt diff --git a/cmd/helm/testdata/output/lint-chart-with-deprecated-api-old-k8s.txt b/pkg/cmd/testdata/output/lint-chart-with-deprecated-api-old-k8s.txt similarity index 100% rename from cmd/helm/testdata/output/lint-chart-with-deprecated-api-old-k8s.txt rename to pkg/cmd/testdata/output/lint-chart-with-deprecated-api-old-k8s.txt diff --git a/cmd/helm/testdata/output/lint-chart-with-deprecated-api-strict.txt b/pkg/cmd/testdata/output/lint-chart-with-deprecated-api-strict.txt similarity index 100% rename from cmd/helm/testdata/output/lint-chart-with-deprecated-api-strict.txt rename to pkg/cmd/testdata/output/lint-chart-with-deprecated-api-strict.txt diff --git a/cmd/helm/testdata/output/lint-chart-with-deprecated-api.txt b/pkg/cmd/testdata/output/lint-chart-with-deprecated-api.txt similarity index 100% rename from cmd/helm/testdata/output/lint-chart-with-deprecated-api.txt rename to pkg/cmd/testdata/output/lint-chart-with-deprecated-api.txt diff --git a/cmd/helm/testdata/output/lint-quiet-with-error.txt b/pkg/cmd/testdata/output/lint-quiet-with-error.txt similarity index 100% rename from cmd/helm/testdata/output/lint-quiet-with-error.txt rename to pkg/cmd/testdata/output/lint-quiet-with-error.txt diff --git a/cmd/helm/testdata/output/lint-quiet-with-warning.txt b/pkg/cmd/testdata/output/lint-quiet-with-warning.txt similarity index 100% rename from cmd/helm/testdata/output/lint-quiet-with-warning.txt rename to pkg/cmd/testdata/output/lint-quiet-with-warning.txt diff --git a/cmd/helm/testdata/output/lint-quiet.txt b/pkg/cmd/testdata/output/lint-quiet.txt similarity index 100% rename from cmd/helm/testdata/output/lint-quiet.txt rename to pkg/cmd/testdata/output/lint-quiet.txt diff --git a/cmd/helm/testdata/output/list-all.txt b/pkg/cmd/testdata/output/list-all.txt similarity index 100% rename from cmd/helm/testdata/output/list-all.txt rename to pkg/cmd/testdata/output/list-all.txt diff --git a/cmd/helm/testdata/output/list-date-reversed.txt b/pkg/cmd/testdata/output/list-date-reversed.txt similarity index 100% rename from cmd/helm/testdata/output/list-date-reversed.txt rename to pkg/cmd/testdata/output/list-date-reversed.txt diff --git a/cmd/helm/testdata/output/list-date.txt b/pkg/cmd/testdata/output/list-date.txt similarity index 100% rename from cmd/helm/testdata/output/list-date.txt rename to pkg/cmd/testdata/output/list-date.txt diff --git a/cmd/helm/testdata/output/list-failed.txt b/pkg/cmd/testdata/output/list-failed.txt similarity index 100% rename from cmd/helm/testdata/output/list-failed.txt rename to pkg/cmd/testdata/output/list-failed.txt diff --git a/cmd/helm/testdata/output/list-filter.txt b/pkg/cmd/testdata/output/list-filter.txt similarity index 100% rename from cmd/helm/testdata/output/list-filter.txt rename to pkg/cmd/testdata/output/list-filter.txt diff --git a/cmd/helm/testdata/output/list-max.txt b/pkg/cmd/testdata/output/list-max.txt similarity index 100% rename from cmd/helm/testdata/output/list-max.txt rename to pkg/cmd/testdata/output/list-max.txt diff --git a/cmd/helm/testdata/output/list-namespace.txt b/pkg/cmd/testdata/output/list-namespace.txt similarity index 100% rename from cmd/helm/testdata/output/list-namespace.txt rename to pkg/cmd/testdata/output/list-namespace.txt diff --git a/cmd/helm/testdata/output/list-no-headers.txt b/pkg/cmd/testdata/output/list-no-headers.txt similarity index 100% rename from cmd/helm/testdata/output/list-no-headers.txt rename to pkg/cmd/testdata/output/list-no-headers.txt diff --git a/cmd/helm/testdata/output/list-offset.txt b/pkg/cmd/testdata/output/list-offset.txt similarity index 100% rename from cmd/helm/testdata/output/list-offset.txt rename to pkg/cmd/testdata/output/list-offset.txt diff --git a/cmd/helm/testdata/output/list-pending.txt b/pkg/cmd/testdata/output/list-pending.txt similarity index 100% rename from cmd/helm/testdata/output/list-pending.txt rename to pkg/cmd/testdata/output/list-pending.txt diff --git a/cmd/helm/testdata/output/list-reverse.txt b/pkg/cmd/testdata/output/list-reverse.txt similarity index 100% rename from cmd/helm/testdata/output/list-reverse.txt rename to pkg/cmd/testdata/output/list-reverse.txt diff --git a/cmd/helm/testdata/output/list-short-json.txt b/pkg/cmd/testdata/output/list-short-json.txt similarity index 100% rename from cmd/helm/testdata/output/list-short-json.txt rename to pkg/cmd/testdata/output/list-short-json.txt diff --git a/cmd/helm/testdata/output/list-short-yaml.txt b/pkg/cmd/testdata/output/list-short-yaml.txt similarity index 100% rename from cmd/helm/testdata/output/list-short-yaml.txt rename to pkg/cmd/testdata/output/list-short-yaml.txt diff --git a/cmd/helm/testdata/output/list-short.txt b/pkg/cmd/testdata/output/list-short.txt similarity index 100% rename from cmd/helm/testdata/output/list-short.txt rename to pkg/cmd/testdata/output/list-short.txt diff --git a/cmd/helm/testdata/output/list-superseded.txt b/pkg/cmd/testdata/output/list-superseded.txt similarity index 100% rename from cmd/helm/testdata/output/list-superseded.txt rename to pkg/cmd/testdata/output/list-superseded.txt diff --git a/cmd/helm/testdata/output/list-uninstalled.txt b/pkg/cmd/testdata/output/list-uninstalled.txt similarity index 100% rename from cmd/helm/testdata/output/list-uninstalled.txt rename to pkg/cmd/testdata/output/list-uninstalled.txt diff --git a/cmd/helm/testdata/output/list-uninstalling.txt b/pkg/cmd/testdata/output/list-uninstalling.txt similarity index 100% rename from cmd/helm/testdata/output/list-uninstalling.txt rename to pkg/cmd/testdata/output/list-uninstalling.txt diff --git a/cmd/helm/testdata/output/list.txt b/pkg/cmd/testdata/output/list.txt similarity index 100% rename from cmd/helm/testdata/output/list.txt rename to pkg/cmd/testdata/output/list.txt diff --git a/cmd/helm/testdata/output/object-order.txt b/pkg/cmd/testdata/output/object-order.txt similarity index 100% rename from cmd/helm/testdata/output/object-order.txt rename to pkg/cmd/testdata/output/object-order.txt diff --git a/cmd/helm/testdata/output/output-comp.txt b/pkg/cmd/testdata/output/output-comp.txt similarity index 100% rename from cmd/helm/testdata/output/output-comp.txt rename to pkg/cmd/testdata/output/output-comp.txt diff --git a/cmd/helm/testdata/output/plugin_args_comp.txt b/pkg/cmd/testdata/output/plugin_args_comp.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_args_comp.txt rename to pkg/cmd/testdata/output/plugin_args_comp.txt diff --git a/cmd/helm/testdata/output/plugin_args_flag_comp.txt b/pkg/cmd/testdata/output/plugin_args_flag_comp.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_args_flag_comp.txt rename to pkg/cmd/testdata/output/plugin_args_flag_comp.txt diff --git a/cmd/helm/testdata/output/plugin_args_many_args_comp.txt b/pkg/cmd/testdata/output/plugin_args_many_args_comp.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_args_many_args_comp.txt rename to pkg/cmd/testdata/output/plugin_args_many_args_comp.txt diff --git a/cmd/helm/testdata/output/plugin_args_ns_comp.txt b/pkg/cmd/testdata/output/plugin_args_ns_comp.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_args_ns_comp.txt rename to pkg/cmd/testdata/output/plugin_args_ns_comp.txt diff --git a/cmd/helm/testdata/output/plugin_echo_no_directive.txt b/pkg/cmd/testdata/output/plugin_echo_no_directive.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_echo_no_directive.txt rename to pkg/cmd/testdata/output/plugin_echo_no_directive.txt diff --git a/cmd/helm/testdata/output/plugin_list_comp.txt b/pkg/cmd/testdata/output/plugin_list_comp.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_list_comp.txt rename to pkg/cmd/testdata/output/plugin_list_comp.txt diff --git a/cmd/helm/testdata/output/plugin_repeat_comp.txt b/pkg/cmd/testdata/output/plugin_repeat_comp.txt similarity index 100% rename from cmd/helm/testdata/output/plugin_repeat_comp.txt rename to pkg/cmd/testdata/output/plugin_repeat_comp.txt diff --git a/cmd/helm/testdata/output/release_list_comp.txt b/pkg/cmd/testdata/output/release_list_comp.txt similarity index 100% rename from cmd/helm/testdata/output/release_list_comp.txt rename to pkg/cmd/testdata/output/release_list_comp.txt diff --git a/cmd/helm/testdata/output/release_list_repeat_comp.txt b/pkg/cmd/testdata/output/release_list_repeat_comp.txt similarity index 100% rename from cmd/helm/testdata/output/release_list_repeat_comp.txt rename to pkg/cmd/testdata/output/release_list_repeat_comp.txt diff --git a/cmd/helm/testdata/output/repo-add.txt b/pkg/cmd/testdata/output/repo-add.txt similarity index 100% rename from cmd/helm/testdata/output/repo-add.txt rename to pkg/cmd/testdata/output/repo-add.txt diff --git a/cmd/helm/testdata/output/repo-add2.txt b/pkg/cmd/testdata/output/repo-add2.txt similarity index 100% rename from cmd/helm/testdata/output/repo-add2.txt rename to pkg/cmd/testdata/output/repo-add2.txt diff --git a/cmd/helm/testdata/output/repo_list_comp.txt b/pkg/cmd/testdata/output/repo_list_comp.txt similarity index 100% rename from cmd/helm/testdata/output/repo_list_comp.txt rename to pkg/cmd/testdata/output/repo_list_comp.txt diff --git a/cmd/helm/testdata/output/repo_repeat_comp.txt b/pkg/cmd/testdata/output/repo_repeat_comp.txt similarity index 100% rename from cmd/helm/testdata/output/repo_repeat_comp.txt rename to pkg/cmd/testdata/output/repo_repeat_comp.txt diff --git a/cmd/helm/testdata/output/revision-comp.txt b/pkg/cmd/testdata/output/revision-comp.txt similarity index 100% rename from cmd/helm/testdata/output/revision-comp.txt rename to pkg/cmd/testdata/output/revision-comp.txt diff --git a/cmd/helm/testdata/output/revision-wrong-args-comp.txt b/pkg/cmd/testdata/output/revision-wrong-args-comp.txt similarity index 100% rename from cmd/helm/testdata/output/revision-wrong-args-comp.txt rename to pkg/cmd/testdata/output/revision-wrong-args-comp.txt diff --git a/cmd/helm/testdata/output/rollback-comp.txt b/pkg/cmd/testdata/output/rollback-comp.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-comp.txt rename to pkg/cmd/testdata/output/rollback-comp.txt diff --git a/cmd/helm/testdata/output/rollback-no-args.txt b/pkg/cmd/testdata/output/rollback-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-no-args.txt rename to pkg/cmd/testdata/output/rollback-no-args.txt diff --git a/cmd/helm/testdata/output/rollback-no-revision.txt b/pkg/cmd/testdata/output/rollback-no-revision.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-no-revision.txt rename to pkg/cmd/testdata/output/rollback-no-revision.txt diff --git a/cmd/helm/testdata/output/rollback-non-existent-version.txt b/pkg/cmd/testdata/output/rollback-non-existent-version.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-non-existent-version.txt rename to pkg/cmd/testdata/output/rollback-non-existent-version.txt diff --git a/cmd/helm/testdata/output/rollback-timeout.txt b/pkg/cmd/testdata/output/rollback-timeout.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-timeout.txt rename to pkg/cmd/testdata/output/rollback-timeout.txt diff --git a/cmd/helm/testdata/output/rollback-wait-for-jobs.txt b/pkg/cmd/testdata/output/rollback-wait-for-jobs.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-wait-for-jobs.txt rename to pkg/cmd/testdata/output/rollback-wait-for-jobs.txt diff --git a/cmd/helm/testdata/output/rollback-wait.txt b/pkg/cmd/testdata/output/rollback-wait.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-wait.txt rename to pkg/cmd/testdata/output/rollback-wait.txt diff --git a/cmd/helm/testdata/output/rollback-wrong-args-comp.txt b/pkg/cmd/testdata/output/rollback-wrong-args-comp.txt similarity index 100% rename from cmd/helm/testdata/output/rollback-wrong-args-comp.txt rename to pkg/cmd/testdata/output/rollback-wrong-args-comp.txt diff --git a/cmd/helm/testdata/output/rollback.txt b/pkg/cmd/testdata/output/rollback.txt similarity index 100% rename from cmd/helm/testdata/output/rollback.txt rename to pkg/cmd/testdata/output/rollback.txt diff --git a/cmd/helm/testdata/output/schema-negative-cli.txt b/pkg/cmd/testdata/output/schema-negative-cli.txt similarity index 100% rename from cmd/helm/testdata/output/schema-negative-cli.txt rename to pkg/cmd/testdata/output/schema-negative-cli.txt diff --git a/cmd/helm/testdata/output/schema-negative.txt b/pkg/cmd/testdata/output/schema-negative.txt similarity index 100% rename from cmd/helm/testdata/output/schema-negative.txt rename to pkg/cmd/testdata/output/schema-negative.txt diff --git a/cmd/helm/testdata/output/schema.txt b/pkg/cmd/testdata/output/schema.txt similarity index 100% rename from cmd/helm/testdata/output/schema.txt rename to pkg/cmd/testdata/output/schema.txt diff --git a/cmd/helm/testdata/output/search-constraint-single.txt b/pkg/cmd/testdata/output/search-constraint-single.txt similarity index 100% rename from cmd/helm/testdata/output/search-constraint-single.txt rename to pkg/cmd/testdata/output/search-constraint-single.txt diff --git a/cmd/helm/testdata/output/search-constraint.txt b/pkg/cmd/testdata/output/search-constraint.txt similarity index 100% rename from cmd/helm/testdata/output/search-constraint.txt rename to pkg/cmd/testdata/output/search-constraint.txt diff --git a/cmd/helm/testdata/output/search-multiple-devel-release.txt b/pkg/cmd/testdata/output/search-multiple-devel-release.txt similarity index 100% rename from cmd/helm/testdata/output/search-multiple-devel-release.txt rename to pkg/cmd/testdata/output/search-multiple-devel-release.txt diff --git a/cmd/helm/testdata/output/search-multiple-stable-release.txt b/pkg/cmd/testdata/output/search-multiple-stable-release.txt similarity index 100% rename from cmd/helm/testdata/output/search-multiple-stable-release.txt rename to pkg/cmd/testdata/output/search-multiple-stable-release.txt diff --git a/cmd/helm/testdata/output/search-multiple-versions-constraints.txt b/pkg/cmd/testdata/output/search-multiple-versions-constraints.txt similarity index 100% rename from cmd/helm/testdata/output/search-multiple-versions-constraints.txt rename to pkg/cmd/testdata/output/search-multiple-versions-constraints.txt diff --git a/cmd/helm/testdata/output/search-multiple-versions.txt b/pkg/cmd/testdata/output/search-multiple-versions.txt similarity index 100% rename from cmd/helm/testdata/output/search-multiple-versions.txt rename to pkg/cmd/testdata/output/search-multiple-versions.txt diff --git a/cmd/helm/testdata/output/search-not-found-error.txt b/pkg/cmd/testdata/output/search-not-found-error.txt similarity index 100% rename from cmd/helm/testdata/output/search-not-found-error.txt rename to pkg/cmd/testdata/output/search-not-found-error.txt diff --git a/cmd/helm/testdata/output/search-not-found.txt b/pkg/cmd/testdata/output/search-not-found.txt similarity index 100% rename from cmd/helm/testdata/output/search-not-found.txt rename to pkg/cmd/testdata/output/search-not-found.txt diff --git a/cmd/helm/testdata/output/search-output-json.txt b/pkg/cmd/testdata/output/search-output-json.txt similarity index 100% rename from cmd/helm/testdata/output/search-output-json.txt rename to pkg/cmd/testdata/output/search-output-json.txt diff --git a/cmd/helm/testdata/output/search-output-yaml.txt b/pkg/cmd/testdata/output/search-output-yaml.txt similarity index 100% rename from cmd/helm/testdata/output/search-output-yaml.txt rename to pkg/cmd/testdata/output/search-output-yaml.txt diff --git a/cmd/helm/testdata/output/search-regex.txt b/pkg/cmd/testdata/output/search-regex.txt similarity index 100% rename from cmd/helm/testdata/output/search-regex.txt rename to pkg/cmd/testdata/output/search-regex.txt diff --git a/cmd/helm/testdata/output/search-versions-constraint.txt b/pkg/cmd/testdata/output/search-versions-constraint.txt similarity index 100% rename from cmd/helm/testdata/output/search-versions-constraint.txt rename to pkg/cmd/testdata/output/search-versions-constraint.txt diff --git a/cmd/helm/testdata/output/status-comp.txt b/pkg/cmd/testdata/output/status-comp.txt similarity index 100% rename from cmd/helm/testdata/output/status-comp.txt rename to pkg/cmd/testdata/output/status-comp.txt diff --git a/cmd/helm/testdata/output/status-with-desc.txt b/pkg/cmd/testdata/output/status-with-desc.txt similarity index 100% rename from cmd/helm/testdata/output/status-with-desc.txt rename to pkg/cmd/testdata/output/status-with-desc.txt diff --git a/cmd/helm/testdata/output/status-with-notes.txt b/pkg/cmd/testdata/output/status-with-notes.txt similarity index 100% rename from cmd/helm/testdata/output/status-with-notes.txt rename to pkg/cmd/testdata/output/status-with-notes.txt diff --git a/cmd/helm/testdata/output/status-with-resources.json b/pkg/cmd/testdata/output/status-with-resources.json similarity index 100% rename from cmd/helm/testdata/output/status-with-resources.json rename to pkg/cmd/testdata/output/status-with-resources.json diff --git a/cmd/helm/testdata/output/status-with-resources.txt b/pkg/cmd/testdata/output/status-with-resources.txt similarity index 100% rename from cmd/helm/testdata/output/status-with-resources.txt rename to pkg/cmd/testdata/output/status-with-resources.txt diff --git a/cmd/helm/testdata/output/status-with-test-suite.txt b/pkg/cmd/testdata/output/status-with-test-suite.txt similarity index 100% rename from cmd/helm/testdata/output/status-with-test-suite.txt rename to pkg/cmd/testdata/output/status-with-test-suite.txt diff --git a/cmd/helm/testdata/output/status-wrong-args-comp.txt b/pkg/cmd/testdata/output/status-wrong-args-comp.txt similarity index 100% rename from cmd/helm/testdata/output/status-wrong-args-comp.txt rename to pkg/cmd/testdata/output/status-wrong-args-comp.txt diff --git a/cmd/helm/testdata/output/status.json b/pkg/cmd/testdata/output/status.json similarity index 100% rename from cmd/helm/testdata/output/status.json rename to pkg/cmd/testdata/output/status.json diff --git a/cmd/helm/testdata/output/status.txt b/pkg/cmd/testdata/output/status.txt similarity index 100% rename from cmd/helm/testdata/output/status.txt rename to pkg/cmd/testdata/output/status.txt diff --git a/cmd/helm/testdata/output/subchart-schema-cli-negative.txt b/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt similarity index 100% rename from cmd/helm/testdata/output/subchart-schema-cli-negative.txt rename to pkg/cmd/testdata/output/subchart-schema-cli-negative.txt diff --git a/cmd/helm/testdata/output/subchart-schema-cli.txt b/pkg/cmd/testdata/output/subchart-schema-cli.txt similarity index 100% rename from cmd/helm/testdata/output/subchart-schema-cli.txt rename to pkg/cmd/testdata/output/subchart-schema-cli.txt diff --git a/cmd/helm/testdata/output/subchart-schema-negative.txt b/pkg/cmd/testdata/output/subchart-schema-negative.txt similarity index 100% rename from cmd/helm/testdata/output/subchart-schema-negative.txt rename to pkg/cmd/testdata/output/subchart-schema-negative.txt diff --git a/cmd/helm/testdata/output/template-chart-bad-type.txt b/pkg/cmd/testdata/output/template-chart-bad-type.txt similarity index 100% rename from cmd/helm/testdata/output/template-chart-bad-type.txt rename to pkg/cmd/testdata/output/template-chart-bad-type.txt diff --git a/cmd/helm/testdata/output/template-chart-with-template-lib-archive-dep.txt b/pkg/cmd/testdata/output/template-chart-with-template-lib-archive-dep.txt similarity index 100% rename from cmd/helm/testdata/output/template-chart-with-template-lib-archive-dep.txt rename to pkg/cmd/testdata/output/template-chart-with-template-lib-archive-dep.txt diff --git a/cmd/helm/testdata/output/template-chart-with-template-lib-dep.txt b/pkg/cmd/testdata/output/template-chart-with-template-lib-dep.txt similarity index 100% rename from cmd/helm/testdata/output/template-chart-with-template-lib-dep.txt rename to pkg/cmd/testdata/output/template-chart-with-template-lib-dep.txt diff --git a/cmd/helm/testdata/output/template-lib-chart.txt b/pkg/cmd/testdata/output/template-lib-chart.txt similarity index 100% rename from cmd/helm/testdata/output/template-lib-chart.txt rename to pkg/cmd/testdata/output/template-lib-chart.txt diff --git a/cmd/helm/testdata/output/template-name-template.txt b/pkg/cmd/testdata/output/template-name-template.txt similarity index 100% rename from cmd/helm/testdata/output/template-name-template.txt rename to pkg/cmd/testdata/output/template-name-template.txt diff --git a/cmd/helm/testdata/output/template-no-args.txt b/pkg/cmd/testdata/output/template-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/template-no-args.txt rename to pkg/cmd/testdata/output/template-no-args.txt diff --git a/cmd/helm/testdata/output/template-set.txt b/pkg/cmd/testdata/output/template-set.txt similarity index 100% rename from cmd/helm/testdata/output/template-set.txt rename to pkg/cmd/testdata/output/template-set.txt diff --git a/cmd/helm/testdata/output/template-show-only-glob.txt b/pkg/cmd/testdata/output/template-show-only-glob.txt similarity index 100% rename from cmd/helm/testdata/output/template-show-only-glob.txt rename to pkg/cmd/testdata/output/template-show-only-glob.txt diff --git a/cmd/helm/testdata/output/template-show-only-multiple.txt b/pkg/cmd/testdata/output/template-show-only-multiple.txt similarity index 100% rename from cmd/helm/testdata/output/template-show-only-multiple.txt rename to pkg/cmd/testdata/output/template-show-only-multiple.txt diff --git a/cmd/helm/testdata/output/template-show-only-one.txt b/pkg/cmd/testdata/output/template-show-only-one.txt similarity index 100% rename from cmd/helm/testdata/output/template-show-only-one.txt rename to pkg/cmd/testdata/output/template-show-only-one.txt diff --git a/cmd/helm/testdata/output/template-skip-tests.txt b/pkg/cmd/testdata/output/template-skip-tests.txt similarity index 100% rename from cmd/helm/testdata/output/template-skip-tests.txt rename to pkg/cmd/testdata/output/template-skip-tests.txt diff --git a/cmd/helm/testdata/output/template-subchart-cm-set-file.txt b/pkg/cmd/testdata/output/template-subchart-cm-set-file.txt similarity index 100% rename from cmd/helm/testdata/output/template-subchart-cm-set-file.txt rename to pkg/cmd/testdata/output/template-subchart-cm-set-file.txt diff --git a/cmd/helm/testdata/output/template-subchart-cm-set.txt b/pkg/cmd/testdata/output/template-subchart-cm-set.txt similarity index 100% rename from cmd/helm/testdata/output/template-subchart-cm-set.txt rename to pkg/cmd/testdata/output/template-subchart-cm-set.txt diff --git a/cmd/helm/testdata/output/template-subchart-cm.txt b/pkg/cmd/testdata/output/template-subchart-cm.txt similarity index 100% rename from cmd/helm/testdata/output/template-subchart-cm.txt rename to pkg/cmd/testdata/output/template-subchart-cm.txt diff --git a/cmd/helm/testdata/output/template-values-files.txt b/pkg/cmd/testdata/output/template-values-files.txt similarity index 100% rename from cmd/helm/testdata/output/template-values-files.txt rename to pkg/cmd/testdata/output/template-values-files.txt diff --git a/cmd/helm/testdata/output/template-with-api-version.txt b/pkg/cmd/testdata/output/template-with-api-version.txt similarity index 100% rename from cmd/helm/testdata/output/template-with-api-version.txt rename to pkg/cmd/testdata/output/template-with-api-version.txt diff --git a/cmd/helm/testdata/output/template-with-crds.txt b/pkg/cmd/testdata/output/template-with-crds.txt similarity index 100% rename from cmd/helm/testdata/output/template-with-crds.txt rename to pkg/cmd/testdata/output/template-with-crds.txt diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt b/pkg/cmd/testdata/output/template-with-invalid-yaml-debug.txt similarity index 100% rename from cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt rename to pkg/cmd/testdata/output/template-with-invalid-yaml-debug.txt diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml.txt b/pkg/cmd/testdata/output/template-with-invalid-yaml.txt similarity index 100% rename from cmd/helm/testdata/output/template-with-invalid-yaml.txt rename to pkg/cmd/testdata/output/template-with-invalid-yaml.txt diff --git a/cmd/helm/testdata/output/template-with-kube-version.txt b/pkg/cmd/testdata/output/template-with-kube-version.txt similarity index 100% rename from cmd/helm/testdata/output/template-with-kube-version.txt rename to pkg/cmd/testdata/output/template-with-kube-version.txt diff --git a/cmd/helm/testdata/output/template.txt b/pkg/cmd/testdata/output/template.txt similarity index 100% rename from cmd/helm/testdata/output/template.txt rename to pkg/cmd/testdata/output/template.txt diff --git a/cmd/helm/testdata/output/uninstall-keep-history.txt b/pkg/cmd/testdata/output/uninstall-keep-history.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall-keep-history.txt rename to pkg/cmd/testdata/output/uninstall-keep-history.txt diff --git a/cmd/helm/testdata/output/uninstall-multiple.txt b/pkg/cmd/testdata/output/uninstall-multiple.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall-multiple.txt rename to pkg/cmd/testdata/output/uninstall-multiple.txt diff --git a/cmd/helm/testdata/output/uninstall-no-args.txt b/pkg/cmd/testdata/output/uninstall-no-args.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall-no-args.txt rename to pkg/cmd/testdata/output/uninstall-no-args.txt diff --git a/cmd/helm/testdata/output/uninstall-no-hooks.txt b/pkg/cmd/testdata/output/uninstall-no-hooks.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall-no-hooks.txt rename to pkg/cmd/testdata/output/uninstall-no-hooks.txt diff --git a/cmd/helm/testdata/output/uninstall-timeout.txt b/pkg/cmd/testdata/output/uninstall-timeout.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall-timeout.txt rename to pkg/cmd/testdata/output/uninstall-timeout.txt diff --git a/cmd/helm/testdata/output/uninstall-wait.txt b/pkg/cmd/testdata/output/uninstall-wait.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall-wait.txt rename to pkg/cmd/testdata/output/uninstall-wait.txt diff --git a/cmd/helm/testdata/output/uninstall.txt b/pkg/cmd/testdata/output/uninstall.txt similarity index 100% rename from cmd/helm/testdata/output/uninstall.txt rename to pkg/cmd/testdata/output/uninstall.txt diff --git a/cmd/helm/testdata/output/upgrade-and-take-ownership.txt b/pkg/cmd/testdata/output/upgrade-and-take-ownership.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-and-take-ownership.txt rename to pkg/cmd/testdata/output/upgrade-and-take-ownership.txt diff --git a/cmd/helm/testdata/output/upgrade-uninstalled-with-keep-history.txt b/pkg/cmd/testdata/output/upgrade-uninstalled-with-keep-history.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-uninstalled-with-keep-history.txt rename to pkg/cmd/testdata/output/upgrade-uninstalled-with-keep-history.txt diff --git a/cmd/helm/testdata/output/upgrade-with-bad-dependencies.txt b/pkg/cmd/testdata/output/upgrade-with-bad-dependencies.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-bad-dependencies.txt rename to pkg/cmd/testdata/output/upgrade-with-bad-dependencies.txt diff --git a/cmd/helm/testdata/output/upgrade-with-bad-or-missing-existing-release.txt b/pkg/cmd/testdata/output/upgrade-with-bad-or-missing-existing-release.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-bad-or-missing-existing-release.txt rename to pkg/cmd/testdata/output/upgrade-with-bad-or-missing-existing-release.txt diff --git a/cmd/helm/testdata/output/upgrade-with-dependency-update.txt b/pkg/cmd/testdata/output/upgrade-with-dependency-update.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-dependency-update.txt rename to pkg/cmd/testdata/output/upgrade-with-dependency-update.txt diff --git a/cmd/helm/testdata/output/upgrade-with-install-timeout.txt b/pkg/cmd/testdata/output/upgrade-with-install-timeout.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-install-timeout.txt rename to pkg/cmd/testdata/output/upgrade-with-install-timeout.txt diff --git a/cmd/helm/testdata/output/upgrade-with-install.txt b/pkg/cmd/testdata/output/upgrade-with-install.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-install.txt rename to pkg/cmd/testdata/output/upgrade-with-install.txt diff --git a/cmd/helm/testdata/output/upgrade-with-missing-dependencies.txt b/pkg/cmd/testdata/output/upgrade-with-missing-dependencies.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-missing-dependencies.txt rename to pkg/cmd/testdata/output/upgrade-with-missing-dependencies.txt diff --git a/cmd/helm/testdata/output/upgrade-with-pending-install.txt b/pkg/cmd/testdata/output/upgrade-with-pending-install.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-pending-install.txt rename to pkg/cmd/testdata/output/upgrade-with-pending-install.txt diff --git a/cmd/helm/testdata/output/upgrade-with-reset-values.txt b/pkg/cmd/testdata/output/upgrade-with-reset-values.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-reset-values.txt rename to pkg/cmd/testdata/output/upgrade-with-reset-values.txt diff --git a/cmd/helm/testdata/output/upgrade-with-reset-values2.txt b/pkg/cmd/testdata/output/upgrade-with-reset-values2.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-reset-values2.txt rename to pkg/cmd/testdata/output/upgrade-with-reset-values2.txt diff --git a/cmd/helm/testdata/output/upgrade-with-timeout.txt b/pkg/cmd/testdata/output/upgrade-with-timeout.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-timeout.txt rename to pkg/cmd/testdata/output/upgrade-with-timeout.txt diff --git a/cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt b/pkg/cmd/testdata/output/upgrade-with-wait-for-jobs.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-wait-for-jobs.txt rename to pkg/cmd/testdata/output/upgrade-with-wait-for-jobs.txt diff --git a/cmd/helm/testdata/output/upgrade-with-wait.txt b/pkg/cmd/testdata/output/upgrade-with-wait.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade-with-wait.txt rename to pkg/cmd/testdata/output/upgrade-with-wait.txt diff --git a/cmd/helm/testdata/output/upgrade.txt b/pkg/cmd/testdata/output/upgrade.txt similarity index 100% rename from cmd/helm/testdata/output/upgrade.txt rename to pkg/cmd/testdata/output/upgrade.txt diff --git a/cmd/helm/testdata/output/values.json b/pkg/cmd/testdata/output/values.json similarity index 100% rename from cmd/helm/testdata/output/values.json rename to pkg/cmd/testdata/output/values.json diff --git a/cmd/helm/testdata/output/values.yaml b/pkg/cmd/testdata/output/values.yaml similarity index 100% rename from cmd/helm/testdata/output/values.yaml rename to pkg/cmd/testdata/output/values.yaml diff --git a/cmd/helm/testdata/output/version-client-shorthand.txt b/pkg/cmd/testdata/output/version-client-shorthand.txt similarity index 100% rename from cmd/helm/testdata/output/version-client-shorthand.txt rename to pkg/cmd/testdata/output/version-client-shorthand.txt diff --git a/cmd/helm/testdata/output/version-client.txt b/pkg/cmd/testdata/output/version-client.txt similarity index 100% rename from cmd/helm/testdata/output/version-client.txt rename to pkg/cmd/testdata/output/version-client.txt diff --git a/cmd/helm/testdata/output/version-comp.txt b/pkg/cmd/testdata/output/version-comp.txt similarity index 100% rename from cmd/helm/testdata/output/version-comp.txt rename to pkg/cmd/testdata/output/version-comp.txt diff --git a/cmd/helm/testdata/output/version-invalid-comp.txt b/pkg/cmd/testdata/output/version-invalid-comp.txt similarity index 100% rename from cmd/helm/testdata/output/version-invalid-comp.txt rename to pkg/cmd/testdata/output/version-invalid-comp.txt diff --git a/cmd/helm/testdata/output/version-short.txt b/pkg/cmd/testdata/output/version-short.txt similarity index 100% rename from cmd/helm/testdata/output/version-short.txt rename to pkg/cmd/testdata/output/version-short.txt diff --git a/cmd/helm/testdata/output/version-template.txt b/pkg/cmd/testdata/output/version-template.txt similarity index 100% rename from cmd/helm/testdata/output/version-template.txt rename to pkg/cmd/testdata/output/version-template.txt diff --git a/cmd/helm/testdata/output/version.txt b/pkg/cmd/testdata/output/version.txt similarity index 100% rename from cmd/helm/testdata/output/version.txt rename to pkg/cmd/testdata/output/version.txt diff --git a/cmd/helm/testdata/password b/pkg/cmd/testdata/password similarity index 100% rename from cmd/helm/testdata/password rename to pkg/cmd/testdata/password diff --git a/cmd/helm/testdata/plugins.yaml b/pkg/cmd/testdata/plugins.yaml similarity index 100% rename from cmd/helm/testdata/plugins.yaml rename to pkg/cmd/testdata/plugins.yaml diff --git a/cmd/helm/testdata/repositories.yaml b/pkg/cmd/testdata/repositories.yaml similarity index 100% rename from cmd/helm/testdata/repositories.yaml rename to pkg/cmd/testdata/repositories.yaml diff --git a/cmd/helm/testdata/testcharts/alpine/Chart.yaml b/pkg/cmd/testdata/testcharts/alpine/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/alpine/Chart.yaml rename to pkg/cmd/testdata/testcharts/alpine/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/alpine/README.md b/pkg/cmd/testdata/testcharts/alpine/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/alpine/README.md rename to pkg/cmd/testdata/testcharts/alpine/README.md diff --git a/cmd/helm/testdata/testcharts/alpine/extra_values.yaml b/pkg/cmd/testdata/testcharts/alpine/extra_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/alpine/extra_values.yaml rename to pkg/cmd/testdata/testcharts/alpine/extra_values.yaml diff --git a/cmd/helm/testdata/testcharts/alpine/more_values.yaml b/pkg/cmd/testdata/testcharts/alpine/more_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/alpine/more_values.yaml rename to pkg/cmd/testdata/testcharts/alpine/more_values.yaml diff --git a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml b/pkg/cmd/testdata/testcharts/alpine/templates/alpine-pod.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml rename to pkg/cmd/testdata/testcharts/alpine/templates/alpine-pod.yaml diff --git a/cmd/helm/testdata/testcharts/alpine/values.yaml b/pkg/cmd/testdata/testcharts/alpine/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/alpine/values.yaml rename to pkg/cmd/testdata/testcharts/alpine/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/.helmignore b/pkg/cmd/testdata/testcharts/chart-bad-requirements/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-requirements/.helmignore rename to pkg/cmd/testdata/testcharts/chart-bad-requirements/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-bad-requirements/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-requirements/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-requirements/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore b/pkg/cmd/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore rename to pkg/cmd/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml b/pkg/cmd/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-requirements/charts/reqsubchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/values.yaml b/pkg/cmd/testdata/testcharts/chart-bad-requirements/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-requirements/values.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-requirements/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-bad-type/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-type/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-type/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/README.md b/pkg/cmd/testdata/testcharts/chart-bad-type/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-type/README.md rename to pkg/cmd/testdata/testcharts/chart-bad-type/README.md diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/extra_values.yaml b/pkg/cmd/testdata/testcharts/chart-bad-type/extra_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-type/extra_values.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-type/extra_values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/more_values.yaml b/pkg/cmd/testdata/testcharts/chart-bad-type/more_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-type/more_values.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-type/more_values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml b/pkg/cmd/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-type/templates/alpine-pod.yaml diff --git a/cmd/helm/testdata/testcharts/chart-bad-type/values.yaml b/pkg/cmd/testdata/testcharts/chart-bad-type/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-bad-type/values.yaml rename to pkg/cmd/testdata/testcharts/chart-bad-type/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore b/pkg/cmd/testdata/testcharts/chart-missing-deps/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-missing-deps/.helmignore rename to pkg/cmd/testdata/testcharts/chart-missing-deps/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-missing-deps/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-missing-deps/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-missing-deps/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore b/pkg/cmd/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore rename to pkg/cmd/testdata/testcharts/chart-missing-deps/charts/reqsubchart/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-missing-deps/charts/reqsubchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml b/pkg/cmd/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml rename to pkg/cmd/testdata/testcharts/chart-missing-deps/charts/reqsubchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml b/pkg/cmd/testdata/testcharts/chart-missing-deps/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-missing-deps/values.yaml rename to pkg/cmd/testdata/testcharts/chart-missing-deps/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-bad-subcharts/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-deprecated-api/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-deprecated-api/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-deprecated-api/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-deprecated-api/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-deprecated-api/templates/horizontalpodautoscaler.yaml b/pkg/cmd/testdata/testcharts/chart-with-deprecated-api/templates/horizontalpodautoscaler.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-deprecated-api/templates/horizontalpodautoscaler.yaml rename to pkg/cmd/testdata/testcharts/chart-with-deprecated-api/templates/horizontalpodautoscaler.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-deprecated-api/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-deprecated-api/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-deprecated-api/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-deprecated-api/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/.helmignore b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/.helmignore rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/charts/common-0.0.5.tgz diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/_helpers.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/deployment.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/ingress.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/service.yaml b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/templates/service.yaml rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/templates/service.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-lib-dep/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-lib-dep/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-lib-dep/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-lib-dep/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-only-crds/.helmignore b/pkg/cmd/testdata/testcharts/chart-with-only-crds/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-only-crds/.helmignore rename to pkg/cmd/testdata/testcharts/chart-with-only-crds/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-with-only-crds/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-only-crds/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-only-crds/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-only-crds/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml b/pkg/cmd/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml rename to pkg/cmd/testdata/testcharts/chart-with-only-crds/crds/test-crd.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/templates/empty.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.schema.json diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/charts/subchart-with-schema/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/templates/empty.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/values.schema.json diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-and-subchart/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-and-subchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/templates/empty.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/templates/empty.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/templates/empty.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/templates/empty.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/values.schema.json b/pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/values.schema.json similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/values.schema.json rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/values.schema.json diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative-skip-validation/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative-skip-validation/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-negative/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative/templates/empty.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.schema.json b/pkg/cmd/testdata/testcharts/chart-with-schema-negative/values.schema.json similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative/values.schema.json rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative/values.schema.json diff --git a/cmd/helm/testdata/testcharts/chart-with-schema-negative/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema-negative/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema-negative/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema-negative/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/extra-values.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema/extra-values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema/extra-values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema/extra-values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/templates/empty.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema/templates/empty.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema/templates/empty.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema/templates/empty.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/values.schema.json b/pkg/cmd/testdata/testcharts/chart-with-schema/values.schema.json similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema/values.schema.json rename to pkg/cmd/testdata/testcharts/chart-with-schema/values.schema.json diff --git a/cmd/helm/testdata/testcharts/chart-with-schema/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-schema/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-schema/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-schema/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-secret/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-secret/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-secret/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-secret/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-secret/templates/configmap.yaml b/pkg/cmd/testdata/testcharts/chart-with-secret/templates/configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-secret/templates/configmap.yaml rename to pkg/cmd/testdata/testcharts/chart-with-secret/templates/configmap.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-secret/templates/secret.yaml b/pkg/cmd/testdata/testcharts/chart-with-secret/templates/secret.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-secret/templates/secret.yaml rename to pkg/cmd/testdata/testcharts/chart-with-secret/templates/secret.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-subchart-notes/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-notes/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-subchart-notes/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-subchart-notes/charts/subchart-with-notes/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-subchart-notes/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.lock b/pkg/cmd/testdata/testcharts/chart-with-subchart-update/Chart.lock similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.lock rename to pkg/cmd/testdata/testcharts/chart-with-subchart-update/Chart.lock diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-subchart-update/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-update/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-subchart-update/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-subchart-update/charts/subchart-with-notes/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-subchart-update/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/charts/common-0.0.5.tgz diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/_helpers.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/deployment.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/ingress.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/templates/service.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-archive-dep/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/.helmignore b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/.helmignore rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/.helmignore diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/README.md diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_chartref.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_configmap.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_container.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_deployment.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_envvar.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_fullname.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_ingress.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_annotations.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_metadata_labels.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_name.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_persistentvolumeclaim.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_secret.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_service.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_util.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/_volume.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/templates/configmap.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/charts/common/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/_helpers.tpl diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/deployment.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/ingress.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/templates/service.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-lib-dep/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-lib-dep/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-lib-dep/values.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md b/pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md rename to pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml b/pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml rename to pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz b/pkg/cmd/testdata/testcharts/compressedchart-0.1.0.tar.gz similarity index 100% rename from cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz rename to pkg/cmd/testdata/testcharts/compressedchart-0.1.0.tar.gz diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz b/pkg/cmd/testdata/testcharts/compressedchart-0.1.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/compressedchart-0.1.0.tgz rename to pkg/cmd/testdata/testcharts/compressedchart-0.1.0.tgz diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz b/pkg/cmd/testdata/testcharts/compressedchart-0.2.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/compressedchart-0.2.0.tgz rename to pkg/cmd/testdata/testcharts/compressedchart-0.2.0.tgz diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz b/pkg/cmd/testdata/testcharts/compressedchart-0.3.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/compressedchart-0.3.0.tgz rename to pkg/cmd/testdata/testcharts/compressedchart-0.3.0.tgz diff --git a/cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz b/pkg/cmd/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz rename to pkg/cmd/testdata/testcharts/compressedchart-with-hyphens-0.1.0.tgz diff --git a/cmd/helm/testdata/testcharts/deprecated/Chart.yaml b/pkg/cmd/testdata/testcharts/deprecated/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/deprecated/Chart.yaml rename to pkg/cmd/testdata/testcharts/deprecated/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/deprecated/README.md b/pkg/cmd/testdata/testcharts/deprecated/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/deprecated/README.md rename to pkg/cmd/testdata/testcharts/deprecated/README.md diff --git a/cmd/helm/testdata/testcharts/empty/Chart.yaml b/pkg/cmd/testdata/testcharts/empty/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/empty/Chart.yaml rename to pkg/cmd/testdata/testcharts/empty/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/empty/README.md b/pkg/cmd/testdata/testcharts/empty/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/empty/README.md rename to pkg/cmd/testdata/testcharts/empty/README.md diff --git a/cmd/helm/testdata/testcharts/empty/templates/empty.yaml b/pkg/cmd/testdata/testcharts/empty/templates/empty.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/empty/templates/empty.yaml rename to pkg/cmd/testdata/testcharts/empty/templates/empty.yaml diff --git a/cmd/helm/testdata/testcharts/empty/values.yaml b/pkg/cmd/testdata/testcharts/empty/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/empty/values.yaml rename to pkg/cmd/testdata/testcharts/empty/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue-7233/.helmignore b/pkg/cmd/testdata/testcharts/issue-7233/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/issue-7233/.helmignore rename to pkg/cmd/testdata/testcharts/issue-7233/.helmignore diff --git a/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml b/pkg/cmd/testdata/testcharts/issue-7233/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-7233/Chart.yaml rename to pkg/cmd/testdata/testcharts/issue-7233/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/issue-7233/requirements.lock b/pkg/cmd/testdata/testcharts/issue-7233/requirements.lock similarity index 100% rename from cmd/helm/testdata/testcharts/issue-7233/requirements.lock rename to pkg/cmd/testdata/testcharts/issue-7233/requirements.lock diff --git a/cmd/helm/testdata/testcharts/issue-7233/requirements.yaml b/pkg/cmd/testdata/testcharts/issue-7233/requirements.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-7233/requirements.yaml rename to pkg/cmd/testdata/testcharts/issue-7233/requirements.yaml diff --git a/cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml b/pkg/cmd/testdata/testcharts/issue-7233/templates/configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml rename to pkg/cmd/testdata/testcharts/issue-7233/templates/configmap.yaml diff --git a/cmd/helm/testdata/testcharts/issue-7233/values.yaml b/pkg/cmd/testdata/testcharts/issue-7233/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-7233/values.yaml rename to pkg/cmd/testdata/testcharts/issue-7233/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue-9027/Chart.yaml b/pkg/cmd/testdata/testcharts/issue-9027/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-9027/Chart.yaml rename to pkg/cmd/testdata/testcharts/issue-9027/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/issue-9027/charts/subchart/Chart.yaml b/pkg/cmd/testdata/testcharts/issue-9027/charts/subchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-9027/charts/subchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/issue-9027/charts/subchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/issue-9027/charts/subchart/templates/values.yaml b/pkg/cmd/testdata/testcharts/issue-9027/charts/subchart/templates/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-9027/charts/subchart/templates/values.yaml rename to pkg/cmd/testdata/testcharts/issue-9027/charts/subchart/templates/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue-9027/charts/subchart/values.yaml b/pkg/cmd/testdata/testcharts/issue-9027/charts/subchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-9027/charts/subchart/values.yaml rename to pkg/cmd/testdata/testcharts/issue-9027/charts/subchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue-9027/templates/values.yaml b/pkg/cmd/testdata/testcharts/issue-9027/templates/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-9027/templates/values.yaml rename to pkg/cmd/testdata/testcharts/issue-9027/templates/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue-9027/values.yaml b/pkg/cmd/testdata/testcharts/issue-9027/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-9027/values.yaml rename to pkg/cmd/testdata/testcharts/issue-9027/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml b/pkg/cmd/testdata/testcharts/issue-totoml/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml rename to pkg/cmd/testdata/testcharts/issue-totoml/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml b/pkg/cmd/testdata/testcharts/issue-totoml/templates/configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml rename to pkg/cmd/testdata/testcharts/issue-totoml/templates/configmap.yaml diff --git a/cmd/helm/testdata/testcharts/issue-totoml/values.yaml b/pkg/cmd/testdata/testcharts/issue-totoml/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue-totoml/values.yaml rename to pkg/cmd/testdata/testcharts/issue-totoml/values.yaml diff --git a/cmd/helm/testdata/testcharts/issue1979/Chart.yaml b/pkg/cmd/testdata/testcharts/issue1979/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue1979/Chart.yaml rename to pkg/cmd/testdata/testcharts/issue1979/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/issue1979/README.md b/pkg/cmd/testdata/testcharts/issue1979/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/issue1979/README.md rename to pkg/cmd/testdata/testcharts/issue1979/README.md diff --git a/cmd/helm/testdata/testcharts/issue1979/extra_values.yaml b/pkg/cmd/testdata/testcharts/issue1979/extra_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue1979/extra_values.yaml rename to pkg/cmd/testdata/testcharts/issue1979/extra_values.yaml diff --git a/cmd/helm/testdata/testcharts/issue1979/more_values.yaml b/pkg/cmd/testdata/testcharts/issue1979/more_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue1979/more_values.yaml rename to pkg/cmd/testdata/testcharts/issue1979/more_values.yaml diff --git a/cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml b/pkg/cmd/testdata/testcharts/issue1979/templates/alpine-pod.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue1979/templates/alpine-pod.yaml rename to pkg/cmd/testdata/testcharts/issue1979/templates/alpine-pod.yaml diff --git a/cmd/helm/testdata/testcharts/issue1979/values.yaml b/pkg/cmd/testdata/testcharts/issue1979/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/issue1979/values.yaml rename to pkg/cmd/testdata/testcharts/issue1979/values.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/.helmignore b/pkg/cmd/testdata/testcharts/lib-chart/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/.helmignore rename to pkg/cmd/testdata/testcharts/lib-chart/.helmignore diff --git a/cmd/helm/testdata/testcharts/lib-chart/Chart.yaml b/pkg/cmd/testdata/testcharts/lib-chart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/Chart.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/README.md b/pkg/cmd/testdata/testcharts/lib-chart/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/README.md rename to pkg/cmd/testdata/testcharts/lib-chart/README.md diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_chartref.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_chartref.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_chartref.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_chartref.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_configmap.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_configmap.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_configmap.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_container.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_container.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_container.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_container.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_deployment.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_deployment.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_deployment.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_envvar.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_envvar.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_envvar.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_envvar.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_fullname.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_fullname.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_fullname.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_fullname.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_ingress.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_ingress.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_ingress.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_ingress.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_metadata.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_metadata.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_metadata.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_metadata_annotations.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_metadata_labels.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_name.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_name.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_name.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_name.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_persistentvolumeclaim.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_secret.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_secret.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_secret.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_secret.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml b/pkg/cmd/testdata/testcharts/lib-chart/templates/_service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_service.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_service.yaml diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_util.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_util.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_util.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_util.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/templates/_volume.tpl b/pkg/cmd/testdata/testcharts/lib-chart/templates/_volume.tpl similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/templates/_volume.tpl rename to pkg/cmd/testdata/testcharts/lib-chart/templates/_volume.tpl diff --git a/cmd/helm/testdata/testcharts/lib-chart/values.yaml b/pkg/cmd/testdata/testcharts/lib-chart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/lib-chart/values.yaml rename to pkg/cmd/testdata/testcharts/lib-chart/values.yaml diff --git a/cmd/helm/testdata/testcharts/object-order/Chart.yaml b/pkg/cmd/testdata/testcharts/object-order/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/object-order/Chart.yaml rename to pkg/cmd/testdata/testcharts/object-order/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml b/pkg/cmd/testdata/testcharts/object-order/templates/01-a.yml similarity index 100% rename from cmd/helm/testdata/testcharts/object-order/templates/01-a.yml rename to pkg/cmd/testdata/testcharts/object-order/templates/01-a.yml diff --git a/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml b/pkg/cmd/testdata/testcharts/object-order/templates/02-b.yml similarity index 100% rename from cmd/helm/testdata/testcharts/object-order/templates/02-b.yml rename to pkg/cmd/testdata/testcharts/object-order/templates/02-b.yml diff --git a/cmd/helm/testdata/testcharts/object-order/values.yaml b/pkg/cmd/testdata/testcharts/object-order/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/object-order/values.yaml rename to pkg/cmd/testdata/testcharts/object-order/values.yaml diff --git a/cmd/helm/testdata/testcharts/oci-dependent-chart-0.1.0.tgz b/pkg/cmd/testdata/testcharts/oci-dependent-chart-0.1.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/oci-dependent-chart-0.1.0.tgz rename to pkg/cmd/testdata/testcharts/oci-dependent-chart-0.1.0.tgz diff --git a/cmd/helm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz b/pkg/cmd/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz rename to pkg/cmd/testdata/testcharts/pre-release-chart-0.1.0-alpha.tgz diff --git a/cmd/helm/testdata/testcharts/reqtest-0.1.0.tgz b/pkg/cmd/testdata/testcharts/reqtest-0.1.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest-0.1.0.tgz rename to pkg/cmd/testdata/testcharts/reqtest-0.1.0.tgz diff --git a/cmd/helm/testdata/testcharts/reqtest/.helmignore b/pkg/cmd/testdata/testcharts/reqtest/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/.helmignore rename to pkg/cmd/testdata/testcharts/reqtest/.helmignore diff --git a/cmd/helm/testdata/testcharts/reqtest/Chart.lock b/pkg/cmd/testdata/testcharts/reqtest/Chart.lock similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/Chart.lock rename to pkg/cmd/testdata/testcharts/reqtest/Chart.lock diff --git a/cmd/helm/testdata/testcharts/reqtest/Chart.yaml b/pkg/cmd/testdata/testcharts/reqtest/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/Chart.yaml rename to pkg/cmd/testdata/testcharts/reqtest/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart/.helmignore diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart2/.helmignore diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart2/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart2/values.yaml diff --git a/cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz b/pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz rename to pkg/cmd/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz diff --git a/cmd/helm/testdata/testcharts/reqtest/values.yaml b/pkg/cmd/testdata/testcharts/reqtest/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/reqtest/values.yaml rename to pkg/cmd/testdata/testcharts/reqtest/values.yaml diff --git a/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz b/pkg/cmd/testdata/testcharts/signtest-0.1.0.tgz similarity index 100% rename from cmd/helm/testdata/testcharts/signtest-0.1.0.tgz rename to pkg/cmd/testdata/testcharts/signtest-0.1.0.tgz diff --git a/cmd/helm/testdata/testcharts/signtest-0.1.0.tgz.prov b/pkg/cmd/testdata/testcharts/signtest-0.1.0.tgz.prov similarity index 100% rename from cmd/helm/testdata/testcharts/signtest-0.1.0.tgz.prov rename to pkg/cmd/testdata/testcharts/signtest-0.1.0.tgz.prov diff --git a/cmd/helm/testdata/testcharts/signtest/.helmignore b/pkg/cmd/testdata/testcharts/signtest/.helmignore similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/.helmignore rename to pkg/cmd/testdata/testcharts/signtest/.helmignore diff --git a/cmd/helm/testdata/testcharts/signtest/Chart.yaml b/pkg/cmd/testdata/testcharts/signtest/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/Chart.yaml rename to pkg/cmd/testdata/testcharts/signtest/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/Chart.yaml b/pkg/cmd/testdata/testcharts/signtest/alpine/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/alpine/Chart.yaml rename to pkg/cmd/testdata/testcharts/signtest/alpine/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/README.md b/pkg/cmd/testdata/testcharts/signtest/alpine/README.md similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/alpine/README.md rename to pkg/cmd/testdata/testcharts/signtest/alpine/README.md diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml b/pkg/cmd/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml rename to pkg/cmd/testdata/testcharts/signtest/alpine/templates/alpine-pod.yaml diff --git a/cmd/helm/testdata/testcharts/signtest/alpine/values.yaml b/pkg/cmd/testdata/testcharts/signtest/alpine/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/alpine/values.yaml rename to pkg/cmd/testdata/testcharts/signtest/alpine/values.yaml diff --git a/cmd/helm/testdata/testcharts/signtest/templates/pod.yaml b/pkg/cmd/testdata/testcharts/signtest/templates/pod.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/templates/pod.yaml rename to pkg/cmd/testdata/testcharts/signtest/templates/pod.yaml diff --git a/cmd/helm/testdata/testcharts/signtest/values.yaml b/pkg/cmd/testdata/testcharts/signtest/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/signtest/values.yaml rename to pkg/cmd/testdata/testcharts/signtest/values.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/Chart.yaml b/pkg/cmd/testdata/testcharts/subchart/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/Chart.yaml rename to pkg/cmd/testdata/testcharts/subchart/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/Chart.yaml b/pkg/cmd/testdata/testcharts/subchart/charts/subchartA/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/charts/subchartA/Chart.yaml rename to pkg/cmd/testdata/testcharts/subchart/charts/subchartA/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml b/pkg/cmd/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml rename to pkg/cmd/testdata/testcharts/subchart/charts/subchartA/templates/service.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartA/values.yaml b/pkg/cmd/testdata/testcharts/subchart/charts/subchartA/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/charts/subchartA/values.yaml rename to pkg/cmd/testdata/testcharts/subchart/charts/subchartA/values.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/Chart.yaml b/pkg/cmd/testdata/testcharts/subchart/charts/subchartB/Chart.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/charts/subchartB/Chart.yaml rename to pkg/cmd/testdata/testcharts/subchart/charts/subchartB/Chart.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml b/pkg/cmd/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml rename to pkg/cmd/testdata/testcharts/subchart/charts/subchartB/templates/service.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/charts/subchartB/values.yaml b/pkg/cmd/testdata/testcharts/subchart/charts/subchartB/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/charts/subchartB/values.yaml rename to pkg/cmd/testdata/testcharts/subchart/charts/subchartB/values.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml b/pkg/cmd/testdata/testcharts/subchart/crds/crdA.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml rename to pkg/cmd/testdata/testcharts/subchart/crds/crdA.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/extra_values.yaml b/pkg/cmd/testdata/testcharts/subchart/extra_values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/extra_values.yaml rename to pkg/cmd/testdata/testcharts/subchart/extra_values.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/NOTES.txt b/pkg/cmd/testdata/testcharts/subchart/templates/NOTES.txt similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/NOTES.txt rename to pkg/cmd/testdata/testcharts/subchart/templates/NOTES.txt diff --git a/cmd/helm/testdata/testcharts/subchart/templates/service.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/service.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/service.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/service.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/configmap.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/subdir/configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/subdir/configmap.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/subdir/configmap.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/role.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/subdir/role.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/subdir/role.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/subdir/role.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/subdir/rolebinding.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/subdir/serviceaccount.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/tests/test-config.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/tests/test-config.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/tests/test-config.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/tests/test-config.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/templates/tests/test-nothing.yaml b/pkg/cmd/testdata/testcharts/subchart/templates/tests/test-nothing.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/templates/tests/test-nothing.yaml rename to pkg/cmd/testdata/testcharts/subchart/templates/tests/test-nothing.yaml diff --git a/cmd/helm/testdata/testcharts/subchart/values.yaml b/pkg/cmd/testdata/testcharts/subchart/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/subchart/values.yaml rename to pkg/cmd/testdata/testcharts/subchart/values.yaml diff --git a/cmd/helm/testdata/testcharts/upgradetest/templates/configmap.yaml b/pkg/cmd/testdata/testcharts/upgradetest/templates/configmap.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/upgradetest/templates/configmap.yaml rename to pkg/cmd/testdata/testcharts/upgradetest/templates/configmap.yaml diff --git a/cmd/helm/testdata/testcharts/upgradetest/values.yaml b/pkg/cmd/testdata/testcharts/upgradetest/values.yaml similarity index 100% rename from cmd/helm/testdata/testcharts/upgradetest/values.yaml rename to pkg/cmd/testdata/testcharts/upgradetest/values.yaml diff --git a/cmd/helm/testdata/testplugin/plugin.yaml b/pkg/cmd/testdata/testplugin/plugin.yaml similarity index 100% rename from cmd/helm/testdata/testplugin/plugin.yaml rename to pkg/cmd/testdata/testplugin/plugin.yaml diff --git a/cmd/helm/testdata/testserver/index.yaml b/pkg/cmd/testdata/testserver/index.yaml similarity index 100% rename from cmd/helm/testdata/testserver/index.yaml rename to pkg/cmd/testdata/testserver/index.yaml diff --git a/cmd/helm/testdata/testserver/repository/repositories.yaml b/pkg/cmd/testdata/testserver/repository/repositories.yaml similarity index 100% rename from cmd/helm/testdata/testserver/repository/repositories.yaml rename to pkg/cmd/testdata/testserver/repository/repositories.yaml diff --git a/cmd/helm/uninstall.go b/pkg/cmd/uninstall.go similarity index 98% rename from cmd/helm/uninstall.go rename to pkg/cmd/uninstall.go index 9c5e25c87..c4e70cf75 100644 --- a/cmd/helm/uninstall.go +++ b/pkg/cmd/uninstall.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const uninstallDesc = ` diff --git a/cmd/helm/uninstall_test.go b/pkg/cmd/uninstall_test.go similarity index 99% rename from cmd/helm/uninstall_test.go rename to pkg/cmd/uninstall_test.go index f9bc71ec2..36d9ad117 100644 --- a/cmd/helm/uninstall_test.go +++ b/pkg/cmd/uninstall_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/cmd/helm/upgrade.go b/pkg/cmd/upgrade.go similarity index 99% rename from cmd/helm/upgrade.go rename to pkg/cmd/upgrade.go index 6684f9ebf..dfb28a98e 100644 --- a/cmd/helm/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "context" @@ -29,11 +29,11 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/chart/loader" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/values" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/release" @@ -173,7 +173,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if client.Version == "" && client.Devel { - debug("setting version to >0.0.0-0") + Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -225,7 +225,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if ch.Metadata.Deprecated { - warning("This chart is deprecated") + Warning("This chart is deprecated") } // Create context and prepare the handle of SIGTERM diff --git a/cmd/helm/upgrade_test.go b/pkg/cmd/upgrade_test.go similarity index 99% rename from cmd/helm/upgrade_test.go rename to pkg/cmd/upgrade_test.go index f97a4a26b..0c454b9bf 100644 --- a/cmd/helm/upgrade_test.go +++ b/pkg/cmd/upgrade_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/verify.go b/pkg/cmd/verify.go similarity index 97% rename from cmd/helm/verify.go rename to pkg/cmd/verify.go index 197a164b6..50f1ea914 100644 --- a/cmd/helm/verify.go +++ b/pkg/cmd/verify.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -21,8 +21,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/cmd/require" ) const verifyDesc = ` diff --git a/cmd/helm/verify_test.go b/pkg/cmd/verify_test.go similarity index 99% rename from cmd/helm/verify_test.go rename to pkg/cmd/verify_test.go index 23b793557..ae373afd2 100644 --- a/cmd/helm/verify_test.go +++ b/pkg/cmd/verify_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/cmd/helm/version.go b/pkg/cmd/version.go similarity index 98% rename from cmd/helm/version.go rename to pkg/cmd/version.go index 030ce2dcd..0211716fe 100644 --- a/cmd/helm/version.go +++ b/pkg/cmd/version.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "fmt" @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/internal/version" + "helm.sh/helm/v4/pkg/cmd/require" ) const versionDesc = ` diff --git a/cmd/helm/version_test.go b/pkg/cmd/version_test.go similarity index 98% rename from cmd/helm/version_test.go rename to pkg/cmd/version_test.go index aa3cbfb7d..c06c72309 100644 --- a/cmd/helm/version_test.go +++ b/pkg/cmd/version_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package cmd import ( "testing" From 18ca7c100250d70b2b5f45964eef22013b1bd384 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 24 Feb 2025 14:58:51 -0500 Subject: [PATCH 152/271] Move pkg/releaseutil to pkg/release/util The releaseutil package was originally designed to work against a generated codebase from a protobuf in Helm v2. This is when Helm used gRPC to communicate to a server side component named Tiller. When Helm moved everything client side, this package remained and it supported the release package. This change moves releaseutil to be a sub-packge of release. This is part of the change to support apiVersion v3 charts which is documented in HIP 20 Signed-off-by: Matt Farina --- cmd/helm/history.go | 2 +- cmd/helm/template.go | 2 +- pkg/action/action.go | 2 +- pkg/action/install.go | 2 +- pkg/action/list.go | 2 +- pkg/action/resource_policy.go | 2 +- pkg/action/uninstall.go | 2 +- pkg/action/upgrade.go | 2 +- pkg/{releaseutil => release/util}/filter.go | 2 +- pkg/{releaseutil => release/util}/filter_test.go | 2 +- pkg/{releaseutil => release/util}/kind_sorter.go | 2 +- pkg/{releaseutil => release/util}/kind_sorter_test.go | 2 +- pkg/{releaseutil => release/util}/manifest.go | 2 +- pkg/{releaseutil => release/util}/manifest_sorter.go | 2 +- pkg/{releaseutil => release/util}/manifest_sorter_test.go | 2 +- pkg/{releaseutil => release/util}/manifest_test.go | 2 +- pkg/{releaseutil => release/util}/sorter.go | 2 +- pkg/{releaseutil => release/util}/sorter_test.go | 2 +- pkg/storage/storage.go | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) rename pkg/{releaseutil => release/util}/filter.go (96%) rename pkg/{releaseutil => release/util}/filter_test.go (96%) rename pkg/{releaseutil => release/util}/kind_sorter.go (99%) rename pkg/{releaseutil => release/util}/kind_sorter_test.go (99%) rename pkg/{releaseutil => release/util}/manifest.go (99%) rename pkg/{releaseutil => release/util}/manifest_sorter.go (99%) rename pkg/{releaseutil => release/util}/manifest_sorter_test.go (99%) rename pkg/{releaseutil => release/util}/manifest_test.go (95%) rename pkg/{releaseutil => release/util}/sorter.go (97%) rename pkg/{releaseutil => release/util}/sorter_test.go (97%) diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 91d005e7a..2c929c161 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -30,7 +30,7 @@ import ( "helm.sh/helm/v4/pkg/chart" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 1a6265eba..212664dc8 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -36,7 +36,7 @@ import ( "helm.sh/helm/v4/pkg/action" chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/cli/values" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" ) const templateDesc = ` diff --git a/pkg/action/action.go b/pkg/action/action.go index 6efc6c2ee..eeaebc15f 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -40,7 +40,7 @@ import ( "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" "helm.sh/helm/v4/pkg/storage" "helm.sh/helm/v4/pkg/storage/driver" "helm.sh/helm/v4/pkg/time" diff --git a/pkg/action/install.go b/pkg/action/install.go index 6ad77a509..68c1848f6 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -49,7 +49,7 @@ import ( "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" "helm.sh/helm/v4/pkg/repo" "helm.sh/helm/v4/pkg/storage" "helm.sh/helm/v4/pkg/storage/driver" diff --git a/pkg/action/list.go b/pkg/action/list.go index f90c31acd..5c2b1e8a1 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" ) // ListStates represents zero or more status codes that a list item may have set diff --git a/pkg/action/resource_policy.go b/pkg/action/resource_policy.go index f18acb880..b72e94124 100644 --- a/pkg/action/resource_policy.go +++ b/pkg/action/resource_policy.go @@ -20,7 +20,7 @@ import ( "strings" "helm.sh/helm/v4/pkg/kube" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" ) func filterManifestsToKeep(manifests []releaseutil.Manifest) (keep, remaining []releaseutil.Manifest) { diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index b786c37f7..6e71197f6 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -27,7 +27,7 @@ import ( chartutil "helm.sh/helm/v4/pkg/chart/util" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index c5397c984..fa799ad2b 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -34,7 +34,7 @@ import ( "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/release" - "helm.sh/helm/v4/pkg/releaseutil" + releaseutil "helm.sh/helm/v4/pkg/release/util" "helm.sh/helm/v4/pkg/storage/driver" ) diff --git a/pkg/releaseutil/filter.go b/pkg/release/util/filter.go similarity index 96% rename from pkg/releaseutil/filter.go rename to pkg/release/util/filter.go index d600d43e8..e56752f86 100644 --- a/pkg/releaseutil/filter.go +++ b/pkg/release/util/filter.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil // import "helm.sh/helm/v4/pkg/releaseutil" +package util // import "helm.sh/helm/v4/pkg/release/util" import rspb "helm.sh/helm/v4/pkg/release" diff --git a/pkg/releaseutil/filter_test.go b/pkg/release/util/filter_test.go similarity index 96% rename from pkg/releaseutil/filter_test.go rename to pkg/release/util/filter_test.go index 9fc5ce9b1..2037ef157 100644 --- a/pkg/releaseutil/filter_test.go +++ b/pkg/release/util/filter_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil // import "helm.sh/helm/v4/pkg/releaseutil" +package util // import "helm.sh/helm/v4/pkg/release/util" import ( "testing" diff --git a/pkg/releaseutil/kind_sorter.go b/pkg/release/util/kind_sorter.go similarity index 99% rename from pkg/releaseutil/kind_sorter.go rename to pkg/release/util/kind_sorter.go index ec51d50d8..130b2c831 100644 --- a/pkg/releaseutil/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil +package util import ( "sort" diff --git a/pkg/releaseutil/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go similarity index 99% rename from pkg/releaseutil/kind_sorter_test.go rename to pkg/release/util/kind_sorter_test.go index f7745d64d..cd40fe459 100644 --- a/pkg/releaseutil/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil +package util import ( "bytes" diff --git a/pkg/releaseutil/manifest.go b/pkg/release/util/manifest.go similarity index 99% rename from pkg/releaseutil/manifest.go rename to pkg/release/util/manifest.go index 0b04a4599..9a87949f8 100644 --- a/pkg/releaseutil/manifest.go +++ b/pkg/release/util/manifest.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil +package util import ( "fmt" diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/release/util/manifest_sorter.go similarity index 99% rename from pkg/releaseutil/manifest_sorter.go rename to pkg/release/util/manifest_sorter.go index 2d9a14bf1..a598743a6 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil +package util import ( "log" diff --git a/pkg/releaseutil/manifest_sorter_test.go b/pkg/release/util/manifest_sorter_test.go similarity index 99% rename from pkg/releaseutil/manifest_sorter_test.go rename to pkg/release/util/manifest_sorter_test.go index 3bd196c12..281f24924 100644 --- a/pkg/releaseutil/manifest_sorter_test.go +++ b/pkg/release/util/manifest_sorter_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil +package util import ( "reflect" diff --git a/pkg/releaseutil/manifest_test.go b/pkg/release/util/manifest_test.go similarity index 95% rename from pkg/releaseutil/manifest_test.go rename to pkg/release/util/manifest_test.go index 8e05b76dc..cfc19563d 100644 --- a/pkg/releaseutil/manifest_test.go +++ b/pkg/release/util/manifest_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil // import "helm.sh/helm/v4/pkg/releaseutil" +package util // import "helm.sh/helm/v4/pkg/release/util" import ( "reflect" diff --git a/pkg/releaseutil/sorter.go b/pkg/release/util/sorter.go similarity index 97% rename from pkg/releaseutil/sorter.go rename to pkg/release/util/sorter.go index a2135d68f..8b1c89aa3 100644 --- a/pkg/releaseutil/sorter.go +++ b/pkg/release/util/sorter.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil // import "helm.sh/helm/v4/pkg/releaseutil" +package util // import "helm.sh/helm/v4/pkg/release/util" import ( "sort" diff --git a/pkg/releaseutil/sorter_test.go b/pkg/release/util/sorter_test.go similarity index 97% rename from pkg/releaseutil/sorter_test.go rename to pkg/release/util/sorter_test.go index bef261ee8..6e92eef5c 100644 --- a/pkg/releaseutil/sorter_test.go +++ b/pkg/release/util/sorter_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package releaseutil // import "helm.sh/helm/v4/pkg/releaseutil" +package util // import "helm.sh/helm/v4/pkg/release/util" import ( "testing" diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index af339b85e..6a77cbae6 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" rspb "helm.sh/helm/v4/pkg/release" - relutil "helm.sh/helm/v4/pkg/releaseutil" + relutil "helm.sh/helm/v4/pkg/release/util" "helm.sh/helm/v4/pkg/storage/driver" ) From 17adaa437a1a5b1240bce8822694ac34ebd13786 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 22:21:24 +0000 Subject: [PATCH 153/271] build(deps): bump golang.org/x/crypto from 0.33.0 to 0.35.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.33.0 to 0.35.0. - [Commits](https://github.com/golang/crypto/compare/v0.33.0...v0.35.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index c84140350..0b2836b06 100644 --- a/go.mod +++ b/go.mod @@ -33,9 +33,10 @@ require ( github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 - golang.org/x/crypto v0.33.0 + golang.org/x/crypto v0.35.0 golang.org/x/term v0.29.0 golang.org/x/text v0.22.0 + gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.32.2 k8s.io/apiextensions-apiserver v0.32.2 k8s.io/apimachinery v0.32.2 @@ -173,7 +174,6 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/component-base v0.32.2 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect diff --git a/go.sum b/go.sum index 995e14598..467cef72f 100644 --- a/go.sum +++ b/go.sum @@ -400,8 +400,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= +golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= From b79dfd09b0b9a8173ec23e5a72b3a0c444863dee Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Feb 2025 03:51:38 +0000 Subject: [PATCH 154/271] refactor Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 9 +++-- pkg/kube/statuswait_test.go | 70 +++++++++++++++++++++++++++---------- 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 3c1e90a36..baf5814b1 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -187,6 +187,11 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func if rs == nil { continue } + // If a resource is already deleted before waiting has started, it will show as unknown + // this check ensures we don't wait forever for a resource that is already deleted + if rs.Status == status.UnknownStatus && desired == status.NotFoundStatus { + continue + } rss = append(rss, rs) if rs.Status != desired { nonDesiredResources = append(nonDesiredResources, rs) @@ -199,12 +204,12 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func } if len(nonDesiredResources) > 0 { - // Log only the first resource so the user knows what they're waiting for without being overwhelmed + // Log a single resource so the user knows what they're waiting for without an overwhelming amount of output sort.Slice(nonDesiredResources, func(i, j int) bool { return nonDesiredResources[i].Identifier.Name < nonDesiredResources[j].Identifier.Name }) first := nonDesiredResources[0] - logFn("waiting for resource: name: %s, kind: %s, desired status: %s, actual status: %s", + logFn("waiting for resource: name: %s, kind: %s, desired status: %s, actual status: %s \n", first.Identifier.Name, first.Identifier.GroupKind.Kind, desired, first.Status) } } diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index df16bf7e9..2b10dfef1 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -160,6 +160,18 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured return mapping.Resource } +func getUnstructuredObjsFromManifests(t *testing.T, manifests []string) []runtime.Object { + objects := []runtime.Object{} + for _, manifest := range manifests { + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(manifest), &m) + assert.NoError(t, err) + resource := &unstructured.Unstructured{Object: m} + objects = append(objects, resource) + } + return objects +} + func TestStatusWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { @@ -190,7 +202,6 @@ func TestStatusWaitForDelete(t *testing.T) { fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) fakeMapper := testutil.NewFakeRESTMapper( v1.SchemeGroupVersion.WithKind("Pod"), - appsv1.SchemeGroupVersion.WithKind("Deployment"), batchv1.SchemeGroupVersion.WithKind("Job"), ) statusWaiter := statusWaiter{ @@ -198,31 +209,25 @@ func TestStatusWaitForDelete(t *testing.T) { client: fakeClient, log: t.Logf, } - createdObjs := []runtime.Object{} - for _, manifest := range tt.manifestsToCreate { - m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(manifest), &m) - assert.NoError(t, err) - resource := &unstructured.Unstructured{Object: m} - createdObjs = append(createdObjs, resource) - gvr := getGVR(t, fakeMapper, resource) - err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) + objsToCreate := getUnstructuredObjsFromManifests(t, tt.manifestsToCreate) + for _, objToCreate := range objsToCreate { + u := objToCreate.(*unstructured.Unstructured) + gvr := getGVR(t, fakeMapper, u) + err := fakeClient.Tracker().Create(gvr, u, u.GetNamespace()) assert.NoError(t, err) } - for _, manifest := range tt.manifestsToDelete { - m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(manifest), &m) - assert.NoError(t, err) - resource := &unstructured.Unstructured{Object: m} - gvr := getGVR(t, fakeMapper, resource) + objsToDelete := getUnstructuredObjsFromManifests(t, tt.manifestsToDelete) + for _, objToDelete := range objsToDelete { + u := objToDelete.(*unstructured.Unstructured) + gvr := getGVR(t, fakeMapper, u) go func() { time.Sleep(timeUntilPodDelete) - err = fakeClient.Tracker().Delete(gvr, resource.GetNamespace(), resource.GetName()) + err := fakeClient.Tracker().Delete(gvr, u.GetNamespace(), u.GetName()) assert.NoError(t, err) }() } resourceList := ResourceList{} - for _, obj := range createdObjs { + for _, obj := range objsToCreate { list, err := c.Build(objBody(obj), false) assert.NoError(t, err) resourceList = append(resourceList, list...) @@ -237,6 +242,35 @@ func TestStatusWaitForDelete(t *testing.T) { } } +func TestStatusWaitForDeleteNonExistentObject(t *testing.T) { + t.Parallel() + c := newTestClient(t) + timeout := time.Second + fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme) + fakeMapper := testutil.NewFakeRESTMapper( + v1.SchemeGroupVersion.WithKind("Pod"), + ) + statusWaiter := statusWaiter{ + restMapper: fakeMapper, + client: fakeClient, + log: t.Logf, + } + createdObjs := []runtime.Object{} + m := make(map[string]interface{}) + err := yaml.Unmarshal([]byte(podCurrentManifest), &m) + assert.NoError(t, err) + resource := &unstructured.Unstructured{Object: m} + createdObjs = append(createdObjs, resource) + resourceList := ResourceList{} + for _, obj := range createdObjs { + list, err := c.Build(objBody(obj), false) + assert.NoError(t, err) + resourceList = append(resourceList, list...) + } + err = statusWaiter.WaitForDelete(resourceList, timeout) + assert.NoError(t, err) +} + func TestStatusWait(t *testing.T) { t.Parallel() tests := []struct { From 75292c5e04e2e6684e6470b59e920e31a23d3492 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Feb 2025 04:05:12 +0000 Subject: [PATCH 155/271] refactor Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 40 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 2b10dfef1..d6d7f5e36 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -160,7 +160,7 @@ func getGVR(t *testing.T, mapper meta.RESTMapper, obj *unstructured.Unstructured return mapping.Resource } -func getUnstructuredObjsFromManifests(t *testing.T, manifests []string) []runtime.Object { +func getRuntimeObjFromManifests(t *testing.T, manifests []string) []runtime.Object { objects := []runtime.Object{} for _, manifest := range manifests { m := make(map[string]interface{}) @@ -172,6 +172,16 @@ func getUnstructuredObjsFromManifests(t *testing.T, manifests []string) []runtim return objects } +func getResourceListFromRuntimeObjs(t *testing.T, c *Client, objs []runtime.Object) ResourceList { + resourceList := ResourceList{} + for _, obj := range objs { + list, err := c.Build(objBody(obj), false) + assert.NoError(t, err) + resourceList = append(resourceList, list...) + } + return resourceList +} + func TestStatusWaitForDelete(t *testing.T) { t.Parallel() tests := []struct { @@ -209,14 +219,14 @@ func TestStatusWaitForDelete(t *testing.T) { client: fakeClient, log: t.Logf, } - objsToCreate := getUnstructuredObjsFromManifests(t, tt.manifestsToCreate) + objsToCreate := getRuntimeObjFromManifests(t, tt.manifestsToCreate) for _, objToCreate := range objsToCreate { u := objToCreate.(*unstructured.Unstructured) gvr := getGVR(t, fakeMapper, u) err := fakeClient.Tracker().Create(gvr, u, u.GetNamespace()) assert.NoError(t, err) } - objsToDelete := getUnstructuredObjsFromManifests(t, tt.manifestsToDelete) + objsToDelete := getRuntimeObjFromManifests(t, tt.manifestsToDelete) for _, objToDelete := range objsToDelete { u := objToDelete.(*unstructured.Unstructured) gvr := getGVR(t, fakeMapper, u) @@ -226,12 +236,7 @@ func TestStatusWaitForDelete(t *testing.T) { assert.NoError(t, err) }() } - resourceList := ResourceList{} - for _, obj := range objsToCreate { - list, err := c.Build(objBody(obj), false) - assert.NoError(t, err) - resourceList = append(resourceList, list...) - } + resourceList := getResourceListFromRuntimeObjs(t, c, objsToCreate) err := statusWaiter.WaitForDelete(resourceList, timeout) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) @@ -255,19 +260,10 @@ func TestStatusWaitForDeleteNonExistentObject(t *testing.T) { client: fakeClient, log: t.Logf, } - createdObjs := []runtime.Object{} - m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(podCurrentManifest), &m) - assert.NoError(t, err) - resource := &unstructured.Unstructured{Object: m} - createdObjs = append(createdObjs, resource) - resourceList := ResourceList{} - for _, obj := range createdObjs { - list, err := c.Build(objBody(obj), false) - assert.NoError(t, err) - resourceList = append(resourceList, list...) - } - err = statusWaiter.WaitForDelete(resourceList, timeout) + // Don't create the object to test that the wait for delete works when the object doesn't exist + objManifest := getRuntimeObjFromManifests(t, []string{podCurrentManifest}) + resourceList := getResourceListFromRuntimeObjs(t, c, objManifest) + err := statusWaiter.WaitForDelete(resourceList, timeout) assert.NoError(t, err) } From 4f33e5c97fe4d38e9bcb742b053d9848f84b8e63 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Feb 2025 04:08:51 +0000 Subject: [PATCH 156/271] test refactoring Signed-off-by: Austin Abro --- pkg/kube/statuswait_test.go | 63 ++++++++++--------------------------- 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index d6d7f5e36..0e88f1bbe 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -319,25 +319,14 @@ func TestStatusWait(t *testing.T) { restMapper: fakeMapper, log: t.Logf, } - objs := []runtime.Object{} - - for _, podYaml := range tt.objManifests { - m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(podYaml), &m) - assert.NoError(t, err) - resource := &unstructured.Unstructured{Object: m} - objs = append(objs, resource) - gvr := getGVR(t, fakeMapper, resource) - err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) - assert.NoError(t, err) - } - resourceList := ResourceList{} + objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { - list, err := c.Build(objBody(obj), false) + u := obj.(*unstructured.Unstructured) + gvr := getGVR(t, fakeMapper, u) + err := fakeClient.Tracker().Create(gvr, u, u.GetNamespace()) assert.NoError(t, err) - resourceList = append(resourceList, list...) } - + resourceList := getResourceListFromRuntimeObjs(t, c, objs) err := statusWaiter.Wait(resourceList, time.Second*3) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) @@ -384,24 +373,14 @@ func TestWaitForJobComplete(t *testing.T) { restMapper: fakeMapper, log: t.Logf, } - objs := []runtime.Object{} - for _, podYaml := range tt.objManifests { - m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(podYaml), &m) - assert.NoError(t, err) - resource := &unstructured.Unstructured{Object: m} - objs = append(objs, resource) - gvr := getGVR(t, fakeMapper, resource) - err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) - assert.NoError(t, err) - } - resourceList := ResourceList{} + objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { - list, err := c.Build(objBody(obj), false) + u := obj.(*unstructured.Unstructured) + gvr := getGVR(t, fakeMapper, u) + err := fakeClient.Tracker().Create(gvr, u, u.GetNamespace()) assert.NoError(t, err) - resourceList = append(resourceList, list...) } - + resourceList := getResourceListFromRuntimeObjs(t, c, objs) err := statusWaiter.WaitWithJobs(resourceList, time.Second*3) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) @@ -424,7 +403,7 @@ func TestWatchForReady(t *testing.T) { objManifests: []string{jobCompleteManifest, podCompleteManifest}, }, { - name: "succeeds even when a resource that's not a pod or job is complete", + name: "succeeds when a resource that's not a pod or job is not ready", objManifests: []string{notReadyDeploymentManifest}, }, { @@ -454,24 +433,14 @@ func TestWatchForReady(t *testing.T) { restMapper: fakeMapper, log: t.Logf, } - objs := []runtime.Object{} - for _, podYaml := range tt.objManifests { - m := make(map[string]interface{}) - err := yaml.Unmarshal([]byte(podYaml), &m) - assert.NoError(t, err) - resource := &unstructured.Unstructured{Object: m} - objs = append(objs, resource) - gvr := getGVR(t, fakeMapper, resource) - err = fakeClient.Tracker().Create(gvr, resource, resource.GetNamespace()) - assert.NoError(t, err) - } - resourceList := ResourceList{} + objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { - list, err := c.Build(objBody(obj), false) + u := obj.(*unstructured.Unstructured) + gvr := getGVR(t, fakeMapper, u) + err := fakeClient.Tracker().Create(gvr, u, u.GetNamespace()) assert.NoError(t, err) - resourceList = append(resourceList, list...) } - + resourceList := getResourceListFromRuntimeObjs(t, c, objs) err := statusWaiter.WatchUntilReady(resourceList, time.Second*3) if tt.expectErrs != nil { assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) From 5a254dae2138e830403685527129a46be74c9b8a Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Feb 2025 14:42:14 +0000 Subject: [PATCH 157/271] cleanup Signed-off-by: Austin Abro --- pkg/kube/client.go | 186 ++++++++++----------------------------------- 1 file changed, 42 insertions(+), 144 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index d174614db..333c0ec65 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -18,6 +18,7 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "bytes" + "context" "encoding/json" "fmt" "io" @@ -687,150 +688,47 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, return nil } -// func (c *Client) watchUntilReady(timeout time.Duration, info *resource.Info) error { -// kind := info.Mapping.GroupVersionKind.Kind -// switch kind { -// case "Job", "Pod": -// default: -// return nil -// } - -// c.Log("Watching for changes to %s %s with timeout of %v", kind, info.Name, timeout) - -// // Use a selector on the name of the resource. This should be unique for the -// // given version and kind -// selector, err := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", info.Name)) -// if err != nil { -// return err -// } -// lw := cachetools.NewListWatchFromClient(info.Client, info.Mapping.Resource.Resource, info.Namespace, selector) - -// // What we watch for depends on the Kind. -// // - For a Job, we watch for completion. -// // - For all else, we watch until Ready. -// // In the future, we might want to add some special logic for types -// // like Ingress, Volume, etc. - -// ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) -// defer cancel() -// _, err = watchtools.UntilWithSync(ctx, lw, &unstructured.Unstructured{}, nil, func(e watch.Event) (bool, error) { -// // Make sure the incoming object is versioned as we use unstructured -// // objects when we build manifests -// obj := convertWithMapper(e.Object, info.Mapping) -// switch e.Type { -// case watch.Added, watch.Modified: -// // For things like a secret or a config map, this is the best indicator -// // we get. We care mostly about jobs, where what we want to see is -// // the status go into a good state. For other types, like ReplicaSet -// // we don't really do anything to support these as hooks. -// c.Log("Add/Modify event for %s: %v", info.Name, e.Type) -// switch kind { -// case "Job": -// return c.waitForJob(obj, info.Name) -// case "Pod": -// return c.waitForPodSuccess(obj, info.Name) -// } -// return true, nil -// case watch.Deleted: -// c.Log("Deleted event for %s", info.Name) -// return true, nil -// case watch.Error: -// // Handle error and return with an error. -// c.Log("Error event for %s", info.Name) -// return true, errors.Errorf("failed to deploy %s", info.Name) -// default: -// return false, nil -// } -// }) -// return err -// } - -// // waitForJob is a helper that waits for a job to complete. -// // -// // This operates on an event returned from a watcher. -// func (c *Client) waitForJob(obj runtime.Object, name string) (bool, error) { -// o, ok := obj.(*batch.Job) -// if !ok { -// return true, errors.Errorf("expected %s to be a *batch.Job, got %T", name, obj) -// } - -// for _, c := range o.Status.Conditions { -// if c.Type == batch.JobComplete && c.Status == "True" { -// return true, nil -// } else if c.Type == batch.JobFailed && c.Status == "True" { -// return true, errors.Errorf("job %s failed: %s", name, c.Reason) -// } -// } - -// c.Log("%s: Jobs active: %d, jobs failed: %d, jobs succeeded: %d", name, o.Status.Active, o.Status.Failed, o.Status.Succeeded) -// return false, nil -// } - -// // waitForPodSuccess is a helper that waits for a pod to complete. -// // -// // This operates on an event returned from a watcher. -// func (c *Client) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { -// o, ok := obj.(*v1.Pod) -// if !ok { -// return true, errors.Errorf("expected %s to be a *v1.Pod, got %T", name, obj) -// } - -// switch o.Status.Phase { -// case v1.PodSucceeded: -// c.Log("Pod %s succeeded", o.Name) -// return true, nil -// case v1.PodFailed: -// return true, errors.Errorf("pod %s failed", o.Name) -// case v1.PodPending: -// c.Log("Pod %s pending", o.Name) -// case v1.PodRunning: -// c.Log("Pod %s running", o.Name) -// } - -// return false, nil -// } - -// // GetPodList uses the kubernetes interface to get the list of pods filtered by listOptions -// func (c *Client) GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) { -// podList, err := c.kubeClient.CoreV1().Pods(namespace).List(context.Background(), listOptions) -// if err != nil { -// return nil, fmt.Errorf("failed to get pod list with options: %+v with error: %v", listOptions, err) -// } -// return podList, nil -// } - -// // OutputContainerLogsForPodList is a helper that outputs logs for a list of pods -// func (c *Client) OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writerFunc func(namespace, pod, container string) io.Writer) error { -// for _, pod := range podList.Items { -// for _, container := range pod.Spec.Containers { -// options := &v1.PodLogOptions{ -// Container: container.Name, -// } -// request := c.kubeClient.CoreV1().Pods(namespace).GetLogs(pod.Name, options) -// err2 := copyRequestStreamToWriter(request, pod.Name, container.Name, writerFunc(namespace, pod.Name, container.Name)) -// if err2 != nil { -// return err2 -// } -// } -// } -// return nil -// } - -// func copyRequestStreamToWriter(request *rest.Request, podName, containerName string, writer io.Writer) error { -// readCloser, err := request.Stream(context.Background()) -// if err != nil { -// return errors.Errorf("Failed to stream pod logs for pod: %s, container: %s", podName, containerName) -// } -// defer readCloser.Close() -// _, err = io.Copy(writer, readCloser) -// if err != nil { -// return errors.Errorf("Failed to copy IO from logs for pod: %s, container: %s", podName, containerName) -// } -// if err != nil { -// return errors.Errorf("Failed to close reader for pod: %s, container: %s", podName, containerName) -// } -// return nil -// } +// GetPodList uses the kubernetes interface to get the list of pods filtered by listOptions +func (c *Client) GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) { + podList, err := c.kubeClient.CoreV1().Pods(namespace).List(context.Background(), listOptions) + if err != nil { + return nil, fmt.Errorf("failed to get pod list with options: %+v with error: %v", listOptions, err) + } + return podList, nil +} + +// OutputContainerLogsForPodList is a helper that outputs logs for a list of pods +func (c *Client) OutputContainerLogsForPodList(podList *v1.PodList, namespace string, writerFunc func(namespace, pod, container string) io.Writer) error { + for _, pod := range podList.Items { + for _, container := range pod.Spec.Containers { + options := &v1.PodLogOptions{ + Container: container.Name, + } + request := c.kubeClient.CoreV1().Pods(namespace).GetLogs(pod.Name, options) + err2 := copyRequestStreamToWriter(request, pod.Name, container.Name, writerFunc(namespace, pod.Name, container.Name)) + if err2 != nil { + return err2 + } + } + } + return nil +} + +func copyRequestStreamToWriter(request *rest.Request, podName, containerName string, writer io.Writer) error { + readCloser, err := request.Stream(context.Background()) + if err != nil { + return errors.Errorf("Failed to stream pod logs for pod: %s, container: %s", podName, containerName) + } + defer readCloser.Close() + _, err = io.Copy(writer, readCloser) + if err != nil { + return errors.Errorf("Failed to copy IO from logs for pod: %s, container: %s", podName, containerName) + } + if err != nil { + return errors.Errorf("Failed to close reader for pod: %s, container: %s", podName, containerName) + } + return nil +} // scrubValidationError removes kubectl info from the message. func scrubValidationError(err error) error { From a18589c4d8d8d7f71e26397d51e41ff967038ca2 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Feb 2025 14:42:52 +0000 Subject: [PATCH 158/271] fmt Signed-off-by: Austin Abro --- pkg/kube/statuswait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index baf5814b1..bc3958848 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -188,7 +188,7 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func continue } // If a resource is already deleted before waiting has started, it will show as unknown - // this check ensures we don't wait forever for a resource that is already deleted + // this check ensures we don't wait forever for a resource that is already deleted if rs.Status == status.UnknownStatus && desired == status.NotFoundStatus { continue } From 29c250c233c3efecc2dc7f2a8c1b9810299de5d8 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Feb 2025 16:09:30 +0000 Subject: [PATCH 159/271] add back interface log check Signed-off-by: Austin Abro --- pkg/kube/interface.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index 64d954853..d6ac823f1 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -118,5 +118,6 @@ type InterfaceResources interface { } var _ Interface = (*Client)(nil) +var _ InterfaceLogs = (*Client)(nil) var _ InterfaceDeletionPropagation = (*Client)(nil) var _ InterfaceResources = (*Client)(nil) From 4da004e2dcd2e7e4e0f1512e05cbd19ad3025239 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Tue, 25 Feb 2025 15:15:06 -0500 Subject: [PATCH 160/271] removing old apis Signed-off-by: Robert Sirchia --- pkg/kube/ready.go | 11 ++++------- pkg/kube/ready_test.go | 10 ++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index 584b8853a..dd5869e6a 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -21,11 +21,8 @@ import ( "fmt" appsv1 "k8s.io/api/apps/v1" - appsv1beta1 "k8s.io/api/apps/v1beta1" - appsv1beta2 "k8s.io/api/apps/v1beta2" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -105,7 +102,7 @@ func (c *ReadyChecker) IsReady(ctx context.Context, v *resource.Info) (bool, err ready, err := c.jobReady(job) return ready, err } - case *appsv1.Deployment, *appsv1beta1.Deployment, *appsv1beta2.Deployment, *extensionsv1beta1.Deployment: + case *appsv1.Deployment: currentDeployment, err := c.client.AppsV1().Deployments(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{}) if err != nil { return false, err @@ -138,7 +135,7 @@ func (c *ReadyChecker) IsReady(ctx context.Context, v *resource.Info) (bool, err if !c.serviceReady(svc) { return false, nil } - case *extensionsv1beta1.DaemonSet, *appsv1.DaemonSet, *appsv1beta2.DaemonSet: + case *appsv1.DaemonSet: ds, err := c.client.AppsV1().DaemonSets(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{}) if err != nil { return false, err @@ -168,7 +165,7 @@ func (c *ReadyChecker) IsReady(ctx context.Context, v *resource.Info) (bool, err if !c.crdReady(*crd) { return false, nil } - case *appsv1.StatefulSet, *appsv1beta1.StatefulSet, *appsv1beta2.StatefulSet: + case *appsv1.StatefulSet: sts, err := c.client.AppsV1().StatefulSets(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{}) if err != nil { return false, err @@ -188,7 +185,7 @@ func (c *ReadyChecker) IsReady(ctx context.Context, v *resource.Info) (bool, err if !ready || err != nil { return false, err } - case *extensionsv1beta1.ReplicaSet, *appsv1beta2.ReplicaSet, *appsv1.ReplicaSet: + case *appsv1.ReplicaSet: rs, err := c.client.AppsV1().ReplicaSets(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{}) if err != nil { return false, err diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index ced0a51a8..a8ba05287 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -20,10 +20,8 @@ import ( "testing" appsv1 "k8s.io/api/apps/v1" - appsv1beta1 "k8s.io/api/apps/v1beta1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -523,7 +521,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { }, args: args{ ctx: context.TODO(), - resource: &resource.Info{Object: &appsv1beta1.StatefulSet{}, Name: "foo", Namespace: defaultNamespace}, + resource: &resource.Info{Object: &appsv1.StatefulSet{}, Name: "foo", Namespace: defaultNamespace}, }, ss: newStatefulSet("foo", 1, 0, 0, 1, true), want: false, @@ -539,7 +537,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { }, args: args{ ctx: context.TODO(), - resource: &resource.Info{Object: &appsv1beta1.StatefulSet{}, Name: "foo", Namespace: defaultNamespace}, + resource: &resource.Info{Object: &appsv1.StatefulSet{}, Name: "foo", Namespace: defaultNamespace}, }, ss: newStatefulSet("bar", 1, 0, 1, 1, true), want: false, @@ -689,7 +687,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { }, args: args{ ctx: context.TODO(), - resource: &resource.Info{Object: &extensionsv1beta1.ReplicaSet{}, Name: "foo", Namespace: defaultNamespace}, + resource: &resource.Info{Object: &appsv1.ReplicaSet{}, Name: "foo", Namespace: defaultNamespace}, }, rs: newReplicaSet("foo", 1, 1, true), want: false, @@ -705,7 +703,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { }, args: args{ ctx: context.TODO(), - resource: &resource.Info{Object: &extensionsv1beta1.ReplicaSet{}, Name: "foo", Namespace: defaultNamespace}, + resource: &resource.Info{Object: &appsv1.ReplicaSet{}, Name: "foo", Namespace: defaultNamespace}, }, rs: newReplicaSet("bar", 1, 1, false), want: false, From 61d3eca55c1c7142c3e344537bf3a7a5be4ca0db Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 25 Feb 2025 15:20:44 -0500 Subject: [PATCH 161/271] Move pkg/chart to pkg/chart/v2 to prepare for v3 charts This change moves the code, updates the import locations, and adds a doc.go file to document what the v2 package is for. This is part of HIP 20 for v3 charts Signed-off-by: Matt Farina --- Makefile | 4 +-- cmd/helm/completion_test.go | 2 +- cmd/helm/create.go | 4 +-- cmd/helm/create_test.go | 6 ++--- cmd/helm/dependency_build_test.go | 2 +- cmd/helm/dependency_update_test.go | 4 +-- cmd/helm/flags_test.go | 2 +- cmd/helm/helm_test.go | 2 +- cmd/helm/history.go | 2 +- cmd/helm/install.go | 4 +-- cmd/helm/lint.go | 2 +- cmd/helm/list_test.go | 2 +- cmd/helm/package_test.go | 4 +-- cmd/helm/rollback_test.go | 2 +- cmd/helm/search/search_test.go | 2 +- cmd/helm/status.go | 2 +- cmd/helm/status_test.go | 2 +- cmd/helm/template.go | 2 +- cmd/helm/upgrade.go | 2 +- cmd/helm/upgrade_test.go | 6 ++--- internal/monocular/search.go | 2 +- internal/resolver/resolver.go | 4 +-- internal/resolver/resolver_test.go | 2 +- pkg/action/action.go | 4 +-- pkg/action/action_test.go | 4 +-- pkg/action/dependency.go | 4 +-- pkg/action/dependency_test.go | 4 +-- pkg/action/get_metadata.go | 2 +- pkg/action/get_values.go | 2 +- pkg/action/history.go | 2 +- pkg/action/hooks_test.go | 2 +- pkg/action/install.go | 4 +-- pkg/action/install_test.go | 4 +-- pkg/action/lint.go | 2 +- pkg/action/package.go | 4 +-- pkg/action/pull.go | 2 +- pkg/action/release_testing.go | 2 +- pkg/action/rollback.go | 2 +- pkg/action/show.go | 6 ++--- pkg/action/show_test.go | 2 +- pkg/action/uninstall.go | 2 +- pkg/action/upgrade.go | 4 +-- pkg/action/upgrade_test.go | 2 +- pkg/chart/{ => v2}/chart.go | 2 +- pkg/chart/{ => v2}/chart_test.go | 2 +- pkg/chart/{ => v2}/dependency.go | 2 +- pkg/chart/{ => v2}/dependency_test.go | 2 +- pkg/chart/v2/doc.go | 23 ++++++++++++++++++ pkg/chart/{ => v2}/errors.go | 2 +- pkg/chart/{ => v2}/file.go | 2 +- pkg/chart/{ => v2}/fuzz_test.go | 2 +- pkg/chart/{ => v2}/loader/archive.go | 2 +- pkg/chart/{ => v2}/loader/archive_test.go | 0 pkg/chart/{ => v2}/loader/directory.go | 2 +- pkg/chart/{ => v2}/loader/load.go | 2 +- pkg/chart/{ => v2}/loader/load_test.go | 2 +- pkg/chart/{ => v2}/loader/testdata/LICENSE | 0 .../loader/testdata/albatross/Chart.yaml | 0 .../loader/testdata/albatross/values.yaml | 0 .../loader/testdata/frobnitz-1.2.3.tgz | Bin .../{ => v2}/loader/testdata/frobnitz.v1.tgz | Bin .../loader/testdata/frobnitz.v1/.helmignore | 0 .../loader/testdata/frobnitz.v1/Chart.lock | 0 .../loader/testdata/frobnitz.v1/Chart.yaml | 0 .../loader/testdata/frobnitz.v1/INSTALL.txt | 0 .../loader/testdata/frobnitz.v1/LICENSE | 0 .../loader/testdata/frobnitz.v1/README.md | 0 .../testdata/frobnitz.v1/charts/_ignore_me | 0 .../frobnitz.v1/charts/alpine/Chart.yaml | 0 .../frobnitz.v1/charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../frobnitz.v1/charts/alpine/values.yaml | 0 .../frobnitz.v1/charts/mariner-4.3.2.tgz | Bin .../testdata/frobnitz.v1/docs/README.md | 0 .../loader/testdata/frobnitz.v1/icon.svg | 0 .../loader/testdata/frobnitz.v1/ignore/me.txt | 0 .../testdata/frobnitz.v1/requirements.yaml | 0 .../frobnitz.v1/templates/template.tpl | 0 .../loader/testdata/frobnitz.v1/values.yaml | 0 .../testdata/frobnitz.v2.reqs/.helmignore | 0 .../testdata/frobnitz.v2.reqs/Chart.yaml | 0 .../testdata/frobnitz.v2.reqs/INSTALL.txt | 0 .../loader/testdata/frobnitz.v2.reqs/LICENSE | 0 .../testdata/frobnitz.v2.reqs/README.md | 0 .../frobnitz.v2.reqs/charts/_ignore_me | 0 .../frobnitz.v2.reqs/charts/alpine/Chart.yaml | 0 .../frobnitz.v2.reqs/charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../frobnitz.v2.reqs/charts/mariner-4.3.2.tgz | Bin .../testdata/frobnitz.v2.reqs/docs/README.md | 0 .../loader/testdata/frobnitz.v2.reqs/icon.svg | 0 .../testdata/frobnitz.v2.reqs/ignore/me.txt | 0 .../frobnitz.v2.reqs/requirements.yaml | 0 .../frobnitz.v2.reqs/templates/template.tpl | 0 .../testdata/frobnitz.v2.reqs/values.yaml | 0 .../loader/testdata/frobnitz/.helmignore | 0 .../loader/testdata/frobnitz/Chart.lock | 0 .../loader/testdata/frobnitz/Chart.yaml | 0 .../loader/testdata/frobnitz/INSTALL.txt | 0 .../{ => v2}/loader/testdata/frobnitz/LICENSE | 0 .../loader/testdata/frobnitz/README.md | 0 .../testdata/frobnitz/charts/_ignore_me | 0 .../frobnitz/charts/alpine/Chart.yaml | 0 .../testdata/frobnitz/charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../frobnitz/charts/alpine/values.yaml | 0 .../frobnitz/charts/mariner-4.3.2.tgz | Bin .../loader/testdata/frobnitz/docs/README.md | 0 .../loader/testdata/frobnitz/icon.svg | 0 .../loader/testdata/frobnitz/ignore/me.txt | 0 .../testdata/frobnitz/templates/template.tpl | 0 .../loader/testdata/frobnitz/values.yaml | 0 .../testdata/frobnitz_backslash-1.2.3.tgz | Bin .../testdata/frobnitz_backslash/.helmignore | 0 .../testdata/frobnitz_backslash/Chart.lock | 0 .../testdata/frobnitz_backslash/Chart.yaml | 0 .../testdata/frobnitz_backslash/INSTALL.txt | 0 .../testdata/frobnitz_backslash/LICENSE | 0 .../testdata/frobnitz_backslash/README.md | 0 .../frobnitz_backslash/charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../frobnitz_backslash/docs/README.md | 0 .../testdata/frobnitz_backslash/icon.svg | 0 .../testdata/frobnitz_backslash/ignore/me.txt | 0 .../frobnitz_backslash/templates/template.tpl | 0 .../testdata/frobnitz_backslash/values.yaml | 0 .../loader/testdata/frobnitz_with_bom.tgz | Bin .../testdata/frobnitz_with_bom/.helmignore | 0 .../testdata/frobnitz_with_bom/Chart.lock | 0 .../testdata/frobnitz_with_bom/Chart.yaml | 0 .../testdata/frobnitz_with_bom/INSTALL.txt | 0 .../loader/testdata/frobnitz_with_bom/LICENSE | 0 .../testdata/frobnitz_with_bom/README.md | 0 .../frobnitz_with_bom/charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../frobnitz_with_bom/charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../testdata/frobnitz_with_bom/docs/README.md | 0 .../testdata/frobnitz_with_bom/icon.svg | 0 .../testdata/frobnitz_with_bom/ignore/me.txt | 0 .../frobnitz_with_bom/templates/template.tpl | 0 .../testdata/frobnitz_with_bom/values.yaml | 0 .../frobnitz_with_dev_null/.helmignore | 0 .../frobnitz_with_dev_null/Chart.lock | 0 .../frobnitz_with_dev_null/Chart.yaml | 0 .../frobnitz_with_dev_null/INSTALL.txt | 0 .../testdata/frobnitz_with_dev_null/LICENSE | 0 .../testdata/frobnitz_with_dev_null/README.md | 0 .../frobnitz_with_dev_null/charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../frobnitz_with_dev_null/docs/README.md | 0 .../testdata/frobnitz_with_dev_null/icon.svg | 0 .../frobnitz_with_dev_null/ignore/me.txt | 0 .../testdata/frobnitz_with_dev_null/null | 0 .../templates/template.tpl | 0 .../frobnitz_with_dev_null/values.yaml | 0 .../frobnitz_with_symlink/.helmignore | 0 .../testdata/frobnitz_with_symlink/Chart.lock | 0 .../testdata/frobnitz_with_symlink/Chart.yaml | 0 .../frobnitz_with_symlink/INSTALL.txt | 0 .../testdata/frobnitz_with_symlink/README.md | 0 .../frobnitz_with_symlink/charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../frobnitz_with_symlink/docs/README.md | 0 .../testdata/frobnitz_with_symlink/icon.svg | 0 .../frobnitz_with_symlink/ignore/me.txt | 0 .../templates/template.tpl | 0 .../frobnitz_with_symlink/values.yaml | 0 pkg/chart/{ => v2}/loader/testdata/genfrob.sh | 0 .../loader/testdata/mariner/Chart.yaml | 0 .../mariner/charts/albatross-0.1.0.tgz | Bin .../mariner/templates/placeholder.tpl | 0 .../loader/testdata/mariner/values.yaml | 0 pkg/chart/{ => v2}/metadata.go | 2 +- pkg/chart/{ => v2}/metadata_test.go | 2 +- pkg/chart/{ => v2}/util/capabilities.go | 0 pkg/chart/{ => v2}/util/capabilities_test.go | 0 pkg/chart/{ => v2}/util/chartfile.go | 2 +- pkg/chart/{ => v2}/util/chartfile_test.go | 2 +- pkg/chart/{ => v2}/util/coalesce.go | 2 +- pkg/chart/{ => v2}/util/coalesce_test.go | 2 +- pkg/chart/{ => v2}/util/compatible.go | 0 pkg/chart/{ => v2}/util/compatible_test.go | 0 pkg/chart/{ => v2}/util/create.go | 4 +-- pkg/chart/{ => v2}/util/create_test.go | 4 +-- pkg/chart/{ => v2}/util/dependencies.go | 2 +- pkg/chart/{ => v2}/util/dependencies_test.go | 4 +-- pkg/chart/{ => v2}/util/doc.go | 2 +- pkg/chart/{ => v2}/util/errors.go | 0 pkg/chart/{ => v2}/util/errors_test.go | 0 pkg/chart/{ => v2}/util/expand.go | 4 +-- pkg/chart/{ => v2}/util/expand_test.go | 0 pkg/chart/{ => v2}/util/jsonschema.go | 2 +- pkg/chart/{ => v2}/util/jsonschema_test.go | 2 +- pkg/chart/{ => v2}/util/save.go | 2 +- pkg/chart/{ => v2}/util/save_test.go | 4 +-- .../{ => v2}/util/testdata/chartfiletest.yaml | 0 .../{ => v2}/util/testdata/coleridge.yaml | 0 .../dependent-chart-alias/.helmignore | 0 .../testdata/dependent-chart-alias/Chart.lock | 0 .../testdata/dependent-chart-alias/Chart.yaml | 0 .../dependent-chart-alias/INSTALL.txt | 0 .../testdata/dependent-chart-alias/LICENSE | 0 .../testdata/dependent-chart-alias/README.md | 0 .../dependent-chart-alias/charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../dependent-chart-alias/docs/README.md | 0 .../testdata/dependent-chart-alias/icon.svg | 0 .../dependent-chart-alias/ignore/me.txt | 0 .../templates/template.tpl | 0 .../dependent-chart-alias/values.yaml | 0 .../dependent-chart-helmignore/.helmignore | 0 .../dependent-chart-helmignore/Chart.yaml | 0 .../charts/.ignore_me | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../templates/template.tpl | 0 .../dependent-chart-helmignore/values.yaml | 0 .../.helmignore | 0 .../Chart.yaml | 0 .../INSTALL.txt | 0 .../LICENSE | 0 .../README.md | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../docs/README.md | 0 .../icon.svg | 0 .../ignore/me.txt | 0 .../templates/template.tpl | 0 .../values.yaml | 0 .../.helmignore | 0 .../Chart.yaml | 0 .../INSTALL.txt | 0 .../LICENSE | 0 .../README.md | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../docs/README.md | 0 .../icon.svg | 0 .../ignore/me.txt | 0 .../templates/template.tpl | 0 .../values.yaml | 0 .../.helmignore | 0 .../Chart.yaml | 0 .../INSTALL.txt | 0 .../LICENSE | 0 .../README.md | 0 .../charts/_ignore_me | 0 .../charts/alpine/Chart.yaml | 0 .../charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../charts/alpine/values.yaml | 0 .../charts/mariner-4.3.2.tgz | Bin .../docs/README.md | 0 .../icon.svg | 0 .../ignore/me.txt | 0 .../templates/template.tpl | 0 .../values.yaml | 0 .../{ => v2}/util/testdata/frobnitz-1.2.3.tgz | Bin .../util/testdata/frobnitz/.helmignore | 0 .../util/testdata/frobnitz/Chart.lock | 0 .../util/testdata/frobnitz/Chart.yaml | 0 .../util/testdata/frobnitz/INSTALL.txt | 0 .../{ => v2}/util/testdata/frobnitz/LICENSE | 0 .../{ => v2}/util/testdata/frobnitz/README.md | 0 .../util/testdata/frobnitz/charts/_ignore_me | 0 .../frobnitz/charts/alpine/Chart.yaml | 0 .../testdata/frobnitz/charts/alpine/README.md | 0 .../charts/alpine/charts/mast1/Chart.yaml | 0 .../charts/alpine/charts/mast1/values.yaml | 0 .../charts/alpine/charts/mast2-0.1.0.tgz | Bin .../charts/alpine/templates/alpine-pod.yaml | 0 .../frobnitz/charts/alpine/values.yaml | 0 .../frobnitz/charts/mariner/Chart.yaml | 0 .../mariner/charts/albatross/Chart.yaml | 0 .../mariner/charts/albatross/values.yaml | 0 .../charts/mariner/templates/placeholder.tpl | 0 .../frobnitz/charts/mariner/values.yaml | 0 .../util/testdata/frobnitz/docs/README.md | 0 .../{ => v2}/util/testdata/frobnitz/icon.svg | 0 .../util/testdata/frobnitz/ignore/me.txt | 0 .../testdata/frobnitz/templates/template.tpl | 0 .../util/testdata/frobnitz/values.yaml | 0 .../testdata/frobnitz_backslash-1.2.3.tgz | Bin pkg/chart/{ => v2}/util/testdata/genfrob.sh | 0 .../parent-chart/Chart.lock | 0 .../parent-chart/Chart.yaml | 0 .../parent-chart/charts/dev-v0.1.0.tgz | Bin .../parent-chart/charts/prod-v0.1.0.tgz | Bin .../parent-chart/envs/dev/Chart.yaml | 0 .../parent-chart/envs/dev/values.yaml | 0 .../parent-chart/envs/prod/Chart.yaml | 0 .../parent-chart/envs/prod/values.yaml | 0 .../parent-chart/templates/autoscaler.yaml | 0 .../parent-chart/values.yaml | 0 .../{ => v2}/util/testdata/joonix/Chart.yaml | 0 .../util/testdata/joonix/charts/.gitkeep | 0 .../{ => v2}/util/testdata/subpop/Chart.yaml | 0 .../{ => v2}/util/testdata/subpop/README.md | 0 .../subpop/charts/subchart1/Chart.yaml | 0 .../subchart1/charts/subchartA/Chart.yaml | 0 .../charts/subchartA/templates/service.yaml | 0 .../subchart1/charts/subchartA/values.yaml | 0 .../subchart1/charts/subchartB/Chart.yaml | 0 .../charts/subchartB/templates/service.yaml | 0 .../subchart1/charts/subchartB/values.yaml | 0 .../subpop/charts/subchart1/crds/crdA.yaml | 0 .../charts/subchart1/templates/NOTES.txt | 0 .../charts/subchart1/templates/service.yaml | 0 .../subchart1/templates/subdir/role.yaml | 0 .../templates/subdir/rolebinding.yaml | 0 .../templates/subdir/serviceaccount.yaml | 0 .../subpop/charts/subchart1/values.yaml | 0 .../subpop/charts/subchart2/Chart.yaml | 0 .../subchart2/charts/subchartB/Chart.yaml | 0 .../charts/subchartB/templates/service.yaml | 0 .../subchart2/charts/subchartB/values.yaml | 0 .../subchart2/charts/subchartC/Chart.yaml | 0 .../charts/subchartC/templates/service.yaml | 0 .../subchart2/charts/subchartC/values.yaml | 0 .../charts/subchart2/templates/service.yaml | 0 .../subpop/charts/subchart2/values.yaml | 0 .../util/testdata/subpop/noreqs/Chart.yaml | 0 .../subpop/noreqs/templates/service.yaml | 0 .../util/testdata/subpop/noreqs/values.yaml | 0 .../{ => v2}/util/testdata/subpop/values.yaml | 0 .../testdata/test-values-invalid.schema.json | 0 .../util/testdata/test-values-negative.yaml | 0 .../util/testdata/test-values.schema.json | 0 .../{ => v2}/util/testdata/test-values.yaml | 0 .../three-level-dependent-chart/README.md | 0 .../umbrella/Chart.yaml | 0 .../umbrella/charts/app1/Chart.yaml | 0 .../charts/app1/charts/library/Chart.yaml | 0 .../charts/library/templates/service.yaml | 0 .../charts/app1/charts/library/values.yaml | 0 .../charts/app1/templates/service.yaml | 0 .../umbrella/charts/app1/values.yaml | 0 .../umbrella/charts/app2/Chart.yaml | 0 .../charts/app2/charts/library/Chart.yaml | 0 .../charts/library/templates/service.yaml | 0 .../charts/app2/charts/library/values.yaml | 0 .../charts/app2/templates/service.yaml | 0 .../umbrella/charts/app2/values.yaml | 0 .../umbrella/charts/app3/Chart.yaml | 0 .../charts/app3/charts/library/Chart.yaml | 0 .../charts/library/templates/service.yaml | 0 .../charts/app3/charts/library/values.yaml | 0 .../charts/app3/templates/service.yaml | 0 .../umbrella/charts/app3/values.yaml | 0 .../umbrella/charts/app4/Chart.yaml | 0 .../charts/app4/charts/library/Chart.yaml | 0 .../charts/library/templates/service.yaml | 0 .../charts/app4/charts/library/values.yaml | 0 .../charts/app4/templates/service.yaml | 0 .../umbrella/charts/app4/values.yaml | 0 .../umbrella/values.yaml | 0 pkg/chart/{ => v2}/util/validate_name.go | 0 pkg/chart/{ => v2}/util/validate_name_test.go | 0 pkg/chart/{ => v2}/util/values.go | 2 +- pkg/chart/{ => v2}/util/values_test.go | 2 +- pkg/cli/values/options.go | 2 +- pkg/downloader/manager.go | 6 ++--- pkg/downloader/manager_test.go | 6 ++--- pkg/engine/engine.go | 4 +-- pkg/engine/engine_test.go | 4 +-- pkg/engine/files.go | 2 +- pkg/lint/lint.go | 2 +- pkg/lint/lint_test.go | 2 +- pkg/lint/rules/chartfile.go | 4 +-- pkg/lint/rules/chartfile_test.go | 4 +-- pkg/lint/rules/dependencies.go | 4 +-- pkg/lint/rules/dependencies_test.go | 4 +-- pkg/lint/rules/deprecations.go | 2 +- pkg/lint/rules/template.go | 4 +-- pkg/lint/rules/template_test.go | 4 +-- pkg/lint/rules/values.go | 2 +- pkg/provenance/sign.go | 4 +-- pkg/pusher/ocipusher.go | 2 +- pkg/registry/client.go | 2 +- pkg/registry/util.go | 4 +-- pkg/registry/util_test.go | 2 +- pkg/release/mock.go | 2 +- pkg/release/release.go | 4 ++- pkg/release/util/manifest_sorter.go | 2 +- pkg/repo/chartrepo.go | 2 +- pkg/repo/chartrepo_test.go | 2 +- pkg/repo/index.go | 4 +-- pkg/repo/index_test.go | 2 +- pkg/repo/repotest/server.go | 6 ++--- 456 files changed, 168 insertions(+), 143 deletions(-) rename pkg/chart/{ => v2}/chart.go (99%) rename pkg/chart/{ => v2}/chart_test.go (99%) rename pkg/chart/{ => v2}/dependency.go (99%) rename pkg/chart/{ => v2}/dependency_test.go (98%) create mode 100644 pkg/chart/v2/doc.go rename pkg/chart/{ => v2}/errors.go (98%) rename pkg/chart/{ => v2}/file.go (98%) rename pkg/chart/{ => v2}/fuzz_test.go (98%) rename pkg/chart/{ => v2}/loader/archive.go (99%) rename pkg/chart/{ => v2}/loader/archive_test.go (100%) rename pkg/chart/{ => v2}/loader/directory.go (98%) rename pkg/chart/{ => v2}/loader/load.go (99%) rename pkg/chart/{ => v2}/loader/load_test.go (99%) rename pkg/chart/{ => v2}/loader/testdata/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/albatross/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/albatross/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz-1.2.3.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/Chart.lock (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/requirements.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/requirements.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz.v2.reqs/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/Chart.lock (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash-1.2.3.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/Chart.lock (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_backslash/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/Chart.lock (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_bom/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/Chart.lock (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/LICENSE (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/null (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_dev_null/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/.helmignore (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/Chart.lock (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/INSTALL.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/docs/README.md (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/icon.svg (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/ignore/me.txt (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/templates/template.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/frobnitz_with_symlink/values.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/genfrob.sh (100%) rename pkg/chart/{ => v2}/loader/testdata/mariner/Chart.yaml (100%) rename pkg/chart/{ => v2}/loader/testdata/mariner/charts/albatross-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/loader/testdata/mariner/templates/placeholder.tpl (100%) rename pkg/chart/{ => v2}/loader/testdata/mariner/values.yaml (100%) rename pkg/chart/{ => v2}/metadata.go (99%) rename pkg/chart/{ => v2}/metadata_test.go (99%) rename pkg/chart/{ => v2}/util/capabilities.go (100%) rename pkg/chart/{ => v2}/util/capabilities_test.go (100%) rename pkg/chart/{ => v2}/util/chartfile.go (98%) rename pkg/chart/{ => v2}/util/chartfile_test.go (98%) rename pkg/chart/{ => v2}/util/coalesce.go (99%) rename pkg/chart/{ => v2}/util/coalesce_test.go (99%) rename pkg/chart/{ => v2}/util/compatible.go (100%) rename pkg/chart/{ => v2}/util/compatible_test.go (100%) rename pkg/chart/{ => v2}/util/create.go (99%) rename pkg/chart/{ => v2}/util/create_test.go (98%) rename pkg/chart/{ => v2}/util/dependencies.go (99%) rename pkg/chart/{ => v2}/util/dependencies_test.go (99%) rename pkg/chart/{ => v2}/util/doc.go (95%) rename pkg/chart/{ => v2}/util/errors.go (100%) rename pkg/chart/{ => v2}/util/errors_test.go (100%) rename pkg/chart/{ => v2}/util/expand.go (96%) rename pkg/chart/{ => v2}/util/expand_test.go (100%) rename pkg/chart/{ => v2}/util/jsonschema.go (98%) rename pkg/chart/{ => v2}/util/jsonschema_test.go (99%) rename pkg/chart/{ => v2}/util/save.go (99%) rename pkg/chart/{ => v2}/util/save_test.go (98%) rename pkg/chart/{ => v2}/util/testdata/chartfiletest.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/coleridge.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/.helmignore (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/Chart.lock (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/INSTALL.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/LICENSE (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/docs/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/icon.svg (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/ignore/me.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/templates/template.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-alias/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/.helmignore (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/.ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/templates/template.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-helmignore/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/.helmignore (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/LICENSE (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/icon.svg (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-no-requirements-yaml/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz-1.2.3.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/.helmignore (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/Chart.lock (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/INSTALL.txt (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/LICENSE (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/_ignore_me (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/alpine/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/mariner/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/charts/mariner/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/docs/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/icon.svg (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/ignore/me.txt (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/templates/template.tpl (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/frobnitz_backslash-1.2.3.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/genfrob.sh (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/joonix/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/joonix/charts/.gitkeep (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/crds/crdA.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/templates/NOTES.txt (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/charts/subchart2/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/noreqs/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/noreqs/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/noreqs/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/subpop/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/test-values-invalid.schema.json (100%) rename pkg/chart/{ => v2}/util/testdata/test-values-negative.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/test-values.schema.json (100%) rename pkg/chart/{ => v2}/util/testdata/test-values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/README.md (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml (100%) rename pkg/chart/{ => v2}/util/testdata/three-level-dependent-chart/umbrella/values.yaml (100%) rename pkg/chart/{ => v2}/util/validate_name.go (100%) rename pkg/chart/{ => v2}/util/validate_name_test.go (100%) rename pkg/chart/{ => v2}/util/values.go (99%) rename pkg/chart/{ => v2}/util/values_test.go (99%) diff --git a/Makefile b/Makefile index d2c82b033..21144cf5a 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,8 @@ K8S_MODULES_MINOR_VER=$(word 2,$(K8S_MODULES_VER)) LDFLAGS += -X helm.sh/helm/v4/pkg/lint/rules.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER) LDFLAGS += -X helm.sh/helm/v4/pkg/lint/rules.k8sVersionMinor=$(K8S_MODULES_MINOR_VER) -LDFLAGS += -X helm.sh/helm/v4/pkg/chart/util.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER) -LDFLAGS += -X helm.sh/helm/v4/pkg/chart/util.k8sVersionMinor=$(K8S_MODULES_MINOR_VER) +LDFLAGS += -X helm.sh/helm/v4/pkg/chart/v2/util.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER) +LDFLAGS += -X helm.sh/helm/v4/pkg/chart/v2/util.k8sVersionMinor=$(K8S_MODULES_MINOR_VER) .PHONY: all all: build diff --git a/cmd/helm/completion_test.go b/cmd/helm/completion_test.go index 4dd427232..3d8383519 100644 --- a/cmd/helm/completion_test.go +++ b/cmd/helm/completion_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/release" ) diff --git a/cmd/helm/create.go b/cmd/helm/create.go index a18f2c915..11c208231 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -24,8 +24,8 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v4/cmd/helm/require" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/helmpath" ) diff --git a/cmd/helm/create_test.go b/cmd/helm/create_test.go index 76fce804c..a8361329e 100644 --- a/cmd/helm/create_test.go +++ b/cmd/helm/create_test.go @@ -23,9 +23,9 @@ import ( "testing" "helm.sh/helm/v4/internal/test/ensure" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/helmpath" ) diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index 76c01d911..022621fe4 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/provenance" "helm.sh/helm/v4/pkg/repo" "helm.sh/helm/v4/pkg/repo/repotest" diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 0732ba7b5..855675f78 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -23,8 +23,8 @@ import ( "testing" "helm.sh/helm/v4/internal/test/ensure" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/provenance" "helm.sh/helm/v4/pkg/repo" diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go index 295f55022..3a9d7e6ef 100644 --- a/cmd/helm/flags_test.go +++ b/cmd/helm/flags_test.go @@ -20,7 +20,7 @@ import ( "fmt" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index e7a05aecf..cfffa6dc7 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -30,7 +30,7 @@ import ( "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/action" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 2c929c161..a47f97688 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -27,7 +27,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" diff --git a/cmd/helm/install.go b/cmd/helm/install.go index fe09dfc53..12f87cd20 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -32,8 +32,8 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/downloader" diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 3e37922b2..279c5d34a 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -27,7 +27,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v4/pkg/action" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/lint/support" diff --git a/cmd/helm/list_test.go b/cmd/helm/list_test.go index 01b6d7490..6a462ee28 100644 --- a/cmd/helm/list_test.go +++ b/cmd/helm/list_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/release" "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/package_test.go b/cmd/helm/package_test.go index 107928765..b86bae294 100644 --- a/cmd/helm/package_test.go +++ b/cmd/helm/package_test.go @@ -23,8 +23,8 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) func TestPackage(t *testing.T) { diff --git a/cmd/helm/rollback_test.go b/cmd/helm/rollback_test.go index a94327e07..88dbf6524 100644 --- a/cmd/helm/rollback_test.go +++ b/cmd/helm/rollback_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/release" ) diff --git a/cmd/helm/search/search_test.go b/cmd/helm/search/search_test.go index 175491b36..7a4ba786b 100644 --- a/cmd/helm/search/search_test.go +++ b/cmd/helm/search/search_test.go @@ -20,7 +20,7 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/repo" ) diff --git a/cmd/helm/status.go b/cmd/helm/status.go index fd3e4ce14..727c3df9e 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -30,7 +30,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/release" ) diff --git a/cmd/helm/status_test.go b/cmd/helm/status_test.go index 1973fe068..7e51849b1 100644 --- a/cmd/helm/status_test.go +++ b/cmd/helm/status_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 212664dc8..c41373337 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -34,7 +34,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli/values" releaseutil "helm.sh/helm/v4/pkg/release/util" ) diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 6684f9ebf..7d6cb33ec 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -31,7 +31,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" - "helm.sh/helm/v4/pkg/chart/loader" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/downloader" diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index f97a4a26b..595ca9fc2 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -24,9 +24,9 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/internal/monocular/search.go b/internal/monocular/search.go index d6d454653..6912be2ce 100644 --- a/internal/monocular/search.go +++ b/internal/monocular/search.go @@ -25,7 +25,7 @@ import ( "time" "helm.sh/helm/v4/internal/version" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // SearchPath is the url path to the search API in monocular. diff --git a/internal/resolver/resolver.go b/internal/resolver/resolver.go index 74348176d..42c9de3b7 100644 --- a/internal/resolver/resolver.go +++ b/internal/resolver/resolver.go @@ -27,8 +27,8 @@ import ( "github.com/Masterminds/semver/v3" "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/provenance" "helm.sh/helm/v4/pkg/registry" diff --git a/internal/resolver/resolver_test.go b/internal/resolver/resolver_test.go index f7ea06fdf..1e33837a9 100644 --- a/internal/resolver/resolver_test.go +++ b/internal/resolver/resolver_test.go @@ -19,7 +19,7 @@ import ( "runtime" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/registry" ) diff --git a/pkg/action/action.go b/pkg/action/action.go index eeaebc15f..d91ccab51 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -33,8 +33,8 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/engine" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index aa5d589f8..4c78ef6c1 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -24,8 +24,8 @@ import ( "github.com/stretchr/testify/assert" fakeclientset "k8s.io/client-go/kubernetes/fake" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/release" diff --git a/pkg/action/dependency.go b/pkg/action/dependency.go index e0ff56cce..03c370c8e 100644 --- a/pkg/action/dependency.go +++ b/pkg/action/dependency.go @@ -26,8 +26,8 @@ import ( "github.com/Masterminds/semver/v3" "github.com/gosuri/uitable" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) // Dependency is the action for building a given chart's dependency tree. diff --git a/pkg/action/dependency_test.go b/pkg/action/dependency_test.go index 38f2668ae..5be7bf5a9 100644 --- a/pkg/action/dependency_test.go +++ b/pkg/action/dependency_test.go @@ -25,8 +25,8 @@ import ( "github.com/stretchr/testify/assert" "helm.sh/helm/v4/internal/test" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" ) func TestList(t *testing.T) { diff --git a/pkg/action/get_metadata.go b/pkg/action/get_metadata.go index 190e9ccb9..e760ae4d1 100644 --- a/pkg/action/get_metadata.go +++ b/pkg/action/get_metadata.go @@ -21,7 +21,7 @@ import ( "strings" "time" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // GetMetadata is the action for checking a given release's metadata. diff --git a/pkg/action/get_values.go b/pkg/action/get_values.go index 21253b7aa..18b8b4838 100644 --- a/pkg/action/get_values.go +++ b/pkg/action/get_values.go @@ -17,7 +17,7 @@ limitations under the License. package action import ( - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" ) // GetValues is the action for checking a given release's values. diff --git a/pkg/action/history.go b/pkg/action/history.go index 1c5cfa86f..e5ac16bfe 100644 --- a/pkg/action/history.go +++ b/pkg/action/history.go @@ -19,7 +19,7 @@ package action import ( "github.com/pkg/errors" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/action/hooks_test.go b/pkg/action/hooks_test.go index 0f4a9be34..b39ffe022 100644 --- a/pkg/action/hooks_test.go +++ b/pkg/action/hooks_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/action/install.go b/pkg/action/install.go index 68c1848f6..ad260c361 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -39,8 +39,8 @@ import ( "k8s.io/cli-runtime/pkg/resource" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 9d90accc5..09715daf3 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -33,8 +33,8 @@ import ( "github.com/stretchr/testify/require" "helm.sh/helm/v4/internal/test" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/release" "helm.sh/helm/v4/pkg/storage/driver" diff --git a/pkg/action/lint.go b/pkg/action/lint.go index a6fd7c71c..451eb65b0 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/action/package.go b/pkg/action/package.go index 8343ba109..9ffe1722e 100644 --- a/pkg/action/package.go +++ b/pkg/action/package.go @@ -26,8 +26,8 @@ import ( "github.com/pkg/errors" "golang.org/x/term" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/provenance" ) diff --git a/pkg/action/pull.go b/pkg/action/pull.go index fa85fe242..eb208ca7b 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index a2c68ad64..b4cdb47c8 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -27,7 +27,7 @@ import ( "github.com/pkg/errors" v1 "k8s.io/api/core/v1" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 961ef8377..0cd9d5d07 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/release" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/show.go b/pkg/action/show.go index 3b2722eef..8f9da58e9 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -25,9 +25,9 @@ import ( "k8s.io/cli-runtime/pkg/printers" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/registry" ) diff --git a/pkg/action/show_test.go b/pkg/action/show_test.go index e8c998198..b1c5d6164 100644 --- a/pkg/action/show_test.go +++ b/pkg/action/show_test.go @@ -19,7 +19,7 @@ package action import ( "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) func TestShow(t *testing.T) { diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 6e71197f6..bfec35fc0 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -24,7 +24,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index fa799ad2b..340f61585 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -28,8 +28,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cli-runtime/pkg/resource" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" diff --git a/pkg/action/upgrade_test.go b/pkg/action/upgrade_test.go index 5437490cb..069578025 100644 --- a/pkg/action/upgrade_test.go +++ b/pkg/action/upgrade_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/storage/driver" "github.com/stretchr/testify/assert" diff --git a/pkg/chart/chart.go b/pkg/chart/v2/chart.go similarity index 99% rename from pkg/chart/chart.go rename to pkg/chart/v2/chart.go index a3bed63a3..dcc2a43eb 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/v2/chart.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart +package v2 import ( "path/filepath" diff --git a/pkg/chart/chart_test.go b/pkg/chart/v2/chart_test.go similarity index 99% rename from pkg/chart/chart_test.go rename to pkg/chart/v2/chart_test.go index 62d60765c..d6311085b 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/v2/chart_test.go @@ -13,7 +13,7 @@ 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 chart +package v2 import ( "encoding/json" diff --git a/pkg/chart/dependency.go b/pkg/chart/v2/dependency.go similarity index 99% rename from pkg/chart/dependency.go rename to pkg/chart/v2/dependency.go index eda0f5a89..8a590a036 100644 --- a/pkg/chart/dependency.go +++ b/pkg/chart/v2/dependency.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart +package v2 import "time" diff --git a/pkg/chart/dependency_test.go b/pkg/chart/v2/dependency_test.go similarity index 98% rename from pkg/chart/dependency_test.go rename to pkg/chart/v2/dependency_test.go index 90488a966..35919bd7a 100644 --- a/pkg/chart/dependency_test.go +++ b/pkg/chart/v2/dependency_test.go @@ -13,7 +13,7 @@ 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 chart +package v2 import ( "testing" diff --git a/pkg/chart/v2/doc.go b/pkg/chart/v2/doc.go new file mode 100644 index 000000000..d36ca3ec4 --- /dev/null +++ b/pkg/chart/v2/doc.go @@ -0,0 +1,23 @@ +/* +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 v2 provides chart handling for apiVersion v1 and v2 charts + +This package and its sub-packages provide handling for apiVersion v1 and v2 charts. +The changes from v1 to v2 charts are minor and were able to be handled with minor +switches based on characteristics. +*/ +package v2 diff --git a/pkg/chart/errors.go b/pkg/chart/v2/errors.go similarity index 98% rename from pkg/chart/errors.go rename to pkg/chart/v2/errors.go index 2fad5f370..eeef75315 100644 --- a/pkg/chart/errors.go +++ b/pkg/chart/v2/errors.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart +package v2 import "fmt" diff --git a/pkg/chart/file.go b/pkg/chart/v2/file.go similarity index 98% rename from pkg/chart/file.go rename to pkg/chart/v2/file.go index 9dd7c08d5..a2eeb0fcd 100644 --- a/pkg/chart/file.go +++ b/pkg/chart/v2/file.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart +package v2 // File represents a file as a name/value pair. // diff --git a/pkg/chart/fuzz_test.go b/pkg/chart/v2/fuzz_test.go similarity index 98% rename from pkg/chart/fuzz_test.go rename to pkg/chart/v2/fuzz_test.go index f3c768444..a897ef7b9 100644 --- a/pkg/chart/fuzz_test.go +++ b/pkg/chart/v2/fuzz_test.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart +package v2 import ( "testing" diff --git a/pkg/chart/loader/archive.go b/pkg/chart/v2/loader/archive.go similarity index 99% rename from pkg/chart/loader/archive.go rename to pkg/chart/v2/loader/archive.go index 51dd264f7..cb6d3bfe8 100644 --- a/pkg/chart/loader/archive.go +++ b/pkg/chart/v2/loader/archive.go @@ -30,7 +30,7 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) var drivePathPattern = regexp.MustCompile(`^[a-zA-Z]:/`) diff --git a/pkg/chart/loader/archive_test.go b/pkg/chart/v2/loader/archive_test.go similarity index 100% rename from pkg/chart/loader/archive_test.go rename to pkg/chart/v2/loader/archive_test.go diff --git a/pkg/chart/loader/directory.go b/pkg/chart/v2/loader/directory.go similarity index 98% rename from pkg/chart/loader/directory.go rename to pkg/chart/v2/loader/directory.go index 1dc30e4dc..37b24d3f9 100644 --- a/pkg/chart/loader/directory.go +++ b/pkg/chart/v2/loader/directory.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" "helm.sh/helm/v4/internal/sympath" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/ignore" ) diff --git a/pkg/chart/loader/load.go b/pkg/chart/v2/loader/load.go similarity index 99% rename from pkg/chart/loader/load.go rename to pkg/chart/v2/loader/load.go index e32094ef5..3c5463720 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/v2/loader/load.go @@ -30,7 +30,7 @@ import ( utilyaml "k8s.io/apimachinery/pkg/util/yaml" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // ChartLoader loads a chart. diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/v2/loader/load_test.go similarity index 99% rename from pkg/chart/loader/load_test.go rename to pkg/chart/v2/loader/load_test.go index e34124829..2e16b8560 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/v2/loader/load_test.go @@ -30,7 +30,7 @@ import ( "testing" "time" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) func TestLoadDir(t *testing.T) { diff --git a/pkg/chart/loader/testdata/LICENSE b/pkg/chart/v2/loader/testdata/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/LICENSE rename to pkg/chart/v2/loader/testdata/LICENSE diff --git a/pkg/chart/loader/testdata/albatross/Chart.yaml b/pkg/chart/v2/loader/testdata/albatross/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/albatross/Chart.yaml rename to pkg/chart/v2/loader/testdata/albatross/Chart.yaml diff --git a/pkg/chart/loader/testdata/albatross/values.yaml b/pkg/chart/v2/loader/testdata/albatross/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/albatross/values.yaml rename to pkg/chart/v2/loader/testdata/albatross/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz-1.2.3.tgz b/pkg/chart/v2/loader/testdata/frobnitz-1.2.3.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz-1.2.3.tgz rename to pkg/chart/v2/loader/testdata/frobnitz-1.2.3.tgz diff --git a/pkg/chart/loader/testdata/frobnitz.v1.tgz b/pkg/chart/v2/loader/testdata/frobnitz.v1.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1.tgz rename to pkg/chart/v2/loader/testdata/frobnitz.v1.tgz diff --git a/pkg/chart/loader/testdata/frobnitz.v1/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz.v1/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz.v1/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz.v1/Chart.lock b/pkg/chart/v2/loader/testdata/frobnitz.v1/Chart.lock similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/Chart.lock rename to pkg/chart/v2/loader/testdata/frobnitz.v1/Chart.lock diff --git a/pkg/chart/loader/testdata/frobnitz.v1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz.v1/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz.v1/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz.v1/LICENSE b/pkg/chart/v2/loader/testdata/frobnitz.v1/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/LICENSE rename to pkg/chart/v2/loader/testdata/frobnitz.v1/LICENSE diff --git a/pkg/chart/loader/testdata/frobnitz.v1/README.md b/pkg/chart/v2/loader/testdata/frobnitz.v1/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/README.md rename to pkg/chart/v2/loader/testdata/frobnitz.v1/README.md diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz.v1/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz.v1/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz.v1/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz.v1/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz.v1/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz.v1/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz.v1/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz.v1/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz.v1/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz.v1/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz.v1/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz.v1/requirements.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/requirements.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/requirements.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/requirements.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v1/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz.v1/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz.v1/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz.v1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/LICENSE b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/LICENSE rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/LICENSE diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/README.md b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/requirements.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/requirements.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/requirements.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/requirements.yaml diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz.v2.reqs/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz.v2.reqs/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz.v2.reqs/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz/Chart.lock b/pkg/chart/v2/loader/testdata/frobnitz/Chart.lock similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/Chart.lock rename to pkg/chart/v2/loader/testdata/frobnitz/Chart.lock diff --git a/pkg/chart/loader/testdata/frobnitz/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz/LICENSE b/pkg/chart/v2/loader/testdata/frobnitz/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/LICENSE rename to pkg/chart/v2/loader/testdata/frobnitz/LICENSE diff --git a/pkg/chart/loader/testdata/frobnitz/README.md b/pkg/chart/v2/loader/testdata/frobnitz/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/README.md rename to pkg/chart/v2/loader/testdata/frobnitz/README.md diff --git a/pkg/chart/loader/testdata/frobnitz/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash-1.2.3.tgz b/pkg/chart/v2/loader/testdata/frobnitz_backslash-1.2.3.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash-1.2.3.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_backslash-1.2.3.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz_backslash/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/Chart.lock b/pkg/chart/v2/loader/testdata/frobnitz_backslash/Chart.lock similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/Chart.lock rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/Chart.lock diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz_backslash/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/LICENSE b/pkg/chart/v2/loader/testdata/frobnitz_backslash/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/LICENSE rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/LICENSE diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/README.md b/pkg/chart/v2/loader/testdata/frobnitz_backslash/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz_backslash/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz_backslash/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz_backslash/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz_backslash/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz_backslash/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_backslash/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_backslash/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_backslash/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_bom.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/Chart.lock b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/Chart.lock similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/Chart.lock rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/Chart.lock diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/LICENSE b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/LICENSE rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/LICENSE diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz_with_bom/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_bom/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_bom/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_bom/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.lock b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/Chart.lock similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.lock rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/Chart.lock diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/LICENSE b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/LICENSE similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/LICENSE rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/LICENSE diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/null b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/null similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/null rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/null diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_dev_null/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_dev_null/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/.helmignore b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/.helmignore similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/.helmignore rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/.helmignore diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.lock b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/Chart.lock similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.lock rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/Chart.lock diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/INSTALL.txt b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/INSTALL.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/INSTALL.txt rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/INSTALL.txt diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/_ignore_me b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/_ignore_me similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/_ignore_me rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/_ignore_me diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/docs/README.md b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/docs/README.md similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/docs/README.md rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/docs/README.md diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/icon.svg b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/icon.svg similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/icon.svg rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/icon.svg diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/ignore/me.txt b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/ignore/me.txt similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/ignore/me.txt rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/ignore/me.txt diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/templates/template.tpl b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/templates/template.tpl similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/templates/template.tpl rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/templates/template.tpl diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/values.yaml b/pkg/chart/v2/loader/testdata/frobnitz_with_symlink/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/frobnitz_with_symlink/values.yaml rename to pkg/chart/v2/loader/testdata/frobnitz_with_symlink/values.yaml diff --git a/pkg/chart/loader/testdata/genfrob.sh b/pkg/chart/v2/loader/testdata/genfrob.sh similarity index 100% rename from pkg/chart/loader/testdata/genfrob.sh rename to pkg/chart/v2/loader/testdata/genfrob.sh diff --git a/pkg/chart/loader/testdata/mariner/Chart.yaml b/pkg/chart/v2/loader/testdata/mariner/Chart.yaml similarity index 100% rename from pkg/chart/loader/testdata/mariner/Chart.yaml rename to pkg/chart/v2/loader/testdata/mariner/Chart.yaml diff --git a/pkg/chart/loader/testdata/mariner/charts/albatross-0.1.0.tgz b/pkg/chart/v2/loader/testdata/mariner/charts/albatross-0.1.0.tgz similarity index 100% rename from pkg/chart/loader/testdata/mariner/charts/albatross-0.1.0.tgz rename to pkg/chart/v2/loader/testdata/mariner/charts/albatross-0.1.0.tgz diff --git a/pkg/chart/loader/testdata/mariner/templates/placeholder.tpl b/pkg/chart/v2/loader/testdata/mariner/templates/placeholder.tpl similarity index 100% rename from pkg/chart/loader/testdata/mariner/templates/placeholder.tpl rename to pkg/chart/v2/loader/testdata/mariner/templates/placeholder.tpl diff --git a/pkg/chart/loader/testdata/mariner/values.yaml b/pkg/chart/v2/loader/testdata/mariner/values.yaml similarity index 100% rename from pkg/chart/loader/testdata/mariner/values.yaml rename to pkg/chart/v2/loader/testdata/mariner/values.yaml diff --git a/pkg/chart/metadata.go b/pkg/chart/v2/metadata.go similarity index 99% rename from pkg/chart/metadata.go rename to pkg/chart/v2/metadata.go index a08a97cd1..d213a3491 100644 --- a/pkg/chart/metadata.go +++ b/pkg/chart/v2/metadata.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart +package v2 import ( "path/filepath" diff --git a/pkg/chart/metadata_test.go b/pkg/chart/v2/metadata_test.go similarity index 99% rename from pkg/chart/metadata_test.go rename to pkg/chart/v2/metadata_test.go index 62aea7261..7892f0209 100644 --- a/pkg/chart/metadata_test.go +++ b/pkg/chart/v2/metadata_test.go @@ -13,7 +13,7 @@ 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 chart +package v2 import ( "testing" diff --git a/pkg/chart/util/capabilities.go b/pkg/chart/v2/util/capabilities.go similarity index 100% rename from pkg/chart/util/capabilities.go rename to pkg/chart/v2/util/capabilities.go diff --git a/pkg/chart/util/capabilities_test.go b/pkg/chart/v2/util/capabilities_test.go similarity index 100% rename from pkg/chart/util/capabilities_test.go rename to pkg/chart/v2/util/capabilities_test.go diff --git a/pkg/chart/util/chartfile.go b/pkg/chart/v2/util/chartfile.go similarity index 98% rename from pkg/chart/util/chartfile.go rename to pkg/chart/v2/util/chartfile.go index acab80d0a..87323c201 100644 --- a/pkg/chart/util/chartfile.go +++ b/pkg/chart/v2/util/chartfile.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // LoadChartfile loads a Chart.yaml file into a *chart.Metadata. diff --git a/pkg/chart/util/chartfile_test.go b/pkg/chart/v2/util/chartfile_test.go similarity index 98% rename from pkg/chart/util/chartfile_test.go rename to pkg/chart/v2/util/chartfile_test.go index 6eb599680..a2896b235 100644 --- a/pkg/chart/util/chartfile_test.go +++ b/pkg/chart/v2/util/chartfile_test.go @@ -19,7 +19,7 @@ package util import ( "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) const testfile = "testdata/chartfiletest.yaml" diff --git a/pkg/chart/util/coalesce.go b/pkg/chart/v2/util/coalesce.go similarity index 99% rename from pkg/chart/util/coalesce.go rename to pkg/chart/v2/util/coalesce.go index 9ab5c1015..33d2d2833 100644 --- a/pkg/chart/util/coalesce.go +++ b/pkg/chart/v2/util/coalesce.go @@ -23,7 +23,7 @@ import ( "github.com/mitchellh/copystructure" "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) func concatPrefix(a, b string) string { diff --git a/pkg/chart/util/coalesce_test.go b/pkg/chart/v2/util/coalesce_test.go similarity index 99% rename from pkg/chart/util/coalesce_test.go rename to pkg/chart/v2/util/coalesce_test.go index 5a8dfe94a..3d4ee4fa8 100644 --- a/pkg/chart/util/coalesce_test.go +++ b/pkg/chart/v2/util/coalesce_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/assert" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // ref: http://www.yaml.org/spec/1.2/spec.html#id2803362 diff --git a/pkg/chart/util/compatible.go b/pkg/chart/v2/util/compatible.go similarity index 100% rename from pkg/chart/util/compatible.go rename to pkg/chart/v2/util/compatible.go diff --git a/pkg/chart/util/compatible_test.go b/pkg/chart/v2/util/compatible_test.go similarity index 100% rename from pkg/chart/util/compatible_test.go rename to pkg/chart/v2/util/compatible_test.go diff --git a/pkg/chart/util/create.go b/pkg/chart/v2/util/create.go similarity index 99% rename from pkg/chart/util/create.go rename to pkg/chart/v2/util/create.go index dfb5099f2..7eb3398f5 100644 --- a/pkg/chart/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -27,8 +27,8 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) // chartName is a regular expression for testing the supplied name of a chart. diff --git a/pkg/chart/util/create_test.go b/pkg/chart/v2/util/create_test.go similarity index 98% rename from pkg/chart/util/create_test.go rename to pkg/chart/v2/util/create_test.go index e67ce3e1f..086c4e5c8 100644 --- a/pkg/chart/util/create_test.go +++ b/pkg/chart/v2/util/create_test.go @@ -22,8 +22,8 @@ import ( "path/filepath" "testing" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) func TestCreate(t *testing.T) { diff --git a/pkg/chart/util/dependencies.go b/pkg/chart/v2/util/dependencies.go similarity index 99% rename from pkg/chart/util/dependencies.go rename to pkg/chart/v2/util/dependencies.go index fb9052d71..78ed46517 100644 --- a/pkg/chart/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -21,7 +21,7 @@ import ( "github.com/mitchellh/copystructure" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // ProcessDependencies checks through this chart's dependencies, processing accordingly. diff --git a/pkg/chart/util/dependencies_test.go b/pkg/chart/v2/util/dependencies_test.go similarity index 99% rename from pkg/chart/util/dependencies_test.go rename to pkg/chart/v2/util/dependencies_test.go index 10fca265e..5bd332990 100644 --- a/pkg/chart/util/dependencies_test.go +++ b/pkg/chart/v2/util/dependencies_test.go @@ -22,8 +22,8 @@ import ( "strconv" "testing" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) func loadChart(t *testing.T, path string) *chart.Chart { diff --git a/pkg/chart/util/doc.go b/pkg/chart/v2/util/doc.go similarity index 95% rename from pkg/chart/util/doc.go rename to pkg/chart/v2/util/doc.go index 587fcaeb1..141062074 100644 --- a/pkg/chart/util/doc.go +++ b/pkg/chart/v2/util/doc.go @@ -42,4 +42,4 @@ into a Chart. When creating charts in memory, use the 'helm.sh/helm/pkg/chart' package directly. */ -package util // import chartutil "helm.sh/helm/v4/pkg/chart/util" +package util // import chartutil "helm.sh/helm/v4/pkg/chart/v2/util" diff --git a/pkg/chart/util/errors.go b/pkg/chart/v2/util/errors.go similarity index 100% rename from pkg/chart/util/errors.go rename to pkg/chart/v2/util/errors.go diff --git a/pkg/chart/util/errors_test.go b/pkg/chart/v2/util/errors_test.go similarity index 100% rename from pkg/chart/util/errors_test.go rename to pkg/chart/v2/util/errors_test.go diff --git a/pkg/chart/util/expand.go b/pkg/chart/v2/util/expand.go similarity index 96% rename from pkg/chart/util/expand.go rename to pkg/chart/v2/util/expand.go index 4b83bf584..e05a1a984 100644 --- a/pkg/chart/util/expand.go +++ b/pkg/chart/v2/util/expand.go @@ -25,8 +25,8 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) // Expand uncompresses and extracts a chart into the specified directory. diff --git a/pkg/chart/util/expand_test.go b/pkg/chart/v2/util/expand_test.go similarity index 100% rename from pkg/chart/util/expand_test.go rename to pkg/chart/v2/util/expand_test.go diff --git a/pkg/chart/util/jsonschema.go b/pkg/chart/v2/util/jsonschema.go similarity index 98% rename from pkg/chart/util/jsonschema.go rename to pkg/chart/v2/util/jsonschema.go index 616c6d444..615dc5320 100644 --- a/pkg/chart/util/jsonschema.go +++ b/pkg/chart/v2/util/jsonschema.go @@ -25,7 +25,7 @@ import ( "github.com/xeipuuv/gojsonschema" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // ValidateAgainstSchema checks that values does not violate the structure laid out in schema diff --git a/pkg/chart/util/jsonschema_test.go b/pkg/chart/v2/util/jsonschema_test.go similarity index 99% rename from pkg/chart/util/jsonschema_test.go rename to pkg/chart/v2/util/jsonschema_test.go index c5600044a..3e3315732 100644 --- a/pkg/chart/util/jsonschema_test.go +++ b/pkg/chart/v2/util/jsonschema_test.go @@ -20,7 +20,7 @@ import ( "os" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) func TestValidateAgainstSingleSchema(t *testing.T) { diff --git a/pkg/chart/util/save.go b/pkg/chart/v2/util/save.go similarity index 99% rename from pkg/chart/util/save.go rename to pkg/chart/v2/util/save.go index 635ff7944..e1285ac88 100644 --- a/pkg/chart/util/save.go +++ b/pkg/chart/v2/util/save.go @@ -28,7 +28,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) var headerBytes = []byte("+aHR0cHM6Ly95b3V0dS5iZS96OVV6MWljandyTQo=") diff --git a/pkg/chart/util/save_test.go b/pkg/chart/v2/util/save_test.go similarity index 98% rename from pkg/chart/util/save_test.go rename to pkg/chart/v2/util/save_test.go index a7338c8d7..ff96331b5 100644 --- a/pkg/chart/util/save_test.go +++ b/pkg/chart/v2/util/save_test.go @@ -29,8 +29,8 @@ import ( "testing" "time" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) func TestSave(t *testing.T) { diff --git a/pkg/chart/util/testdata/chartfiletest.yaml b/pkg/chart/v2/util/testdata/chartfiletest.yaml similarity index 100% rename from pkg/chart/util/testdata/chartfiletest.yaml rename to pkg/chart/v2/util/testdata/chartfiletest.yaml diff --git a/pkg/chart/util/testdata/coleridge.yaml b/pkg/chart/v2/util/testdata/coleridge.yaml similarity index 100% rename from pkg/chart/util/testdata/coleridge.yaml rename to pkg/chart/v2/util/testdata/coleridge.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/.helmignore b/pkg/chart/v2/util/testdata/dependent-chart-alias/.helmignore similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/.helmignore rename to pkg/chart/v2/util/testdata/dependent-chart-alias/.helmignore diff --git a/pkg/chart/util/testdata/dependent-chart-alias/Chart.lock b/pkg/chart/v2/util/testdata/dependent-chart-alias/Chart.lock similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/Chart.lock rename to pkg/chart/v2/util/testdata/dependent-chart-alias/Chart.lock diff --git a/pkg/chart/util/testdata/dependent-chart-alias/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/INSTALL.txt b/pkg/chart/v2/util/testdata/dependent-chart-alias/INSTALL.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/INSTALL.txt rename to pkg/chart/v2/util/testdata/dependent-chart-alias/INSTALL.txt diff --git a/pkg/chart/util/testdata/dependent-chart-alias/LICENSE b/pkg/chart/v2/util/testdata/dependent-chart-alias/LICENSE similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/LICENSE rename to pkg/chart/v2/util/testdata/dependent-chart-alias/LICENSE diff --git a/pkg/chart/util/testdata/dependent-chart-alias/README.md b/pkg/chart/v2/util/testdata/dependent-chart-alias/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-alias/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/_ignore_me b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/_ignore_me similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/_ignore_me rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/_ignore_me diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/README.md b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/alpine/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/alpine/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz b/pkg/chart/v2/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-alias/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-alias/docs/README.md b/pkg/chart/v2/util/testdata/dependent-chart-alias/docs/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/docs/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-alias/docs/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-alias/icon.svg b/pkg/chart/v2/util/testdata/dependent-chart-alias/icon.svg similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/icon.svg rename to pkg/chart/v2/util/testdata/dependent-chart-alias/icon.svg diff --git a/pkg/chart/util/testdata/dependent-chart-alias/ignore/me.txt b/pkg/chart/v2/util/testdata/dependent-chart-alias/ignore/me.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/ignore/me.txt rename to pkg/chart/v2/util/testdata/dependent-chart-alias/ignore/me.txt diff --git a/pkg/chart/util/testdata/dependent-chart-alias/templates/template.tpl b/pkg/chart/v2/util/testdata/dependent-chart-alias/templates/template.tpl similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/templates/template.tpl rename to pkg/chart/v2/util/testdata/dependent-chart-alias/templates/template.tpl diff --git a/pkg/chart/util/testdata/dependent-chart-alias/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-alias/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-alias/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-alias/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/.helmignore b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/.helmignore similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/.helmignore rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/.helmignore diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/.ignore_me b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/.ignore_me similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/.ignore_me rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/.ignore_me diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/_ignore_me b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/_ignore_me similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/_ignore_me rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/_ignore_me diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/README.md b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/charts/alpine/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/templates/template.tpl b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/templates/template.tpl similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/templates/template.tpl rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/templates/template.tpl diff --git a/pkg/chart/util/testdata/dependent-chart-helmignore/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-helmignore/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-helmignore/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-helmignore/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/.helmignore b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/.helmignore similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/.helmignore rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/.helmignore diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/INSTALL.txt diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/LICENSE b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/LICENSE similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/LICENSE rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/LICENSE diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/README.md b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/_ignore_me diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/alpine/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/docs/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/icon.svg b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/icon.svg similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/icon.svg rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/icon.svg diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/ignore/me.txt diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/templates/template.tpl diff --git a/pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-no-requirements-yaml/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-no-requirements-yaml/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/.helmignore diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/INSTALL.txt diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/LICENSE diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/_ignore_me diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/alpine/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/docs/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/icon.svg diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/ignore/me.txt diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/templates/template.tpl diff --git a/pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-all-in-requirements-yaml/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/.helmignore diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/INSTALL.txt diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/LICENSE diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/_ignore_me diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/alpine/values.yaml diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/charts/mariner-4.3.2.tgz diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/docs/README.md diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/icon.svg diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/ignore/me.txt diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/templates/template.tpl diff --git a/pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml b/pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml similarity index 100% rename from pkg/chart/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml rename to pkg/chart/v2/util/testdata/dependent-chart-with-mixed-requirements-yaml/values.yaml diff --git a/pkg/chart/util/testdata/frobnitz-1.2.3.tgz b/pkg/chart/v2/util/testdata/frobnitz-1.2.3.tgz similarity index 100% rename from pkg/chart/util/testdata/frobnitz-1.2.3.tgz rename to pkg/chart/v2/util/testdata/frobnitz-1.2.3.tgz diff --git a/pkg/chart/util/testdata/frobnitz/.helmignore b/pkg/chart/v2/util/testdata/frobnitz/.helmignore similarity index 100% rename from pkg/chart/util/testdata/frobnitz/.helmignore rename to pkg/chart/v2/util/testdata/frobnitz/.helmignore diff --git a/pkg/chart/util/testdata/frobnitz/Chart.lock b/pkg/chart/v2/util/testdata/frobnitz/Chart.lock similarity index 100% rename from pkg/chart/util/testdata/frobnitz/Chart.lock rename to pkg/chart/v2/util/testdata/frobnitz/Chart.lock diff --git a/pkg/chart/util/testdata/frobnitz/Chart.yaml b/pkg/chart/v2/util/testdata/frobnitz/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/Chart.yaml rename to pkg/chart/v2/util/testdata/frobnitz/Chart.yaml diff --git a/pkg/chart/util/testdata/frobnitz/INSTALL.txt b/pkg/chart/v2/util/testdata/frobnitz/INSTALL.txt similarity index 100% rename from pkg/chart/util/testdata/frobnitz/INSTALL.txt rename to pkg/chart/v2/util/testdata/frobnitz/INSTALL.txt diff --git a/pkg/chart/util/testdata/frobnitz/LICENSE b/pkg/chart/v2/util/testdata/frobnitz/LICENSE similarity index 100% rename from pkg/chart/util/testdata/frobnitz/LICENSE rename to pkg/chart/v2/util/testdata/frobnitz/LICENSE diff --git a/pkg/chart/util/testdata/frobnitz/README.md b/pkg/chart/v2/util/testdata/frobnitz/README.md similarity index 100% rename from pkg/chart/util/testdata/frobnitz/README.md rename to pkg/chart/v2/util/testdata/frobnitz/README.md diff --git a/pkg/chart/util/testdata/frobnitz/charts/_ignore_me b/pkg/chart/v2/util/testdata/frobnitz/charts/_ignore_me similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/_ignore_me rename to pkg/chart/v2/util/testdata/frobnitz/charts/_ignore_me diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/Chart.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/Chart.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/Chart.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/README.md b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/README.md similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/README.md rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/README.md diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/charts/mast1/Chart.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/charts/mast1/values.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/charts/mast2-0.1.0.tgz diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/templates/alpine-pod.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/alpine/values.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/alpine/values.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/alpine/values.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/alpine/values.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/mariner/Chart.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/mariner/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/mariner/Chart.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/mariner/Chart.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/mariner/charts/albatross/Chart.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/mariner/charts/albatross/values.yaml diff --git a/pkg/chart/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl b/pkg/chart/v2/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl rename to pkg/chart/v2/util/testdata/frobnitz/charts/mariner/templates/placeholder.tpl diff --git a/pkg/chart/util/testdata/frobnitz/charts/mariner/values.yaml b/pkg/chart/v2/util/testdata/frobnitz/charts/mariner/values.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/charts/mariner/values.yaml rename to pkg/chart/v2/util/testdata/frobnitz/charts/mariner/values.yaml diff --git a/pkg/chart/util/testdata/frobnitz/docs/README.md b/pkg/chart/v2/util/testdata/frobnitz/docs/README.md similarity index 100% rename from pkg/chart/util/testdata/frobnitz/docs/README.md rename to pkg/chart/v2/util/testdata/frobnitz/docs/README.md diff --git a/pkg/chart/util/testdata/frobnitz/icon.svg b/pkg/chart/v2/util/testdata/frobnitz/icon.svg similarity index 100% rename from pkg/chart/util/testdata/frobnitz/icon.svg rename to pkg/chart/v2/util/testdata/frobnitz/icon.svg diff --git a/pkg/chart/util/testdata/frobnitz/ignore/me.txt b/pkg/chart/v2/util/testdata/frobnitz/ignore/me.txt similarity index 100% rename from pkg/chart/util/testdata/frobnitz/ignore/me.txt rename to pkg/chart/v2/util/testdata/frobnitz/ignore/me.txt diff --git a/pkg/chart/util/testdata/frobnitz/templates/template.tpl b/pkg/chart/v2/util/testdata/frobnitz/templates/template.tpl similarity index 100% rename from pkg/chart/util/testdata/frobnitz/templates/template.tpl rename to pkg/chart/v2/util/testdata/frobnitz/templates/template.tpl diff --git a/pkg/chart/util/testdata/frobnitz/values.yaml b/pkg/chart/v2/util/testdata/frobnitz/values.yaml similarity index 100% rename from pkg/chart/util/testdata/frobnitz/values.yaml rename to pkg/chart/v2/util/testdata/frobnitz/values.yaml diff --git a/pkg/chart/util/testdata/frobnitz_backslash-1.2.3.tgz b/pkg/chart/v2/util/testdata/frobnitz_backslash-1.2.3.tgz similarity index 100% rename from pkg/chart/util/testdata/frobnitz_backslash-1.2.3.tgz rename to pkg/chart/v2/util/testdata/frobnitz_backslash-1.2.3.tgz diff --git a/pkg/chart/util/testdata/genfrob.sh b/pkg/chart/v2/util/testdata/genfrob.sh similarity index 100% rename from pkg/chart/util/testdata/genfrob.sh rename to pkg/chart/v2/util/testdata/genfrob.sh diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml diff --git a/pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml b/pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml similarity index 100% rename from pkg/chart/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml rename to pkg/chart/v2/util/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml diff --git a/pkg/chart/util/testdata/joonix/Chart.yaml b/pkg/chart/v2/util/testdata/joonix/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/joonix/Chart.yaml rename to pkg/chart/v2/util/testdata/joonix/Chart.yaml diff --git a/pkg/chart/util/testdata/joonix/charts/.gitkeep b/pkg/chart/v2/util/testdata/joonix/charts/.gitkeep similarity index 100% rename from pkg/chart/util/testdata/joonix/charts/.gitkeep rename to pkg/chart/v2/util/testdata/joonix/charts/.gitkeep diff --git a/pkg/chart/util/testdata/subpop/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/README.md b/pkg/chart/v2/util/testdata/subpop/README.md similarity index 100% rename from pkg/chart/util/testdata/subpop/README.md rename to pkg/chart/v2/util/testdata/subpop/README.md diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartA/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartA/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartA/values.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartB/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartB/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/charts/subchartB/values.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/crds/crdA.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/crds/crdA.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/crds/crdA.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/crds/crdA.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/templates/NOTES.txt b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/NOTES.txt similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/templates/NOTES.txt rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/NOTES.txt diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/subdir/role.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/subdir/rolebinding.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/templates/subdir/serviceaccount.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart1/values.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart1/values.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart1/values.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartB/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartB/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartB/values.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartC/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartC/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/charts/subchartC/values.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/charts/subchart2/values.yaml b/pkg/chart/v2/util/testdata/subpop/charts/subchart2/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/charts/subchart2/values.yaml rename to pkg/chart/v2/util/testdata/subpop/charts/subchart2/values.yaml diff --git a/pkg/chart/util/testdata/subpop/noreqs/Chart.yaml b/pkg/chart/v2/util/testdata/subpop/noreqs/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/noreqs/Chart.yaml rename to pkg/chart/v2/util/testdata/subpop/noreqs/Chart.yaml diff --git a/pkg/chart/util/testdata/subpop/noreqs/templates/service.yaml b/pkg/chart/v2/util/testdata/subpop/noreqs/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/noreqs/templates/service.yaml rename to pkg/chart/v2/util/testdata/subpop/noreqs/templates/service.yaml diff --git a/pkg/chart/util/testdata/subpop/noreqs/values.yaml b/pkg/chart/v2/util/testdata/subpop/noreqs/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/noreqs/values.yaml rename to pkg/chart/v2/util/testdata/subpop/noreqs/values.yaml diff --git a/pkg/chart/util/testdata/subpop/values.yaml b/pkg/chart/v2/util/testdata/subpop/values.yaml similarity index 100% rename from pkg/chart/util/testdata/subpop/values.yaml rename to pkg/chart/v2/util/testdata/subpop/values.yaml diff --git a/pkg/chart/util/testdata/test-values-invalid.schema.json b/pkg/chart/v2/util/testdata/test-values-invalid.schema.json similarity index 100% rename from pkg/chart/util/testdata/test-values-invalid.schema.json rename to pkg/chart/v2/util/testdata/test-values-invalid.schema.json diff --git a/pkg/chart/util/testdata/test-values-negative.yaml b/pkg/chart/v2/util/testdata/test-values-negative.yaml similarity index 100% rename from pkg/chart/util/testdata/test-values-negative.yaml rename to pkg/chart/v2/util/testdata/test-values-negative.yaml diff --git a/pkg/chart/util/testdata/test-values.schema.json b/pkg/chart/v2/util/testdata/test-values.schema.json similarity index 100% rename from pkg/chart/util/testdata/test-values.schema.json rename to pkg/chart/v2/util/testdata/test-values.schema.json diff --git a/pkg/chart/util/testdata/test-values.yaml b/pkg/chart/v2/util/testdata/test-values.yaml similarity index 100% rename from pkg/chart/util/testdata/test-values.yaml rename to pkg/chart/v2/util/testdata/test-values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/README.md b/pkg/chart/v2/util/testdata/three-level-dependent-chart/README.md similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/README.md rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/README.md diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/charts/library/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app1/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/charts/library/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app2/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/charts/library/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app3/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/Chart.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/charts/library/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/templates/service.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/charts/app4/values.yaml diff --git a/pkg/chart/util/testdata/three-level-dependent-chart/umbrella/values.yaml b/pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/values.yaml similarity index 100% rename from pkg/chart/util/testdata/three-level-dependent-chart/umbrella/values.yaml rename to pkg/chart/v2/util/testdata/three-level-dependent-chart/umbrella/values.yaml diff --git a/pkg/chart/util/validate_name.go b/pkg/chart/v2/util/validate_name.go similarity index 100% rename from pkg/chart/util/validate_name.go rename to pkg/chart/v2/util/validate_name.go diff --git a/pkg/chart/util/validate_name_test.go b/pkg/chart/v2/util/validate_name_test.go similarity index 100% rename from pkg/chart/util/validate_name_test.go rename to pkg/chart/v2/util/validate_name_test.go diff --git a/pkg/chart/util/values.go b/pkg/chart/v2/util/values.go similarity index 99% rename from pkg/chart/util/values.go rename to pkg/chart/v2/util/values.go index 46952c079..404ba9842 100644 --- a/pkg/chart/util/values.go +++ b/pkg/chart/v2/util/values.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // GlobalKey is the name of the Values key that is used for storing global vars. diff --git a/pkg/chart/util/values_test.go b/pkg/chart/v2/util/values_test.go similarity index 99% rename from pkg/chart/util/values_test.go rename to pkg/chart/v2/util/values_test.go index 660b7e4ed..6a5400f78 100644 --- a/pkg/chart/util/values_test.go +++ b/pkg/chart/v2/util/values_test.go @@ -22,7 +22,7 @@ import ( "testing" "text/template" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) func TestReadValues(t *testing.T) { diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index 2c3706b84..461db3cc2 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chart/loader" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/strvals" ) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index e5dac8b10..d38509311 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -36,9 +36,9 @@ import ( "helm.sh/helm/v4/internal/resolver" "helm.sh/helm/v4/internal/third_party/dep/fs" "helm.sh/helm/v4/internal/urlutil" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/registry" diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index 8731fb003..b8b009f1b 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -24,9 +24,9 @@ import ( "github.com/stretchr/testify/assert" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/repo" "helm.sh/helm/v4/pkg/repo/repotest" diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 0229b1833..0d0a398be 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -29,8 +29,8 @@ import ( "github.com/pkg/errors" "k8s.io/client-go/rest" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" ) // Engine is an implementation of the Helm rendering implementation for templates. diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index 4c28c2965..a54e99cad 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -30,8 +30,8 @@ import ( "k8s.io/client-go/dynamic" "k8s.io/client-go/dynamic/fake" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" ) func TestSortTemplates(t *testing.T) { diff --git a/pkg/engine/files.go b/pkg/engine/files.go index dc6a67de8..87166728c 100644 --- a/pkg/engine/files.go +++ b/pkg/engine/files.go @@ -23,7 +23,7 @@ import ( "github.com/gobwas/glob" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" ) // files is a map of files in a chart that can be accessed from a template. diff --git a/pkg/lint/lint.go b/pkg/lint/lint.go index b53400c87..a61d5e43f 100644 --- a/pkg/lint/lint.go +++ b/pkg/lint/lint.go @@ -19,7 +19,7 @@ package lint // import "helm.sh/helm/v4/pkg/lint" import ( "path/filepath" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/rules" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/lint_test.go b/pkg/lint/lint_test.go index bba024d59..067d140f6 100644 --- a/pkg/lint/lint_test.go +++ b/pkg/lint/lint_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/chartfile.go b/pkg/lint/rules/chartfile.go index a1e08b58d..598557a97 100644 --- a/pkg/lint/rules/chartfile.go +++ b/pkg/lint/rules/chartfile.go @@ -26,8 +26,8 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index 6d709790a..061d90e33 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -24,8 +24,8 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/dependencies.go b/pkg/lint/rules/dependencies.go index 5f71dd144..2ab56eca5 100644 --- a/pkg/lint/rules/dependencies.go +++ b/pkg/lint/rules/dependencies.go @@ -22,8 +22,8 @@ import ( "github.com/pkg/errors" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/dependencies_test.go b/pkg/lint/rules/dependencies_test.go index e946b1c01..1369b2372 100644 --- a/pkg/lint/rules/dependencies_test.go +++ b/pkg/lint/rules/dependencies_test.go @@ -19,8 +19,8 @@ import ( "path/filepath" "testing" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/deprecations.go b/pkg/lint/rules/deprecations.go index 0a8e642c9..bd4a4436a 100644 --- a/pkg/lint/rules/deprecations.go +++ b/pkg/lint/rules/deprecations.go @@ -25,7 +25,7 @@ import ( "k8s.io/apiserver/pkg/endpoints/deprecation" kscheme "k8s.io/client-go/kubernetes/scheme" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" ) var ( diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index ec434aba5..287968340 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -33,8 +33,8 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/yaml" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/engine" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/template_test.go b/pkg/lint/rules/template_test.go index d3185d8c8..7205ace6d 100644 --- a/pkg/lint/rules/template_test.go +++ b/pkg/lint/rules/template_test.go @@ -23,8 +23,8 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chart" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/lint/rules/values.go b/pkg/lint/rules/values.go index f430178c3..8aae250c6 100644 --- a/pkg/lint/rules/values.go +++ b/pkg/lint/rules/values.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/lint/support" ) diff --git a/pkg/provenance/sign.go b/pkg/provenance/sign.go index bbb68322f..cd7664edd 100644 --- a/pkg/provenance/sign.go +++ b/pkg/provenance/sign.go @@ -30,8 +30,8 @@ import ( "golang.org/x/crypto/openpgp/packet" //nolint "sigs.k8s.io/yaml" - hapi "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + hapi "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" ) var defaultPGPConfig = packet.Config{ diff --git a/pkg/pusher/ocipusher.go b/pkg/pusher/ocipusher.go index a5149d1c7..5cea78a44 100644 --- a/pkg/pusher/ocipusher.go +++ b/pkg/pusher/ocipusher.go @@ -27,7 +27,7 @@ import ( "github.com/pkg/errors" "helm.sh/helm/v4/internal/tlsutil" - "helm.sh/helm/v4/pkg/chart/loader" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/time/ctime" ) diff --git a/pkg/registry/client.go b/pkg/registry/client.go index 01e5dff7b..ecc7a0d04 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -45,7 +45,7 @@ import ( "oras.land/oras-go/v2/registry/remote/retry" "helm.sh/helm/v4/internal/version" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/helmpath" ) diff --git a/pkg/registry/util.go b/pkg/registry/util.go index 8c0106fb9..1a96b0768 100644 --- a/pkg/registry/util.go +++ b/pkg/registry/util.go @@ -25,8 +25,8 @@ import ( "time" "helm.sh/helm/v4/internal/tlsutil" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" helmtime "helm.sh/helm/v4/pkg/time" "github.com/Masterminds/semver/v3" diff --git a/pkg/registry/util_test.go b/pkg/registry/util_test.go index 93a11a998..c8ce4e4a4 100644 --- a/pkg/registry/util_test.go +++ b/pkg/registry/util_test.go @@ -23,7 +23,7 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/release/mock.go b/pkg/release/mock.go index ab21d3cf2..94b4d01f3 100644 --- a/pkg/release/mock.go +++ b/pkg/release/mock.go @@ -20,7 +20,7 @@ import ( "fmt" "math/rand" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/release/release.go b/pkg/release/release.go index 2a4963d9b..1a7c7b18c 100644 --- a/pkg/release/release.go +++ b/pkg/release/release.go @@ -15,7 +15,9 @@ limitations under the License. package release -import "helm.sh/helm/v4/pkg/chart" +import ( + chart "helm.sh/helm/v4/pkg/chart/v2" +) // Release describes a deployment of a chart, together with the chart // and the variables used to deploy that chart. diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index a598743a6..c4ad62161 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/release" ) diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 3629bd24b..52f81be57 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -31,7 +31,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart/loader" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/helmpath" "helm.sh/helm/v4/pkg/provenance" diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index e3330b8eb..42d00e0ee 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/getter" ) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index 2526cba1b..c5f808229 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -33,8 +33,8 @@ import ( "helm.sh/helm/v4/internal/fileutil" "helm.sh/helm/v4/internal/urlutil" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" "helm.sh/helm/v4/pkg/provenance" ) diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index 8c22bdc3e..f50c7e65e 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -28,7 +28,7 @@ import ( "strings" "testing" - "helm.sh/helm/v4/pkg/chart" + chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/getter" "helm.sh/helm/v4/pkg/helmpath" diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index 7b004dbc3..709a6f5fd 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -34,9 +34,9 @@ import ( "golang.org/x/crypto/bcrypt" "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/chart" - "helm.sh/helm/v4/pkg/chart/loader" - chartutil "helm.sh/helm/v4/pkg/chart/util" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" ociRegistry "helm.sh/helm/v4/pkg/registry" "helm.sh/helm/v4/pkg/repo" ) From 0d5e64c1f28d0ef5e1d24e4bbb268a435f5cfcd6 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Tue, 25 Feb 2025 22:34:50 +0200 Subject: [PATCH 162/271] Fix formatting Signed-off-by: Yarden Shoham --- cmd/helm/flags_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go index fbdc597d6..e55c51ce4 100644 --- a/cmd/helm/flags_test.go +++ b/cmd/helm/flags_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "helm.sh/helm/v4/pkg/action" chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/release" From f04c456bd67a758f99443a735d933f6f735ed4d1 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Wed, 26 Feb 2025 13:21:00 +0000 Subject: [PATCH 163/271] gofmt Signed-off-by: Austin Abro --- pkg/cmd/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/create.go b/pkg/cmd/create.go index f6938d660..435c8ca82 100644 --- a/pkg/cmd/create.go +++ b/pkg/cmd/create.go @@ -23,9 +23,9 @@ import ( "github.com/spf13/cobra" - "helm.sh/helm/v4/pkg/cmd/require" chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" + "helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/helmpath" ) From e7114889705644bb2db8ca2e8ab317e28ffd48c1 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 26 Feb 2025 09:04:32 -0500 Subject: [PATCH 164/271] Move pkg/release to pkg/release/v1 to support v3 charts This is part of HIP 20 which provides a means to have v3 charts that live alongside v2 charts while having breaking changes. The plan is to have a different release object for v3 chart instances for at least a couple reasons: 1. So that the chart object on the release can be fundamentally different. 2. So that Helm v3 does not detect or try to work with instances of charts whose apiVersion it does not know about. Note: it is expected that Helm v3 usage will be used long after the Helm project no longer supports it. 5 years after Helm v2 had reached end-of-life there was still usage of it. Note: The release util package is separate from the versioned elements as it is planned to use generics to handle multiple release object versions. Signed-off-by: Matt Farina --- cmd/helm/completion_test.go | 2 +- cmd/helm/flags_test.go | 2 +- cmd/helm/get_all_test.go | 2 +- cmd/helm/get_hooks_test.go | 2 +- cmd/helm/get_manifest_test.go | 2 +- cmd/helm/get_metadata_test.go | 2 +- cmd/helm/get_notes_test.go | 2 +- cmd/helm/get_values_test.go | 2 +- cmd/helm/helm.go | 2 +- cmd/helm/helm_test.go | 2 +- cmd/helm/history.go | 2 +- cmd/helm/history_test.go | 2 +- cmd/helm/install.go | 2 +- cmd/helm/list.go | 2 +- cmd/helm/list_test.go | 2 +- cmd/helm/plugin_test.go | 2 +- cmd/helm/rollback_test.go | 2 +- cmd/helm/status.go | 2 +- cmd/helm/status_test.go | 2 +- cmd/helm/template.go | 2 +- cmd/helm/uninstall_test.go | 2 +- cmd/helm/upgrade.go | 2 +- cmd/helm/upgrade_test.go | 2 +- pkg/action/action.go | 2 +- pkg/action/action_test.go | 2 +- pkg/action/get.go | 2 +- pkg/action/history.go | 2 +- pkg/action/hooks.go | 2 +- pkg/action/hooks_test.go | 2 +- pkg/action/install.go | 2 +- pkg/action/install_test.go | 2 +- pkg/action/list.go | 2 +- pkg/action/list_test.go | 2 +- pkg/action/release_testing.go | 2 +- pkg/action/rollback.go | 2 +- pkg/action/status.go | 2 +- pkg/action/uninstall.go | 2 +- pkg/action/uninstall_test.go | 2 +- pkg/action/upgrade.go | 2 +- pkg/action/upgrade_test.go | 2 +- pkg/release/util/filter.go | 2 +- pkg/release/util/filter_test.go | 2 +- pkg/release/util/kind_sorter.go | 2 +- pkg/release/util/kind_sorter_test.go | 2 +- pkg/release/util/manifest_sorter.go | 2 +- pkg/release/util/manifest_sorter_test.go | 2 +- pkg/release/util/sorter.go | 2 +- pkg/release/util/sorter_test.go | 2 +- pkg/release/{ => v1}/hook.go | 2 +- pkg/release/{ => v1}/info.go | 2 +- pkg/release/{ => v1}/mock.go | 2 +- pkg/release/{ => v1}/release.go | 2 +- pkg/release/{ => v1}/responses.go | 2 +- pkg/release/{ => v1}/status.go | 2 +- pkg/storage/driver/cfgmaps.go | 2 +- pkg/storage/driver/cfgmaps_test.go | 2 +- pkg/storage/driver/driver.go | 2 +- pkg/storage/driver/memory.go | 2 +- pkg/storage/driver/memory_test.go | 2 +- pkg/storage/driver/mock_test.go | 2 +- pkg/storage/driver/records.go | 2 +- pkg/storage/driver/records_test.go | 2 +- pkg/storage/driver/secrets.go | 2 +- pkg/storage/driver/secrets_test.go | 2 +- pkg/storage/driver/sql.go | 2 +- pkg/storage/driver/sql_test.go | 2 +- pkg/storage/driver/util.go | 2 +- pkg/storage/storage.go | 2 +- pkg/storage/storage_test.go | 2 +- 69 files changed, 69 insertions(+), 69 deletions(-) rename pkg/release/{ => v1}/hook.go (99%) rename pkg/release/{ => v1}/info.go (98%) rename pkg/release/{ => v1}/mock.go (99%) rename pkg/release/{ => v1}/release.go (99%) rename pkg/release/{ => v1}/responses.go (98%) rename pkg/release/{ => v1}/status.go (99%) diff --git a/cmd/helm/completion_test.go b/cmd/helm/completion_test.go index 3d8383519..b1089596b 100644 --- a/cmd/helm/completion_test.go +++ b/cmd/helm/completion_test.go @@ -22,7 +22,7 @@ import ( "testing" chart "helm.sh/helm/v4/pkg/chart/v2" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // Check if file completion should be performed according to parameter 'shouldBePerformed' diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go index e55c51ce4..62a6fdcd4 100644 --- a/cmd/helm/flags_test.go +++ b/cmd/helm/flags_test.go @@ -24,7 +24,7 @@ import ( "helm.sh/helm/v4/pkg/action" chart "helm.sh/helm/v4/pkg/chart/v2" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/get_all_test.go b/cmd/helm/get_all_test.go index 60ea1161d..5de01bfcf 100644 --- a/cmd/helm/get_all_test.go +++ b/cmd/helm/get_all_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestGetCmd(t *testing.T) { diff --git a/cmd/helm/get_hooks_test.go b/cmd/helm/get_hooks_test.go index 75cf448cc..fa18204e3 100644 --- a/cmd/helm/get_hooks_test.go +++ b/cmd/helm/get_hooks_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestGetHooks(t *testing.T) { diff --git a/cmd/helm/get_manifest_test.go b/cmd/helm/get_manifest_test.go index b266620e7..96da50b75 100644 --- a/cmd/helm/get_manifest_test.go +++ b/cmd/helm/get_manifest_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestGetManifest(t *testing.T) { diff --git a/cmd/helm/get_metadata_test.go b/cmd/helm/get_metadata_test.go index 28c3c3649..29ca77253 100644 --- a/cmd/helm/get_metadata_test.go +++ b/cmd/helm/get_metadata_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestGetMetadataCmd(t *testing.T) { diff --git a/cmd/helm/get_notes_test.go b/cmd/helm/get_notes_test.go index 4ddd4c7a8..88d9584b8 100644 --- a/cmd/helm/get_notes_test.go +++ b/cmd/helm/get_notes_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestGetNotesCmd(t *testing.T) { diff --git a/cmd/helm/get_values_test.go b/cmd/helm/get_values_test.go index 44610c103..0fe141cf7 100644 --- a/cmd/helm/get_values_test.go +++ b/cmd/helm/get_values_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestGetValuesCmd(t *testing.T) { diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index c8de18796..7cce9436f 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -34,7 +34,7 @@ import ( "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/kube" kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage/driver" ) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index cfffa6dc7..a1d2b8505 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -33,7 +33,7 @@ import ( chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli" kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage" "helm.sh/helm/v4/pkg/storage/driver" "helm.sh/helm/v4/pkg/time" diff --git a/cmd/helm/history.go b/cmd/helm/history.go index a47f97688..86fad4b04 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -29,8 +29,8 @@ import ( "helm.sh/helm/v4/pkg/action" chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/cli/output" - "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/history_test.go b/cmd/helm/history_test.go index 07f5134c6..0df64cd1c 100644 --- a/cmd/helm/history_test.go +++ b/cmd/helm/history_test.go @@ -20,7 +20,7 @@ import ( "fmt" "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestHistoryCmd(t *testing.T) { diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 12f87cd20..3e8d04cb2 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -38,7 +38,7 @@ import ( "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) const installDesc = ` diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 67da22cdf..9bbe580a2 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -28,7 +28,7 @@ import ( "helm.sh/helm/v4/cmd/helm/require" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) var listHelp = ` diff --git a/cmd/helm/list_test.go b/cmd/helm/list_test.go index 6a462ee28..6f9754459 100644 --- a/cmd/helm/list_test.go +++ b/cmd/helm/list_test.go @@ -20,7 +20,7 @@ import ( "testing" chart "helm.sh/helm/v4/pkg/chart/v2" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index 4d2aa1a59..cbaf05321 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -26,7 +26,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestManuallyProcessArgs(t *testing.T) { diff --git a/cmd/helm/rollback_test.go b/cmd/helm/rollback_test.go index 88dbf6524..a3bad2ef7 100644 --- a/cmd/helm/rollback_test.go +++ b/cmd/helm/rollback_test.go @@ -22,7 +22,7 @@ import ( "testing" chart "helm.sh/helm/v4/pkg/chart/v2" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestRollbackCmd(t *testing.T) { diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 727c3df9e..d1e25dd45 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -32,7 +32,7 @@ import ( "helm.sh/helm/v4/pkg/action" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli/output" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // NOTE: Keep the list of statuses up-to-date with pkg/release/status.go. diff --git a/cmd/helm/status_test.go b/cmd/helm/status_test.go index 7e51849b1..7063e203f 100644 --- a/cmd/helm/status_test.go +++ b/cmd/helm/status_test.go @@ -21,7 +21,7 @@ import ( "time" chart "helm.sh/helm/v4/pkg/chart/v2" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index c41373337..4c07dac98 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -28,7 +28,7 @@ import ( "sort" "strings" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "github.com/spf13/cobra" diff --git a/cmd/helm/uninstall_test.go b/cmd/helm/uninstall_test.go index f9bc71ec2..852823591 100644 --- a/cmd/helm/uninstall_test.go +++ b/cmd/helm/uninstall_test.go @@ -19,7 +19,7 @@ package main import ( "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestUninstall(t *testing.T) { diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 7d6cb33ec..929051306 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -36,7 +36,7 @@ import ( "helm.sh/helm/v4/pkg/cli/values" "helm.sh/helm/v4/pkg/downloader" "helm.sh/helm/v4/pkg/getter" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage/driver" ) diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index 595ca9fc2..9b414c90a 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -27,7 +27,7 @@ import ( chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/chart/v2/loader" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestUpgradeCmd(t *testing.T) { diff --git a/pkg/action/action.go b/pkg/action/action.go index d91ccab51..ea2dc0dd7 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -39,8 +39,8 @@ import ( "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" - "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage" "helm.sh/helm/v4/pkg/storage/driver" "helm.sh/helm/v4/pkg/time" diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 4c78ef6c1..b1cf20597 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -28,7 +28,7 @@ import ( chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/registry" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage" "helm.sh/helm/v4/pkg/storage/driver" "helm.sh/helm/v4/pkg/time" diff --git a/pkg/action/get.go b/pkg/action/get.go index 4c0683f3e..dbe5f4cb3 100644 --- a/pkg/action/get.go +++ b/pkg/action/get.go @@ -17,7 +17,7 @@ limitations under the License. package action import ( - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // Get is the action for checking a given release's information. diff --git a/pkg/action/history.go b/pkg/action/history.go index e5ac16bfe..04743f4cd 100644 --- a/pkg/action/history.go +++ b/pkg/action/history.go @@ -20,7 +20,7 @@ import ( "github.com/pkg/errors" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // History is the action for checking the release's ledger. diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index b6c505807..230e9ec81 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -30,7 +30,7 @@ import ( "github.com/pkg/errors" "gopkg.in/yaml.v3" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/hooks_test.go b/pkg/action/hooks_test.go index b39ffe022..38f25d9ab 100644 --- a/pkg/action/hooks_test.go +++ b/pkg/action/hooks_test.go @@ -26,7 +26,7 @@ import ( chart "helm.sh/helm/v4/pkg/chart/v2" kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func podManifestWithOutputLogs(hookDefinitions []release.HookOutputLogPolicy) string { diff --git a/pkg/action/install.go b/pkg/action/install.go index ad260c361..f1896351e 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -48,8 +48,8 @@ import ( kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" - "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/repo" "helm.sh/helm/v4/pkg/storage" "helm.sh/helm/v4/pkg/storage/driver" diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 09715daf3..869055657 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -36,7 +36,7 @@ import ( chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage/driver" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/list.go b/pkg/action/list.go index 5c2b1e8a1..82500582f 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -22,8 +22,8 @@ import ( "k8s.io/apimachinery/pkg/labels" - "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" + release "helm.sh/helm/v4/pkg/release/v1" ) // ListStates represents zero or more status codes that a list item may have set diff --git a/pkg/action/list_test.go b/pkg/action/list_test.go index a7eb8a920..e41949310 100644 --- a/pkg/action/list_test.go +++ b/pkg/action/list_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage" ) diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index b4cdb47c8..c6374523e 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -28,7 +28,7 @@ import ( v1 "k8s.io/api/core/v1" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) const ( diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 0cd9d5d07..4006f565f 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -25,7 +25,7 @@ import ( "github.com/pkg/errors" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/status.go b/pkg/action/status.go index db9a3b3f0..509c52cd9 100644 --- a/pkg/action/status.go +++ b/pkg/action/status.go @@ -21,7 +21,7 @@ import ( "errors" "helm.sh/helm/v4/pkg/kube" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // Status is the action for checking the deployment status of releases. diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index bfec35fc0..fdbeb5dc8 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -26,8 +26,8 @@ import ( chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/kube" - "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go index eca9e6ad8..071b76943 100644 --- a/pkg/action/uninstall_test.go +++ b/pkg/action/uninstall_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/assert" kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func uninstallAction(t *testing.T) *Uninstall { diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 340f61585..e32c8dcaf 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -33,8 +33,8 @@ import ( "helm.sh/helm/v4/pkg/kube" "helm.sh/helm/v4/pkg/postrender" "helm.sh/helm/v4/pkg/registry" - "helm.sh/helm/v4/pkg/release" releaseutil "helm.sh/helm/v4/pkg/release/util" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage/driver" ) diff --git a/pkg/action/upgrade_test.go b/pkg/action/upgrade_test.go index 069578025..303f49e70 100644 --- a/pkg/action/upgrade_test.go +++ b/pkg/action/upgrade_test.go @@ -30,7 +30,7 @@ import ( "github.com/stretchr/testify/require" kubefake "helm.sh/helm/v4/pkg/kube/fake" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/release/util/filter.go b/pkg/release/util/filter.go index e56752f86..f0a082cfd 100644 --- a/pkg/release/util/filter.go +++ b/pkg/release/util/filter.go @@ -16,7 +16,7 @@ limitations under the License. package util // import "helm.sh/helm/v4/pkg/release/util" -import rspb "helm.sh/helm/v4/pkg/release" +import rspb "helm.sh/helm/v4/pkg/release/v1" // FilterFunc returns true if the release object satisfies // the predicate of the underlying filter func. diff --git a/pkg/release/util/filter_test.go b/pkg/release/util/filter_test.go index 2037ef157..5d2564619 100644 --- a/pkg/release/util/filter_test.go +++ b/pkg/release/util/filter_test.go @@ -19,7 +19,7 @@ package util // import "helm.sh/helm/v4/pkg/release/util" import ( "testing" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func TestFilterAny(t *testing.T) { diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 130b2c831..22795733c 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -19,7 +19,7 @@ package util import ( "sort" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // KindSortOrder is an ordering of Kinds. diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index cd40fe459..00d80ecf2 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -20,7 +20,7 @@ import ( "bytes" "testing" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestKindSorter(t *testing.T) { diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index c4ad62161..15eb76174 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/yaml" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) // Manifest represents a manifest file, which has a name and some content. diff --git a/pkg/release/util/manifest_sorter_test.go b/pkg/release/util/manifest_sorter_test.go index 281f24924..4360013e5 100644 --- a/pkg/release/util/manifest_sorter_test.go +++ b/pkg/release/util/manifest_sorter_test.go @@ -22,7 +22,7 @@ import ( "sigs.k8s.io/yaml" - "helm.sh/helm/v4/pkg/release" + release "helm.sh/helm/v4/pkg/release/v1" ) func TestSortManifests(t *testing.T) { diff --git a/pkg/release/util/sorter.go b/pkg/release/util/sorter.go index 8b1c89aa3..949adbda9 100644 --- a/pkg/release/util/sorter.go +++ b/pkg/release/util/sorter.go @@ -19,7 +19,7 @@ package util // import "helm.sh/helm/v4/pkg/release/util" import ( "sort" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) type list []*rspb.Release diff --git a/pkg/release/util/sorter_test.go b/pkg/release/util/sorter_test.go index 6e92eef5c..8a766efc9 100644 --- a/pkg/release/util/sorter_test.go +++ b/pkg/release/util/sorter_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" helmtime "helm.sh/helm/v4/pkg/time" ) diff --git a/pkg/release/hook.go b/pkg/release/v1/hook.go similarity index 99% rename from pkg/release/hook.go rename to pkg/release/v1/hook.go index 5ff61fdaa..1ef5c1eb8 100644 --- a/pkg/release/hook.go +++ b/pkg/release/v1/hook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package release +package v1 import ( "helm.sh/helm/v4/pkg/time" diff --git a/pkg/release/info.go b/pkg/release/v1/info.go similarity index 98% rename from pkg/release/info.go rename to pkg/release/v1/info.go index 514807a35..ff98ab63e 100644 --- a/pkg/release/info.go +++ b/pkg/release/v1/info.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package release +package v1 import ( "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/release/mock.go b/pkg/release/v1/mock.go similarity index 99% rename from pkg/release/mock.go rename to pkg/release/v1/mock.go index 94b4d01f3..9ca57284c 100644 --- a/pkg/release/mock.go +++ b/pkg/release/v1/mock.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package release +package v1 import ( "fmt" diff --git a/pkg/release/release.go b/pkg/release/v1/release.go similarity index 99% rename from pkg/release/release.go rename to pkg/release/v1/release.go index 1a7c7b18c..74e834f7b 100644 --- a/pkg/release/release.go +++ b/pkg/release/v1/release.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package release +package v1 import ( chart "helm.sh/helm/v4/pkg/chart/v2" diff --git a/pkg/release/responses.go b/pkg/release/v1/responses.go similarity index 98% rename from pkg/release/responses.go rename to pkg/release/v1/responses.go index 7ee1fc2ee..2a5608c67 100644 --- a/pkg/release/responses.go +++ b/pkg/release/v1/responses.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package release +package v1 // UninstallReleaseResponse represents a successful response to an uninstall request. type UninstallReleaseResponse struct { diff --git a/pkg/release/status.go b/pkg/release/v1/status.go similarity index 99% rename from pkg/release/status.go rename to pkg/release/v1/status.go index edd27a5f1..8d6459013 100644 --- a/pkg/release/status.go +++ b/pkg/release/v1/status.go @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package release +package v1 // Status is the status of a release type Status string diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 48edc3172..2b84b7f82 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) var _ Driver = (*ConfigMaps)(nil) diff --git a/pkg/storage/driver/cfgmaps_test.go b/pkg/storage/driver/cfgmaps_test.go index c93ef8ea4..8ba6832fa 100644 --- a/pkg/storage/driver/cfgmaps_test.go +++ b/pkg/storage/driver/cfgmaps_test.go @@ -21,7 +21,7 @@ import ( v1 "k8s.io/api/core/v1" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func TestConfigMapName(t *testing.T) { diff --git a/pkg/storage/driver/driver.go b/pkg/storage/driver/driver.go index 2987ba38e..661c32e52 100644 --- a/pkg/storage/driver/driver.go +++ b/pkg/storage/driver/driver.go @@ -21,7 +21,7 @@ import ( "github.com/pkg/errors" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) var ( diff --git a/pkg/storage/driver/memory.go b/pkg/storage/driver/memory.go index 430ab215f..79e7f090e 100644 --- a/pkg/storage/driver/memory.go +++ b/pkg/storage/driver/memory.go @@ -21,7 +21,7 @@ import ( "strings" "sync" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) var _ Driver = (*Memory)(nil) diff --git a/pkg/storage/driver/memory_test.go b/pkg/storage/driver/memory_test.go index 999649635..ee547b58b 100644 --- a/pkg/storage/driver/memory_test.go +++ b/pkg/storage/driver/memory_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func TestMemoryName(t *testing.T) { diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index 359f2d079..199da6505 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -31,7 +31,7 @@ import ( kblabels "k8s.io/apimachinery/pkg/labels" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func releaseStub(name string, vers int, namespace string, status rspb.Status) *rspb.Release { diff --git a/pkg/storage/driver/records.go b/pkg/storage/driver/records.go index 3b8f078fd..6b4efef3a 100644 --- a/pkg/storage/driver/records.go +++ b/pkg/storage/driver/records.go @@ -20,7 +20,7 @@ import ( "sort" "strconv" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) // records holds a list of in-memory release records diff --git a/pkg/storage/driver/records_test.go b/pkg/storage/driver/records_test.go index b1bb051d5..34b2fb80c 100644 --- a/pkg/storage/driver/records_test.go +++ b/pkg/storage/driver/records_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func TestRecordsAdd(t *testing.T) { diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index eb215a755..2ab128c6b 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) var _ Driver = (*Secrets)(nil) diff --git a/pkg/storage/driver/secrets_test.go b/pkg/storage/driver/secrets_test.go index 37ecc20dd..7affc81ab 100644 --- a/pkg/storage/driver/secrets_test.go +++ b/pkg/storage/driver/secrets_test.go @@ -21,7 +21,7 @@ import ( v1 "k8s.io/api/core/v1" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func TestSecretName(t *testing.T) { diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index d5ab6b0a1..12bdd3ff4 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -30,7 +30,7 @@ import ( // Import pq for postgres dialect _ "github.com/lib/pq" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) var _ Driver = (*SQL)(nil) diff --git a/pkg/storage/driver/sql_test.go b/pkg/storage/driver/sql_test.go index 8d7b88475..bd2918aad 100644 --- a/pkg/storage/driver/sql_test.go +++ b/pkg/storage/driver/sql_test.go @@ -23,7 +23,7 @@ import ( sqlmock "github.com/DATA-DOG/go-sqlmock" migrate "github.com/rubenv/sql-migrate" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) func TestSQLName(t *testing.T) { diff --git a/pkg/storage/driver/util.go b/pkg/storage/driver/util.go index 7f1bc716c..0abbe41b2 100644 --- a/pkg/storage/driver/util.go +++ b/pkg/storage/driver/util.go @@ -23,7 +23,7 @@ import ( "encoding/json" "io" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" ) var b64 = base64.StdEncoding diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 6a77cbae6..5e8718ea0 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -22,8 +22,8 @@ import ( "github.com/pkg/errors" - rspb "helm.sh/helm/v4/pkg/release" relutil "helm.sh/helm/v4/pkg/release/util" + rspb "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage/driver" ) diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index 80011520e..056b7f5f5 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" - rspb "helm.sh/helm/v4/pkg/release" + rspb "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/storage/driver" ) From 48f03d316b81b2f9d2d10e2e411c93930d349ff5 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 26 Feb 2025 15:21:47 -0500 Subject: [PATCH 165/271] changing from log to slog Signed-off-by: Robert Sirchia --- pkg/repo/index.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index c5f808229..3e063becf 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -19,7 +19,7 @@ package repo import ( "bytes" "encoding/json" - "log" + "log/slog" "os" "path" "path/filepath" @@ -154,7 +154,7 @@ func (i IndexFile) MustAdd(md *chart.Metadata, filename, baseURL, digest string) // Deprecated: Use index.MustAdd instead. func (i IndexFile) Add(md *chart.Metadata, filename, baseURL, digest string) { if err := i.MustAdd(md, filename, baseURL, digest); err != nil { - log.Printf("skipping loading invalid entry for chart %q %q from %s: %s", md.Name, md.Version, filename, err) + slog.Error("skipping loading invalid entry for chart %q %q from %s: %s", md.Name, md.Version, filename, err) } } @@ -356,7 +356,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { for name, cvs := range i.Entries { for idx := len(cvs) - 1; idx >= 0; idx-- { if cvs[idx] == nil { - log.Printf("skipping loading invalid entry for chart %q from %s: empty entry", name, source) + slog.Info("skipping loading invalid entry for chart %q from %s: empty entry", name, source) continue } // When metadata section missing, initialize with no data @@ -367,7 +367,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { cvs[idx].APIVersion = chart.APIVersionV1 } if err := cvs[idx].Validate(); ignoreSkippableChartValidationError(err) != nil { - log.Printf("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err) + slog.Error("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err) cvs = append(cvs[:idx], cvs[idx+1:]...) } } From a11f4c00265bdef681d2a84d3c7dfa4bb81d4812 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 12:56:52 -0500 Subject: [PATCH 166/271] changing info to error Signed-off-by: Robert Sirchia --- pkg/repo/index.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index 3e063becf..954d7486c 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -356,7 +356,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { for name, cvs := range i.Entries { for idx := len(cvs) - 1; idx >= 0; idx-- { if cvs[idx] == nil { - slog.Info("skipping loading invalid entry for chart %q from %s: empty entry", name, source) + slog.Error("skipping loading invalid entry for chart %q from %s: empty entry", name, source) continue } // When metadata section missing, initialize with no data From 1ad79a2bb71c94cb4c232a8527ddde1953d41b39 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 14:21:57 -0500 Subject: [PATCH 167/271] converting inline log to slog Signed-off-by: Robert Sirchia --- internal/sympath/walk.go | 4 ++-- pkg/chart/v2/util/dependencies.go | 12 ++++++------ pkg/engine/engine.go | 8 ++++---- pkg/engine/lookup_func.go | 10 +++++----- pkg/ignore/rules.go | 10 +++++----- pkg/plugin/installer/http_installer.go | 3 ++- pkg/plugin/installer/installer.go | 10 ---------- pkg/plugin/installer/local_installer.go | 5 +++-- pkg/plugin/installer/vcs_installer.go | 15 ++++++++------- pkg/release/util/manifest_sorter.go | 4 ++-- pkg/repo/chartrepo.go | 5 +++-- 11 files changed, 40 insertions(+), 46 deletions(-) diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index 6b221fb6c..938a99bfe 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -21,7 +21,7 @@ limitations under the License. package sympath import ( - "log" + "log/slog" "os" "path/filepath" "sort" @@ -72,7 +72,7 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { return errors.Wrapf(err, "error evaluating symlink %s", path) } //This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons. - log.Printf("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) + slog.Info("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) if info, err = os.Lstat(resolved); err != nil { return err } diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 78ed46517..2a6912e84 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -16,7 +16,7 @@ limitations under the License. package util import ( - "log" + "log/slog" "strings" "github.com/mitchellh/copystructure" @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - log.Printf("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - log.Printf("Warning: PathValue returned error %v", err) + slog.Error("Warning: PathValue returned error %v", err) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - log.Printf("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err) + slog.Error("Warning: ImportValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - log.Printf("Warning: ImportValues missing table: %v", err) + slog.Error("Warning: ImportValues missing table: %v", err) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 0d0a398be..650b56a3a 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -18,7 +18,7 @@ package engine import ( "fmt" - "log" + "log/slog" "path" "path/filepath" "regexp" @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - log.Printf("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - log.Printf("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - log.Printf("[INFO] Fail: %s", msg) + slog.Info("[INFO] Fail: %s", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 75e85098d..c7f7226f4 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -18,7 +18,7 @@ package engine import ( "context" - "log" + "log/slog" "strings" "github.com/pkg/errors" @@ -101,7 +101,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + slog.Error("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - log.Printf("[ERROR] unable to get dynamic client %s", err) + slog.Error("[ERROR] unable to get dynamic client %s", err) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - log.Printf("[ERROR] unable to create discovery client %s", err) + slog.Error("[ERROR] unable to create discovery client %s", err) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - log.Printf("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 88de407ad..e59e8dee5 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -20,7 +20,7 @@ import ( "bufio" "bytes" "io" - "log" + "log/slog" "os" "path/filepath" "strings" @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - log.Printf("ignore: no matcher supplied for %q", p.raw) + slog.Info("ignore: no matcher supplied for %q", p.raw) return false } @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - log.Printf("Failed to compile %q: %s", rule, err) + slog.Error("Failed to compile %q: %s", rule, err) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - log.Printf("Failed to compile %q: %s", rule, err) + slog.Error("Failed to compile %q: %s", rule, err) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - log.Printf("Failed to compile %q: %s", rule, err) + slog.Error("Failed to compile %q: %s", rule, err) return false } return ok diff --git a/pkg/plugin/installer/http_installer.go b/pkg/plugin/installer/http_installer.go index b900fa401..7e457b0d0 100644 --- a/pkg/plugin/installer/http_installer.go +++ b/pkg/plugin/installer/http_installer.go @@ -20,6 +20,7 @@ import ( "bytes" "compress/gzip" "io" + "log/slog" "os" "path" "path/filepath" @@ -144,7 +145,7 @@ func (i *HTTPInstaller) Install() error { return err } - debug("copying %s to %s", src, i.Path()) + slog.Debug("copying %s to %s", src, i.Path()) return fs.CopyDir(src, i.Path()) } diff --git a/pkg/plugin/installer/installer.go b/pkg/plugin/installer/installer.go index 5fad58f99..1e90bcaa0 100644 --- a/pkg/plugin/installer/installer.go +++ b/pkg/plugin/installer/installer.go @@ -16,8 +16,6 @@ limitations under the License. package installer import ( - "fmt" - "log" "net/http" "os" "path/filepath" @@ -125,11 +123,3 @@ func isPlugin(dirname string) bool { _, err := os.Stat(filepath.Join(dirname, plugin.PluginFileName)) return err == nil } - -var logger = log.New(os.Stderr, "[debug] ", log.Lshortfile) - -func debug(format string, args ...interface{}) { - if Debug { - logger.Output(2, fmt.Sprintf(format, args...)) - } -} diff --git a/pkg/plugin/installer/local_installer.go b/pkg/plugin/installer/local_installer.go index a79ca7ec7..4c95134ca 100644 --- a/pkg/plugin/installer/local_installer.go +++ b/pkg/plugin/installer/local_installer.go @@ -16,6 +16,7 @@ limitations under the License. package installer // import "helm.sh/helm/v4/pkg/plugin/installer" import ( + "log/slog" "os" "path/filepath" @@ -57,12 +58,12 @@ func (i *LocalInstaller) Install() error { if !isPlugin(i.Source) { return ErrMissingMetadata } - debug("symlinking %s to %s", i.Source, i.Path()) + slog.Debug("symlinking %s to %s", i.Source, i.Path()) return os.Symlink(i.Source, i.Path()) } // Update updates a local repository func (i *LocalInstaller) Update() error { - debug("local repository is auto-updated") + slog.Debug("local repository is auto-updated") return nil } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 3967e46cd..41b47ed13 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -16,6 +16,7 @@ limitations under the License. package installer // import "helm.sh/helm/v4/pkg/plugin/installer" import ( + "log/slog" "os" "sort" @@ -88,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - debug("updating %s", i.Repo.Remote()) + slog.Debug("updating %s", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -128,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - debug("found refs: %s", refs) + slog.Debug("found refs: %s", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -139,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - debug("setting to %s", ver) + slog.Debug("setting to %s", ver) return ver, nil } } @@ -149,17 +150,17 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - debug("setting version to %q", i.Version) + slog.Debug("setting version to %q", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - debug("updating %s", repo.Remote()) + slog.Debug("updating %s", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index 15eb76174..8b5247cad 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -17,7 +17,7 @@ limitations under the License. package util import ( - "log" + "log/slog" "path" "sort" "strconv" @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - log.Printf("info: skipping unknown hook: %q", hookTypes) + slog.Info("info: skipping unknown hook: %q", hookTypes) continue } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 52f81be57..070069748 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -22,7 +22,7 @@ import ( "encoding/json" "fmt" "io" - "log" + "log/slog" "net/url" "os" "path/filepath" @@ -343,7 +343,8 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - log.Panic(err) + slog.Error("failed to marshal entry: %s", err) + panic(err) } return string(buf) } From c36bc25fb16577559c6573633c630f1295040202 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 14:48:29 -0500 Subject: [PATCH 168/271] fixing missing attributes Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 4 ++-- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 4 ++-- pkg/ignore/rules.go | 2 +- pkg/plugin/installer/vcs_installer.go | 10 +++++----- pkg/release/util/manifest_sorter.go | 2 +- pkg/repo/chartrepo.go | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 2a6912e84..8c64298c9 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("Warning: PathValue returned error %v", err) + slog.Error("Warning: PathValue returned error %v", slog.Any("err", err)) } } } @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("Warning: ImportValues missing table: %v", err) + slog.Error("Warning: ImportValues missing table: %v", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 650b56a3a..157338bbd 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("[INFO] Fail: %s", msg) + slog.Info("[INFO] Fail: %s", "LintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index c7f7226f4..b8a0b8378 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("[ERROR] unable to get dynamic client %s", err) + slog.Error("[ERROR] unable to get dynamic client %s", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,7 +122,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("[ERROR] unable to create discovery client %s", err) + slog.Error("[ERROR] unable to create discovery client %s", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index e59e8dee5..6d146e719 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("ignore: no matcher supplied for %q", p.raw) + slog.Info("ignore: no matcher supplied for %q", "patterns", p.raw) return false } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 41b47ed13..cb7f3fa09 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -95,7 +95,7 @@ func (i *VCSInstaller) Install() error { // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating %s", i.Repo.Remote()) + slog.Debug("updating %s", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("found refs: %s", refs) + slog.Debug("found refs: %s", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("setting to %s", ver) + slog.Debug("setting to %s", "versions", ver) return ver, nil } } @@ -150,7 +150,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("setting version to %q", i.Version) + slog.Debug("setting version to %q", "versions", i.Version) return repo.UpdateVersion(ref) } @@ -160,7 +160,7 @@ func (i *VCSInstaller) sync(repo vcs.Repo) error { slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - slog.Debug("updating %s", repo.Remote()) + slog.Debug("updating %s", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index 8b5247cad..e1cf9171a 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("info: skipping unknown hook: %q", hookTypes) + slog.Info("info: skipping unknown hook: %q", "hookTypes", hookTypes) continue } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 070069748..748730f27 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -343,7 +343,7 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - slog.Error("failed to marshal entry: %s", err) + slog.Error("failed to marshal entry: %s", slog.Any("err", err)) panic(err) } return string(buf) From 8887d017915507ae3a28d6cfff4244f3fae79c5d Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 15:47:28 -0500 Subject: [PATCH 169/271] fixing issues with my PR Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 10 +++++----- pkg/engine/engine.go | 10 +++++----- pkg/engine/lookup_func.go | 10 +++++----- pkg/ignore/rules.go | 2 +- pkg/plugin/installer/vcs_installer.go | 16 ++++++++-------- pkg/release/util/manifest_sorter.go | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 8c64298c9..387d8b297 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - slog.Warn("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("Condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("Warning: PathValue returned error %v", slog.Any("err", err)) + slog.Error("PathValue returned error %v", slog.Any("err", err)) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - slog.Warn("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("Tag '%s' for chart %s returned non-bool value", k, r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("Warning: ImportValues missing table from chart %s: %v", r.Name, err) + slog.Error("ImportValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("Warning: ImportValues missing table: %v", slog.Any("err", err)) + slog.Error("ImportValues missing table: %v", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 157338bbd..fa51f0923 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -176,12 +176,12 @@ func tplFun(parent *template.Template, includedNames map[string]int, strict bool // text string. (Maybe we could use a hash appended to the name?) t, err = t.New(parent.Name()).Parse(tpl) if err != nil { - return "", errors.Wrapf(err, "cannot parse template %q", tpl) + return "", errors.Wrapf(err, "Cannot parse template %q", tpl) } var buf strings.Builder if err := t.Execute(&buf, vals); err != nil { - return "", errors.Wrapf(err, "error during tpl function execution for %q", tpl) + return "", errors.Wrapf(err, "Error during tpl function execution for %q", tpl) } // See comment in renderWithReferences explaining the hack. @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) + slog.Warn("Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) + slog.Warn("Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("[INFO] Fail: %s", "LintMode", msg) + slog.Info("Fail: %s", "LintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index b8a0b8378..47f7dd179 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,8 +101,8 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) + slog.Error("Unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + return nil, false, errors.Wrapf(err, "Unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ Group: apiRes.Group, @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("[ERROR] unable to get dynamic client %s", slog.Any("err", err)) + slog.Error("Unable to get dynamic client %s", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("[ERROR] unable to create discovery client %s", slog.Any("err", err)) + slog.Error("Unable to create discovery client %s", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("Unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 6d146e719..a343030ea 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("ignore: no matcher supplied for %q", "patterns", p.raw) + slog.Info("This will be ignored no matcher supplied for %q", "patterns", p.raw) return false } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index cb7f3fa09..97b2f1cd4 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -89,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("Copying %s to %s", i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating %s", "repo", i.Repo.Remote()) + slog.Debug("Updating %s", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("found refs: %s", "refs", refs) + slog.Debug("Found refs: %s", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,27 +140,27 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("setting to %s", "versions", ver) + slog.Debug("Setting to %s", "versions", ver) return ver, nil } } - return "", errors.Errorf("requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) + return "", errors.Errorf("Requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) } // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("setting version to %q", "versions", i.Version) + slog.Debug("Setting version to %q", "versions", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("Cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - slog.Debug("updating %s", "remote", repo.Remote()) + slog.Debug("Updating %s", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index e1cf9171a..495b0ae0d 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("info: skipping unknown hook: %q", "hookTypes", hookTypes) + slog.Info("Skipping unknown hook: %q", "hookTypes", hookTypes) continue } From 5a8058dc31a8326691f52533e9b08b41cfd0b5f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 21:29:19 +0000 Subject: [PATCH 170/271] build(deps): bump github.com/containerd/containerd from 1.7.25 to 1.7.26 Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.25 to 1.7.26. - [Release notes](https://github.com/containerd/containerd/releases) - [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md) - [Commits](https://github.com/containerd/containerd/compare/v1.7.25...v1.7.26) --- updated-dependencies: - dependency-name: github.com/containerd/containerd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0b2836b06..7aaff78cc 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/Masterminds/squirrel v1.5.4 github.com/Masterminds/vcs v1.13.3 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 - github.com/containerd/containerd v1.7.25 + github.com/containerd/containerd v1.7.26 github.com/cyphar/filepath-securejoin v0.4.1 github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/evanphx/json-patch v5.9.11+incompatible diff --git a/go.sum b/go.sum index 467cef72f..874bde217 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= -github.com/containerd/containerd v1.7.25 h1:khEQOAXOEJalRO228yzVsuASLH42vT7DIo9Ss+9SMFQ= -github.com/containerd/containerd v1.7.25/go.mod h1:tWfHzVI0azhw4CT2vaIjsb2CoV4LJ9PrMPaULAr21Ok= +github.com/containerd/containerd v1.7.26 h1:3cs8K2RHlMQaPifLqgRyI4VBkoldNdEw62cb7qQga7k= +github.com/containerd/containerd v1.7.26/go.mod h1:m4JU0E+h0ebbo9yXD7Hyt+sWnc8tChm7MudCjj4jRvQ= github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= From c2e6ed8ae5bcfa3ca1932bb4e0fb6a498b23283b Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 28 Feb 2025 08:22:53 -0500 Subject: [PATCH 171/271] fixing build error Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 10 +++++----- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 10 +++++----- pkg/ignore/rules.go | 8 ++++---- pkg/plugin/installer/vcs_installer.go | 16 ++++++++-------- pkg/release/util/manifest_sorter.go | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 387d8b297..07d2ad055 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - slog.Warn("Condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("PathValue returned error %v", slog.Any("err", err)) + slog.Error("pathValue returned error %v", slog.Any("err", err)) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - slog.Warn("Tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("tag '%s' for chart %s returned non-bool value", k, r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table from chart %s: %v", r.Name, err) + slog.Error("importValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table: %v", slog.Any("err", err)) + slog.Error("importValues missing table: %v", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index fa51f0923..4da458e73 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("Missing required value: %s", "LintMode", warn) + slog.Warn("missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("Missing required value: %s", "LintMode", warn) + slog.Warn("missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("Fail: %s", "LintMode", msg) + slog.Info("fail: %s", "lintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 47f7dd179..9043b519b 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,8 +101,8 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("Unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, false, errors.Wrapf(err, "Unable to get apiresource from unstructured: %s", gvk.String()) + slog.Error("unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ Group: apiRes.Group, @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("Unable to get dynamic client %s", slog.Any("err", err)) + slog.Error("unable to get dynamic client %s", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("Unable to create discovery client %s", slog.Any("err", err)) + slog.Error("unable to create discovery client %s", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("Unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index a343030ea..25a9c6715 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("This will be ignored no matcher supplied for %q", "patterns", p.raw) + slog.Info("this will be ignored no matcher supplied for %q", "patterns", p.raw) return false } @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("Failed to compile %q: %s", rule, err) + slog.Error("failed to compile %q: %s", rule, err) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("Failed to compile %q: %s", rule, err) + slog.Error("failed to compile %q: %s", rule, err) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("Failed to compile %q: %s", rule, err) + slog.Error("failed to compile %q: %s", rule, err) return false } return ok diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 97b2f1cd4..cb7f3fa09 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -89,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - slog.Debug("Copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("Updating %s", "repo", i.Repo.Remote()) + slog.Debug("updating %s", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("Found refs: %s", "refs", refs) + slog.Debug("found refs: %s", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,27 +140,27 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("Setting to %s", "versions", ver) + slog.Debug("setting to %s", "versions", ver) return ver, nil } } - return "", errors.Errorf("Requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) + return "", errors.Errorf("requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) } // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("Setting version to %q", "versions", i.Version) + slog.Debug("setting version to %q", "versions", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - slog.Debug("Cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - slog.Debug("Updating %s", "remote", repo.Remote()) + slog.Debug("updating %s", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index 495b0ae0d..a0107c8ee 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("Skipping unknown hook: %q", "hookTypes", hookTypes) + slog.Info("skipping unknown hook: %q", "hookTypes", hookTypes) continue } From f50547bf51aab27966b332fa10d80ac62873b85c Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 28 Feb 2025 15:22:47 -0500 Subject: [PATCH 172/271] changing error to warn as requested by Matt Signed-off-by: Robert Sirchia --- pkg/repo/index.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index 954d7486c..4f0266ca6 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -356,7 +356,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { for name, cvs := range i.Entries { for idx := len(cvs) - 1; idx >= 0; idx-- { if cvs[idx] == nil { - slog.Error("skipping loading invalid entry for chart %q from %s: empty entry", name, source) + slog.Warn("skipping loading invalid entry for chart %q from %s: empty entry", name, source) continue } // When metadata section missing, initialize with no data @@ -367,7 +367,7 @@ func loadIndex(data []byte, source string) (*IndexFile, error) { cvs[idx].APIVersion = chart.APIVersionV1 } if err := cvs[idx].Validate(); ignoreSkippableChartValidationError(err) != nil { - slog.Error("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err) + slog.Warn("skipping loading invalid entry for chart %q %q from %s: %s", name, cvs[idx].Version, source, err) cvs = append(cvs[:idx], cvs[idx+1:]...) } } From 848c134e0c0b8d47285a61c5c923e7c449e1a67c Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 28 Feb 2025 16:14:48 -0500 Subject: [PATCH 173/271] fixing error messages Signed-off-by: Robert Sirchia --- internal/sympath/walk.go | 2 +- pkg/chart/v2/util/dependencies.go | 10 +++++----- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 8 ++++---- pkg/ignore/rules.go | 8 ++++---- pkg/plugin/installer/http_installer.go | 2 +- pkg/plugin/installer/local_installer.go | 2 +- pkg/plugin/installer/vcs_installer.go | 14 +++++++------- pkg/release/util/manifest_sorter.go | 2 +- pkg/repo/chartrepo.go | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index 938a99bfe..0cd258d39 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -72,7 +72,7 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { return errors.Wrapf(err, "error evaluating symlink %s", path) } //This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons. - slog.Info("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) + slog.Info("found symbolic link in path. Contents of linked file included and used", "path", path, "resolved", resolved) if info, err = os.Lstat(resolved); err != nil { return err } diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 07d2ad055..80268b45c 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - slog.Warn("condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("pathValue returned error %v", slog.Any("err", err)) + slog.Error("pathValue returned error", slog.Any("err", err)) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - slog.Warn("tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("returned non-bool value", "tag", k, "chart", r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table from chart %s: %v", r.Name, err) + slog.Error("importValues missing table from chart", "chart", r.Name, "value", err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table: %v", slog.Any("err", err)) + slog.Error("importValues missing table", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 4da458e73..d47606ee6 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required value: %s", "LintMode", warn) + slog.Warn("missing required value", "value", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required value: %s", "LintMode", warn) + slog.Warn("missing required values", "value", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("fail: %s", "lintMode", msg) + slog.Info("funcMap fail", "lintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 9043b519b..b36e6a7ef 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,7 +101,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + slog.Error("unable to get apiresource", "groupVersionKind", gvk.String(), "error", err) return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("unable to get dynamic client %s", slog.Any("err", err)) + slog.Error("unable to get dynamic client", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("unable to create discovery client %s", slog.Any("err", err)) + slog.Error("unable to create discovery client", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("unable to retrieve resource list", "list", gvk.GroupVersion().String(), "error", err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 25a9c6715..3f672873c 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("this will be ignored no matcher supplied for %q", "patterns", p.raw) + slog.Info("this will be ignored no matcher supplied", "patterns", p.raw) return false } @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile %q: %s", rule, err) + slog.Error("failed to compile", "rule", rule, "error", err) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile %q: %s", rule, err) + slog.Error("failed to compile", "rule", rule, "error", err) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile %q: %s", rule, err) + slog.Error("failed to compile", "rule", rule, "error", err) return false } return ok diff --git a/pkg/plugin/installer/http_installer.go b/pkg/plugin/installer/http_installer.go index 7e457b0d0..cc45787bf 100644 --- a/pkg/plugin/installer/http_installer.go +++ b/pkg/plugin/installer/http_installer.go @@ -145,7 +145,7 @@ func (i *HTTPInstaller) Install() error { return err } - slog.Debug("copying %s to %s", src, i.Path()) + slog.Debug("copying", "source", src, "path", i.Path()) return fs.CopyDir(src, i.Path()) } diff --git a/pkg/plugin/installer/local_installer.go b/pkg/plugin/installer/local_installer.go index 4c95134ca..52636d019 100644 --- a/pkg/plugin/installer/local_installer.go +++ b/pkg/plugin/installer/local_installer.go @@ -58,7 +58,7 @@ func (i *LocalInstaller) Install() error { if !isPlugin(i.Source) { return ErrMissingMetadata } - slog.Debug("symlinking %s to %s", i.Source, i.Path()) + slog.Debug("symlinking", "source", i.Source, "path", i.Path()) return os.Symlink(i.Source, i.Path()) } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index cb7f3fa09..049775094 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -89,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("copying files", "source", i.Repo.LocalPath(), "destination", i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating %s", "repo", i.Repo.Remote()) + slog.Debug("updating", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("found refs: %s", "refs", refs) + slog.Debug("found refs", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("setting to %s", "versions", ver) + slog.Debug("setting to version", "version", ver) return ver, nil } } @@ -150,17 +150,17 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("setting version to %q", "versions", i.Version) + slog.Debug("setting version", "version", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("cloning", "source", repo.Remote(), "destination", repo.LocalPath()) return repo.Get() } - slog.Debug("updating %s", "remote", repo.Remote()) + slog.Debug("updating", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index a0107c8ee..df3bd71d7 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("skipping unknown hook: %q", "hookTypes", hookTypes) + slog.Info("skipping unknown hooks", "hookTypes", hookTypes) continue } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 748730f27..766e31a61 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -343,7 +343,7 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - slog.Error("failed to marshal entry: %s", slog.Any("err", err)) + slog.Error("failed to marshal entry", slog.Any("err", err)) panic(err) } return string(buf) From 12b8eb8b618a8faa309fce42d1bfa9006b9a0214 Mon Sep 17 00:00:00 2001 From: Rongrong Liu Date: Wed, 26 Feb 2025 09:16:39 -0800 Subject: [PATCH 174/271] fix:add proxy support when mTLS configured Signed-off-by: Rongrong Liu --- pkg/cmd/root.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index ff4dcecbc..942060896 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -339,6 +339,7 @@ func newRegistryClientWithTLS( registry.ClientOptHTTPClient(&http.Client{ Transport: &http.Transport{ TLSClientConfig: tlsConf, + Proxy: http.ProxyFromEnvironment, }, }), registry.ClientOptBasicAuth(username, password), From b298910e079ee53bb818e7508b9a4ec57b8c418a Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Sat, 1 Mar 2025 16:48:21 -0800 Subject: [PATCH 175/271] Remove 'coveralls' Signed-off-by: George Jenkins --- scripts/coverage.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 2d8258866..2164d94da 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -20,10 +20,6 @@ covermode=${COVERMODE:-atomic} coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX) profile="${coverdir}/cover.out" -pushd / -hash goveralls 2>/dev/null || go install github.com/mattn/goveralls@v0.0.11 -popd - generate_cover_data() { for d in $(go list ./...) ; do ( @@ -36,10 +32,6 @@ generate_cover_data() { grep -h -v "^mode:" "$coverdir"/*.cover >>"$profile" } -push_to_coveralls() { - goveralls -coverprofile="${profile}" -service=github -} - generate_cover_data go tool cover -func "${profile}" @@ -47,8 +39,5 @@ case "${1-}" in --html) go tool cover -html "${profile}" ;; - --coveralls) - push_to_coveralls - ;; esac From 763e61e47e9ebc0fd15a2534c9ce00c90d51e99e Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Sat, 1 Mar 2025 17:50:15 -0800 Subject: [PATCH 176/271] fix: Fix go report card badge reference/link Signed-off-by: George Jenkins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf177aa4b..5f4d71d4c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Helm [![Build Status](https://github.com/helm/helm/workflows/release/badge.svg)](https://github.com/helm/helm/actions?workflow=release) -[![Go Report Card](https://goreportcard.com/badge/github.com/helm/helm)](https://goreportcard.com/report/github.com/helm/helm) +[![Go Report Card](https://goreportcard.com/badge/helm.sh/helm/v4)](https://goreportcard.com/report/helm.sh/helm/v4) [![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/helm.sh/helm/v4) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3131/badge)](https://bestpractices.coreinfrastructure.org/projects/3131) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/helm/helm/badge)](https://scorecard.dev/viewer/?uri=github.com/helm/helm) From 5ecca2ed143187ba4c8e3dde44c9ec5f1627ce6b Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Mon, 3 Mar 2025 11:53:00 -0500 Subject: [PATCH 177/271] Apply suggestions from code review Co-authored-by: Scott Rigby Signed-off-by: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> --- internal/statusreaders/job_status_reader.go | 5 +++-- internal/statusreaders/job_status_reader_test.go | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/statusreaders/job_status_reader.go b/internal/statusreaders/job_status_reader.go index d493d9e13..e11843f6d 100644 --- a/internal/statusreaders/job_status_reader.go +++ b/internal/statusreaders/job_status_reader.go @@ -1,5 +1,8 @@ /* Copyright The Helm Authors. +This file was initially copied and modified from + https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go +Copyright 2022 The Flux authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +19,6 @@ limitations under the License. package statusreaders -// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go - import ( "context" "fmt" diff --git a/internal/statusreaders/job_status_reader_test.go b/internal/statusreaders/job_status_reader_test.go index 70e4ee29a..5f07be91c 100644 --- a/internal/statusreaders/job_status_reader_test.go +++ b/internal/statusreaders/job_status_reader_test.go @@ -1,5 +1,8 @@ /* Copyright The Helm Authors. +This file was initially copied and modified from + https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job_test.go +Copyright 2022 The Flux authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,7 +19,6 @@ limitations under the License. package statusreaders -// This file was copied and modified from https://github.com/fluxcd/kustomize-controller/blob/main/internal/statusreaders/job.go import ( "testing" From 20c75f0c10023a652f310cce1f1582b5fa71c193 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 3 Mar 2025 17:26:21 +0000 Subject: [PATCH 178/271] fix namespace assignment not passing through Signed-off-by: Austin Abro --- cmd/helm/helm.go | 65 ------------------------------------------------ pkg/cmd/root.go | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 65 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 4bdd9a388..538aa9ed8 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -17,37 +17,21 @@ limitations under the License. package main // import "helm.sh/helm/v4/cmd/helm" import ( - "io" "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/v4/pkg/action" - "helm.sh/helm/v4/pkg/cli" helmcmd "helm.sh/helm/v4/pkg/cmd" "helm.sh/helm/v4/pkg/kube" - kubefake "helm.sh/helm/v4/pkg/kube/fake" - release "helm.sh/helm/v4/pkg/release/v1" - "helm.sh/helm/v4/pkg/storage/driver" ) -var settings = cli.New() - func init() { log.SetFlags(log.Lshortfile) } -// hookOutputWriter provides the writer for writing hook logs. -func hookOutputWriter(_, _, _ string) io.Writer { - return log.Writer() -} - 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 @@ -62,17 +46,6 @@ func main() { os.Exit(1) } - cobra.OnInitialize(func() { - helmDriver := os.Getenv("HELM_DRIVER") - if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, helmcmd.Debug); err != nil { - log.Fatal(err) - } - if helmDriver == "memory" { - loadReleasesInMemory(actionConfig) - } - actionConfig.SetHookOutputFunc(hookOutputWriter) - }) - if err := cmd.Execute(); err != nil { helmcmd.Debug("%+v", err) switch e := err.(type) { @@ -83,41 +56,3 @@ func main() { } } } - -// 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: io.Discard} - - for _, path := range filePaths { - b, err := os.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/pkg/cmd/root.go b/pkg/cmd/root.go index 942060896..c035181e3 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -26,6 +26,7 @@ import ( "strings" "github.com/spf13/cobra" + "sigs.k8s.io/yaml" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" @@ -33,8 +34,11 @@ import ( "helm.sh/helm/v4/internal/tlsutil" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli" + kubefake "helm.sh/helm/v4/pkg/kube/fake" "helm.sh/helm/v4/pkg/registry" + release "helm.sh/helm/v4/pkg/release/v1" "helm.sh/helm/v4/pkg/repo" + "helm.sh/helm/v4/pkg/storage/driver" ) var globalUsage = `The Kubernetes package manager @@ -119,6 +123,17 @@ func NewRootCmd(actionConfig *action.Configuration, out io.Writer, args []string } }, } + + 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) + } + actionConfig.SetHookOutputFunc(hookOutputWriter) + }) flags := cmd.PersistentFlags() settings.AddFlags(flags) @@ -232,6 +247,49 @@ func NewRootCmd(actionConfig *action.Configuration, out io.Writer, args []string return cmd, nil } +// 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: io.Discard} + + for _, path := range filePaths { + b, err := os.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()) +} + +// hookOutputWriter provides the writer for writing hook logs. +func hookOutputWriter(_, _, _ string) io.Writer { + return log.Writer() +} + func checkForExpiredRepos(repofile string) { expiredRepos := []struct { From 022d4db6af8d6d0307164be41a0c1cb68ea12ec0 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 3 Mar 2025 18:43:03 +0000 Subject: [PATCH 179/271] move logic from cmd/helm to pkg/cmd Signed-off-by: Austin Abro --- cmd/helm/helm.go | 4 +--- pkg/cmd/helpers_test.go | 2 +- pkg/cmd/root.go | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 538aa9ed8..da6a5c54e 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -23,7 +23,6 @@ import ( // Import to initialize client auth plugins. _ "k8s.io/client-go/plugin/pkg/client/auth" - "helm.sh/helm/v4/pkg/action" helmcmd "helm.sh/helm/v4/pkg/cmd" "helm.sh/helm/v4/pkg/kube" ) @@ -39,8 +38,7 @@ func main() { // manager as picked up by the automated name detection. kube.ManagedFieldsManager = "helm" - actionConfig := new(action.Configuration) - cmd, err := helmcmd.NewRootCmd(actionConfig, os.Stdout, os.Args[1:]) + cmd, err := helmcmd.NewRootCmd(os.Stdout, os.Args[1:]) if err != nil { helmcmd.Warning("%+v", err) os.Exit(1) diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index 5f9f4e769..effbc1673 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -95,7 +95,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) Log: func(_ string, _ ...interface{}) {}, } - root, err := NewRootCmd(actionConfig, buf, args) + root, err := newRootCmdWithConfig(actionConfig, buf, args) if err != nil { return nil, "", err } diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index c035181e3..ea686be7c 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -106,7 +106,26 @@ func Warning(format string, v ...interface{}) { fmt.Fprintf(os.Stderr, "WARNING: "+format+"\n", v...) } -func NewRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) { +func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { + actionConfig := new(action.Configuration) + cmd, err := newRootCmdWithConfig(actionConfig, out, args) + if err != nil { + return nil, err + } + 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) + } + actionConfig.SetHookOutputFunc(hookOutputWriter) + }) + return cmd, nil +} + +func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) { cmd := &cobra.Command{ Use: "helm", Short: "The Helm package manager for Kubernetes.", @@ -124,16 +143,6 @@ func NewRootCmd(actionConfig *action.Configuration, out io.Writer, args []string }, } - 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) - } - actionConfig.SetHookOutputFunc(hookOutputWriter) - }) flags := cmd.PersistentFlags() settings.AddFlags(flags) From 68f72e5c3fb9c2bc6486a29a6eb5522a05ea8f81 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 3 Mar 2025 19:56:00 +0000 Subject: [PATCH 180/271] hook only strategy when wait=false Signed-off-by: Austin Abro --- pkg/cmd/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index 10c7e9714..044b19e04 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -85,7 +85,7 @@ func (ws *waitValue) Set(s string) error { *ws = waitValue(kube.StatusWatcherStrategy) return nil case "false": - *ws = "" + *ws = waitValue(kube.HookOnlyStrategy) return nil default: return fmt.Errorf("invalid wait input %q. Valid inputs are true, false, %s, and %s", s, kube.StatusWatcherStrategy, kube.LegacyStrategy) From 20f478ce09c6098afb2f7b5521ff9d5d399ad69b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 22:03:47 +0000 Subject: [PATCH 181/271] build(deps): bump github.com/opencontainers/image-spec Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0 to 1.1.1. - [Release notes](https://github.com/opencontainers/image-spec/releases) - [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md) - [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: github.com/opencontainers/image-spec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7aaff78cc..84ab22d12 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/mattn/go-shellwords v1.0.12 github.com/mitchellh/copystructure v1.2.0 github.com/moby/term v0.5.2 - github.com/opencontainers/image-spec v1.1.0 + github.com/opencontainers/image-spec v1.1.1 github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/pkg/errors v0.9.1 github.com/rubenv/sql-migrate v1.7.1 diff --git a/go.sum b/go.sum index 874bde217..01e37e8e5 100644 --- a/go.sum +++ b/go.sum @@ -259,8 +259,8 @@ github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= From 8d964588cd3b54b470510ee9663eedba25c6186b Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Tue, 4 Mar 2025 17:47:25 -0500 Subject: [PATCH 182/271] Update internal/statusreaders/job_status_reader.go Co-authored-by: Scott Rigby Signed-off-by: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> --- internal/statusreaders/job_status_reader.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/statusreaders/job_status_reader.go b/internal/statusreaders/job_status_reader.go index e11843f6d..3cd9ac7ac 100644 --- a/internal/statusreaders/job_status_reader.go +++ b/internal/statusreaders/job_status_reader.go @@ -29,11 +29,11 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" - "sigs.k8s.io/cli-utils/pkg/object" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/engine" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/event" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/statusreaders" + "github.com/fluxcd/cli-utils/pkg/kstatus/status" + "github.com/fluxcd/cli-utils/pkg/object" ) type customJobStatusReader struct { From 24dc64382292cbc3ad30743f6d2c63fbfcd810d5 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 4 Mar 2025 22:56:11 +0000 Subject: [PATCH 183/271] restmapper Signed-off-by: Austin Abro --- go.mod | 49 ++++---- go.sum | 117 ++++++++---------- .../statusreaders/job_status_reader_test.go | 2 +- internal/statusreaders/pod_status_reader.go | 10 +- .../statusreaders/pod_status_reader_test.go | 2 +- pkg/kube/statuswait.go | 16 +-- pkg/kube/statuswait_test.go | 2 +- 7 files changed, 95 insertions(+), 103 deletions(-) diff --git a/go.mod b/go.mod index 1d318ea25..3e4c81cdc 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/cyphar/filepath-securejoin v0.4.1 github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/evanphx/json-patch v5.9.11+incompatible + github.com/fluxcd/cli-utils v0.36.0-flux.12 github.com/foxcpp/go-mockdns v1.1.0 github.com/gobwas/glob v0.2.3 github.com/gofrs/flock v0.12.1 @@ -46,7 +47,6 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/kubectl v0.32.2 oras.land/oras-go/v2 v2.5.0 - sigs.k8s.io/cli-utils v0.37.2 sigs.k8s.io/controller-runtime v0.20.1 sigs.k8s.io/yaml v1.4.0 ) @@ -73,30 +73,30 @@ require ( github.com/docker/docker-credential-helpers v0.8.2 // indirect github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect github.com/docker/go-metrics v0.0.1 // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch/v5 v5.9.0 // indirect + github.com/emicklei/go-restful/v3 v3.12.1 // indirect + github.com/evanphx/json-patch/v5 v5.9.11 // indirect github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect github.com/fatih/color v1.13.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/go-errors/errors v1.4.2 // indirect + github.com/go-errors/errors v1.5.1 // indirect github.com/go-gorp/gorp/v3 v3.1.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/btree v1.1.3 // indirect - github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/handlers v1.5.2 // indirect github.com/gorilla/mux v1.8.1 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/websocket v1.5.3 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -110,7 +110,7 @@ require ( github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/mailru/easyjson v0.7.7 // indirect + github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect @@ -123,13 +123,13 @@ require ( github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/onsi/gomega v1.35.1 // indirect + github.com/onsi/gomega v1.36.2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.60.1 // indirect + github.com/prometheus/common v0.62.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 // indirect @@ -142,10 +142,11 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xlab/treeprint v1.2.0 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 // indirect go.opentelemetry.io/contrib/exporters/autoexport v0.57.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 // indirect - go.opentelemetry.io/otel v1.32.0 // indirect + go.opentelemetry.io/otel v1.34.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 // indirect @@ -158,31 +159,31 @@ require ( go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.32.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.32.0 // indirect go.opentelemetry.io/otel/log v0.8.0 // indirect - go.opentelemetry.io/otel/metric v1.32.0 // indirect + go.opentelemetry.io/otel/metric v1.34.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/sdk/log v0.8.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect - go.opentelemetry.io/otel/trace v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.34.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/mod v0.22.0 // indirect + golang.org/x/net v0.34.0 // indirect + golang.org/x/oauth2 v0.25.0 // indirect golang.org/x/sync v0.11.0 // indirect golang.org/x/sys v0.30.0 // indirect - golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/time v0.9.0 // indirect + golang.org/x/tools v0.29.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/grpc v1.68.0 // indirect - google.golang.org/protobuf v1.35.2 // indirect + google.golang.org/protobuf v1.36.4 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/component-base v0.32.2 // indirect - k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect - k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect - sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect + sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/kustomize/api v0.18.0 // indirect - sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect ) diff --git a/go.sum b/go.sum index 57fbc6117..9fbf29bfc 100644 --- a/go.sum +++ b/go.sum @@ -60,7 +60,6 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= @@ -81,26 +80,28 @@ github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= -github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= -github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU= +github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.9.11+incompatible h1:ixHHqfcGvxhWkniF1tWxBHA0yb4Z+d1UQi45df52xW8= github.com/evanphx/json-patch v5.9.11+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= -github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU= +github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM= github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f h1:Wl78ApPPB2Wvf/TIe2xdyJxTlb6obmF18d8QdkxNDu4= github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f/go.mod h1:OSYXu++VVOHnXeitef/D8n/6y4QV8uLHSFXX4NeXMGc= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fluxcd/cli-utils v0.36.0-flux.12 h1:8cD6SmaKa/lGo0KCu0XWiGrXJMLMBQwSsnoP0cG+Gjw= +github.com/fluxcd/cli-utils v0.36.0-flux.12/go.mod h1:Nb/zMqsJAzjz4/HIsEc2LTqxC6eC0rV26t4hkJT/F9o= github.com/foxcpp/go-mockdns v1.1.0 h1:jI0rD8M0wuYAxL7r/ynTrCQQq0BVqfB99Vgk7DlmewI= github.com/foxcpp/go-mockdns v1.1.0/go.mod h1:IhLeSFGed3mJIAXPH2aiRQB+kqz7oqu8ld2qVbOu7Wk= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= +github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs= github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -113,12 +114,10 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= @@ -141,8 +140,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -150,8 +149,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= -github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20250128161936-077ca0a936bf h1:BvBLUD2hkvLI3dJTJMiopAq8/wp43AAZKTP7qdpptbU= +github.com/google/pprof v0.0.0-20250128161936-077ca0a936bf/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -160,8 +159,8 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= @@ -197,11 +196,8 @@ github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IX github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -214,8 +210,8 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= +github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -257,10 +253,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= -github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= -github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= -github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU= +github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk= +github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= +github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= @@ -288,8 +284,8 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= -github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= -github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= +github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= @@ -323,17 +319,12 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= @@ -350,14 +341,16 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 h1:UW0+QyeyBVhn+COBec3nGhfnFe5lwB0ic1JBVjzhk0w= go.opentelemetry.io/contrib/bridges/prometheus v0.57.0/go.mod h1:ppciCHRLsyCio54qbzQv0E4Jyth/fLWDTJYfvWpcSVk= go.opentelemetry.io/contrib/exporters/autoexport v0.57.0 h1:jmTVJ86dP60C01K3slFQa2NQ/Aoi7zA+wy7vMOKD9H4= go.opentelemetry.io/contrib/exporters/autoexport v0.57.0/go.mod h1:EJBheUMttD/lABFyLXhce47Wr6DPWYReCzaZiXadH7g= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 h1:DheMAlT6POBP+gh8RUH19EOTnQIor5QE0uSRPtzCpSw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0/go.mod h1:wZcGmeVO9nzP67aYSLDqXNWK87EZWhi7JWj1v7ZXf94= -go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= -go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 h1:WzNab7hOOLzdDF/EoWCt4glhrbMPVMOO5JYTmpz36Ls= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0/go.mod h1:hKvJwTzJdp90Vh7p6q/9PAOd55dI6WA6sWj62a/JvSs= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 h1:S+LdBGiQXtJdowoJoQPEtI52syEP/JYBUpjO49EQhV8= @@ -382,16 +375,16 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.32.0 h1:cC2yDI3IQd0Udsu go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.32.0/go.mod h1:2PD5Ex6z8CFzDbTdOlwyNIUywRr1DN0ospafJM1wJ+s= go.opentelemetry.io/otel/log v0.8.0 h1:egZ8vV5atrUWUbnSsHn6vB8R21G2wrKqNiDt3iWertk= go.opentelemetry.io/otel/log v0.8.0/go.mod h1:M9qvDdUTRCopJcGRKg57+JSQ9LgLBrwwfC32epk5NX8= -go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= -go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/sdk/log v0.8.0 h1:zg7GUYXqxk1jnGF/dTdLPrK06xJdrXgqgFLnI4Crxvs= go.opentelemetry.io/otel/sdk/log v0.8.0/go.mod h1:50iXr0UVwQrYS45KbruFrEt4LvAdCaWWgIrsN3ZQggo= go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= -go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= -go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -416,8 +409,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -431,10 +424,10 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= +golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= +golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -488,8 +481,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= -golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= -golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= +golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -498,8 +491,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= +golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -510,8 +503,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= -google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= -google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= +google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -542,25 +535,23 @@ k8s.io/component-base v0.32.2 h1:1aUL5Vdmu7qNo4ZsE+569PV5zFatM9hl+lb3dEea2zU= k8s.io/component-base v0.32.2/go.mod h1:PXJ61Vx9Lg+P5mS8TLd7bCIr+eMJRQTyXe8KvkrvJq0= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= -k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= +k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= +k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= k8s.io/kubectl v0.32.2 h1:TAkag6+XfSBgkqK9I7ZvwtF0WVtUAvK8ZqTt+5zi1Us= k8s.io/kubectl v0.32.2/go.mod h1:+h/NQFSPxiDZYX/WZaWw9fwYezGLISP0ud8nQKg+3g8= -k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= -k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0= +k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= oras.land/oras-go/v2 v2.5.0/go.mod h1:z4eisnLP530vwIOUOJeBIj0aGI0L1C3d53atvCBqZHg= -sigs.k8s.io/cli-utils v0.37.2 h1:GOfKw5RV2HDQZDJlru5KkfLO1tbxqMoyn1IYUxqBpNg= -sigs.k8s.io/cli-utils v0.37.2/go.mod h1:V+IZZr4UoGj7gMJXklWBg6t5xbdThFBcpj4MrZuCYco= sigs.k8s.io/controller-runtime v0.20.1 h1:JbGMAG/X94NeM3xvjenVUaBjy6Ui4Ogd/J5ZtjZnHaE= sigs.k8s.io/controller-runtime v0.20.1/go.mod h1:BrP3w158MwvB3ZbNpaAcIKkHQ7YGpYnzpoSTZ8E14WU= -sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= -sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= +sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/kustomize/api v0.18.0 h1:hTzp67k+3NEVInwz5BHyzc9rGxIauoXferXyjv5lWPo= sigs.k8s.io/kustomize/api v0.18.0/go.mod h1:f8isXnX+8b+SGLHQ6yO4JG1rdkZlvhaCf/uZbLVMb0U= -sigs.k8s.io/kustomize/kyaml v0.18.1 h1:WvBo56Wzw3fjS+7vBjN6TeivvpbW9GmRaWZ9CIVmt4E= -sigs.k8s.io/kustomize/kyaml v0.18.1/go.mod h1:C3L2BFVU1jgcddNBE1TxuVLgS46TjObMwW5FT9FcjYo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA= +sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY= +sigs.k8s.io/structured-merge-diff/v4 v4.5.0 h1:nbCitCK2hfnhyiKo6uf2HxUPTCodY6Qaf85SbDIaMBk= +sigs.k8s.io/structured-merge-diff/v4 v4.5.0/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/statusreaders/job_status_reader_test.go b/internal/statusreaders/job_status_reader_test.go index 5f07be91c..6e9ed5a79 100644 --- a/internal/statusreaders/job_status_reader_test.go +++ b/internal/statusreaders/job_status_reader_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" + "github.com/fluxcd/cli-utils/pkg/kstatus/status" ) func toUnstructured(t *testing.T, obj runtime.Object) (*unstructured.Unstructured, error) { diff --git a/internal/statusreaders/pod_status_reader.go b/internal/statusreaders/pod_status_reader.go index d3daf7cc3..c074c3487 100644 --- a/internal/statusreaders/pod_status_reader.go +++ b/internal/statusreaders/pod_status_reader.go @@ -25,11 +25,11 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" - "sigs.k8s.io/cli-utils/pkg/object" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/engine" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/event" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/statusreaders" + "github.com/fluxcd/cli-utils/pkg/kstatus/status" + "github.com/fluxcd/cli-utils/pkg/object" ) type customPodStatusReader struct { diff --git a/internal/statusreaders/pod_status_reader_test.go b/internal/statusreaders/pod_status_reader_test.go index a151f1aed..ba0d1f1bb 100644 --- a/internal/statusreaders/pod_status_reader_test.go +++ b/internal/statusreaders/pod_status_reader_test.go @@ -23,7 +23,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" + "github.com/fluxcd/cli-utils/pkg/kstatus/status" ) func TestPodConditions(t *testing.T) { diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index bc3958848..22242b40f 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -23,18 +23,18 @@ import ( "sort" "time" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/aggregator" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/collector" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/engine" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/event" + "github.com/fluxcd/cli-utils/pkg/kstatus/polling/statusreaders" + "github.com/fluxcd/cli-utils/pkg/kstatus/status" + "github.com/fluxcd/cli-utils/pkg/kstatus/watcher" + "github.com/fluxcd/cli-utils/pkg/object" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/dynamic" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/event" - "sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders" - "sigs.k8s.io/cli-utils/pkg/kstatus/status" - "sigs.k8s.io/cli-utils/pkg/kstatus/watcher" - "sigs.k8s.io/cli-utils/pkg/object" helmStatusReaders "helm.sh/helm/v4/internal/statusreaders" ) diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 0e88f1bbe..fee325ddc 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -21,6 +21,7 @@ import ( "testing" "time" + "github.com/fluxcd/cli-utils/pkg/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" @@ -33,7 +34,6 @@ import ( "k8s.io/apimachinery/pkg/util/yaml" dynamicfake "k8s.io/client-go/dynamic/fake" "k8s.io/kubectl/pkg/scheme" - "sigs.k8s.io/cli-utils/pkg/testutil" ) var podCurrentManifest = ` From 3a296aacade3e66a68e3aac88fc3abf0ef2f81a5 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 4 Mar 2025 23:15:02 +0000 Subject: [PATCH 184/271] rest mapper Signed-off-by: Austin Abro --- internal/client/client.go | 369 ++++++++++++++++++++++++++++++++++++++ pkg/kube/client.go | 5 +- 2 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 internal/client/client.go diff --git a/internal/client/client.go b/internal/client/client.go new file mode 100644 index 000000000..b55ddb3f8 --- /dev/null +++ b/internal/client/client.go @@ -0,0 +1,369 @@ +/* +Copyright 2023 The Kubernetes 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 client + +import ( + "fmt" + "net/http" + "sort" + "strings" + "sync" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/discovery" + "k8s.io/client-go/rest" + "k8s.io/client-go/restmapper" +) + +/* +Adapted from controller-runtime v0.19 before The Kubernetes Aggregated Discovery was enabled +in controller-runtime v0.20 which broke the preferred version discovery in the RESTMapper. +https://github.com/kubernetes-sigs/controller-runtime/blob/e818ce450d3d358600848dcfa1b585de64e7c865/pkg/client/apiutil/restmapper.go +*/ + +// NewLazyRESTMapper returns a dynamic RESTMapper for cfg. The dynamic +// RESTMapper dynamically discovers resource types at runtime. +func NewLazyRESTMapper(cfg *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) { + if httpClient == nil { + return nil, fmt.Errorf("httpClient must not be nil, consider using rest.HTTPClientFor(c) to create a client") + } + + client, err := discovery.NewDiscoveryClientForConfigAndClient(cfg, httpClient) + if err != nil { + return nil, err + } + return &mapper{ + mapper: restmapper.NewDiscoveryRESTMapper([]*restmapper.APIGroupResources{}), + client: client, + knownGroups: map[string]*restmapper.APIGroupResources{}, + apiGroups: map[string]*metav1.APIGroup{}, + }, nil +} + +// mapper is a RESTMapper that will lazily query the provided +// client for discovery information to do REST mappings. +type mapper struct { + mapper meta.RESTMapper + client discovery.DiscoveryInterface + knownGroups map[string]*restmapper.APIGroupResources + apiGroups map[string]*metav1.APIGroup + + // mutex to provide thread-safe mapper reloading. + mu sync.RWMutex +} + +// KindFor implements Mapper.KindFor. +func (m *mapper) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error) { + res, err := m.getMapper().KindFor(resource) + if meta.IsNoMatchError(err) { + if err := m.addKnownGroupAndReload(resource.Group, resource.Version); err != nil { + return schema.GroupVersionKind{}, err + } + res, err = m.getMapper().KindFor(resource) + } + + return res, err +} + +// KindsFor implements Mapper.KindsFor. +func (m *mapper) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error) { + res, err := m.getMapper().KindsFor(resource) + if meta.IsNoMatchError(err) { + if err := m.addKnownGroupAndReload(resource.Group, resource.Version); err != nil { + return nil, err + } + res, err = m.getMapper().KindsFor(resource) + } + + return res, err +} + +// ResourceFor implements Mapper.ResourceFor. +func (m *mapper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error) { + res, err := m.getMapper().ResourceFor(input) + if meta.IsNoMatchError(err) { + if err := m.addKnownGroupAndReload(input.Group, input.Version); err != nil { + return schema.GroupVersionResource{}, err + } + res, err = m.getMapper().ResourceFor(input) + } + + return res, err +} + +// ResourcesFor implements Mapper.ResourcesFor. +func (m *mapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error) { + res, err := m.getMapper().ResourcesFor(input) + if meta.IsNoMatchError(err) { + if err := m.addKnownGroupAndReload(input.Group, input.Version); err != nil { + return nil, err + } + res, err = m.getMapper().ResourcesFor(input) + } + + return res, err +} + +// RESTMapping implements Mapper.RESTMapping. +func (m *mapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error) { + res, err := m.getMapper().RESTMapping(gk, versions...) + if meta.IsNoMatchError(err) { + if err := m.addKnownGroupAndReload(gk.Group, versions...); err != nil { + return nil, err + } + res, err = m.getMapper().RESTMapping(gk, versions...) + } + + return res, err +} + +// RESTMappings implements Mapper.RESTMappings. +func (m *mapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error) { + res, err := m.getMapper().RESTMappings(gk, versions...) + if meta.IsNoMatchError(err) { + if err := m.addKnownGroupAndReload(gk.Group, versions...); err != nil { + return nil, err + } + res, err = m.getMapper().RESTMappings(gk, versions...) + } + + return res, err +} + +// ResourceSingularizer implements Mapper.ResourceSingularizer. +func (m *mapper) ResourceSingularizer(resource string) (string, error) { + return m.getMapper().ResourceSingularizer(resource) +} + +func (m *mapper) getMapper() meta.RESTMapper { + m.mu.RLock() + defer m.mu.RUnlock() + return m.mapper +} + +// addKnownGroupAndReload reloads the mapper with updated information about missing API group. +// versions can be specified for partial updates, for instance for v1beta1 version only. +func (m *mapper) addKnownGroupAndReload(groupName string, versions ...string) error { + // versions will here be [""] if the forwarded Version value of + // GroupVersionResource (in calling method) was not specified. + if len(versions) == 1 && versions[0] == "" { + versions = nil + } + + // If no specific versions are set by user, we will scan all available ones for the API group. + // This operation requires 2 requests: /api and /apis, but only once. For all subsequent calls + // this data will be taken from cache. + if len(versions) == 0 { + apiGroup, err := m.findAPIGroupByName(groupName) + if err != nil { + return err + } + if apiGroup != nil { + for _, version := range apiGroup.Versions { + versions = append(versions, version.Version) + } + } + } + + m.mu.Lock() + defer m.mu.Unlock() + + // Create or fetch group resources from cache. + groupResources := &restmapper.APIGroupResources{ + Group: metav1.APIGroup{Name: groupName}, + VersionedResources: make(map[string][]metav1.APIResource), + } + + // Update information for group resources about versioned resources. + // The number of API calls is equal to the number of versions: /apis//. + // If we encounter a missing API version (NotFound error), we will remove the group from + // the m.apiGroups and m.knownGroups caches. + // If this happens, in the next call the group will be added back to apiGroups + // and only the existing versions will be loaded in knownGroups. + groupVersionResources, err := m.fetchGroupVersionResourcesLocked(groupName, versions...) + if err != nil { + return fmt.Errorf("failed to get API group resources: %w", err) + } + + if _, ok := m.knownGroups[groupName]; ok { + groupResources = m.knownGroups[groupName] + } + + // Update information for group resources about the API group by adding new versions. + // Ignore the versions that are already registered. + for groupVersion, resources := range groupVersionResources { + version := groupVersion.Version + + groupResources.VersionedResources[version] = resources.APIResources + found := false + for _, v := range groupResources.Group.Versions { + if v.Version == version { + found = true + break + } + } + + if !found { + groupResources.Group.Versions = append(groupResources.Group.Versions, metav1.GroupVersionForDiscovery{ + GroupVersion: metav1.GroupVersion{Group: groupName, Version: version}.String(), + Version: version, + }) + } + } + + // Update data in the cache. + m.knownGroups[groupName] = groupResources + + // Finally, update the group with received information and regenerate the mapper. + updatedGroupResources := make([]*restmapper.APIGroupResources, 0, len(m.knownGroups)) + for _, agr := range m.knownGroups { + updatedGroupResources = append(updatedGroupResources, agr) + } + + m.mapper = restmapper.NewDiscoveryRESTMapper(updatedGroupResources) + return nil +} + +// findAPIGroupByNameLocked returns API group by its name. +func (m *mapper) findAPIGroupByName(groupName string) (*metav1.APIGroup, error) { + // Looking in the cache first. + { + m.mu.RLock() + group, ok := m.apiGroups[groupName] + m.mu.RUnlock() + if ok { + return group, nil + } + } + + // Update the cache if nothing was found. + apiGroups, err := m.client.ServerGroups() + if err != nil { + return nil, fmt.Errorf("failed to get server groups: %w", err) + } + if len(apiGroups.Groups) == 0 { + return nil, fmt.Errorf("received an empty API groups list") + } + + m.mu.Lock() + for i := range apiGroups.Groups { + group := &apiGroups.Groups[i] + m.apiGroups[group.Name] = group + } + m.mu.Unlock() + + // Looking in the cache again. + m.mu.RLock() + defer m.mu.RUnlock() + + // Don't return an error here if the API group is not present. + // The reloaded RESTMapper will take care of returning a NoMatchError. + return m.apiGroups[groupName], nil +} + +// fetchGroupVersionResourcesLocked fetches the resources for the specified group and its versions. +// This method might modify the cache so it needs to be called under the lock. +func (m *mapper) fetchGroupVersionResourcesLocked(groupName string, versions ...string) (map[schema.GroupVersion]*metav1.APIResourceList, error) { + groupVersionResources := make(map[schema.GroupVersion]*metav1.APIResourceList) + failedGroups := make(map[schema.GroupVersion]error) + + for _, version := range versions { + groupVersion := schema.GroupVersion{Group: groupName, Version: version} + + apiResourceList, err := m.client.ServerResourcesForGroupVersion(groupVersion.String()) + if apierrors.IsNotFound(err) { + // If the version is not found, we remove the group from the cache + // so it gets refreshed on the next call. + if m.isAPIGroupCached(groupVersion) { + delete(m.apiGroups, groupName) + } + if m.isGroupVersionCached(groupVersion) { + delete(m.knownGroups, groupName) + } + continue + } else if err != nil { + failedGroups[groupVersion] = err + } + + if apiResourceList != nil { + // even in case of error, some fallback might have been returned. + groupVersionResources[groupVersion] = apiResourceList + } + } + + if len(failedGroups) > 0 { + err := ErrResourceDiscoveryFailed(failedGroups) + return nil, &err + } + + return groupVersionResources, nil +} + +// isGroupVersionCached checks if a version for a group is cached in the known groups cache. +func (m *mapper) isGroupVersionCached(gv schema.GroupVersion) bool { + if cachedGroup, ok := m.knownGroups[gv.Group]; ok { + _, cached := cachedGroup.VersionedResources[gv.Version] + return cached + } + + return false +} + +// isAPIGroupCached checks if a version for a group is cached in the api groups cache. +func (m *mapper) isAPIGroupCached(gv schema.GroupVersion) bool { + cachedGroup, ok := m.apiGroups[gv.Group] + if !ok { + return false + } + + for _, version := range cachedGroup.Versions { + if version.Version == gv.Version { + return true + } + } + + return false +} + +// ErrResourceDiscoveryFailed is returned if the RESTMapper cannot discover supported resources for some GroupVersions. +// It wraps the errors encountered, except "NotFound" errors are replaced with meta.NoResourceMatchError, for +// backwards compatibility with code that uses meta.IsNoMatchError() to check for unsupported APIs. +type ErrResourceDiscoveryFailed map[schema.GroupVersion]error + +// Error implements the error interface. +func (e *ErrResourceDiscoveryFailed) Error() string { + subErrors := []string{} + for k, v := range *e { + subErrors = append(subErrors, fmt.Sprintf("%s: %v", k, v)) + } + sort.Strings(subErrors) + return fmt.Sprintf("unable to retrieve the complete list of server APIs: %s", strings.Join(subErrors, ", ")) +} + +func (e *ErrResourceDiscoveryFailed) Unwrap() []error { + subErrors := []error{} + for gv, err := range *e { + if apierrors.IsNotFound(err) { + err = &meta.NoResourceMatchError{PartialResource: gv.WithResource("")} + } + subErrors = append(subErrors, err) + } + return subErrors +} diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 333c0ec65..582c05c58 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -35,7 +35,6 @@ import ( apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/client/apiutil" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -51,6 +50,8 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" + + helmClient "helm.sh/helm/v4/internal/client" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. @@ -113,7 +114,7 @@ func (c *Client) newStatusWatcher() (*statusWaiter, error) { if err != nil { return nil, err } - restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) + restMapper, err := helmClient.NewLazyRESTMapper(cfg, httpClient) if err != nil { return nil, err } From ddc7baaacac3b1aeaf5f4dd4e3e029cac40282ee Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 4 Mar 2025 23:17:40 +0000 Subject: [PATCH 185/271] copyright things Signed-off-by: Austin Abro --- internal/client/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/client/client.go b/internal/client/client.go index b55ddb3f8..cb4ddb60e 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -1,4 +1,7 @@ /* +Copyright The Helm Authors. +This file was initially copied and modified from + https://github.com/kubernetes-sigs/controller-runtime/blob/e818ce450d3d358600848dcfa1b585de64e7c865/pkg/client/apiutil/restmapper.go Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); From 442200033027ce2512a5974a52993a7af4aac3d6 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 5 Mar 2025 17:21:29 +0100 Subject: [PATCH 186/271] fixing case issues with the logging of my errors Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 6 +++--- pkg/engine/engine.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 80268b45c..493bd31d6 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("pathValue returned error", slog.Any("err", err)) + slog.Error("the method PathValue returned error", slog.Any("err", err)) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table from chart", "chart", r.Name, "value", err) + slog.Error("ImportValues missing table from chart", "chart", r.Name, "value", err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table", slog.Any("err", err)) + slog.Error("ImportValues missing table", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index d47606ee6..9c91fd43b 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -176,12 +176,12 @@ func tplFun(parent *template.Template, includedNames map[string]int, strict bool // text string. (Maybe we could use a hash appended to the name?) t, err = t.New(parent.Name()).Parse(tpl) if err != nil { - return "", errors.Wrapf(err, "Cannot parse template %q", tpl) + return "", errors.Wrapf(err, "cannot parse template %q", tpl) } var buf strings.Builder if err := t.Execute(&buf, vals); err != nil { - return "", errors.Wrapf(err, "Error during tpl function execution for %q", tpl) + return "", errors.Wrapf(err, "error during tpl function execution for %q", tpl) } // See comment in renderWithReferences explaining the hack. From 2192c4e0d172ad2d200a8ccd496fef988335f5ca Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 5 Mar 2025 17:25:32 +0100 Subject: [PATCH 187/271] changing errors back to warns Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 493bd31d6..9a77920b1 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("the method PathValue returned error", slog.Any("err", err)) + slog.Warn("the method PathValue returned error", slog.Any("err", err)) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table from chart", "chart", r.Name, "value", err) + slog.Warn("ImportValues missing table from chart", "chart", r.Name, "value", err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table", slog.Any("err", err)) + slog.Warn("ImportValues missing table", slog.Any("err", err)) continue } if merge { From ebdb5dbb5b434aab6c14e3c0b634169a641073dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 21:35:32 +0000 Subject: [PATCH 188/271] build(deps): bump golang.org/x/crypto from 0.35.0 to 0.36.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.35.0 to 0.36.0. - [Commits](https://github.com/golang/crypto/compare/v0.35.0...v0.36.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 84ab22d12..cefaac3c7 100644 --- a/go.mod +++ b/go.mod @@ -33,9 +33,9 @@ require ( github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 - golang.org/x/crypto v0.35.0 - golang.org/x/term v0.29.0 - golang.org/x/text v0.22.0 + golang.org/x/crypto v0.36.0 + golang.org/x/term v0.30.0 + golang.org/x/text v0.23.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.32.2 k8s.io/apiextensions-apiserver v0.32.2 @@ -163,8 +163,8 @@ require ( golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sync v0.11.0 // indirect - golang.org/x/sys v0.30.0 // indirect + golang.org/x/sync v0.12.0 // indirect + golang.org/x/sys v0.31.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect diff --git a/go.sum b/go.sum index 01e37e8e5..d947675fd 100644 --- a/go.sum +++ b/go.sum @@ -400,8 +400,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= -golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -437,8 +437,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -460,8 +460,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -469,8 +469,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= -golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= -golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= +golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= +golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -478,8 +478,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 600947b32e6557ab6f5ebf44fb754abbb5e63d2a Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Mar 2025 14:27:09 +0000 Subject: [PATCH 189/271] client->restmapper Signed-off-by: Austin Abro --- internal/{client/client.go => restmapper/restmapper.go} | 2 +- pkg/kube/client.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename internal/{client/client.go => restmapper/restmapper.go} (99%) diff --git a/internal/client/client.go b/internal/restmapper/restmapper.go similarity index 99% rename from internal/client/client.go rename to internal/restmapper/restmapper.go index cb4ddb60e..85b7c2a69 100644 --- a/internal/client/client.go +++ b/internal/restmapper/restmapper.go @@ -17,7 +17,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package client +package restmapper import ( "fmt" diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 582c05c58..1244882aa 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -51,7 +51,7 @@ import ( "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" - helmClient "helm.sh/helm/v4/internal/client" + helmRestmapper "helm.sh/helm/v4/internal/restmapper" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. @@ -114,7 +114,7 @@ func (c *Client) newStatusWatcher() (*statusWaiter, error) { if err != nil { return nil, err } - restMapper, err := helmClient.NewLazyRESTMapper(cfg, httpClient) + restMapper, err := helmRestmapper.NewLazyRESTMapper(cfg, httpClient) if err != nil { return nil, err } From 2948279fb90bcb0d22e9f160f1f96b424ce74b7d Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Mar 2025 14:29:47 +0000 Subject: [PATCH 190/271] cleanup if statement Signed-off-by: Austin Abro --- pkg/action/install.go | 6 ++---- pkg/action/upgrade.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index c96e1a0ff..be76a634f 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -289,10 +289,8 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - if i.Wait == kube.HookOnlyStrategy { - if i.Atomic { - i.Wait = kube.StatusWatcherStrategy - } + if i.Wait == kube.HookOnlyStrategy && i.Atomic { + i.Wait = kube.StatusWatcherStrategy } if err := i.cfg.KubeClient.SetWaiter(i.Wait); err != nil { return nil, fmt.Errorf("failed to set kube client waiter: %w", err) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 851ac512a..ba5dfb5d1 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -155,10 +155,8 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - if u.Wait == kube.HookOnlyStrategy { - if u.Atomic { - u.Wait = kube.StatusWatcherStrategy - } + if u.Wait == kube.HookOnlyStrategy && u.Atomic { + u.Wait = kube.StatusWatcherStrategy } if err := u.cfg.KubeClient.SetWaiter(u.Wait); err != nil { return nil, fmt.Errorf("failed to set kube client waiter: %w", err) From e773a810eea2649d3cb52e2b140cc4492a94be26 Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Fri, 7 Mar 2025 09:30:28 -0500 Subject: [PATCH 191/271] Update pkg/cmd/flags.go Co-authored-by: George Jenkins Signed-off-by: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> --- pkg/cmd/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index 044b19e04..0fcad59fa 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -56,7 +56,7 @@ func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) { cmd.Flags().Var( newWaitValue(kube.HookOnlyStrategy, wait), "wait", - "if set, will wait until all resources are in the expected state before marking the operation as successful. It will wait for as long as --timeout. Valid inputs are true, false, watcher, and legacy", + "if specified, will wait until all resources are in the expected state before marking the operation as successful. It will wait for as long as --timeout. Valid inputs are 'watcher' and 'legacy'", ) // Sets the strategy to use the watcher strategy if `--wait` is used without an argument cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy) From 0dffe83ef3299aaa3e2e17a76743ad791c40f559 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Mar 2025 14:35:44 +0000 Subject: [PATCH 192/271] warnings Signed-off-by: Austin Abro --- pkg/cmd/flags.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index 0fcad59fa..ed3b83a55 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -82,13 +82,15 @@ func (ws *waitValue) Set(s string) error { *ws = waitValue(s) return nil case "true": + Warning("--wait=true is deprecated (boolean value) and can be replaced with --wait=watcher") *ws = waitValue(kube.StatusWatcherStrategy) return nil case "false": + Warning("--wait=false is deprecated (boolean value) and can be replaced by omitting the --wait flag") *ws = waitValue(kube.HookOnlyStrategy) return nil default: - return fmt.Errorf("invalid wait input %q. Valid inputs are true, false, %s, and %s", s, kube.StatusWatcherStrategy, kube.LegacyStrategy) + return fmt.Errorf("invalid wait input %q. Valid inputs are %s, and %s", s, kube.StatusWatcherStrategy, kube.LegacyStrategy) } } From 10f78c814cd1c7d0b784a9371bcf56c1609ceece Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 7 Mar 2025 14:37:04 +0000 Subject: [PATCH 193/271] legacy waiter Signed-off-by: Austin Abro --- pkg/kube/client.go | 2 +- pkg/kube/wait.go | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 1244882aa..61e681ad3 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -132,7 +132,7 @@ func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { if err != nil { return nil, err } - return &HelmWaiter{kubeClient: kc, log: c.Log}, nil + return &legacyWaiter{kubeClient: kc, log: c.Log}, nil case StatusWatcherStrategy: return c.newStatusWatcher() case HookOnlyStrategy: diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index a7e3a1c7e..9aeb93451 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -45,27 +45,27 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ) -// HelmWaiter is the legacy implementation of the Waiter interface. This logic was used by default in Helm 3 +// legacyWaiter is the legacy implementation of the Waiter interface. This logic was used by default in Helm 3 // Helm 4 now uses the StatusWaiter implementation instead -type HelmWaiter struct { +type legacyWaiter struct { c ReadyChecker log func(string, ...interface{}) kubeClient *kubernetes.Clientset } -func (hw *HelmWaiter) Wait(resources ResourceList, timeout time.Duration) error { +func (hw *legacyWaiter) Wait(resources ResourceList, timeout time.Duration) error { hw.c = NewReadyChecker(hw.kubeClient, hw.log, PausedAsReady(true)) return hw.waitForResources(resources, timeout) } -func (hw *HelmWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { +func (hw *legacyWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { hw.c = NewReadyChecker(hw.kubeClient, hw.log, PausedAsReady(true), CheckJobs(true)) return hw.waitForResources(resources, timeout) } // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached -func (hw *HelmWaiter) waitForResources(created ResourceList, timeout time.Duration) error { +func (hw *legacyWaiter) waitForResources(created ResourceList, timeout time.Duration) error { hw.log("beginning wait for %d resources with timeout of %v", len(created), timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) @@ -99,7 +99,7 @@ func (hw *HelmWaiter) waitForResources(created ResourceList, timeout time.Durati }) } -func (hw *HelmWaiter) isRetryableError(err error, resource *resource.Info) bool { +func (hw *legacyWaiter) isRetryableError(err error, resource *resource.Info) bool { if err == nil { return false } @@ -114,12 +114,12 @@ func (hw *HelmWaiter) isRetryableError(err error, resource *resource.Info) bool return true } -func (hw *HelmWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { +func (hw *legacyWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { return httpStatusCode == 0 || httpStatusCode == http.StatusTooManyRequests || (httpStatusCode >= 500 && httpStatusCode != http.StatusNotImplemented) } // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached -func (hw *HelmWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { +func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { hw.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) @@ -184,7 +184,7 @@ func SelectorsForObject(object runtime.Object) (selector labels.Selector, err er return selector, errors.Wrap(err, "invalid label selector") } -func (hw *HelmWaiter) watchTimeout(t time.Duration) func(*resource.Info) error { +func (hw *legacyWaiter) watchTimeout(t time.Duration) func(*resource.Info) error { return func(info *resource.Info) error { return hw.watchUntilReady(t, info) } @@ -204,7 +204,7 @@ func (hw *HelmWaiter) watchTimeout(t time.Duration) func(*resource.Info) error { // ascertained by watching the status.phase field in a pod's output. // // Handling for other kinds will be added as necessary. -func (hw *HelmWaiter) WatchUntilReady(resources ResourceList, timeout time.Duration) error { +func (hw *legacyWaiter) WatchUntilReady(resources ResourceList, timeout time.Duration) error { // For jobs, there's also the option to do poll c.Jobs(namespace).Get(): // https://github.com/adamreese/kubernetes/blob/master/test/e2e/job.go#L291-L300 return perform(resources, hw.watchTimeout(timeout)) @@ -230,7 +230,7 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error { return result } -func (hw *HelmWaiter) watchUntilReady(timeout time.Duration, info *resource.Info) error { +func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.Info) error { kind := info.Mapping.GroupVersionKind.Kind switch kind { case "Job", "Pod": @@ -291,7 +291,7 @@ func (hw *HelmWaiter) watchUntilReady(timeout time.Duration, info *resource.Info // waitForJob is a helper that waits for a job to complete. // // This operates on an event returned from a watcher. -func (hw *HelmWaiter) waitForJob(obj runtime.Object, name string) (bool, error) { +func (hw *legacyWaiter) waitForJob(obj runtime.Object, name string) (bool, error) { o, ok := obj.(*batchv1.Job) if !ok { return true, errors.Errorf("expected %s to be a *batch.Job, got %T", name, obj) @@ -312,7 +312,7 @@ func (hw *HelmWaiter) waitForJob(obj runtime.Object, name string) (bool, error) // waitForPodSuccess is a helper that waits for a pod to complete. // // This operates on an event returned from a watcher. -func (hw *HelmWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { +func (hw *legacyWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool, error) { o, ok := obj.(*corev1.Pod) if !ok { return true, errors.Errorf("expected %s to be a *v1.Pod, got %T", name, obj) From 3a195763778f52fe6cd5a9e1f478f6a232b3d15d Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Mon, 10 Mar 2025 15:40:10 -0400 Subject: [PATCH 194/271] making changes as requested by matt Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 4 ++-- pkg/engine/lookup_func.go | 4 ++-- pkg/plugin/installer/vcs_installer.go | 4 ++-- pkg/repo/chartrepo.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 9a77920b1..6c9da4430 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Warn("the method PathValue returned error", slog.Any("err", err)) + slog.Warn("the method PathValue returned error", slog.Any("error", err)) } } } @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Warn("ImportValues missing table", slog.Any("err", err)) + slog.Warn("ImportValues missing table", slog.Any("error", err)) continue } if merge { diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index b36e6a7ef..89f2707ec 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("unable to get dynamic client", slog.Any("err", err)) + slog.Error("unable to get dynamic client", slog.Any("error", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,7 +122,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("unable to create discovery client", slog.Any("err", err)) + slog.Error("unable to create discovery client", slog.Any("error", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 049775094..d1b704d6e 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -95,7 +95,7 @@ func (i *VCSInstaller) Install() error { // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating", "repo", i.Repo.Remote()) + slog.Debug("updating", "source", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -160,7 +160,7 @@ func (i *VCSInstaller) sync(repo vcs.Repo) error { slog.Debug("cloning", "source", repo.Remote(), "destination", repo.LocalPath()) return repo.Get() } - slog.Debug("updating", "remote", repo.Remote()) + slog.Debug("updating", "source", repo.Remote(), "destination", repo.LocalPath()) return repo.Update() } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 766e31a61..3fe5383f3 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -343,7 +343,7 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - slog.Error("failed to marshal entry", slog.Any("err", err)) + slog.Error("failed to marshal entry", slog.Any("error", err)) panic(err) } return string(buf) From 90daeadeb521b40baa1669029549e2d68c1ce5bc Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Tue, 26 Mar 2024 19:32:32 +0100 Subject: [PATCH 195/271] feat: add httproute from gateway-api to create chart template Adds the HTTPRoute from https://gateway-api.sigs.k8s.io/reference/spec/ to the example getting started chart. This closes #12603 Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index 7eb3398f5..fdb740fa9 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -54,6 +54,8 @@ const ( IgnorefileName = ".helmignore" // IngressFileName is the name of the example ingress file. IngressFileName = TemplatesDir + sep + "ingress.yaml" + // HttpRouteFileName is the name of the example HTTPRoute file. + HttpRouteFileName = TemplatesDir + sep + "httproute.yaml" // DeploymentName is the name of the example deployment file. DeploymentName = TemplatesDir + sep + "deployment.yaml" // ServiceName is the name of the example service file. @@ -177,6 +179,41 @@ ingress: # hosts: # - chart-example.local +# -- How the service is exposed via gateway-apis HTTPRoute. +httpRoute: + # -- HTTPRoute enabled. + enabled: false + # -- HTTPRoute annotations. + annotations: {} + # -- Which Gateways this Route is attached to + parentRefs: + - name: gateway + sectionName: http + # -- Hostnames matching HTTP header. + hostnames: + - "example.com" + # -- List of rules and filters applied. + rules: + - matches: + - path: + type: PathPrefix + value: /headers + # filters: + # - type: RequestHeaderModifier + # requestHeaderModifier: + # set: + # - name: My-Overwrite-Header + # value: this-is-the-only-value + # remove: + # - User-Agent + # - matches: + # - path: + # type: PathPrefix + # value: /echo + # headers: + # - name: version + # value: v2 + 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 @@ -297,6 +334,50 @@ spec: {{- end }} ` +const defaultHttpRoute = `{{- if .Values.httpRoute.enabled -}} +{{- $fullName := include ".fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1" -}} +apiVersion: gateway.networking.k8s.io/v1 +{{- else -}} +apiVersion: gateway.networking.k8s.io/v1alpha2 +{{- end }} +kind: HTTPRoute +metadata: + name: {{ $fullName }} + labels: + {{- include ".labels" . | nindent 4 }} + {{- with .Values.httpRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- with .Values.httpRoute.parentRefs }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.httpRoute.hostnames }} + hostnames: + {{- toYaml . | nindent 4 }} + {{- end }} + rules: + {{- range .Values.httpRoute.rules }} + {{- with .matches }} + - matches: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .filters }} + filters: + {{- toYaml . | nindent 8 }} + {{- end }} + backendRefs: + - name: {{ $fullName }} + port: {{ $svcPort }} + weight: 1 + {{- end }} +{{- end }} +` + const defaultDeployment = `apiVersion: apps/v1 kind: Deployment metadata: @@ -658,6 +739,11 @@ func Create(name, dir string) (string, error) { path: filepath.Join(cdir, IngressFileName), content: transform(defaultIngress, name), }, + { + // httproute.yaml + path: filepath.Join(cdir, HttpRouteFileName), + content: transform(defaultHttpRoute, name), + }, { // deployment.yaml path: filepath.Join(cdir, DeploymentName), From 3fc5d689e611416e4d5fe9ff12004b58df315a85 Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Thu, 28 Mar 2024 19:07:18 +0100 Subject: [PATCH 196/271] docs: add notes in chart templates for accessing httproute Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index fdb740fa9..149d9f456 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -189,6 +189,7 @@ httpRoute: parentRefs: - name: gateway sectionName: http + # namespace: default # -- Hostnames matching HTTP header. hostnames: - "example.com" @@ -525,7 +526,20 @@ spec: ` const defaultNotes = `1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} +{{- if .Values.httpRoute.enabled }} +{{- if .Values.httpRoute.hostnames }} + export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }} +{{- else }} + export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}") + {{- end }} +{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }} + echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application" + + NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules. + The rules can be set for path, method, header and query parameters. + You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml' +{{- end }} +{{- else if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} {{- range .paths }} http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} From d22939b439831f1c28ac9ad6643939aaee46f970 Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Thu, 11 Apr 2024 21:19:21 +0200 Subject: [PATCH 197/271] fix: correct expected number of template files in unit-test Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 10 +++++----- pkg/cmd/create_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index 149d9f456..0330055e4 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -54,8 +54,8 @@ const ( IgnorefileName = ".helmignore" // IngressFileName is the name of the example ingress file. IngressFileName = TemplatesDir + sep + "ingress.yaml" - // HttpRouteFileName is the name of the example HTTPRoute file. - HttpRouteFileName = TemplatesDir + sep + "httproute.yaml" + // HTTPRouteFileName is the name of the example HTTPRoute file. + HTTPRouteFileName = TemplatesDir + sep + "httproute.yaml" // DeploymentName is the name of the example deployment file. DeploymentName = TemplatesDir + sep + "deployment.yaml" // ServiceName is the name of the example service file. @@ -335,7 +335,7 @@ spec: {{- end }} ` -const defaultHttpRoute = `{{- if .Values.httpRoute.enabled -}} +const defaultHTTPRoute = `{{- if .Values.httpRoute.enabled -}} {{- $fullName := include ".fullname" . -}} {{- $svcPort := .Values.service.port -}} {{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1" -}} @@ -755,8 +755,8 @@ func Create(name, dir string) (string, error) { }, { // httproute.yaml - path: filepath.Join(cdir, HttpRouteFileName), - content: transform(defaultHttpRoute, name), + path: filepath.Join(cdir, HTTPRouteFileName), + content: transform(defaultHTTPRoute, name), }, { // deployment.yaml diff --git a/pkg/cmd/create_test.go b/pkg/cmd/create_test.go index bfdf3db5a..26eabbfc3 100644 --- a/pkg/cmd/create_test.go +++ b/pkg/cmd/create_test.go @@ -105,7 +105,7 @@ func TestCreateStarterCmd(t *testing.T) { t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) } - expectedNumberOfTemplates := 9 + expectedNumberOfTemplates := 10 if l := len(c.Templates); l != expectedNumberOfTemplates { t.Errorf("Expected %d templates, got %d", expectedNumberOfTemplates, l) } @@ -173,7 +173,7 @@ func TestCreateStarterAbsoluteCmd(t *testing.T) { t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) } - expectedNumberOfTemplates := 9 + expectedNumberOfTemplates := 10 if l := len(c.Templates); l != expectedNumberOfTemplates { t.Errorf("Expected %d templates, got %d", expectedNumberOfTemplates, l) } From 5d0c6e9ae4da0fff8b79a43506ac90f114f5de16 Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Mon, 15 Apr 2024 17:56:27 +0200 Subject: [PATCH 198/271] fix: remove v1alpha2 gateway api support Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index 0330055e4..0c61d353f 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -338,11 +338,7 @@ spec: const defaultHTTPRoute = `{{- if .Values.httpRoute.enabled -}} {{- $fullName := include ".fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1" -}} apiVersion: gateway.networking.k8s.io/v1 -{{- else -}} -apiVersion: gateway.networking.k8s.io/v1alpha2 -{{- end }} kind: HTTPRoute metadata: name: {{ $fullName }} From 1aac5b0b70e650e1d02142095c6847fc5e0f7b3b Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Sat, 8 Jun 2024 19:25:07 +0200 Subject: [PATCH 199/271] fix: use common chart-example.local hostname for http-route default Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index 0c61d353f..489571ba4 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -192,7 +192,7 @@ httpRoute: # namespace: default # -- Hostnames matching HTTP header. hostnames: - - "example.com" + - chart-example.local # -- List of rules and filters applied. rules: - matches: From ca367d970cf14be07449b02eb97af1a5ec85f1b9 Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Tue, 19 Nov 2024 19:05:41 +0100 Subject: [PATCH 200/271] docs: more user-friendly info for httpRoute scaffold Co-authored-by: George Jenkins Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index 489571ba4..658a9846a 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -179,7 +179,9 @@ ingress: # hosts: # - chart-example.local -# -- How the service is exposed via gateway-apis HTTPRoute. +# -- Expose the service via gateway-api HTTPRoute +# Requires Gateway API resources and suitable controller installed incluster +# (see: https://gateway-api.sigs.k8s.io/guides/) httpRoute: # -- HTTPRoute enabled. enabled: false From 597c35852a185284695e74b193aeef983b0c9da0 Mon Sep 17 00:00:00 2001 From: Henrik Gerdes Date: Mon, 10 Feb 2025 10:20:57 +0100 Subject: [PATCH 201/271] fix: align values comments/docs to scaffold standard Signed-off-by: Henrik Gerdes --- pkg/chart/v2/util/create.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/chart/v2/util/create.go b/pkg/chart/v2/util/create.go index 658a9846a..35a8c64a0 100644 --- a/pkg/chart/v2/util/create.go +++ b/pkg/chart/v2/util/create.go @@ -180,22 +180,22 @@ ingress: # - chart-example.local # -- Expose the service via gateway-api HTTPRoute -# Requires Gateway API resources and suitable controller installed incluster +# Requires Gateway API resources and suitable controller installed within the cluster # (see: https://gateway-api.sigs.k8s.io/guides/) httpRoute: - # -- HTTPRoute enabled. + # HTTPRoute enabled. enabled: false - # -- HTTPRoute annotations. + # HTTPRoute annotations. annotations: {} - # -- Which Gateways this Route is attached to + # Which Gateways this Route is attached to. parentRefs: - name: gateway sectionName: http # namespace: default - # -- Hostnames matching HTTP header. + # Hostnames matching HTTP header. hostnames: - chart-example.local - # -- List of rules and filters applied. + # List of rules and filters applied. rules: - matches: - path: From f0ceaba103ad3adb64bd50b81f46382c5dc7543a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 21:25:14 +0000 Subject: [PATCH 202/271] build(deps): bump the k8s-io group with 7 updates Bumps the k8s-io group with 7 updates: | Package | From | To | | --- | --- | --- | | [k8s.io/api](https://github.com/kubernetes/api) | `0.32.2` | `0.32.3` | | [k8s.io/apiextensions-apiserver](https://github.com/kubernetes/apiextensions-apiserver) | `0.32.2` | `0.32.3` | | [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) | `0.32.2` | `0.32.3` | | [k8s.io/apiserver](https://github.com/kubernetes/apiserver) | `0.32.2` | `0.32.3` | | [k8s.io/cli-runtime](https://github.com/kubernetes/cli-runtime) | `0.32.2` | `0.32.3` | | [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.32.2` | `0.32.3` | | [k8s.io/kubectl](https://github.com/kubernetes/kubectl) | `0.32.2` | `0.32.3` | Updates `k8s.io/api` from 0.32.2 to 0.32.3 - [Commits](https://github.com/kubernetes/api/compare/v0.32.2...v0.32.3) Updates `k8s.io/apiextensions-apiserver` from 0.32.2 to 0.32.3 - [Release notes](https://github.com/kubernetes/apiextensions-apiserver/releases) - [Commits](https://github.com/kubernetes/apiextensions-apiserver/compare/v0.32.2...v0.32.3) Updates `k8s.io/apimachinery` from 0.32.2 to 0.32.3 - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.32.2...v0.32.3) Updates `k8s.io/apiserver` from 0.32.2 to 0.32.3 - [Commits](https://github.com/kubernetes/apiserver/compare/v0.32.2...v0.32.3) Updates `k8s.io/cli-runtime` from 0.32.2 to 0.32.3 - [Commits](https://github.com/kubernetes/cli-runtime/compare/v0.32.2...v0.32.3) Updates `k8s.io/client-go` from 0.32.2 to 0.32.3 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.32.2...v0.32.3) Updates `k8s.io/kubectl` from 0.32.2 to 0.32.3 - [Commits](https://github.com/kubernetes/kubectl/compare/v0.32.2...v0.32.3) --- updated-dependencies: - dependency-name: k8s.io/api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/apiextensions-apiserver dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/apiserver dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/cli-runtime dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io - dependency-name: k8s.io/kubectl dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-io ... Signed-off-by: dependabot[bot] --- go.mod | 16 ++++++++-------- go.sum | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index cefaac3c7..7a57525fc 100644 --- a/go.mod +++ b/go.mod @@ -37,14 +37,14 @@ require ( golang.org/x/term v0.30.0 golang.org/x/text v0.23.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.32.2 - k8s.io/apiextensions-apiserver v0.32.2 - k8s.io/apimachinery v0.32.2 - k8s.io/apiserver v0.32.2 - k8s.io/cli-runtime v0.32.2 - k8s.io/client-go v0.32.2 + k8s.io/api v0.32.3 + k8s.io/apiextensions-apiserver v0.32.3 + k8s.io/apimachinery v0.32.3 + k8s.io/apiserver v0.32.3 + k8s.io/cli-runtime v0.32.3 + k8s.io/client-go v0.32.3 k8s.io/klog/v2 v2.130.1 - k8s.io/kubectl v0.32.2 + k8s.io/kubectl v0.32.3 oras.land/oras-go/v2 v2.5.0 sigs.k8s.io/yaml v1.4.0 ) @@ -174,7 +174,7 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/component-base v0.32.2 // indirect + k8s.io/component-base v0.32.3 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect diff --git a/go.sum b/go.sum index d947675fd..b48ede075 100644 --- a/go.sum +++ b/go.sum @@ -518,26 +518,26 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw= -k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y= -k8s.io/apiextensions-apiserver v0.32.2 h1:2YMk285jWMk2188V2AERy5yDwBYrjgWYggscghPCvV4= -k8s.io/apiextensions-apiserver v0.32.2/go.mod h1:GPwf8sph7YlJT3H6aKUWtd0E+oyShk/YHWQHf/OOgCA= -k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ= -k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= -k8s.io/apiserver v0.32.2 h1:WzyxAu4mvLkQxwD9hGa4ZfExo3yZZaYzoYvvVDlM6vw= -k8s.io/apiserver v0.32.2/go.mod h1:PEwREHiHNU2oFdte7BjzA1ZyjWjuckORLIK/wLV5goM= -k8s.io/cli-runtime v0.32.2 h1:aKQR4foh9qeyckKRkNXUccP9moxzffyndZAvr+IXMks= -k8s.io/cli-runtime v0.32.2/go.mod h1:a/JpeMztz3xDa7GCyyShcwe55p8pbcCVQxvqZnIwXN8= -k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA= -k8s.io/client-go v0.32.2/go.mod h1:fpZ4oJXclZ3r2nDOv+Ux3XcJutfrwjKTCHz2H3sww94= -k8s.io/component-base v0.32.2 h1:1aUL5Vdmu7qNo4ZsE+569PV5zFatM9hl+lb3dEea2zU= -k8s.io/component-base v0.32.2/go.mod h1:PXJ61Vx9Lg+P5mS8TLd7bCIr+eMJRQTyXe8KvkrvJq0= +k8s.io/api v0.32.3 h1:Hw7KqxRusq+6QSplE3NYG4MBxZw1BZnq4aP4cJVINls= +k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k= +k8s.io/apiextensions-apiserver v0.32.3 h1:4D8vy+9GWerlErCwVIbcQjsWunF9SUGNu7O7hiQTyPY= +k8s.io/apiextensions-apiserver v0.32.3/go.mod h1:8YwcvVRMVzw0r1Stc7XfGAzB/SIVLunqApySV5V7Dss= +k8s.io/apimachinery v0.32.3 h1:JmDuDarhDmA/Li7j3aPrwhpNBA94Nvk5zLeOge9HH1U= +k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= +k8s.io/apiserver v0.32.3 h1:kOw2KBuHOA+wetX1MkmrxgBr648ksz653j26ESuWNY8= +k8s.io/apiserver v0.32.3/go.mod h1:q1x9B8E/WzShF49wh3ADOh6muSfpmFL0I2t+TG0Zdgc= +k8s.io/cli-runtime v0.32.3 h1:khLF2ivU2T6Q77H97atx3REY9tXiA3OLOjWJxUrdvss= +k8s.io/cli-runtime v0.32.3/go.mod h1:vZT6dZq7mZAca53rwUfdFSZjdtLyfF61mkf/8q+Xjak= +k8s.io/client-go v0.32.3 h1:RKPVltzopkSgHS7aS98QdscAgtgah/+zmpAogooIqVU= +k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY= +k8s.io/component-base v0.32.3 h1:98WJvvMs3QZ2LYHBzvltFSeJjEx7t5+8s71P7M74u8k= +k8s.io/component-base v0.32.3/go.mod h1:LWi9cR+yPAv7cu2X9rZanTiFKB2kHA+JjmhkKjCZRpI= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= -k8s.io/kubectl v0.32.2 h1:TAkag6+XfSBgkqK9I7ZvwtF0WVtUAvK8ZqTt+5zi1Us= -k8s.io/kubectl v0.32.2/go.mod h1:+h/NQFSPxiDZYX/WZaWw9fwYezGLISP0ud8nQKg+3g8= +k8s.io/kubectl v0.32.3 h1:VMi584rbboso+yjfv0d8uBHwwxbC438LKq+dXd5tOAI= +k8s.io/kubectl v0.32.3/go.mod h1:6Euv2aso5GKzo/UVMacV6C7miuyevpfI91SvBvV9Zdg= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= From fd547184f1b92fd05d0f5f7492611bcb8dc4542e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 21:36:54 +0000 Subject: [PATCH 203/271] build(deps): bump golangci/golangci-lint-action from 6.5.0 to 6.5.1 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.5.0 to 6.5.1. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/2226d7cb06a077cd73e56eedd38eecad18e5d837...4696ba8babb6127d732c3c6dde519db15edab9ea) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 5971ada24..d7eafdd72 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,6 @@ jobs: go-version: '1.23' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 #pin@6.5.0 + uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea #pin@6.5.1 with: version: v1.62 From 667a5b733804960ea3f49d4566847db81def27ab Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 13 Mar 2025 11:30:21 -0400 Subject: [PATCH 204/271] Updating to 0.37.0 for x/net This is due to a CVE present in the current version. Dependabot has stopped making PRs for x/net so this is created due to that. An issue was filed to look in to the dependabot issue. Signed-off-by: Matt Farina --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index cefaac3c7..c006a353f 100644 --- a/go.mod +++ b/go.mod @@ -161,7 +161,7 @@ require ( go.opentelemetry.io/otel/trace v1.32.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.37.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.31.0 // indirect diff --git a/go.sum b/go.sum index d947675fd..44fa03718 100644 --- a/go.sum +++ b/go.sum @@ -425,6 +425,8 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From b533189cb371d676db949217ebb8c18160b92306 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 00:19:41 +0000 Subject: [PATCH 205/271] build(deps): bump github.com/containerd/containerd from 1.7.26 to 1.7.27 Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.26 to 1.7.27. - [Release notes](https://github.com/containerd/containerd/releases) - [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md) - [Commits](https://github.com/containerd/containerd/compare/v1.7.26...v1.7.27) --- updated-dependencies: - dependency-name: github.com/containerd/containerd dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 789cc723f..723cfc769 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/Masterminds/squirrel v1.5.4 github.com/Masterminds/vcs v1.13.3 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 - github.com/containerd/containerd v1.7.26 + github.com/containerd/containerd v1.7.27 github.com/cyphar/filepath-securejoin v0.4.1 github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/evanphx/json-patch v5.9.11+incompatible diff --git a/go.sum b/go.sum index fec96dac6..b0e35d8b9 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= -github.com/containerd/containerd v1.7.26 h1:3cs8K2RHlMQaPifLqgRyI4VBkoldNdEw62cb7qQga7k= -github.com/containerd/containerd v1.7.26/go.mod h1:m4JU0E+h0ebbo9yXD7Hyt+sWnc8tChm7MudCjj4jRvQ= +github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII= +github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0= github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= @@ -423,8 +423,6 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= From d5d75ad0c7c16b8b630492559dd97c857cca7bb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:41:09 +0000 Subject: [PATCH 206/271] build(deps): bump golangci/golangci-lint-action from 6.5.1 to 6.5.2 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.5.1 to 6.5.2. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/4696ba8babb6127d732c3c6dde519db15edab9ea...55c2c1448f86e01eaae002a5a3a9624417608d84) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d7eafdd72..0d11cd531 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,6 @@ jobs: go-version: '1.23' check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea #pin@6.5.1 + uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 #pin@6.5.2 with: version: v1.62 From 835ff78f482c12703c61720e293a3ad82d652d03 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Wed, 19 Mar 2025 14:50:16 +0100 Subject: [PATCH 207/271] Remove ClientOptResolver from OCI Client This option was kept to avoid compile-time incompatibilities in Helm v3 when upgrading to ORAS v2. Let's remove it for Helm v4. This allows Helm to drop the containerd dependency entirely. Signed-off-by: Tom Wieczorek --- go.mod | 4 ---- go.sum | 8 -------- pkg/registry/client.go | 9 --------- pkg/registry/client_test.go | 33 --------------------------------- 4 files changed, 54 deletions(-) delete mode 100644 pkg/registry/client_test.go diff --git a/go.mod b/go.mod index 723cfc769..0589b84e9 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/Masterminds/squirrel v1.5.4 github.com/Masterminds/vcs v1.13.3 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 - github.com/containerd/containerd v1.7.27 github.com/cyphar/filepath-securejoin v0.4.1 github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/evanphx/json-patch v5.9.11+incompatible @@ -60,9 +59,6 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect - github.com/containerd/errdefs v0.3.0 // indirect - github.com/containerd/log v0.1.0 // indirect - github.com/containerd/platforms v0.2.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect diff --git a/go.sum b/go.sum index b0e35d8b9..20dd5c0b9 100644 --- a/go.sum +++ b/go.sum @@ -48,14 +48,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= -github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII= -github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0= -github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= -github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= -github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= diff --git a/pkg/registry/client.go b/pkg/registry/client.go index ecc7a0d04..2078ecd75 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -31,7 +31,6 @@ import ( "sync" "github.com/Masterminds/semver/v3" - "github.com/containerd/containerd/remotes" "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" @@ -56,8 +55,6 @@ storing semantic versions, Helm adopts the convention of changing plus (+) to an underscore (_) in chart version tags when pushing to a registry and back to a plus (+) when pulling from a registry.` -var errDeprecatedRemote = errors.New("providing github.com/containerd/containerd/remotes.Resolver via ClientOptResolver is no longer suported") - type ( // RemoteClient shadows the ORAS remote.Client interface // (hiding the ORAS type from Helm client visibility) @@ -231,12 +228,6 @@ func ClientOptPlainHTTP() ClientOption { } } -func ClientOptResolver(_ remotes.Resolver) ClientOption { - return func(c *Client) { - c.err = errDeprecatedRemote - } -} - type ( // LoginOption allows specifying various settings on login LoginOption func(*loginOperation) diff --git a/pkg/registry/client_test.go b/pkg/registry/client_test.go deleted file mode 100644 index 4c5a78849..000000000 --- a/pkg/registry/client_test.go +++ /dev/null @@ -1,33 +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 registry - -import ( - "testing" - - "github.com/containerd/containerd/remotes" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewClientResolverNotSupported(t *testing.T) { - var r remotes.Resolver - - client, err := NewClient(ClientOptResolver(r)) - require.Equal(t, err, errDeprecatedRemote) - assert.Nil(t, client) -} From a45cf1bab970430d599aa1d735615ef5264e9f38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:51:55 +0000 Subject: [PATCH 208/271] build(deps): bump actions/upload-artifact from 4.6.1 to 4.6.2 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1...ea165f8d65b6e75b540449e92b4886f43607fa02) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index f89fcd98c..a8c2e8a15 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -55,7 +55,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: SARIF file path: results.sarif From f95410f66c42759325dec33ca162056a762affbb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:51:59 +0000 Subject: [PATCH 209/271] build(deps): bump actions/setup-go from 5.3.0 to 5.4.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.3.0 to 5.4.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/f111f3307d8850f501ac008e886eec1fd1932a34...0aaccfd150d50ccaeb58ebd88d36e91967a5f35b) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/govulncheck.yml | 2 +- .github/workflows/release.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 2ccea3d0e..b654bf4d6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -20,7 +20,7 @@ jobs: - name: Checkout source code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 0d11cd531..6fbbd2c53 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index f8572f2d6..b376c7b8e 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5e7c6840..63e5c0e26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' @@ -81,7 +81,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true From fc476f7235a6135acbf902aacb42af54d8edccad Mon Sep 17 00:00:00 2001 From: linghuying <1599935829@qq.com> Date: Thu, 20 Mar 2025 22:18:28 +0800 Subject: [PATCH 210/271] chore: make function comment match function name Signed-off-by: linghuying <1599935829@qq.com> --- pkg/registry/client.go | 2 +- pkg/storage/driver/mock_test.go | 2 +- pkg/storage/storage_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/registry/client.go b/pkg/registry/client.go index ecc7a0d04..fadffac5b 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -771,7 +771,7 @@ func PushOptStrictMode(strictMode bool) PushOption { } } -// PushOptCreationDate returns a function that sets the creation time +// PushOptCreationTime returns a function that sets the creation time func PushOptCreationTime(creationTime string) PushOption { return func(operation *pushOperation) { operation.creationTime = creationTime diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index 199da6505..53919b45d 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -166,7 +166,7 @@ func (mock *MockConfigMapsInterface) Delete(_ context.Context, name string, _ me return nil } -// newTestFixture initializes a MockSecretsInterface. +// newTestFixtureSecrets initializes a MockSecretsInterface. // Secrets are created for each release provided. func newTestFixtureSecrets(t *testing.T, releases ...*rspb.Release) *Secrets { var mock MockSecretsInterface diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index 056b7f5f5..1dadc9c93 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -476,7 +476,7 @@ func TestStorageLast(t *testing.T) { } } -// TestUpgradeInitiallyFailedRelease tests a case when there are no deployed release yet, but history limit has been +// TestUpgradeInitiallyFailedReleaseWithHistoryLimit tests a case when there are no deployed release yet, but history limit has been // reached: the has-no-deployed-releases error should not occur in such case. func TestUpgradeInitiallyFailedReleaseWithHistoryLimit(t *testing.T) { storage := Init(driver.NewMemory()) From 0e4d185370b6e1e8cf186dcb8946bb44ca410e24 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 21 Mar 2025 09:54:44 +0100 Subject: [PATCH 211/271] Inform about time spent waiting resources to be ready in slog format Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 7eb931496..8844b0876 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -19,6 +19,7 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" "fmt" + "log/slog" "net/http" "time" @@ -101,12 +102,13 @@ func (w *waiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached func (w *waiter) waitForDeletedResources(deleted ResourceList) error { - w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), w.timeout) + slog.Info("beginning wait for resources to be deleted", "count", len(deleted), "timeout", w.timeout) + startTime := time.Now() ctx, cancel := context.WithTimeout(context.Background(), w.timeout) defer cancel() - return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) { + err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) { for _, v := range deleted { err := v.Get() if err == nil || !apierrors.IsNotFound(err) { @@ -115,6 +117,15 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error { } return true, nil }) + + elapsed := time.Since(startTime).Round(time.Second) + if err != nil { + slog.Debug("wait for resources failed", "elapsed", elapsed, "error", err) + } else { + slog.Debug("wait for resources succeeded", "elapsed", elapsed) + } + + return err } // SelectorsForObject returns the pod label selector for a given object From e3e84b6dfe462cbd45e5252796f0b3b7f431dc6e Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 21 Mar 2025 10:08:05 +0100 Subject: [PATCH 212/271] "beginning wait" is dedicated to be display as debug log Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 8844b0876..de53a67f1 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -102,7 +102,7 @@ func (w *waiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached func (w *waiter) waitForDeletedResources(deleted ResourceList) error { - slog.Info("beginning wait for resources to be deleted", "count", len(deleted), "timeout", w.timeout) + slog.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", w.timeout) startTime := time.Now() ctx, cancel := context.WithTimeout(context.Background(), w.timeout) From 94cb21c7c48ccefafbd8ad04defe5846bcfb2751 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 21 Mar 2025 10:33:45 +0100 Subject: [PATCH 213/271] Follow convention for error with slog.Any() Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index de53a67f1..6a709b22d 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -120,7 +120,7 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error { elapsed := time.Since(startTime).Round(time.Second) if err != nil { - slog.Debug("wait for resources failed", "elapsed", elapsed, "error", err) + slog.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err)) } else { slog.Debug("wait for resources succeeded", "elapsed", elapsed) } From e4e602e13c3363b8c479607cd932e6a4efd9c38f Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 21 Mar 2025 08:06:01 -0400 Subject: [PATCH 214/271] Error when failed repo update. In Helm v3 we did not change exit codes for existing commands to maintain compat. A flag was introduced so a failure would result in a non-0 exit code. A note was left to make this the default in Helm v4. That's what this change does. Closes #10016 Signed-off-by: Matt Farina --- pkg/cmd/repo_update.go | 21 ++++++------------ pkg/cmd/repo_update_test.go | 43 +++++-------------------------------- 2 files changed, 12 insertions(+), 52 deletions(-) diff --git a/pkg/cmd/repo_update.go b/pkg/cmd/repo_update.go index 25071377b..6590d9872 100644 --- a/pkg/cmd/repo_update.go +++ b/pkg/cmd/repo_update.go @@ -42,11 +42,10 @@ 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 + update func([]*repo.ChartRepository, io.Writer) error + repoFile string + repoCache string + names []string } func newRepoUpdateCmd(out io.Writer) *cobra.Command { @@ -69,12 +68,6 @@ func newRepoUpdateCmd(out io.Writer) *cobra.Command { }, } - 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 } @@ -112,10 +105,10 @@ func (o *repoUpdateOptions) run(out io.Writer) error { } } - return o.update(repos, out, o.failOnRepoUpdateFail) + return o.update(repos, out) } -func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { +func updateCharts(repos []*repo.ChartRepository, out io.Writer) error { fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") var wg sync.WaitGroup var repoFailList []string @@ -133,7 +126,7 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdate } wg.Wait() - if len(repoFailList) > 0 && failOnRepoUpdateFail { + if len(repoFailList) > 0 { return fmt.Errorf("Failed to update the following repositories: %s", repoFailList) } diff --git a/pkg/cmd/repo_update_test.go b/pkg/cmd/repo_update_test.go index 5b27a6dfb..6fc4c8f4b 100644 --- a/pkg/cmd/repo_update_test.go +++ b/pkg/cmd/repo_update_test.go @@ -34,7 +34,7 @@ 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, _ bool) error { + updater := func(repos []*repo.ChartRepository, out io.Writer) error { for _, re := range repos { fmt.Fprintln(out, re.Config.Name) } @@ -59,7 +59,7 @@ 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, _ bool) error { + updater := func(repos []*repo.ChartRepository, out io.Writer) error { for _, re := range repos { fmt.Fprintln(out, re.Config.Name) } @@ -85,7 +85,7 @@ 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, _ bool) error { + updater := func(repos []*repo.ChartRepository, out io.Writer) error { for _, re := range repos { fmt.Fprintln(out, re.Config.Name) } @@ -145,7 +145,7 @@ func TestUpdateCharts(t *testing.T) { } b := bytes.NewBuffer(nil) - updateCharts([]*repo.ChartRepository{r}, b, false) + updateCharts([]*repo.ChartRepository{r}, b) got := b.String() if strings.Contains(got, "Unable to get an update") { @@ -161,39 +161,6 @@ func TestRepoUpdateFileCompletion(t *testing.T) { checkFileCompletion(t, "repo update repo1", false) } -func TestUpdateChartsFail(t *testing.T) { - defer resetEnv()() - ensure.HelmHome(t) - - ts := repotest.NewTempServer( - t, - repotest.WithChartSourceGlob("testdata/testserver/*.*"), - ) - 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()() ensure.HelmHome(t) @@ -214,7 +181,7 @@ func TestUpdateChartsFailWithError(t *testing.T) { } b := bytes.NewBuffer(nil) - err = updateCharts([]*repo.ChartRepository{r}, b, true) + err = updateCharts([]*repo.ChartRepository{r}, b) if err == nil { t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set") return From c5991028e01588a4f5b86cc31d794e15ffde8f64 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 21 Mar 2025 16:12:53 -0400 Subject: [PATCH 215/271] fixing matts changes Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 2 +- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 6c9da4430..72a08b2a9 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Warn("ImportValues missing table from chart", "chart", r.Name, "value", err) + slog.Warn("ImportValues missing table from chart", "chart", r.Name, "error", err) continue } // create value map from child to be merged into parent diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 9c91fd43b..7235b026a 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required value", "value", warn) + slog.Warn("missing required value", "message", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required values", "value", warn) + slog.Warn("missing required values", "message", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("funcMap fail", "lintMode", msg) + slog.Info("funcMap fail", "message", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 89f2707ec..b7460850a 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -127,7 +127,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("unable to retrieve resource list", "list", gvk.GroupVersion().String(), "error", err) + slog.Error("unable to retrieve resource list", "GroupVersion", gvk.GroupVersion().String(), "error", err) return res, err } for _, resource := range resList.APIResources { From 4f4c858f9c8f2e55871d80e877241abb9fa69b21 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sun, 23 Mar 2025 15:38:59 +0100 Subject: [PATCH 216/271] Ignore unused parameter Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 6a709b22d..71c6add53 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -108,7 +108,7 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error { ctx, cancel := context.WithTimeout(context.Background(), w.timeout) defer cancel() - err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) { for _, v := range deleted { err := v.Get() if err == nil || !apierrors.IsNotFound(err) { From 3ca2558f0455ba7e50f260e2ef26745140b0277c Mon Sep 17 00:00:00 2001 From: Wahab Ali Date: Wed, 7 Jun 2023 19:00:11 -0400 Subject: [PATCH 217/271] Do not explicitly set SNI in HTTPGetter Signed-off-by: Wahab Ali --- pkg/getter/httpgetter.go | 7 -- pkg/getter/httpgetter_test.go | 118 +++++++++++++++++++++++++++++++++- testdata/localhost-crt.pem | 73 +++++++++++++++++++++ testdata/openssl.conf | 4 ++ 4 files changed, 192 insertions(+), 10 deletions(-) create mode 100644 testdata/localhost-crt.pem diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index 37d80cda7..a945dec2b 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -26,7 +26,6 @@ import ( "github.com/pkg/errors" "helm.sh/helm/v4/internal/tlsutil" - "helm.sh/helm/v4/internal/urlutil" "helm.sh/helm/v4/internal/version" ) @@ -137,12 +136,6 @@ func (g *HTTPGetter) httpClient() (*http.Client, error) { return nil, errors.Wrap(err, "can't create TLS config for client") } - sni, err := urlutil.ExtractHostname(g.opts.url) - if err != nil { - return nil, err - } - tlsConf.ServerName = sni - g.transport.TLSClientConfig = tlsConf } diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 24e670f6e..dc60b9982 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -358,6 +358,121 @@ func TestDownloadTLS(t *testing.T) { } } +func TestDownloadTLSWithRedirect(t *testing.T) { + cd := "../../testdata" + srv2Resp := "hello" + insecureSkipTLSverify := false + + // Server 2 that will actually fulfil the request. + ca, pub, priv := filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "localhost-crt.pem"), filepath.Join(cd, "key.pem") + tlsConf, err := tlsutil.NewClientTLS(pub, priv, ca, insecureSkipTLSverify) + if err != nil { + t.Fatal(errors.Wrap(err, "can't create TLS config for client")) + } + + tlsSrv2 := httptest.NewUnstartedServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + rw.Header().Set("Content-Type", "text/plain") + rw.Write([]byte(srv2Resp)) + })) + + tlsSrv2.TLS = tlsConf + tlsSrv2.StartTLS() + defer tlsSrv2.Close() + + // Server 1 responds with a redirect to Server 2. + ca, pub, priv = filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "crt.pem"), filepath.Join(cd, "key.pem") + tlsConf, err = tlsutil.NewClientTLS(pub, priv, ca, insecureSkipTLSverify) + if err != nil { + t.Fatal(errors.Wrap(err, "can't create TLS config for client")) + } + + tlsSrv1 := httptest.NewUnstartedServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + u, _ := url.ParseRequestURI(tlsSrv2.URL) + + // Make the request using the hostname 'localhost' (to which 'localhost-crt.pem' is issued) + // to verify that a successful TLS connection is made even if the client doesn't specify + // the hostname (SNI) in `tls.Config.ServerName`. By default the hostname is derived from the + // request URL for every request (including redirects). Setting `tls.Config.ServerName` on the + // client just overrides the remote endpoint's hostname. + // See https://github.com/golang/go/blob/3979fb9/src/net/http/transport.go#L1505-L1513. + u.Host = fmt.Sprintf("localhost:%s", u.Port()) + + http.Redirect(rw, r, u.String(), http.StatusTemporaryRedirect) + })) + + tlsSrv1.TLS = tlsConf + tlsSrv1.StartTLS() + defer tlsSrv1.Close() + + u, _ := url.ParseRequestURI(tlsSrv1.URL) + + t.Run("Test with TLS", func(t *testing.T) { + g, err := NewHTTPGetter( + WithURL(u.String()), + WithTLSClientConfig(pub, priv, ca), + ) + if err != nil { + t.Fatal(err) + } + + buf, err := g.Get(u.String()) + if err != nil { + t.Error(err) + } + + b, err := io.ReadAll(buf) + if err != nil { + t.Error(err) + } + + if string(b) != srv2Resp { + t.Errorf("expected response from Server2 to be '%s', instead got: %s", srv2Resp, string(b)) + } + }) + + t.Run("Test with TLS config being passed along in .Get (see #6635)", func(t *testing.T) { + g, err := NewHTTPGetter() + if err != nil { + t.Fatal(err) + } + + buf, err := g.Get(u.String(), WithURL(u.String()), WithTLSClientConfig(pub, priv, ca)) + if err != nil { + t.Error(err) + } + + b, err := io.ReadAll(buf) + if err != nil { + t.Error(err) + } + + if string(b) != srv2Resp { + t.Errorf("expected response from Server2 to be '%s', instead got: %s", srv2Resp, string(b)) + } + }) + + t.Run("Test with only the CA file (see also #6635)", func(t *testing.T) { + g, err := NewHTTPGetter() + if err != nil { + t.Fatal(err) + } + + buf, err := g.Get(u.String(), WithURL(u.String()), WithTLSClientConfig("", "", ca)) + if err != nil { + t.Error(err) + } + + b, err := io.ReadAll(buf) + if err != nil { + t.Error(err) + } + + if string(b) != srv2Resp { + t.Errorf("expected response from Server2 to be '%s', instead got: %s", srv2Resp, string(b)) + } + }) +} + func TestDownloadInsecureSkipTLSVerify(t *testing.T) { ts := httptest.NewTLSServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})) defer ts.Close() @@ -450,9 +565,6 @@ func TestHttpClientInsecureSkipVerify(t *testing.T) { if len(transport.TLSClientConfig.Certificates) <= 0 { t.Fatal("transport.TLSClientConfig.Certificates is not present") } - if transport.TLSClientConfig.ServerName == "" { - t.Fatal("TLSClientConfig.ServerName is blank") - } } func verifyInsecureSkipVerify(t *testing.T, g *HTTPGetter, caseName string, expectedValue bool) *http.Transport { diff --git a/testdata/localhost-crt.pem b/testdata/localhost-crt.pem new file mode 100644 index 000000000..70fa0a429 --- /dev/null +++ b/testdata/localhost-crt.pem @@ -0,0 +1,73 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 7f:5e:fa:21:fa:ee:e4:6a:be:9b:c2:80:bf:ed:42:f3:2d:47:f5:d2 + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=CO, L=Boulder, O=Helm, CN=helm.sh + Validity + Not Before: Nov 6 21:59:18 2023 GMT + Not After : Nov 3 21:59:18 2033 GMT + Subject: C=CA, ST=ON, L=Kitchener, O=Helm, CN=localhost + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public-Key: (2048 bit) + Modulus: + 00:c8:89:55:0d:0b:f1:da:e6:c0:70:7d:d3:27:cd: + b8:a8:81:8b:7c:a4:89:e5:d1:b1:78:01:1d:df:44: + 88:0b:fc:d6:81:35:3d:d1:3b:5e:8f:bb:93:b3:7e: + 28:db:ed:ff:a0:13:3a:70:a3:fe:94:6b:0b:fe:fb: + 63:00:b0:cb:dc:81:cd:80:dc:d0:2f:bf:b2:4f:9a: + 81:d4:22:dc:97:c8:8f:27:86:59:91:fa:92:05:75: + c4:cc:6b:f5:a9:6b:74:1e:f5:db:a9:f8:bf:8c:a2: + 25:fd:a0:cc:79:f4:25:57:74:a9:23:9b:e2:b7:22: + 7a:14:7a:3d:ea:f1:7e:32:6b:57:6c:2e:c6:4f:75: + 54:f9:6b:54:d2:ca:eb:54:1c:af:39:15:9b:d0:7c: + 0f:f8:55:51:04:ea:da:fa:7b:8b:63:0f:ac:39:b1: + f6:4b:8e:4e:f6:ea:e9:7b:e6:ba:5e:5a:8e:91:ef: + dc:b1:7d:52:3f:73:83:52:46:83:48:49:ff:f2:2d: + ca:54:f2:36:bb:49:cc:59:99:c0:9e:cf:8e:78:55: + 6c:ed:7d:7e:83:b8:59:2c:7d:f8:1a:81:f0:7d:f5: + 27:f2:db:ae:d4:31:54:38:fe:47:b2:ee:16:20:0f: + f1:db:2d:28:bf:6f:38:eb:11:bb:9a:d4:b2:5a:3a: + 4a:7f + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Alternative Name: + DNS:localhost + Signature Algorithm: sha256WithRSAEncryption + 47:47:fe:29:ca:94:28:75:59:ba:ab:67:ab:c6:a6:0b:0a:f2: + 0f:26:d9:1d:35:db:68:a5:d8:f5:1f:d1:87:e7:a7:74:fd:c0: + 22:aa:c8:ec:6c:d3:ac:8a:0b:ed:59:3a:a0:12:77:7c:53:74: + fd:30:59:34:8f:a4:ef:5b:98:3f:ff:cf:89:87:ed:d3:7f:41: + 2f:b1:9a:12:71:bb:fe:3a:cf:77:16:32:bc:83:90:cc:52:2f: + 3b:f4:ae:db:b1:bb:f0:dd:30:d4:03:17:5e:47:b7:06:86:7a: + 16:b1:72:2f:80:5d:d4:c0:f9:6c:91:df:5a:c5:15:86:66:68: + c8:90:8e:f1:a2:bb:40:0f:ef:26:1b:02:c4:42:de:8c:69:ec: + ad:27:d0:bc:da:7c:76:33:86:de:b7:c4:04:64:e6:f6:dc:44: + 89:7b:b8:2f:c7:28:7a:4c:a6:01:ad:a5:17:64:3a:23:da:aa: + db:ce:3f:86:e9:92:dc:0d:c4:5a:b4:52:a8:8a:ee:3d:62:7d: + b1:c8:fa:ef:96:2b:ab:f1:e1:6d:6f:7d:1e:ce:bc:7a:d0:92: + 02:1b:c8:55:36:77:bf:d4:42:d3:fc:57:ca:b7:cc:95:be:ce: + f8:6e:b2:28:ca:4d:9a:00:7d:78:c8:56:04:2e:b3:ac:03:fa: + 05:d8:42:bd +-----BEGIN CERTIFICATE----- +MIIDRDCCAiygAwIBAgIUf176Ifru5Gq+m8KAv+1C8y1H9dIwDQYJKoZIhvcNAQEL +BQAwTTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNPMRAwDgYDVQQHDAdCb3VsZGVy +MQ0wCwYDVQQKDARIZWxtMRAwDgYDVQQDDAdoZWxtLnNoMB4XDTIzMTEwNjIxNTkx +OFoXDTMzMTEwMzIxNTkxOFowUTELMAkGA1UEBhMCQ0ExCzAJBgNVBAgMAk9OMRIw +EAYDVQQHDAlLaXRjaGVuZXIxDTALBgNVBAoMBEhlbG0xEjAQBgNVBAMMCWxvY2Fs +aG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMiJVQ0L8drmwHB9 +0yfNuKiBi3ykieXRsXgBHd9EiAv81oE1PdE7Xo+7k7N+KNvt/6ATOnCj/pRrC/77 +YwCwy9yBzYDc0C+/sk+agdQi3JfIjyeGWZH6kgV1xMxr9alrdB7126n4v4yiJf2g +zHn0JVd0qSOb4rciehR6PerxfjJrV2wuxk91VPlrVNLK61QcrzkVm9B8D/hVUQTq +2vp7i2MPrDmx9kuOTvbq6Xvmul5ajpHv3LF9Uj9zg1JGg0hJ//ItylTyNrtJzFmZ +wJ7PjnhVbO19foO4WSx9+BqB8H31J/LbrtQxVDj+R7LuFiAP8dstKL9vOOsRu5rU +slo6Sn8CAwEAAaMYMBYwFAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEB +CwUAA4IBAQBHR/4pypQodVm6q2erxqYLCvIPJtkdNdtopdj1H9GH56d0/cAiqsjs +bNOsigvtWTqgEnd8U3T9MFk0j6TvW5g//8+Jh+3Tf0EvsZoScbv+Os93FjK8g5DM +Ui879K7bsbvw3TDUAxdeR7cGhnoWsXIvgF3UwPlskd9axRWGZmjIkI7xortAD+8m +GwLEQt6MaeytJ9C82nx2M4bet8QEZOb23ESJe7gvxyh6TKYBraUXZDoj2qrbzj+G +6ZLcDcRatFKoiu49Yn2xyPrvliur8eFtb30ezrx60JICG8hVNne/1ELT/FfKt8yV +vs74brIoyk2aAH14yFYELrOsA/oF2EK9 +-----END CERTIFICATE----- diff --git a/testdata/openssl.conf b/testdata/openssl.conf index 9b27e445b..be5ff04b7 100644 --- a/testdata/openssl.conf +++ b/testdata/openssl.conf @@ -40,3 +40,7 @@ subjectAltName = @alternate_names [alternate_names] DNS.1 = helm.sh IP.1 = 127.0.0.1 + +# # Used to generate localhost-crt.pem +# [alternate_names] +# DNS.1 = localhost From e7895245f08cccb9bf0716f986c6cc1baf3fff28 Mon Sep 17 00:00:00 2001 From: Wahab Ali Date: Thu, 6 Feb 2025 19:32:08 +0500 Subject: [PATCH 218/271] Fix lint errors Signed-off-by: Wahab Ali --- pkg/getter/httpgetter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index dc60b9982..02e0735b5 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -370,7 +370,7 @@ func TestDownloadTLSWithRedirect(t *testing.T) { t.Fatal(errors.Wrap(err, "can't create TLS config for client")) } - tlsSrv2 := httptest.NewUnstartedServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + tlsSrv2 := httptest.NewUnstartedServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { rw.Header().Set("Content-Type", "text/plain") rw.Write([]byte(srv2Resp)) })) From ec31aab851abf6a2377769a2db4ba1d610e152a5 Mon Sep 17 00:00:00 2001 From: Wahab Ali Date: Mon, 24 Mar 2025 10:51:02 -0400 Subject: [PATCH 219/271] Use NewTLSConfig instead of the outdated NewClientTLS func Signed-off-by: Wahab Ali --- pkg/getter/httpgetter_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 02e0735b5..27752a257 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -365,7 +365,12 @@ func TestDownloadTLSWithRedirect(t *testing.T) { // Server 2 that will actually fulfil the request. ca, pub, priv := filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "localhost-crt.pem"), filepath.Join(cd, "key.pem") - tlsConf, err := tlsutil.NewClientTLS(pub, priv, ca, insecureSkipTLSverify) + tlsConf, err := tlsutil.NewTLSConfig( + tlsutil.WithCAFile(ca), + tlsutil.WithCertKeyPairFiles(pub, priv), + tlsutil.WithInsecureSkipVerify(insecureSkipTLSverify), + ) + if err != nil { t.Fatal(errors.Wrap(err, "can't create TLS config for client")) } @@ -381,7 +386,12 @@ func TestDownloadTLSWithRedirect(t *testing.T) { // Server 1 responds with a redirect to Server 2. ca, pub, priv = filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "crt.pem"), filepath.Join(cd, "key.pem") - tlsConf, err = tlsutil.NewClientTLS(pub, priv, ca, insecureSkipTLSverify) + tlsConf, err = tlsutil.NewTLSConfig( + tlsutil.WithCAFile(ca), + tlsutil.WithCertKeyPairFiles(pub, priv), + tlsutil.WithInsecureSkipVerify(insecureSkipTLSverify), + ) + if err != nil { t.Fatal(errors.Wrap(err, "can't create TLS config for client")) } From 386523bdbc6f5e5f289ade7d9d4cf4c935354450 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Mar 2025 13:55:39 +0000 Subject: [PATCH 220/271] update to get waiter instead of set Signed-off-by: Austin Abro --- pkg/action/action.go | 5 +-- pkg/action/hooks.go | 22 ++++++++---- pkg/action/install.go | 28 ++++++++++------ pkg/action/install_test.go | 6 ++-- pkg/action/release_testing.go | 3 +- pkg/action/rollback.go | 19 +++++------ pkg/action/uninstall.go | 14 ++++---- pkg/action/uninstall_test.go | 4 +-- pkg/action/upgrade.go | 35 +++++++++---------- pkg/action/upgrade_test.go | 10 +++--- pkg/cmd/install.go | 2 +- pkg/cmd/rollback.go | 2 +- pkg/cmd/uninstall.go | 2 +- pkg/cmd/upgrade.go | 4 +-- pkg/kube/client.go | 13 +++----- pkg/kube/client_test.go | 16 +++------ pkg/kube/fake/fake.go | 63 ++++++++++++++++++++++------------- pkg/kube/fake/printer.go | 28 ++++++++++------ pkg/kube/interface.go | 6 ++-- 19 files changed, 151 insertions(+), 131 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 1ca6a4dfa..ea2dc0dd7 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -375,10 +375,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { - kc, err := kube.New(getter) - if err != nil { - return err - } + kc := kube.New(getter) kc.Log = log lazyClient := &lazyClient{ diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 6637891c5..9d0bb390b 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -35,7 +35,7 @@ import ( ) // execHook executes all of the hooks for the given hook event. -func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, timeout time.Duration) error { +func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, waitStrategy kube.WaitStrategy, timeout time.Duration) error { executingHooks := []*release.Hook{} for _, h := range rl.Hooks { @@ -59,7 +59,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, h.DeletePolicies = []release.HookDeletePolicy{release.HookBeforeHookCreation} } - if err := cfg.deleteHookByPolicy(h, release.HookBeforeHookCreation, timeout); err != nil { + if err := cfg.deleteHookByPolicy(h, release.HookBeforeHookCreation, waitStrategy, timeout); err != nil { return err } @@ -87,8 +87,12 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, return errors.Wrapf(err, "warning: Hook %s %s failed", hook, h.Path) } + waiter, err := cfg.KubeClient.GetWaiter(waitStrategy) + if err != nil { + return errors.Wrapf(err, "unable to get waiter") + } // Watch hook resources until they have completed - err = cfg.KubeClient.WatchUntilReady(resources, timeout) + err = waiter.WatchUntilReady(resources, timeout) // Note the time of success/failure h.LastRun.CompletedAt = helmtime.Now() // Mark hook as succeeded or failed @@ -101,7 +105,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, } // If a hook is failed, check the annotation of the hook to determine whether the hook should be deleted // under failed condition. If so, then clear the corresponding resource object in the hook - if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, timeout); errDeleting != nil { + if errDeleting := cfg.deleteHookByPolicy(h, release.HookFailed, waitStrategy, timeout); errDeleting != nil { // We log the error here as we want to propagate the hook failure upwards to the release object. log.Printf("error deleting the hook resource on hook failure: %v", errDeleting) } @@ -118,7 +122,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // We log here as we still want to attempt hook resource deletion even if output logging fails. log.Printf("error outputting logs for hook failure: %v", err) } - if err := cfg.deleteHookByPolicy(h, release.HookSucceeded, timeout); err != nil { + if err := cfg.deleteHookByPolicy(h, release.HookSucceeded, waitStrategy, timeout); err != nil { return err } } @@ -139,7 +143,7 @@ func (x hookByWeight) Less(i, j int) bool { } // deleteHookByPolicy deletes a hook if the hook policy instructs it to -func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.HookDeletePolicy, timeout time.Duration) error { +func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.HookDeletePolicy, waitStrategy kube.WaitStrategy, timeout time.Duration) error { // Never delete CustomResourceDefinitions; this could cause lots of // cascading garbage collection. if h.Kind == "CustomResourceDefinition" { @@ -155,7 +159,11 @@ func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.Hoo return errors.New(joinErrors(errs)) } - if err := cfg.KubeClient.WaitForDelete(resources, timeout); err != nil { + waiter, err := cfg.KubeClient.GetWaiter(waitStrategy) + if err != nil { + return err + } + if err := waiter.WaitForDelete(resources, timeout); err != nil { return err } } diff --git a/pkg/action/install.go b/pkg/action/install.go index be76a634f..735b8ac17 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -79,7 +79,7 @@ type Install struct { HideSecret bool DisableHooks bool Replace bool - Wait kube.WaitStrategy + WaitStrategy kube.WaitStrategy WaitForJobs bool Devel bool DependencyUpdate bool @@ -180,8 +180,12 @@ func (i *Install) installCRDs(crds []chart.CRD) error { totalItems = append(totalItems, res...) } if len(totalItems) > 0 { + waiter, err := i.cfg.KubeClient.GetWaiter(i.WaitStrategy) + if err != nil { + return errors.Wrapf(err, "unable to get waiter") + } // Give time for the CRD to be recognized. - if err := i.cfg.KubeClient.Wait(totalItems, 60*time.Second); err != nil { + if err := waiter.Wait(totalItems, 60*time.Second); err != nil { return err } @@ -289,11 +293,8 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - if i.Wait == kube.HookOnlyStrategy && i.Atomic { - i.Wait = kube.StatusWatcherStrategy - } - if err := i.cfg.KubeClient.SetWaiter(i.Wait); err != nil { - return nil, fmt.Errorf("failed to set kube client waiter: %w", err) + if i.WaitStrategy == kube.HookOnlyStrategy && i.Atomic { + i.WaitStrategy = kube.StatusWatcherStrategy } caps, err := i.cfg.getCapabilities() @@ -453,7 +454,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource var err error // pre-install hooks if !i.DisableHooks { - if err := i.cfg.execHook(rel, release.HookPreInstall, i.Timeout); err != nil { + if err := i.cfg.execHook(rel, release.HookPreInstall, i.WaitStrategy, i.Timeout); err != nil { return rel, fmt.Errorf("failed pre-install: %s", err) } } @@ -470,17 +471,22 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource return rel, err } + waiter, err := i.cfg.KubeClient.GetWaiter(i.WaitStrategy) + if err != nil { + return rel, fmt.Errorf("failed to get waiter: %w", err) + } + if i.WaitForJobs { - err = i.cfg.KubeClient.WaitWithJobs(resources, i.Timeout) + err = waiter.WaitWithJobs(resources, i.Timeout) } else { - err = i.cfg.KubeClient.Wait(resources, i.Timeout) + err = waiter.Wait(resources, i.Timeout) } if err != nil { return rel, err } if !i.DisableHooks { - if err := i.cfg.execHook(rel, release.HookPostInstall, i.Timeout); err != nil { + if err := i.cfg.execHook(rel, release.HookPostInstall, i.WaitStrategy, i.Timeout); err != nil { return rel, fmt.Errorf("failed post-install: %s", err) } } diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 331a2f71b..aafda86c2 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -412,7 +412,7 @@ func TestInstallRelease_Wait(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") instAction.cfg.KubeClient = failer - instAction.Wait = kube.StatusWatcherStrategy + instAction.WaitStrategy = kube.StatusWatcherStrategy vals := map[string]interface{}{} goroutines := runtime.NumGoroutine() @@ -431,7 +431,7 @@ func TestInstallRelease_Wait_Interrupted(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitDuration = 10 * time.Second instAction.cfg.KubeClient = failer - instAction.Wait = kube.StatusWatcherStrategy + instAction.WaitStrategy = kube.StatusWatcherStrategy vals := map[string]interface{}{} ctx, cancel := context.WithCancel(context.Background()) @@ -454,7 +454,7 @@ func TestInstallRelease_WaitForJobs(t *testing.T) { failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") instAction.cfg.KubeClient = failer - instAction.Wait = kube.StatusWatcherStrategy + instAction.WaitStrategy = kube.StatusWatcherStrategy instAction.WaitForJobs = true vals := map[string]interface{}{} diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index c6374523e..7edc3ed34 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -28,6 +28,7 @@ import ( v1 "k8s.io/api/core/v1" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" + "helm.sh/helm/v4/pkg/kube" release "helm.sh/helm/v4/pkg/release/v1" ) @@ -96,7 +97,7 @@ func (r *ReleaseTesting) Run(name string) (*release.Release, error) { rel.Hooks = executingHooks } - if err := r.cfg.execHook(rel, release.HookTest, r.Timeout); err != nil { + if err := r.cfg.execHook(rel, release.HookTest, kube.StatusWatcherStrategy, r.Timeout); err != nil { rel.Hooks = append(skippedHooks, rel.Hooks...) r.cfg.Releases.Update(rel) return rel, err diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index a96a706e3..870f1e635 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -38,7 +38,7 @@ type Rollback struct { Version int Timeout time.Duration - Wait kube.WaitStrategy + WaitStrategy kube.WaitStrategy WaitForJobs bool DisableHooks bool DryRun bool @@ -61,10 +61,6 @@ func (r *Rollback) Run(name string) error { return err } - if err := r.cfg.KubeClient.SetWaiter(r.Wait); err != nil { - return fmt.Errorf("failed to set kube client waiter: %w", err) - } - r.cfg.Releases.MaxHistory = r.MaxHistory r.cfg.Log("preparing rollback of %s", name) @@ -181,7 +177,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas // pre-rollback hooks if !r.DisableHooks { - if err := r.cfg.execHook(targetRelease, release.HookPreRollback, r.Timeout); err != nil { + if err := r.cfg.execHook(targetRelease, release.HookPreRollback, r.WaitStrategy, r.Timeout); err != nil { return targetRelease, err } } else { @@ -227,16 +223,19 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas r.cfg.Log(err.Error()) } } - + waiter, err := r.cfg.KubeClient.GetWaiter(r.WaitStrategy) + if err != nil { + return nil, errors.Wrap(err, "unable to set metadata visitor from target release") + } if r.WaitForJobs { - if err := r.cfg.KubeClient.WaitWithJobs(target, r.Timeout); err != nil { + if err := waiter.WaitWithJobs(target, r.Timeout); err != nil { targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) r.cfg.recordRelease(currentRelease) r.cfg.recordRelease(targetRelease) return targetRelease, errors.Wrapf(err, "release %s failed", targetRelease.Name) } } else { - if err := r.cfg.KubeClient.Wait(target, r.Timeout); err != nil { + if err := waiter.Wait(target, r.Timeout); err != nil { targetRelease.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", targetRelease.Name, err.Error())) r.cfg.recordRelease(currentRelease) r.cfg.recordRelease(targetRelease) @@ -246,7 +245,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas // post-rollback hooks if !r.DisableHooks { - if err := r.cfg.execHook(targetRelease, release.HookPostRollback, r.Timeout); err != nil { + if err := r.cfg.execHook(targetRelease, release.HookPostRollback, r.WaitStrategy, r.Timeout); err != nil { return targetRelease, err } } diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 503be0da5..eeff997d3 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -17,7 +17,6 @@ limitations under the License. package action import ( - "fmt" "strings" "time" @@ -42,7 +41,7 @@ type Uninstall struct { DryRun bool IgnoreNotFound bool KeepHistory bool - Wait kube.WaitStrategy + WaitStrategy kube.WaitStrategy DeletionPropagation string Timeout time.Duration Description string @@ -61,8 +60,9 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) return nil, err } - if err := u.cfg.KubeClient.SetWaiter(u.Wait); err != nil { - return nil, fmt.Errorf("failed to set kube client waiter: %w", err) + waiter, err := u.cfg.KubeClient.GetWaiter(u.WaitStrategy) + if err != nil { + return nil, err } if u.DryRun { @@ -111,7 +111,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) res := &release.UninstallReleaseResponse{Release: rel} if !u.DisableHooks { - if err := u.cfg.execHook(rel, release.HookPreDelete, u.Timeout); err != nil { + if err := u.cfg.execHook(rel, release.HookPreDelete, u.WaitStrategy, u.Timeout); err != nil { return res, err } } else { @@ -135,12 +135,12 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } res.Info = kept - if err := u.cfg.KubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil { + if err := waiter.WaitForDelete(deletedResources, u.Timeout); err != nil { errs = append(errs, err) } if !u.DisableHooks { - if err := u.cfg.execHook(rel, release.HookPostDelete, u.Timeout); err != nil { + if err := u.cfg.execHook(rel, release.HookPostDelete, u.WaitStrategy, u.Timeout); err != nil { errs = append(errs, err) } } diff --git a/pkg/action/uninstall_test.go b/pkg/action/uninstall_test.go index 5597abcdf..a83e4bc75 100644 --- a/pkg/action/uninstall_test.go +++ b/pkg/action/uninstall_test.go @@ -83,7 +83,7 @@ func TestUninstallRelease_Wait(t *testing.T) { unAction := uninstallAction(t) unAction.DisableHooks = true unAction.DryRun = false - unAction.Wait = kube.StatusWatcherStrategy + unAction.WaitStrategy = kube.StatusWatcherStrategy rel := releaseStub() rel.Name = "come-fail-away" @@ -114,7 +114,7 @@ func TestUninstallRelease_Cascade(t *testing.T) { unAction := uninstallAction(t) unAction.DisableHooks = true unAction.DryRun = false - unAction.Wait = kube.HookOnlyStrategy + unAction.WaitStrategy = kube.HookOnlyStrategy unAction.DeletionPropagation = "foreground" rel := releaseStub() diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index ba5dfb5d1..e3b775a25 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -64,8 +64,8 @@ type Upgrade struct { SkipCRDs bool // Timeout is the timeout for this operation Timeout time.Duration - // Wait determines whether the wait operation should be performed and what type of wait. - Wait kube.WaitStrategy + // WaitStrategy determines what type of waiting should be done + WaitStrategy kube.WaitStrategy // WaitForJobs determines whether the wait operation for the Jobs should be performed after the upgrade is requested. WaitForJobs bool // DisableHooks disables hook processing if set to true. @@ -155,11 +155,8 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. // Make sure if Atomic is set, that wait is set as well. This makes it so // the user doesn't have to specify both - if u.Wait == kube.HookOnlyStrategy && u.Atomic { - u.Wait = kube.StatusWatcherStrategy - } - if err := u.cfg.KubeClient.SetWaiter(u.Wait); err != nil { - return nil, fmt.Errorf("failed to set kube client waiter: %w", err) + if u.WaitStrategy == kube.HookOnlyStrategy && u.Atomic { + u.WaitStrategy = kube.StatusWatcherStrategy } if err := chartutil.ValidateReleaseName(name); err != nil { @@ -423,7 +420,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele // pre-upgrade hooks if !u.DisableHooks { - if err := u.cfg.execHook(upgradedRelease, release.HookPreUpgrade, u.Timeout); err != nil { + if err := u.cfg.execHook(upgradedRelease, release.HookPreUpgrade, u.WaitStrategy, u.Timeout); err != nil { u.reportToPerformUpgrade(c, upgradedRelease, kube.ResourceList{}, fmt.Errorf("pre-upgrade hooks failed: %s", err)) return } @@ -447,15 +444,20 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele u.cfg.Log(err.Error()) } } - + waiter, err := u.cfg.KubeClient.GetWaiter(u.WaitStrategy) + if err != nil { + u.cfg.recordRelease(originalRelease) + u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) + return + } if u.WaitForJobs { - if err := u.cfg.KubeClient.WaitWithJobs(target, u.Timeout); err != nil { + if err := waiter.WaitWithJobs(target, u.Timeout); err != nil { u.cfg.recordRelease(originalRelease) u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) return } } else { - if err := u.cfg.KubeClient.Wait(target, u.Timeout); err != nil { + if err := waiter.Wait(target, u.Timeout); err != nil { u.cfg.recordRelease(originalRelease) u.reportToPerformUpgrade(c, upgradedRelease, results.Created, err) return @@ -464,7 +466,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele // post-upgrade hooks if !u.DisableHooks { - if err := u.cfg.execHook(upgradedRelease, release.HookPostUpgrade, u.Timeout); err != nil { + if err := u.cfg.execHook(upgradedRelease, release.HookPostUpgrade, u.WaitStrategy, u.Timeout); err != nil { u.reportToPerformUpgrade(c, upgradedRelease, results.Created, fmt.Errorf("post-upgrade hooks failed: %s", err)) return } @@ -526,13 +528,8 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e rollin := NewRollback(u.cfg) rollin.Version = filteredHistory[0].Version - if u.Wait == kube.HookOnlyStrategy { - rollin.Wait = kube.StatusWatcherStrategy - } - // TODO pretty sure this is unnecessary as the waiter is already set if atomic at the start of upgrade - werr := u.cfg.KubeClient.SetWaiter(u.Wait) - if werr != nil { - return rel, errors.Wrapf(herr, "an error occurred while creating the waiter. original upgrade error: %s", err) + if u.WaitStrategy == kube.HookOnlyStrategy { + rollin.WaitStrategy = kube.StatusWatcherStrategy } rollin.WaitForJobs = u.WaitForJobs rollin.DisableHooks = u.DisableHooks diff --git a/pkg/action/upgrade_test.go b/pkg/action/upgrade_test.go index a36b7a3de..19869f6d6 100644 --- a/pkg/action/upgrade_test.go +++ b/pkg/action/upgrade_test.go @@ -53,7 +53,7 @@ func TestUpgradeRelease_Success(t *testing.T) { rel.Info.Status = release.StatusDeployed req.NoError(upAction.cfg.Releases.Create(rel)) - upAction.Wait = kube.StatusWatcherStrategy + upAction.WaitStrategy = kube.StatusWatcherStrategy vals := map[string]interface{}{} ctx, done := context.WithCancel(context.Background()) @@ -83,7 +83,7 @@ func TestUpgradeRelease_Wait(t *testing.T) { failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") upAction.cfg.KubeClient = failer - upAction.Wait = kube.StatusWatcherStrategy + upAction.WaitStrategy = kube.StatusWatcherStrategy vals := map[string]interface{}{} res, err := upAction.Run(rel.Name, buildChart(), vals) @@ -105,7 +105,7 @@ func TestUpgradeRelease_WaitForJobs(t *testing.T) { failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitError = fmt.Errorf("I timed out") upAction.cfg.KubeClient = failer - upAction.Wait = kube.StatusWatcherStrategy + upAction.WaitStrategy = kube.StatusWatcherStrategy upAction.WaitForJobs = true vals := map[string]interface{}{} @@ -129,7 +129,7 @@ func TestUpgradeRelease_CleanupOnFail(t *testing.T) { failer.WaitError = fmt.Errorf("I timed out") failer.DeleteError = fmt.Errorf("I tried to delete nil") upAction.cfg.KubeClient = failer - upAction.Wait = kube.StatusWatcherStrategy + upAction.WaitStrategy = kube.StatusWatcherStrategy upAction.CleanupOnFail = true vals := map[string]interface{}{} @@ -396,7 +396,7 @@ func TestUpgradeRelease_Interrupted_Wait(t *testing.T) { failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) failer.WaitDuration = 10 * time.Second upAction.cfg.KubeClient = failer - upAction.Wait = kube.StatusWatcherStrategy + upAction.WaitStrategy = kube.StatusWatcherStrategy vals := map[string]interface{}{} ctx := context.Background() diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 04055fde9..051612bb8 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -211,7 +211,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal f.BoolVar(&client.TakeOwnership, "take-ownership", false, "if set, install will ignore the check for helm annotations and take ownership of the existing resources") addValueOptionsFlags(f, valueOpts) addChartPathOptionsFlags(f, &client.ChartPathOptions) - AddWaitFlag(cmd, &client.Wait) + AddWaitFlag(cmd, &client.WaitStrategy) err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { requiredArgs := 2 diff --git a/pkg/cmd/rollback.go b/pkg/cmd/rollback.go index 01a32b184..1823432dc 100644 --- a/pkg/cmd/rollback.go +++ b/pkg/cmd/rollback.go @@ -84,7 +84,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 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") - AddWaitFlag(cmd, &client.Wait) + AddWaitFlag(cmd, &client.WaitStrategy) return cmd } diff --git a/pkg/cmd/uninstall.go b/pkg/cmd/uninstall.go index 3a86cc598..4680c324a 100644 --- a/pkg/cmd/uninstall.go +++ b/pkg/cmd/uninstall.go @@ -79,7 +79,7 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.StringVar(&client.DeletionPropagation, "cascade", "background", "Must be \"background\", \"orphan\", or \"foreground\". Selects the deletion cascading strategy for the dependents. Defaults to background.") 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") - AddWaitFlag(cmd, &client.Wait) + AddWaitFlag(cmd, &client.WaitStrategy) return cmd } diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index 74d12ac40..afbbde435 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -136,7 +136,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { instClient.DisableHooks = client.DisableHooks instClient.SkipCRDs = client.SkipCRDs instClient.Timeout = client.Timeout - instClient.Wait = client.Wait + instClient.WaitStrategy = client.WaitStrategy instClient.WaitForJobs = client.WaitForJobs instClient.Devel = client.Devel instClient.Namespace = client.Namespace @@ -294,7 +294,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { addValueOptionsFlags(f, valueOpts) bindOutputFlag(cmd, &outfmt) bindPostRenderFlag(cmd, &client.PostRenderer) - AddWaitFlag(cmd, &client.Wait) + AddWaitFlag(cmd, &client.WaitStrategy) err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { if len(args) != 2 { diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 61e681ad3..032f79850 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -125,7 +125,7 @@ func (c *Client) newStatusWatcher() (*statusWaiter, error) { }, nil } -func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { +func (c *Client) GetWaiter(strategy WaitStrategy) (Waiter, error) { switch strategy { case LegacyStrategy: kc, err := c.Factory.KubernetesClientSet() @@ -148,7 +148,7 @@ func (c *Client) newWaiter(strategy WaitStrategy) (Waiter, error) { func (c *Client) SetWaiter(ws WaitStrategy) error { var err error - c.Waiter, err = c.newWaiter(ws) + c.Waiter, err = c.GetWaiter(ws) if err != nil { return err } @@ -156,7 +156,7 @@ func (c *Client) SetWaiter(ws WaitStrategy) error { } // New creates a new Client. -func New(getter genericclioptions.RESTClientGetter) (*Client, error) { +func New(getter genericclioptions.RESTClientGetter) *Client { if getter == nil { getter = genericclioptions.NewConfigFlags(true) } @@ -165,12 +165,7 @@ func New(getter genericclioptions.RESTClientGetter) (*Client, error) { Factory: factory, Log: nopLogger, } - var err error - c.Waiter, err = c.newWaiter(HookOnlyStrategy) - if err != nil { - return nil, err - } - return c, nil + return c } var nopLogger = func(_ string, _ ...interface{}) {} diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 527f28a72..8ae1df238 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -516,7 +516,7 @@ func TestWait(t *testing.T) { }), } var err error - c.Waiter, err = c.newWaiter(LegacyStrategy) + c.Waiter, err = c.GetWaiter(LegacyStrategy) if err != nil { t.Fatal(err) } @@ -573,7 +573,7 @@ func TestWaitJob(t *testing.T) { }), } var err error - c.Waiter, err = c.newWaiter(LegacyStrategy) + c.Waiter, err = c.GetWaiter(LegacyStrategy) if err != nil { t.Fatal(err) } @@ -632,7 +632,7 @@ func TestWaitDelete(t *testing.T) { }), } var err error - c.Waiter, err = c.newWaiter(LegacyStrategy) + c.Waiter, err = c.GetWaiter(LegacyStrategy) if err != nil { t.Fatal(err) } @@ -662,10 +662,7 @@ func TestWaitDelete(t *testing.T) { func TestReal(t *testing.T) { t.Skip("This is a live test, comment this line to run") - c, err := New(nil) - if err != nil { - t.Fatal(err) - } + c := New(nil) resources, err := c.Build(strings.NewReader(guestbookManifest), false) if err != nil { t.Fatal(err) @@ -675,10 +672,7 @@ func TestReal(t *testing.T) { } testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest - c, err = New(nil) - if err != nil { - t.Fatal(err) - } + c = New(nil) resources, err = c.Build(strings.NewReader(testSvcEndpointManifest), false) if err != nil { t.Fatal(err) diff --git a/pkg/kube/fake/fake.go b/pkg/kube/fake/fake.go index c4322733a..f868afa1a 100644 --- a/pkg/kube/fake/fake.go +++ b/pkg/kube/fake/fake.go @@ -35,19 +35,29 @@ type FailingKubeClient struct { PrintingKubeClient CreateError error GetError error - WaitError error - WaitForDeleteError error DeleteError error DeleteWithPropagationError error - WatchUntilReadyError error UpdateError error BuildError error BuildTableError error BuildDummy bool BuildUnstructuredError error + WaitError error + WaitForDeleteError error + WatchUntilReadyError error WaitDuration time.Duration } +// FailingKubeWaiter implements kube.Waiter for testing purposes. +// It also has additional errors you can set to fail different functions, otherwise it delegates all its calls to `PrintingKubeWaiter` +type FailingKubeWaiter struct { + *PrintingKubeWaiter + waitError error + waitForDeleteError error + watchUntilReadyError error + waitDuration time.Duration +} + // Create returns the configured error if set or prints func (f *FailingKubeClient) Create(resources kube.ResourceList) (*kube.Result, error) { if f.CreateError != nil { @@ -65,28 +75,28 @@ func (f *FailingKubeClient) Get(resources kube.ResourceList, related bool) (map[ } // Waits the amount of time defined on f.WaitDuration, then returns the configured error if set or prints. -func (f *FailingKubeClient) Wait(resources kube.ResourceList, d time.Duration) error { - time.Sleep(f.WaitDuration) - if f.WaitError != nil { - return f.WaitError +func (f *FailingKubeWaiter) Wait(resources kube.ResourceList, d time.Duration) error { + time.Sleep(f.waitDuration) + if f.waitError != nil { + return f.waitError } - return f.PrintingKubeClient.Wait(resources, d) + return f.PrintingKubeWaiter.Wait(resources, d) } // WaitWithJobs returns the configured error if set or prints -func (f *FailingKubeClient) WaitWithJobs(resources kube.ResourceList, d time.Duration) error { - if f.WaitError != nil { - return f.WaitError +func (f *FailingKubeWaiter) WaitWithJobs(resources kube.ResourceList, d time.Duration) error { + if f.waitError != nil { + return f.waitError } - return f.PrintingKubeClient.WaitWithJobs(resources, d) + return f.PrintingKubeWaiter.WaitWithJobs(resources, d) } // WaitForDelete returns the configured error if set or prints -func (f *FailingKubeClient) WaitForDelete(resources kube.ResourceList, d time.Duration) error { - if f.WaitForDeleteError != nil { - return f.WaitForDeleteError +func (f *FailingKubeWaiter) WaitForDelete(resources kube.ResourceList, d time.Duration) error { + if f.waitForDeleteError != nil { + return f.waitForDeleteError } - return f.PrintingKubeClient.WaitForDelete(resources, d) + return f.PrintingKubeWaiter.WaitForDelete(resources, d) } // Delete returns the configured error if set or prints @@ -98,11 +108,11 @@ func (f *FailingKubeClient) Delete(resources kube.ResourceList) (*kube.Result, [ } // WatchUntilReady returns the configured error if set or prints -func (f *FailingKubeClient) WatchUntilReady(resources kube.ResourceList, d time.Duration) error { - if f.WatchUntilReadyError != nil { - return f.WatchUntilReadyError +func (f *FailingKubeWaiter) WatchUntilReady(resources kube.ResourceList, d time.Duration) error { + if f.watchUntilReadyError != nil { + return f.watchUntilReadyError } - return f.PrintingKubeClient.WatchUntilReady(resources, d) + return f.PrintingKubeWaiter.WatchUntilReady(resources, d) } // Update returns the configured error if set or prints @@ -140,8 +150,16 @@ func (f *FailingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceL return f.PrintingKubeClient.DeleteWithPropagationPolicy(resources, policy) } -func (f *FailingKubeClient) SetWaiter(_ kube.WaitStrategy) error { - return nil +func (f *FailingKubeClient) GetWaiter(ws kube.WaitStrategy) (kube.Waiter, error) { + waiter, _ := f.PrintingKubeClient.GetWaiter(ws) + printingKubeWaiter, _ := waiter.(*PrintingKubeWaiter) + return &FailingKubeWaiter{ + PrintingKubeWaiter: printingKubeWaiter, + waitError: f.WaitError, + waitForDeleteError: f.WaitForDeleteError, + watchUntilReadyError: f.WatchUntilReadyError, + waitDuration: f.WaitDuration, + }, nil } func createDummyResourceList() kube.ResourceList { @@ -151,5 +169,4 @@ func createDummyResourceList() kube.ResourceList { var resourceList kube.ResourceList resourceList.Append(&resInfo) return resourceList - } diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index fa25a04b3..f6659a904 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -37,6 +37,12 @@ type PrintingKubeClient struct { LogOutput io.Writer } +// PrintingKubeWaiter implements kube.Waiter, but simply prints the reader to the given output +type PrintingKubeWaiter struct { + Out io.Writer + LogOutput io.Writer +} + // IsReachable checks if the cluster is reachable func (p *PrintingKubeClient) IsReachable() error { return nil @@ -59,17 +65,23 @@ func (p *PrintingKubeClient) Get(resources kube.ResourceList, _ bool) (map[strin return make(map[string][]runtime.Object), nil } -func (p *PrintingKubeClient) Wait(resources kube.ResourceList, _ time.Duration) error { +func (p *PrintingKubeWaiter) Wait(resources kube.ResourceList, _ time.Duration) error { _, err := io.Copy(p.Out, bufferize(resources)) return err } -func (p *PrintingKubeClient) WaitWithJobs(resources kube.ResourceList, _ time.Duration) error { +func (p *PrintingKubeWaiter) WaitWithJobs(resources kube.ResourceList, _ time.Duration) error { _, err := io.Copy(p.Out, bufferize(resources)) return err } -func (p *PrintingKubeClient) WaitForDelete(resources kube.ResourceList, _ time.Duration) error { +func (p *PrintingKubeWaiter) WaitForDelete(resources kube.ResourceList, _ time.Duration) error { + _, err := io.Copy(p.Out, bufferize(resources)) + return err +} + +// WatchUntilReady implements KubeClient WatchUntilReady. +func (p *PrintingKubeWaiter) WatchUntilReady(resources kube.ResourceList, _ time.Duration) error { _, err := io.Copy(p.Out, bufferize(resources)) return err } @@ -85,12 +97,6 @@ func (p *PrintingKubeClient) Delete(resources kube.ResourceList) (*kube.Result, return &kube.Result{Deleted: resources}, nil } -// WatchUntilReady implements KubeClient WatchUntilReady. -func (p *PrintingKubeClient) WatchUntilReady(resources kube.ResourceList, _ time.Duration) error { - _, err := io.Copy(p.Out, bufferize(resources)) - return err -} - // Update implements KubeClient Update. func (p *PrintingKubeClient) Update(_, modified kube.ResourceList, _ bool) (*kube.Result, error) { _, err := io.Copy(p.Out, bufferize(modified)) @@ -140,8 +146,8 @@ func (p *PrintingKubeClient) DeleteWithPropagationPolicy(resources kube.Resource return &kube.Result{Deleted: resources}, nil } -func (p *PrintingKubeClient) SetWaiter(_ kube.WaitStrategy) error { - return nil +func (p *PrintingKubeClient) GetWaiter(_ kube.WaitStrategy) (kube.Waiter, error) { + return &PrintingKubeWaiter{Out: p.Out, LogOutput: p.LogOutput}, nil } func bufferize(resources kube.ResourceList) io.Reader { diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index d6ac823f1..fb42fed06 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -48,9 +48,9 @@ type Interface interface { Build(reader io.Reader, validate bool) (ResourceList, error) // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error - // Set Waiter sets the Kube.Waiter - SetWaiter(ws WaitStrategy) error - Waiter + + // Get Waiter gets the Kube.Waiter + GetWaiter(ws WaitStrategy) (Waiter, error) } // Waiter defines methods related to waiting for resource states. From 8efd428e5da26d035eb7a095e348c9cbbfae9f26 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Mar 2025 14:10:31 +0000 Subject: [PATCH 221/271] switch back to k8s rest mapper Signed-off-by: Austin Abro --- go.mod | 2 +- go.sum | 4 +- internal/restmapper/restmapper.go | 372 ------------------------------ pkg/kube/client.go | 5 +- 4 files changed, 5 insertions(+), 378 deletions(-) delete mode 100644 internal/restmapper/restmapper.go diff --git a/go.mod b/go.mod index c0f172c1e..bfc55057a 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/kubectl v0.32.3 oras.land/oras-go/v2 v2.5.0 + sigs.k8s.io/controller-runtime v0.20.4 sigs.k8s.io/yaml v1.4.0 ) @@ -177,7 +178,6 @@ require ( k8s.io/component-base v0.32.3 // indirect k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect - sigs.k8s.io/controller-runtime v0.20.1 // indirect sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/kustomize/api v0.18.0 // indirect sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect diff --git a/go.sum b/go.sum index 620678cbf..1153931d8 100644 --- a/go.sum +++ b/go.sum @@ -535,8 +535,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c= oras.land/oras-go/v2 v2.5.0/go.mod h1:z4eisnLP530vwIOUOJeBIj0aGI0L1C3d53atvCBqZHg= -sigs.k8s.io/controller-runtime v0.20.1 h1:JbGMAG/X94NeM3xvjenVUaBjy6Ui4Ogd/J5ZtjZnHaE= -sigs.k8s.io/controller-runtime v0.20.1/go.mod h1:BrP3w158MwvB3ZbNpaAcIKkHQ7YGpYnzpoSTZ8E14WU= +sigs.k8s.io/controller-runtime v0.20.4 h1:X3c+Odnxz+iPTRobG4tp092+CvBU9UK0t/bRf+n0DGU= +sigs.k8s.io/controller-runtime v0.20.4/go.mod h1:xg2XB0K5ShQzAgsoujxuKN4LNXR2LfwwHsPj7Iaw+XY= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/kustomize/api v0.18.0 h1:hTzp67k+3NEVInwz5BHyzc9rGxIauoXferXyjv5lWPo= diff --git a/internal/restmapper/restmapper.go b/internal/restmapper/restmapper.go deleted file mode 100644 index 85b7c2a69..000000000 --- a/internal/restmapper/restmapper.go +++ /dev/null @@ -1,372 +0,0 @@ -/* -Copyright The Helm Authors. -This file was initially copied and modified from - https://github.com/kubernetes-sigs/controller-runtime/blob/e818ce450d3d358600848dcfa1b585de64e7c865/pkg/client/apiutil/restmapper.go -Copyright 2023 The Kubernetes 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 restmapper - -import ( - "fmt" - "net/http" - "sort" - "strings" - "sync" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/discovery" - "k8s.io/client-go/rest" - "k8s.io/client-go/restmapper" -) - -/* -Adapted from controller-runtime v0.19 before The Kubernetes Aggregated Discovery was enabled -in controller-runtime v0.20 which broke the preferred version discovery in the RESTMapper. -https://github.com/kubernetes-sigs/controller-runtime/blob/e818ce450d3d358600848dcfa1b585de64e7c865/pkg/client/apiutil/restmapper.go -*/ - -// NewLazyRESTMapper returns a dynamic RESTMapper for cfg. The dynamic -// RESTMapper dynamically discovers resource types at runtime. -func NewLazyRESTMapper(cfg *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) { - if httpClient == nil { - return nil, fmt.Errorf("httpClient must not be nil, consider using rest.HTTPClientFor(c) to create a client") - } - - client, err := discovery.NewDiscoveryClientForConfigAndClient(cfg, httpClient) - if err != nil { - return nil, err - } - return &mapper{ - mapper: restmapper.NewDiscoveryRESTMapper([]*restmapper.APIGroupResources{}), - client: client, - knownGroups: map[string]*restmapper.APIGroupResources{}, - apiGroups: map[string]*metav1.APIGroup{}, - }, nil -} - -// mapper is a RESTMapper that will lazily query the provided -// client for discovery information to do REST mappings. -type mapper struct { - mapper meta.RESTMapper - client discovery.DiscoveryInterface - knownGroups map[string]*restmapper.APIGroupResources - apiGroups map[string]*metav1.APIGroup - - // mutex to provide thread-safe mapper reloading. - mu sync.RWMutex -} - -// KindFor implements Mapper.KindFor. -func (m *mapper) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error) { - res, err := m.getMapper().KindFor(resource) - if meta.IsNoMatchError(err) { - if err := m.addKnownGroupAndReload(resource.Group, resource.Version); err != nil { - return schema.GroupVersionKind{}, err - } - res, err = m.getMapper().KindFor(resource) - } - - return res, err -} - -// KindsFor implements Mapper.KindsFor. -func (m *mapper) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error) { - res, err := m.getMapper().KindsFor(resource) - if meta.IsNoMatchError(err) { - if err := m.addKnownGroupAndReload(resource.Group, resource.Version); err != nil { - return nil, err - } - res, err = m.getMapper().KindsFor(resource) - } - - return res, err -} - -// ResourceFor implements Mapper.ResourceFor. -func (m *mapper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error) { - res, err := m.getMapper().ResourceFor(input) - if meta.IsNoMatchError(err) { - if err := m.addKnownGroupAndReload(input.Group, input.Version); err != nil { - return schema.GroupVersionResource{}, err - } - res, err = m.getMapper().ResourceFor(input) - } - - return res, err -} - -// ResourcesFor implements Mapper.ResourcesFor. -func (m *mapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error) { - res, err := m.getMapper().ResourcesFor(input) - if meta.IsNoMatchError(err) { - if err := m.addKnownGroupAndReload(input.Group, input.Version); err != nil { - return nil, err - } - res, err = m.getMapper().ResourcesFor(input) - } - - return res, err -} - -// RESTMapping implements Mapper.RESTMapping. -func (m *mapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error) { - res, err := m.getMapper().RESTMapping(gk, versions...) - if meta.IsNoMatchError(err) { - if err := m.addKnownGroupAndReload(gk.Group, versions...); err != nil { - return nil, err - } - res, err = m.getMapper().RESTMapping(gk, versions...) - } - - return res, err -} - -// RESTMappings implements Mapper.RESTMappings. -func (m *mapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error) { - res, err := m.getMapper().RESTMappings(gk, versions...) - if meta.IsNoMatchError(err) { - if err := m.addKnownGroupAndReload(gk.Group, versions...); err != nil { - return nil, err - } - res, err = m.getMapper().RESTMappings(gk, versions...) - } - - return res, err -} - -// ResourceSingularizer implements Mapper.ResourceSingularizer. -func (m *mapper) ResourceSingularizer(resource string) (string, error) { - return m.getMapper().ResourceSingularizer(resource) -} - -func (m *mapper) getMapper() meta.RESTMapper { - m.mu.RLock() - defer m.mu.RUnlock() - return m.mapper -} - -// addKnownGroupAndReload reloads the mapper with updated information about missing API group. -// versions can be specified for partial updates, for instance for v1beta1 version only. -func (m *mapper) addKnownGroupAndReload(groupName string, versions ...string) error { - // versions will here be [""] if the forwarded Version value of - // GroupVersionResource (in calling method) was not specified. - if len(versions) == 1 && versions[0] == "" { - versions = nil - } - - // If no specific versions are set by user, we will scan all available ones for the API group. - // This operation requires 2 requests: /api and /apis, but only once. For all subsequent calls - // this data will be taken from cache. - if len(versions) == 0 { - apiGroup, err := m.findAPIGroupByName(groupName) - if err != nil { - return err - } - if apiGroup != nil { - for _, version := range apiGroup.Versions { - versions = append(versions, version.Version) - } - } - } - - m.mu.Lock() - defer m.mu.Unlock() - - // Create or fetch group resources from cache. - groupResources := &restmapper.APIGroupResources{ - Group: metav1.APIGroup{Name: groupName}, - VersionedResources: make(map[string][]metav1.APIResource), - } - - // Update information for group resources about versioned resources. - // The number of API calls is equal to the number of versions: /apis//. - // If we encounter a missing API version (NotFound error), we will remove the group from - // the m.apiGroups and m.knownGroups caches. - // If this happens, in the next call the group will be added back to apiGroups - // and only the existing versions will be loaded in knownGroups. - groupVersionResources, err := m.fetchGroupVersionResourcesLocked(groupName, versions...) - if err != nil { - return fmt.Errorf("failed to get API group resources: %w", err) - } - - if _, ok := m.knownGroups[groupName]; ok { - groupResources = m.knownGroups[groupName] - } - - // Update information for group resources about the API group by adding new versions. - // Ignore the versions that are already registered. - for groupVersion, resources := range groupVersionResources { - version := groupVersion.Version - - groupResources.VersionedResources[version] = resources.APIResources - found := false - for _, v := range groupResources.Group.Versions { - if v.Version == version { - found = true - break - } - } - - if !found { - groupResources.Group.Versions = append(groupResources.Group.Versions, metav1.GroupVersionForDiscovery{ - GroupVersion: metav1.GroupVersion{Group: groupName, Version: version}.String(), - Version: version, - }) - } - } - - // Update data in the cache. - m.knownGroups[groupName] = groupResources - - // Finally, update the group with received information and regenerate the mapper. - updatedGroupResources := make([]*restmapper.APIGroupResources, 0, len(m.knownGroups)) - for _, agr := range m.knownGroups { - updatedGroupResources = append(updatedGroupResources, agr) - } - - m.mapper = restmapper.NewDiscoveryRESTMapper(updatedGroupResources) - return nil -} - -// findAPIGroupByNameLocked returns API group by its name. -func (m *mapper) findAPIGroupByName(groupName string) (*metav1.APIGroup, error) { - // Looking in the cache first. - { - m.mu.RLock() - group, ok := m.apiGroups[groupName] - m.mu.RUnlock() - if ok { - return group, nil - } - } - - // Update the cache if nothing was found. - apiGroups, err := m.client.ServerGroups() - if err != nil { - return nil, fmt.Errorf("failed to get server groups: %w", err) - } - if len(apiGroups.Groups) == 0 { - return nil, fmt.Errorf("received an empty API groups list") - } - - m.mu.Lock() - for i := range apiGroups.Groups { - group := &apiGroups.Groups[i] - m.apiGroups[group.Name] = group - } - m.mu.Unlock() - - // Looking in the cache again. - m.mu.RLock() - defer m.mu.RUnlock() - - // Don't return an error here if the API group is not present. - // The reloaded RESTMapper will take care of returning a NoMatchError. - return m.apiGroups[groupName], nil -} - -// fetchGroupVersionResourcesLocked fetches the resources for the specified group and its versions. -// This method might modify the cache so it needs to be called under the lock. -func (m *mapper) fetchGroupVersionResourcesLocked(groupName string, versions ...string) (map[schema.GroupVersion]*metav1.APIResourceList, error) { - groupVersionResources := make(map[schema.GroupVersion]*metav1.APIResourceList) - failedGroups := make(map[schema.GroupVersion]error) - - for _, version := range versions { - groupVersion := schema.GroupVersion{Group: groupName, Version: version} - - apiResourceList, err := m.client.ServerResourcesForGroupVersion(groupVersion.String()) - if apierrors.IsNotFound(err) { - // If the version is not found, we remove the group from the cache - // so it gets refreshed on the next call. - if m.isAPIGroupCached(groupVersion) { - delete(m.apiGroups, groupName) - } - if m.isGroupVersionCached(groupVersion) { - delete(m.knownGroups, groupName) - } - continue - } else if err != nil { - failedGroups[groupVersion] = err - } - - if apiResourceList != nil { - // even in case of error, some fallback might have been returned. - groupVersionResources[groupVersion] = apiResourceList - } - } - - if len(failedGroups) > 0 { - err := ErrResourceDiscoveryFailed(failedGroups) - return nil, &err - } - - return groupVersionResources, nil -} - -// isGroupVersionCached checks if a version for a group is cached in the known groups cache. -func (m *mapper) isGroupVersionCached(gv schema.GroupVersion) bool { - if cachedGroup, ok := m.knownGroups[gv.Group]; ok { - _, cached := cachedGroup.VersionedResources[gv.Version] - return cached - } - - return false -} - -// isAPIGroupCached checks if a version for a group is cached in the api groups cache. -func (m *mapper) isAPIGroupCached(gv schema.GroupVersion) bool { - cachedGroup, ok := m.apiGroups[gv.Group] - if !ok { - return false - } - - for _, version := range cachedGroup.Versions { - if version.Version == gv.Version { - return true - } - } - - return false -} - -// ErrResourceDiscoveryFailed is returned if the RESTMapper cannot discover supported resources for some GroupVersions. -// It wraps the errors encountered, except "NotFound" errors are replaced with meta.NoResourceMatchError, for -// backwards compatibility with code that uses meta.IsNoMatchError() to check for unsupported APIs. -type ErrResourceDiscoveryFailed map[schema.GroupVersion]error - -// Error implements the error interface. -func (e *ErrResourceDiscoveryFailed) Error() string { - subErrors := []string{} - for k, v := range *e { - subErrors = append(subErrors, fmt.Sprintf("%s: %v", k, v)) - } - sort.Strings(subErrors) - return fmt.Sprintf("unable to retrieve the complete list of server APIs: %s", strings.Join(subErrors, ", ")) -} - -func (e *ErrResourceDiscoveryFailed) Unwrap() []error { - subErrors := []error{} - for gv, err := range *e { - if apierrors.IsNotFound(err) { - err = &meta.NoResourceMatchError{PartialResource: gv.WithResource("")} - } - subErrors = append(subErrors, err) - } - return subErrors -} diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 032f79850..a62b83b3e 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -35,6 +35,7 @@ import ( apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -50,8 +51,6 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" - - helmRestmapper "helm.sh/helm/v4/internal/restmapper" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. @@ -114,7 +113,7 @@ func (c *Client) newStatusWatcher() (*statusWaiter, error) { if err != nil { return nil, err } - restMapper, err := helmRestmapper.NewLazyRESTMapper(cfg, httpClient) + restMapper, err := apiutil.NewDynamicRESTMapper(cfg, httpClient) if err != nil { return nil, err } From 21ee7212429ed8354f3093af40272c3c730520b7 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 25 Mar 2025 14:15:27 +0000 Subject: [PATCH 222/271] go fmt Signed-off-by: Austin Abro --- pkg/kube/interface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/interface.go b/pkg/kube/interface.go index fb42fed06..f68367dcd 100644 --- a/pkg/kube/interface.go +++ b/pkg/kube/interface.go @@ -48,7 +48,7 @@ type Interface interface { Build(reader io.Reader, validate bool) (ResourceList, error) // IsReachable checks whether the client is able to connect to the cluster. IsReachable() error - + // Get Waiter gets the Kube.Waiter GetWaiter(ws WaitStrategy) (Waiter, error) } From 000c098a41b15147652256e9b863ebf30dcd17d9 Mon Sep 17 00:00:00 2001 From: Suleiman Dibirov Date: Sat, 5 Apr 2025 17:47:25 +0300 Subject: [PATCH 223/271] fix(concurrency): add mutex to protect repoFailList and out in updateCharts Signed-off-by: Suleiman Dibirov --- pkg/cmd/repo_update.go | 16 +++++++++++++--- pkg/cmd/repo_update_test.go | 11 +++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/repo_update.go b/pkg/cmd/repo_update.go index 6590d9872..12de2bdaa 100644 --- a/pkg/cmd/repo_update.go +++ b/pkg/cmd/repo_update.go @@ -111,20 +111,30 @@ func (o *repoUpdateOptions) run(out io.Writer) error { func updateCharts(repos []*repo.ChartRepository, out io.Writer) error { fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") var wg sync.WaitGroup - var repoFailList []string + failRepoURLChan := make(chan string, len(repos)) + 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) + failRepoURLChan <- re.Config.URL } else { fmt.Fprintf(out, "...Successfully got an update from the %q chart repository\n", re.Config.Name) } }(re) } - wg.Wait() + + go func() { + wg.Wait() + close(failRepoURLChan) + }() + + var repoFailList []string + for url := range failRepoURLChan { + repoFailList = append(repoFailList, url) + } if len(repoFailList) > 0 { return fmt.Errorf("Failed to update the following repositories: %s", diff --git a/pkg/cmd/repo_update_test.go b/pkg/cmd/repo_update_test.go index 6fc4c8f4b..aa8f52beb 100644 --- a/pkg/cmd/repo_update_test.go +++ b/pkg/cmd/repo_update_test.go @@ -172,7 +172,14 @@ func TestUpdateChartsFailWithError(t *testing.T) { defer ts.Stop() var invalidURL = ts.URL() + "55" - r, err := repo.NewChartRepository(&repo.Entry{ + r1, err := repo.NewChartRepository(&repo.Entry{ + Name: "charts", + URL: invalidURL, + }, getter.All(settings)) + if err != nil { + t.Error(err) + } + r2, err := repo.NewChartRepository(&repo.Entry{ Name: "charts", URL: invalidURL, }, getter.All(settings)) @@ -181,7 +188,7 @@ func TestUpdateChartsFailWithError(t *testing.T) { } b := bytes.NewBuffer(nil) - err = updateCharts([]*repo.ChartRepository{r}, b) + err = updateCharts([]*repo.ChartRepository{r1, r2}, b) if err == nil { t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set") return From be2b84685af03aeb34b5b7d84960315aec71c270 Mon Sep 17 00:00:00 2001 From: George Jenkins Date: Mon, 31 Mar 2025 09:21:33 -0700 Subject: [PATCH 224/271] cleanup: Remove Helm v2 template lint rules Signed-off-by: George Jenkins --- pkg/lint/rules/template.go | 26 +------------------------- pkg/lint/rules/template_test.go | 20 -------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 287968340..4d421f5bf 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -24,7 +24,6 @@ import ( "os" "path" "path/filepath" - "regexp" "strings" "github.com/pkg/errors" @@ -39,11 +38,6 @@ import ( "helm.sh/helm/v4/pkg/lint/support" ) -var ( - crdHookSearch = regexp.MustCompile(`"?helm\.sh/hook"?:\s+crd-install`) - releaseTimeSearch = regexp.MustCompile(`\.Release\.Time`) -) - // Templates lints the templates in the Linter. func Templates(linter *support.Linter, values map[string]interface{}, namespace string, _ bool) { TemplatesWithKubeVersion(linter, values, namespace, nil) @@ -119,14 +113,10 @@ func TemplatesWithSkipSchemaValidation(linter *support.Linter, values map[string - Metadata.Namespace is not set */ for _, template := range chart.Templates { - fileName, data := template.Name, template.Data + fileName := template.Name fpath = fileName linter.RunLinterRule(support.ErrorSev, fpath, validateAllowedExtension(fileName)) - // These are v3 specific checks to make sure and warn people if their - // chart is not compatible with v3 - linter.RunLinterRule(support.WarningSev, fpath, validateNoCRDHooks(data)) - linter.RunLinterRule(support.ErrorSev, fpath, validateNoReleaseTime(data)) // We only apply the following lint rules to yaml files if filepath.Ext(fileName) != ".yaml" || filepath.Ext(fileName) == ".yml" { @@ -291,20 +281,6 @@ func validateMetadataNameFunc(obj *K8sYamlStruct) validation.ValidateNameFunc { } } -func validateNoCRDHooks(manifest []byte) error { - if crdHookSearch.Match(manifest) { - return errors.New("manifest is a crd-install hook. This hook is no longer supported in v3 and all CRDs should also exist the crds/ directory at the top level of the chart") - } - return nil -} - -func validateNoReleaseTime(manifest []byte) error { - if releaseTimeSearch.Match(manifest) { - return errors.New(".Release.Time has been removed in v3, please replace with the `now` function in your templates") - } - return nil -} - // validateMatchSelector ensures that template specs have a selector declared. // See https://github.com/helm/helm/issues/1990 func validateMatchSelector(yamlStruct *K8sYamlStruct, manifest string) error { diff --git a/pkg/lint/rules/template_test.go b/pkg/lint/rules/template_test.go index 7205ace6d..bd503368d 100644 --- a/pkg/lint/rules/template_test.go +++ b/pkg/lint/rules/template_test.go @@ -85,26 +85,6 @@ func TestTemplateIntegrationHappyPath(t *testing.T) { } } -func TestV3Fail(t *testing.T) { - linter := support.Linter{ChartDir: "./testdata/v3-fail"} - Templates(&linter, values, namespace, strict) - res := linter.Messages - - if len(res) != 3 { - t.Fatalf("Expected 3 errors, got %d, %v", len(res), res) - } - - if !strings.Contains(res[0].Err.Error(), ".Release.Time has been removed in v3") { - t.Errorf("Unexpected error: %s", res[0].Err) - } - if !strings.Contains(res[1].Err.Error(), "manifest is a crd-install hook") { - t.Errorf("Unexpected error: %s", res[1].Err) - } - if !strings.Contains(res[2].Err.Error(), "manifest is a crd-install hook") { - t.Errorf("Unexpected error: %s", res[2].Err) - } -} - func TestMultiTemplateFail(t *testing.T) { linter := support.Linter{ChartDir: "./testdata/multi-template-fail"} Templates(&linter, values, namespace, strict) From f4631bf3d8e7fe64395e4f5faec505539e73fb9e Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 12:32:35 +0100 Subject: [PATCH 225/271] Migrate kube package to slog As for helm v4. We want to migrate logs to slog. Signed-off-by: Benoit Tigeot --- pkg/action/action.go | 2 +- pkg/kube/client.go | 36 ++++++++++++++---------------- pkg/kube/logger.go | 30 +++++++++++++++++++++++++ pkg/kube/ready.go | 50 ++++++++++++++++++++++-------------------- pkg/kube/ready_test.go | 18 +++++++-------- 5 files changed, 83 insertions(+), 53 deletions(-) create mode 100644 pkg/kube/logger.go diff --git a/pkg/action/action.go b/pkg/action/action.go index ea2dc0dd7..4f100f833 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -376,7 +376,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { kc := kube.New(getter) - kc.Log = log + kc.Log = log // TODO: Switch to slog compatible logger lazyClient := &lazyClient{ namespace: namespace, diff --git a/pkg/kube/client.go b/pkg/kube/client.go index a62b83b3e..44baa4ba0 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -73,7 +73,7 @@ type Client struct { // needs. The smaller surface area of the interface means there is a lower // chance of it changing. Factory Factory - Log func(string, ...interface{}) + Log Logger // Namespace allows to bypass the kubeconfig file for the choice of the namespace Namespace string @@ -167,8 +167,6 @@ func New(getter genericclioptions.RESTClientGetter) *Client { return c } -var nopLogger = func(_ string, _ ...interface{}) {} - // getKubeClient get or create a new KubernetesClientSet func (c *Client) getKubeClient() (kubernetes.Interface, error) { var err error @@ -198,7 +196,7 @@ func (c *Client) IsReachable() error { // Create creates Kubernetes resources specified in the resource list. func (c *Client) Create(resources ResourceList) (*Result, error) { - c.Log("creating %d resource(s)", len(resources)) + c.Log.Debug("creating resource(s)", "resources", resources) if err := perform(resources, createResource); err != nil { return nil, err } @@ -250,7 +248,7 @@ func (c *Client) Get(resources ResourceList, related bool) (map[string][]runtime objs, err = c.getSelectRelationPod(info, objs, isTable, &podSelectors) if err != nil { - c.Log("Warning: get the relation pod is failed, err:%s", err.Error()) + c.Log.Debug("failed to get related pods", "error", err) } } } @@ -268,7 +266,7 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objs map[string][]run if info == nil { return objs, nil } - c.Log("get relation pod of object: %s/%s/%s", info.Namespace, info.Mapping.GroupVersionKind.Kind, info.Name) + c.Log.Debug("get relation pod of object", "namespace", info.Namespace, "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name) selector, ok, _ := getSelectorFromObject(info.Object) if !ok { return objs, nil @@ -410,7 +408,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err updateErrors := []string{} res := &Result{} - c.Log("checking %d resources for changes", len(target)) + c.Log.Debug("checking resources for changes", "original", original, "target", target) err := target.Visit(func(info *resource.Info, err error) error { if err != nil { return err @@ -431,7 +429,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } kind := info.Mapping.GroupVersionKind.Kind - c.Log("Created a new %s called %q in %s\n", kind, info.Name, info.Namespace) + c.Log.Debug("created a new resource", "kind", kind, "name", info.Name, "namespace", info.Namespace) return nil } @@ -442,7 +440,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } if err := updateResource(c, info, originalInfo.Object, force); err != nil { - c.Log("error updating the resource %q:\n\t %v", info.Name, err) + c.Log.Debug("error updating the resource", "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name, "error", err) updateErrors = append(updateErrors, err.Error()) } // Because we check for errors later, append the info regardless @@ -459,22 +457,22 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } for _, info := range original.Difference(target) { - c.Log("Deleting %s %q in namespace %s...", info.Mapping.GroupVersionKind.Kind, info.Name, info.Namespace) + c.Log.Debug("deleting resource", "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name, "namespace", info.Namespace) if err := info.Get(); err != nil { - c.Log("Unable to get obj %q, err: %s", info.Name, err) + c.Log.Debug("unable to get object", "name", info.Name, "error", err) continue } annotations, err := metadataAccessor.Annotations(info.Object) if err != nil { - c.Log("Unable to get annotations on %q, err: %s", info.Name, err) + c.Log.Debug("unable to get annotations", "name", info.Name, "error", err) } if annotations != nil && annotations[ResourcePolicyAnno] == KeepPolicy { - c.Log("Skipping delete of %q due to annotation [%s=%s]", info.Name, ResourcePolicyAnno, KeepPolicy) + c.Log.Debug("skipping delete due to annotation", "name", info.Name, "annotation", ResourcePolicyAnno, "value", KeepPolicy) continue } if err := deleteResource(info, metav1.DeletePropagationBackground); err != nil { - c.Log("Failed to delete %q, err: %s", info.ObjectName(), err) + c.Log.Debug("failed to delete resource", "name", info.Name, "error", err) continue } res.Deleted = append(res.Deleted, info) @@ -503,11 +501,11 @@ func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropa res := &Result{} mtx := sync.Mutex{} err := perform(resources, func(info *resource.Info) error { - c.Log("Starting delete for %q %s", info.Name, info.Mapping.GroupVersionKind.Kind) + c.Log.Debug("starting delete resource", "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name, "namespace", info.Namespace) err := deleteResource(info, propagation) if err == nil || apierrors.IsNotFound(err) { if err != nil { - c.Log("Ignoring delete failure for %q %s: %v", info.Name, info.Mapping.GroupVersionKind, err) + c.Log.Debug("ignoring delete failure", "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) } mtx.Lock() defer mtx.Unlock() @@ -655,7 +653,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, if err != nil { return errors.Wrap(err, "failed to replace object") } - c.Log("Replaced %q with kind %s for kind %s", target.Name, currentObj.GetObjectKind().GroupVersionKind().Kind, kind) + c.Log.Debug("replace succeeded", "name", target.Name, "initialKind", currentObj.GetObjectKind().GroupVersionKind().Kind, "kind", kind) } else { patch, patchType, err := createPatch(target, currentObj) if err != nil { @@ -663,7 +661,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, } if patch == nil || string(patch) == "{}" { - c.Log("Looks like there are no changes for %s %q", kind, target.Name) + c.Log.Debug("no changes detected", "kind", kind, "name", target.Name) // This needs to happen to make sure that Helm has the latest info from the API // Otherwise there will be no labels and other functions that use labels will panic if err := target.Get(); err != nil { @@ -672,7 +670,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, return nil } // send patch to server - c.Log("Patch %s %q in namespace %s", kind, target.Name, target.Namespace) + c.Log.Debug("patching resource", "kind", kind, "name", target.Name, "namespace", target.Namespace) obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch, nil) if err != nil { return errors.Wrapf(err, "cannot patch %q with kind %s", target.Name, kind) diff --git a/pkg/kube/logger.go b/pkg/kube/logger.go new file mode 100644 index 000000000..da032b752 --- /dev/null +++ b/pkg/kube/logger.go @@ -0,0 +1,30 @@ +/* +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 kube + +// Logger defines a minimal logging interface compatible with slog.Logger +type Logger interface { + Debug(msg string, args ...any) +} + +// NopLogger is a logger that does nothing +type NopLogger struct{} + +// Debug implements the Logger interface +func (n NopLogger) Debug(msg string, args ...any) {} + +var nopLogger = NopLogger{} diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index dd5869e6a..2814aa72e 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -19,6 +19,8 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" "fmt" + "io" + "log/slog" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" @@ -57,13 +59,13 @@ func CheckJobs(checkJobs bool) ReadyCheckerOption { // NewReadyChecker creates a new checker. Passed ReadyCheckerOptions can // be used to override defaults. -func NewReadyChecker(cl kubernetes.Interface, log func(string, ...interface{}), opts ...ReadyCheckerOption) ReadyChecker { +func NewReadyChecker(cl kubernetes.Interface, logger Logger, opts ...ReadyCheckerOption) ReadyChecker { c := ReadyChecker{ client: cl, - log: log, + log: logger, } if c.log == nil { - c.log = nopLogger + c.log = slog.New(slog.NewTextHandler(io.Discard, nil)) } for _, opt := range opts { opt(&c) @@ -74,7 +76,7 @@ func NewReadyChecker(cl kubernetes.Interface, log func(string, ...interface{}), // ReadyChecker is a type that can check core Kubernetes types for readiness. type ReadyChecker struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -230,18 +232,18 @@ func (c *ReadyChecker) isPodReady(pod *corev1.Pod) bool { return true } } - c.log("Pod is not ready: %s/%s", pod.GetNamespace(), pod.GetName()) + c.log.Debug("Pod is not ready", "namespace", pod.GetNamespace(), "name", pod.GetName()) return false } func (c *ReadyChecker) jobReady(job *batchv1.Job) (bool, error) { if job.Status.Failed > *job.Spec.BackoffLimit { - c.log("Job is failed: %s/%s", job.GetNamespace(), job.GetName()) + c.log.Debug("Job is failed", "namespace", job.GetNamespace(), "name", job.GetName()) // If a job is failed, it can't recover, so throw an error return false, fmt.Errorf("job is failed: %s/%s", job.GetNamespace(), job.GetName()) } if job.Spec.Completions != nil && job.Status.Succeeded < *job.Spec.Completions { - c.log("Job is not completed: %s/%s", job.GetNamespace(), job.GetName()) + c.log.Debug("Job is not completed", "namespace", job.GetNamespace(), "name", job.GetName()) return false, nil } return true, nil @@ -255,7 +257,7 @@ func (c *ReadyChecker) serviceReady(s *corev1.Service) bool { // Ensure that the service cluster IP is not empty if s.Spec.ClusterIP == "" { - c.log("Service does not have cluster IP address: %s/%s", s.GetNamespace(), s.GetName()) + c.log.Debug("Service does not have cluster IP address", "namespace", s.GetNamespace(), "name", s.GetName()) return false } @@ -263,12 +265,12 @@ func (c *ReadyChecker) serviceReady(s *corev1.Service) bool { if s.Spec.Type == corev1.ServiceTypeLoadBalancer { // do not wait when at least 1 external IP is set if len(s.Spec.ExternalIPs) > 0 { - c.log("Service %s/%s has external IP addresses (%v), marking as ready", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) + c.log.Debug("Service has external IP addresses", "namespace", s.GetNamespace(), "name", s.GetName(), "externalIPs", s.Spec.ExternalIPs) return true } if s.Status.LoadBalancer.Ingress == nil { - c.log("Service does not have load balancer ingress IP address: %s/%s", s.GetNamespace(), s.GetName()) + c.log.Debug("Service does not have load balancer ingress IP address", "namespace", s.GetNamespace(), "name", s.GetName()) return false } } @@ -278,7 +280,7 @@ func (c *ReadyChecker) serviceReady(s *corev1.Service) bool { func (c *ReadyChecker) volumeReady(v *corev1.PersistentVolumeClaim) bool { if v.Status.Phase != corev1.ClaimBound { - c.log("PersistentVolumeClaim is not bound: %s/%s", v.GetNamespace(), v.GetName()) + c.log.Debug("PersistentVolumeClaim is not bound", "namespace", v.GetNamespace(), "name", v.GetName()) return false } return true @@ -291,13 +293,13 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy } // Verify the generation observed by the deployment controller matches the spec generation if dep.Status.ObservedGeneration != dep.ObjectMeta.Generation { - c.log("Deployment is not ready: %s/%s. observedGeneration (%d) does not match spec generation (%d).", dep.Namespace, dep.Name, dep.Status.ObservedGeneration, dep.ObjectMeta.Generation) + c.log.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "observedGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.ObjectMeta.Generation) return false } expectedReady := *dep.Spec.Replicas - deploymentutil.MaxUnavailable(*dep) if !(rs.Status.ReadyReplicas >= expectedReady) { - c.log("Deployment is not ready: %s/%s. %d out of %d expected pods are ready", dep.Namespace, dep.Name, rs.Status.ReadyReplicas, expectedReady) + c.log.Debug("Deployment is not ready, not all Pods are ready", "namespace", dep.GetNamespace(), "name", dep.GetName(), "readyPods", rs.Status.ReadyReplicas, "totalPods", expectedReady) return false } return true @@ -306,7 +308,7 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { // Verify the generation observed by the daemonSet controller matches the spec generation if ds.Status.ObservedGeneration != ds.ObjectMeta.Generation { - c.log("DaemonSet is not ready: %s/%s. observedGeneration (%d) does not match spec generation (%d).", ds.Namespace, ds.Name, ds.Status.ObservedGeneration, ds.ObjectMeta.Generation) + c.log.Debug("DaemonSet is not ready, observedGeneration does not match spec generation", "namespace", ds.GetNamespace(), "name", ds.GetName(), "observedGeneration", ds.Status.ObservedGeneration, "expectedGeneration", ds.ObjectMeta.Generation) return false } @@ -317,7 +319,7 @@ func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { // Make sure all the updated pods have been scheduled if ds.Status.UpdatedNumberScheduled != ds.Status.DesiredNumberScheduled { - c.log("DaemonSet is not ready: %s/%s. %d out of %d expected pods have been scheduled", ds.Namespace, ds.Name, ds.Status.UpdatedNumberScheduled, ds.Status.DesiredNumberScheduled) + c.log.Debug("DaemonSet is not ready, not all Pods scheduled", "namespace", ds.GetNamespace(), "name", ds.GetName(), "scheduledPods", ds.Status.UpdatedNumberScheduled, "totalPods", ds.Status.DesiredNumberScheduled) return false } maxUnavailable, err := intstr.GetScaledValueFromIntOrPercent(ds.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable, int(ds.Status.DesiredNumberScheduled), true) @@ -330,7 +332,7 @@ func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { expectedReady := int(ds.Status.DesiredNumberScheduled) - maxUnavailable if !(int(ds.Status.NumberReady) >= expectedReady) { - c.log("DaemonSet is not ready: %s/%s. %d out of %d expected pods are ready", ds.Namespace, ds.Name, ds.Status.NumberReady, expectedReady) + c.log.Debug("DaemonSet is not ready. All Pods are not ready", "namespace", ds.GetNamespace(), "name", ds.GetName(), "readyPods", ds.Status.NumberReady, "totalPods", expectedReady) return false } return true @@ -382,13 +384,13 @@ func (c *ReadyChecker) crdReady(crd apiextv1.CustomResourceDefinition) bool { func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { // Verify the generation observed by the statefulSet controller matches the spec generation if sts.Status.ObservedGeneration != sts.ObjectMeta.Generation { - c.log("StatefulSet is not ready: %s/%s. observedGeneration (%d) does not match spec generation (%d).", sts.Namespace, sts.Name, sts.Status.ObservedGeneration, sts.ObjectMeta.Generation) + c.log.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "observedGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.ObjectMeta.Generation) return false } // If the update strategy is not a rolling update, there will be nothing to wait for if sts.Spec.UpdateStrategy.Type != appsv1.RollingUpdateStatefulSetStrategyType { - c.log("StatefulSet skipped ready check: %s/%s. updateStrategy is %v", sts.Namespace, sts.Name, sts.Spec.UpdateStrategy.Type) + c.log.Debug("StatefulSet skipped ready check", "namespace", sts.GetNamespace(), "name", sts.GetName(), "updateStrategy", sts.Spec.UpdateStrategy.Type) return true } @@ -414,30 +416,30 @@ func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { // Make sure all the updated pods have been scheduled if int(sts.Status.UpdatedReplicas) < expectedReplicas { - c.log("StatefulSet is not ready: %s/%s. %d out of %d expected pods have been scheduled", sts.Namespace, sts.Name, sts.Status.UpdatedReplicas, expectedReplicas) + c.log.Debug("StatefulSet is not ready, not all Pods have been scheduled", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.UpdatedReplicas, "totalPods", expectedReplicas) return false } if int(sts.Status.ReadyReplicas) != replicas { - c.log("StatefulSet is not ready: %s/%s. %d out of %d expected pods are ready", sts.Namespace, sts.Name, sts.Status.ReadyReplicas, replicas) + c.log.Debug("StatefulSet is not ready, not all Pods are ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) return false } // This check only makes sense when all partitions are being upgraded otherwise during a // partitioned rolling upgrade, this condition will never evaluate to true, leading to // error. if partition == 0 && sts.Status.CurrentRevision != sts.Status.UpdateRevision { - c.log("StatefulSet is not ready: %s/%s. currentRevision %s does not yet match updateRevision %s", sts.Namespace, sts.Name, sts.Status.CurrentRevision, sts.Status.UpdateRevision) + c.log.Debug("StatefulSet is not ready, currentRevision does not match updateRevision", "namespace", sts.GetNamespace(), "name", sts.GetName(), "currentRevision", sts.Status.CurrentRevision, "updateRevision", sts.Status.UpdateRevision) return false } - c.log("StatefulSet is ready: %s/%s. %d out of %d expected pods are ready", sts.Namespace, sts.Name, sts.Status.ReadyReplicas, replicas) + c.log.Debug("StatefulSet is ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) return true } func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationController) bool { // Verify the generation observed by the replicationController controller matches the spec generation if rc.Status.ObservedGeneration != rc.ObjectMeta.Generation { - c.log("ReplicationController is not ready: %s/%s. observedGeneration (%d) does not match spec generation (%d).", rc.Namespace, rc.Name, rc.Status.ObservedGeneration, rc.ObjectMeta.Generation) + c.log.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "observedGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.ObjectMeta.Generation) return false } return true @@ -446,7 +448,7 @@ func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationControll func (c *ReadyChecker) replicaSetReady(rs *appsv1.ReplicaSet) bool { // Verify the generation observed by the replicaSet controller matches the spec generation if rs.Status.ObservedGeneration != rs.ObjectMeta.Generation { - c.log("ReplicaSet is not ready: %s/%s. observedGeneration (%d) does not match spec generation (%d).", rs.Namespace, rs.Name, rs.Status.ObservedGeneration, rs.ObjectMeta.Generation) + c.log.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "observedGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.ObjectMeta.Generation) return false } return true diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index 879fa4c76..bd382a9c2 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -37,7 +37,7 @@ const defaultNamespace = metav1.NamespaceDefault func Test_ReadyChecker_IsReady_Pod(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -113,7 +113,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { func Test_ReadyChecker_IsReady_Job(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -188,7 +188,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -270,7 +270,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -345,7 +345,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { func Test_ReadyChecker_IsReady_Service(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -420,7 +420,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -495,7 +495,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -570,7 +570,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } @@ -661,7 +661,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { type fields struct { client kubernetes.Interface - log func(string, ...interface{}) + log Logger checkJobs bool pausedAsReady bool } From dfaf2492213e19783ea36b72ae153ec9fd966513 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 16:15:18 +0100 Subject: [PATCH 226/271] Remove unreachable error Signed-off-by: Benoit Tigeot --- pkg/kube/client.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 44baa4ba0..5b2fcc56f 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -717,9 +717,6 @@ func copyRequestStreamToWriter(request *rest.Request, podName, containerName str if err != nil { return errors.Errorf("Failed to copy IO from logs for pod: %s, container: %s", podName, containerName) } - if err != nil { - return errors.Errorf("Failed to close reader for pod: %s, container: %s", podName, containerName) - } return nil } From 8d30464f2c80158b88db4a6dc4273e07fc3b09ea Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 16:17:01 +0100 Subject: [PATCH 227/271] Do no mask warning alerts Signed-off-by: Benoit Tigeot --- pkg/kube/client.go | 2 +- pkg/kube/logger.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 5b2fcc56f..dcba9b0a4 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -248,7 +248,7 @@ func (c *Client) Get(resources ResourceList, related bool) (map[string][]runtime objs, err = c.getSelectRelationPod(info, objs, isTable, &podSelectors) if err != nil { - c.Log.Debug("failed to get related pods", "error", err) + c.Log.Warn("get the relation pod is failed", "error", err) } } } diff --git a/pkg/kube/logger.go b/pkg/kube/logger.go index da032b752..357a6827f 100644 --- a/pkg/kube/logger.go +++ b/pkg/kube/logger.go @@ -19,6 +19,7 @@ package kube // Logger defines a minimal logging interface compatible with slog.Logger type Logger interface { Debug(msg string, args ...any) + Warn(msg string, args ...any) } // NopLogger is a logger that does nothing @@ -26,5 +27,6 @@ type NopLogger struct{} // Debug implements the Logger interface func (n NopLogger) Debug(msg string, args ...any) {} +func (n NopLogger) Warn(msg string, args ...any) {} var nopLogger = NopLogger{} From d6d7cff4179b2ca111333220ea383a279b6ea489 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 16:30:23 +0100 Subject: [PATCH 228/271] Try to make log more common and more easily grepable Signed-off-by: Benoit Tigeot --- pkg/kube/client.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index dcba9b0a4..a7279e40b 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -196,7 +196,7 @@ func (c *Client) IsReachable() error { // Create creates Kubernetes resources specified in the resource list. func (c *Client) Create(resources ResourceList) (*Result, error) { - c.Log.Debug("creating resource(s)", "resources", resources) + c.Log.Debug("creating resource(s)", "resources", len(resources)) if err := perform(resources, createResource); err != nil { return nil, err } @@ -266,7 +266,7 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objs map[string][]run if info == nil { return objs, nil } - c.Log.Debug("get relation pod of object", "namespace", info.Namespace, "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name) + c.Log.Debug("get relation pod of object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) selector, ok, _ := getSelectorFromObject(info.Object) if !ok { return objs, nil @@ -408,7 +408,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err updateErrors := []string{} res := &Result{} - c.Log.Debug("checking resources for changes", "original", original, "target", target) + c.Log.Debug("checking resources for changes", "resources", len(target)) err := target.Visit(func(info *resource.Info, err error) error { if err != nil { return err @@ -429,7 +429,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } kind := info.Mapping.GroupVersionKind.Kind - c.Log.Debug("created a new resource", "kind", kind, "name", info.Name, "namespace", info.Namespace) + c.Log.Debug("created a new resource", "namespace", info.Namespace, "name", info.Name, "kind", kind) return nil } @@ -440,7 +440,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } if err := updateResource(c, info, originalInfo.Object, force); err != nil { - c.Log.Debug("error updating the resource", "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name, "error", err) + c.Log.Debug("error updating the resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) updateErrors = append(updateErrors, err.Error()) } // Because we check for errors later, append the info regardless @@ -457,22 +457,22 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } for _, info := range original.Difference(target) { - c.Log.Debug("deleting resource", "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name, "namespace", info.Namespace) + c.Log.Debug("deleting resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) if err := info.Get(); err != nil { - c.Log.Debug("unable to get object", "name", info.Name, "error", err) + c.Log.Debug("unable to get object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) continue } annotations, err := metadataAccessor.Annotations(info.Object) if err != nil { - c.Log.Debug("unable to get annotations", "name", info.Name, "error", err) + c.Log.Debug("unable to get annotations", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) } if annotations != nil && annotations[ResourcePolicyAnno] == KeepPolicy { - c.Log.Debug("skipping delete due to annotation", "name", info.Name, "annotation", ResourcePolicyAnno, "value", KeepPolicy) + c.Log.Debug("skipping delete due to annotation", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "annotation", ResourcePolicyAnno, "value", KeepPolicy) continue } if err := deleteResource(info, metav1.DeletePropagationBackground); err != nil { - c.Log.Debug("failed to delete resource", "name", info.Name, "error", err) + c.Log.Debug("failed to delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) continue } res.Deleted = append(res.Deleted, info) @@ -501,11 +501,11 @@ func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropa res := &Result{} mtx := sync.Mutex{} err := perform(resources, func(info *resource.Info) error { - c.Log.Debug("starting delete resource", "kind", info.Mapping.GroupVersionKind.Kind, "name", info.Name, "namespace", info.Namespace) + c.Log.Debug("starting delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) err := deleteResource(info, propagation) if err == nil || apierrors.IsNotFound(err) { if err != nil { - c.Log.Debug("ignoring delete failure", "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) + c.Log.Debug("ignoring delete failure", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) } mtx.Lock() defer mtx.Unlock() From b642bca8f61dfbe19e98ad75b73b2eaac2511405 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 17:16:21 +0100 Subject: [PATCH 229/271] Provide an adapter to easily pass a slog.Default() ``` helmClient.Log = NewSlogAdapter(slog.Default()) ``` Signed-off-by: Benoit Tigeot --- pkg/kube/logger.go | 20 ++++++++++++++++++-- pkg/kube/ready.go | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pkg/kube/logger.go b/pkg/kube/logger.go index 357a6827f..00724c7c3 100644 --- a/pkg/kube/logger.go +++ b/pkg/kube/logger.go @@ -16,17 +16,33 @@ limitations under the License. package kube +import "log/slog" + // Logger defines a minimal logging interface compatible with slog.Logger type Logger interface { Debug(msg string, args ...any) Warn(msg string, args ...any) } -// NopLogger is a logger that does nothing +type SlogAdapter struct { + logger *slog.Logger +} + type NopLogger struct{} -// Debug implements the Logger interface func (n NopLogger) Debug(msg string, args ...any) {} func (n NopLogger) Warn(msg string, args ...any) {} var nopLogger = NopLogger{} + +func (a SlogAdapter) Debug(msg string, args ...any) { + a.logger.Debug(msg, args...) +} + +func (a SlogAdapter) Warn(msg string, args ...any) { + a.logger.Warn(msg, args...) +} + +func NewSlogAdapter(logger *slog.Logger) Logger { + return SlogAdapter{logger: logger} +} diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index 2814aa72e..871bd4eee 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -19,8 +19,6 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" "fmt" - "io" - "log/slog" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" @@ -65,7 +63,7 @@ func NewReadyChecker(cl kubernetes.Interface, logger Logger, opts ...ReadyChecke log: logger, } if c.log == nil { - c.log = slog.New(slog.NewTextHandler(io.Discard, nil)) + c.log = nopLogger } for _, opt := range opts { opt(&c) From 227d2707888188ec823b1e0421f4ce0a88c3fe63 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 17:19:59 +0100 Subject: [PATCH 230/271] Extra comment + Default logger fallback Signed-off-by: Benoit Tigeot --- pkg/kube/logger.go | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/pkg/kube/logger.go b/pkg/kube/logger.go index 00724c7c3..f0ddfe49a 100644 --- a/pkg/kube/logger.go +++ b/pkg/kube/logger.go @@ -14,35 +14,53 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package kube provides Kubernetes client utilities for Helm. package kube import "log/slog" -// Logger defines a minimal logging interface compatible with slog.Logger +// Logger defines a minimal logging interface compatible with structured logging. +// It provides methods for different log levels with structured key-value pairs. type Logger interface { + // Debug logs a message at debug level with structured key-value pairs. Debug(msg string, args ...any) - Warn(msg string, args ...any) -} -type SlogAdapter struct { - logger *slog.Logger + // Warn logs a message at warning level with structured key-value pairs. + Warn(msg string, args ...any) } +// NopLogger is a logger implementation that discards all log messages. type NopLogger struct{} -func (n NopLogger) Debug(msg string, args ...any) {} -func (n NopLogger) Warn(msg string, args ...any) {} +// Debug implements Logger.Debug by doing nothing. +func (NopLogger) Debug(msg string, args ...any) {} -var nopLogger = NopLogger{} +// Warn implements Logger.Warn by doing nothing. +func (NopLogger) Warn(msg string, args ...any) {} + +// DefaultLogger provides a no-op logger that discards all messages. +// It can be used as a default when no logger is provided. +var DefaultLogger Logger = NopLogger{} + +// SlogAdapter adapts a standard library slog.Logger to the Logger interface. +type SlogAdapter struct { + logger *slog.Logger +} +// Debug implements Logger.Debug by forwarding to the underlying slog.Logger. func (a SlogAdapter) Debug(msg string, args ...any) { a.logger.Debug(msg, args...) } +// Warn implements Logger.Warn by forwarding to the underlying slog.Logger. func (a SlogAdapter) Warn(msg string, args ...any) { a.logger.Warn(msg, args...) } +// NewSlogAdapter creates a Logger that forwards log messages to a slog.Logger. func NewSlogAdapter(logger *slog.Logger) Logger { + if logger == nil { + return DefaultLogger + } return SlogAdapter{logger: logger} } From eb2dfe7dbf8f23adcbccfc10f7b93d1ef3fcd7d6 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 17:31:05 +0100 Subject: [PATCH 231/271] Some interesting rephrasing by Terry Howe See: https://github.com/helm/helm/pull/30698#discussion_r2012394228 Signed-off-by: Benoit Tigeot --- pkg/kube/ready.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index 871bd4eee..ab467bc01 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -291,13 +291,13 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy } // Verify the generation observed by the deployment controller matches the spec generation if dep.Status.ObservedGeneration != dep.ObjectMeta.Generation { - c.log.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "observedGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.ObjectMeta.Generation) + c.log.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "actualGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.ObjectMeta.Generation) return false } expectedReady := *dep.Spec.Replicas - deploymentutil.MaxUnavailable(*dep) if !(rs.Status.ReadyReplicas >= expectedReady) { - c.log.Debug("Deployment is not ready, not all Pods are ready", "namespace", dep.GetNamespace(), "name", dep.GetName(), "readyPods", rs.Status.ReadyReplicas, "totalPods", expectedReady) + c.log.Debug("Deployment does not have enough pods ready", "namespace", dep.GetNamespace(), "name", dep.GetName(), "readyPods", rs.Status.ReadyReplicas, "totalPods", expectedReady) return false } return true @@ -317,7 +317,7 @@ func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { // Make sure all the updated pods have been scheduled if ds.Status.UpdatedNumberScheduled != ds.Status.DesiredNumberScheduled { - c.log.Debug("DaemonSet is not ready, not all Pods scheduled", "namespace", ds.GetNamespace(), "name", ds.GetName(), "scheduledPods", ds.Status.UpdatedNumberScheduled, "totalPods", ds.Status.DesiredNumberScheduled) + c.log.Debug("DaemonSet does not have enough Pods scheduled", "namespace", ds.GetNamespace(), "name", ds.GetName(), "scheduledPods", ds.Status.UpdatedNumberScheduled, "totalPods", ds.Status.DesiredNumberScheduled) return false } maxUnavailable, err := intstr.GetScaledValueFromIntOrPercent(ds.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable, int(ds.Status.DesiredNumberScheduled), true) @@ -330,7 +330,7 @@ func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { expectedReady := int(ds.Status.DesiredNumberScheduled) - maxUnavailable if !(int(ds.Status.NumberReady) >= expectedReady) { - c.log.Debug("DaemonSet is not ready. All Pods are not ready", "namespace", ds.GetNamespace(), "name", ds.GetName(), "readyPods", ds.Status.NumberReady, "totalPods", expectedReady) + c.log.Debug("DaemonSet does not have enough Pods ready", "namespace", ds.GetNamespace(), "name", ds.GetName(), "readyPods", ds.Status.NumberReady, "totalPods", expectedReady) return false } return true @@ -382,7 +382,7 @@ func (c *ReadyChecker) crdReady(crd apiextv1.CustomResourceDefinition) bool { func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { // Verify the generation observed by the statefulSet controller matches the spec generation if sts.Status.ObservedGeneration != sts.ObjectMeta.Generation { - c.log.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "observedGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.ObjectMeta.Generation) + c.log.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "actualGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.ObjectMeta.Generation) return false } @@ -414,12 +414,12 @@ func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { // Make sure all the updated pods have been scheduled if int(sts.Status.UpdatedReplicas) < expectedReplicas { - c.log.Debug("StatefulSet is not ready, not all Pods have been scheduled", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.UpdatedReplicas, "totalPods", expectedReplicas) + c.log.Debug("StatefulSet does not have enough Pods scheduled", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.UpdatedReplicas, "totalPods", expectedReplicas) return false } if int(sts.Status.ReadyReplicas) != replicas { - c.log.Debug("StatefulSet is not ready, not all Pods are ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) + c.log.Debug("StatefulSet does not have enough Pods ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) return false } // This check only makes sense when all partitions are being upgraded otherwise during a @@ -437,7 +437,7 @@ func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationController) bool { // Verify the generation observed by the replicationController controller matches the spec generation if rc.Status.ObservedGeneration != rc.ObjectMeta.Generation { - c.log.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "observedGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.ObjectMeta.Generation) + c.log.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "actualGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.ObjectMeta.Generation) return false } return true @@ -446,7 +446,7 @@ func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationControll func (c *ReadyChecker) replicaSetReady(rs *appsv1.ReplicaSet) bool { // Verify the generation observed by the replicaSet controller matches the spec generation if rs.Status.ObservedGeneration != rs.ObjectMeta.Generation { - c.log.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "observedGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.ObjectMeta.Generation) + c.log.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "actualGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.ObjectMeta.Generation) return false } return true From 394ba2d55e923f0aa954863490f6d4e02ff2b209 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 17:33:29 +0100 Subject: [PATCH 232/271] Properly use DefaultLogger Signed-off-by: Benoit Tigeot --- pkg/kube/client_test.go | 2 +- pkg/kube/ready.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 8ae1df238..994b2be5c 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -107,7 +107,7 @@ func newTestClient(t *testing.T) *Client { return &Client{ Factory: testFactory.WithNamespace("default"), - Log: nopLogger, + Log: DefaultLogger, } } diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index ab467bc01..510576997 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -63,7 +63,7 @@ func NewReadyChecker(cl kubernetes.Interface, logger Logger, opts ...ReadyChecke log: logger, } if c.log == nil { - c.log = nopLogger + c.log = DefaultLogger } for _, opt := range opts { opt(&c) From 3a22df9731a5c91c399d56f124702a501dd56d9c Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 17:46:44 +0100 Subject: [PATCH 233/271] Deal with linting errors Signed-off-by: Benoit Tigeot --- pkg/kube/logger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kube/logger.go b/pkg/kube/logger.go index f0ddfe49a..616cdba7f 100644 --- a/pkg/kube/logger.go +++ b/pkg/kube/logger.go @@ -33,10 +33,10 @@ type Logger interface { type NopLogger struct{} // Debug implements Logger.Debug by doing nothing. -func (NopLogger) Debug(msg string, args ...any) {} +func (NopLogger) Debug(_ string, args ...any) {} // Warn implements Logger.Warn by doing nothing. -func (NopLogger) Warn(msg string, args ...any) {} +func (NopLogger) Warn(_ string, args ...any) {} // DefaultLogger provides a no-op logger that discards all messages. // It can be used as a default when no logger is provided. From ede73860c1478b4b100137bb1daf6b321e153284 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 25 Mar 2025 19:55:50 +0100 Subject: [PATCH 234/271] Fix call to kube log Signed-off-by: Benoit Tigeot --- pkg/action/action.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 4f100f833..3caf91b71 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -20,6 +20,7 @@ import ( "bytes" "fmt" "io" + "log/slog" "os" "path" "path/filepath" @@ -376,7 +377,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { // Init initializes the action configuration func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { kc := kube.New(getter) - kc.Log = log // TODO: Switch to slog compatible logger + kc.Log = kube.NewSlogAdapter(slog.Default()) lazyClient := &lazyClient{ namespace: namespace, From fae2345edf20f5bd9b01aba0e4bcd2e6d23bda3c Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Wed, 26 Mar 2025 22:45:58 +0100 Subject: [PATCH 235/271] Demonstrate the impact of having Logger defined in kube package Signed-off-by: Benoit Tigeot --- pkg/action/action.go | 13 ++++++------- pkg/cmd/list.go | 6 +++++- pkg/storage/driver/cfgmaps.go | 4 ++-- pkg/storage/driver/secrets.go | 8 ++++---- pkg/storage/driver/sql.go | 9 +++++---- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 3caf91b71..edff0ea2c 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -20,7 +20,6 @@ import ( "bytes" "fmt" "io" - "log/slog" "os" "path" "path/filepath" @@ -96,7 +95,7 @@ type Configuration struct { // Capabilities describes the capabilities of the Kubernetes cluster. Capabilities *chartutil.Capabilities - Log func(string, ...interface{}) + Log kube.Logger // HookOutputFunc called with container name and returns and expects writer that will receive the log output. HookOutputFunc func(namespace, pod, container string) io.Writer @@ -270,8 +269,8 @@ func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { apiVersions, err := GetVersionSet(dc) if err != nil { if discovery.IsGroupDiscoveryFailedError(err) { - cfg.Log("WARNING: The Kubernetes server has an orphaned API service. Server reports: %s", err) - cfg.Log("WARNING: To fix this, kubectl delete apiservice ") + cfg.Log.Warn("The Kubernetes server has an orphaned API service. Server reports: %s", err) + cfg.Log.Warn("To fix this, kubectl delete apiservice ") } else { return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") } @@ -370,14 +369,14 @@ func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.Version // recordRelease with an update operation in case reuse has been set. func (cfg *Configuration) recordRelease(r *release.Release) { if err := cfg.Releases.Update(r); err != nil { - cfg.Log("warning: Failed to update release %s: %s", r.Name, err) + cfg.Log.Warn("Failed to update release %s: %s", r.Name, err) } } // Init initializes the action configuration -func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log kube.Logger) error { kc := kube.New(getter) - kc.Log = kube.NewSlogAdapter(slog.Default()) + kc.Log = log lazyClient := &lazyClient{ namespace: namespace, diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 85acbc97f..1f1095f2b 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -19,6 +19,7 @@ package cmd import ( "fmt" "io" + "log/slog" "os" "strconv" @@ -28,6 +29,7 @@ import ( "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cmd/require" + "helm.sh/helm/v4/pkg/kube" release "helm.sh/helm/v4/pkg/release/v1" ) @@ -61,6 +63,8 @@ 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 + slogger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) + adapter := kube.NewSlogAdapter(slogger) cmd := &cobra.Command{ Use: "list", @@ -71,7 +75,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(cmd *cobra.Command, _ []string) error { if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), Debug); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), adapter); err != nil { return err } } diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 2b84b7f82..8a70f5064 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -31,6 +31,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" + "helm.sh/helm/v4/pkg/kube" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -43,7 +44,7 @@ const ConfigMapsDriverName = "ConfigMap" // ConfigMapsInterface. type ConfigMaps struct { impl corev1.ConfigMapInterface - Log func(string, ...interface{}) + Log kube.Logger } // NewConfigMaps initializes a new ConfigMaps wrapping an implementation of @@ -51,7 +52,6 @@ type ConfigMaps struct { func NewConfigMaps(impl corev1.ConfigMapInterface) *ConfigMaps { return &ConfigMaps{ impl: impl, - Log: func(_ string, _ ...interface{}) {}, } } diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index 2ab128c6b..816965b0c 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -31,6 +31,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" + "helm.sh/helm/v4/pkg/kube" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -43,7 +44,7 @@ const SecretsDriverName = "Secret" // SecretsInterface. type Secrets struct { impl corev1.SecretInterface - Log func(string, ...interface{}) + Log kube.Logger } // NewSecrets initializes a new Secrets wrapping an implementation of @@ -51,7 +52,6 @@ type Secrets struct { func NewSecrets(impl corev1.SecretInterface) *Secrets { return &Secrets{ impl: impl, - Log: func(_ string, _ ...interface{}) {}, } } @@ -96,7 +96,7 @@ func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log("list: failed to decode release: %v: %s", item, err) + secrets.Log.Debug("list: failed to decode release: %v: %s", item, err) continue } @@ -135,7 +135,7 @@ func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error) for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log("query: failed to decode release: %s", err) + secrets.Log.Debug("query: failed to decode release: %s", err) continue } rls.Labels = item.ObjectMeta.Labels diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index 12bdd3ff4..b9f9f534b 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -30,6 +30,7 @@ import ( // Import pq for postgres dialect _ "github.com/lib/pq" + "helm.sh/helm/v4/pkg/kube" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -87,7 +88,7 @@ type SQL struct { namespace string statementBuilder sq.StatementBuilderType - Log func(string, ...interface{}) + Log kube.Logger } // Name returns the name of the driver. @@ -108,13 +109,13 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool { records, err := migrate.GetMigrationRecords(s.db.DB, postgreSQLDialect) migrate.SetDisableCreateTable(false) if err != nil { - s.Log("checkAlreadyApplied: failed to get migration records: %v", err) + s.Log.Debug("checkAlreadyApplied: failed to get migration records: %v", err) return false } for _, record := range records { if _, ok := migrationsIDs[record.Id]; ok { - s.Log("checkAlreadyApplied: found previous migration (Id: %v) applied at %v", record.Id, record.AppliedAt) + s.Log.Debug("checkAlreadyApplied: found previous migration (Id: %v) applied at %v", record.Id, record.AppliedAt) delete(migrationsIDs, record.Id) } } @@ -276,7 +277,7 @@ type SQLReleaseCustomLabelWrapper struct { } // NewSQL initializes a new sql driver. -func NewSQL(connectionString string, logger func(string, ...interface{}), namespace string) (*SQL, error) { +func NewSQL(connectionString string, logger kube.Logger, namespace string) (*SQL, error) { db, err := sqlx.Connect(postgreSQLDialect, connectionString) if err != nil { return nil, err From 83cdffe4aeeded92b2dc7e8b4ef04068b931fbf6 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 31 Mar 2025 09:51:37 +0200 Subject: [PATCH 236/271] Migrate to a dedicated internal package for slog adapter + migrate more Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 4 +- {pkg/kube => internal/log}/logger.go | 34 +++---------- internal/log/slog.go | 71 ++++++++++++++++++++++++++++ pkg/action/action.go | 5 +- pkg/action/action_test.go | 8 +--- pkg/action/history.go | 2 +- pkg/action/install.go | 22 ++++----- pkg/cmd/helpers_test.go | 3 +- pkg/cmd/install.go | 2 +- pkg/cmd/list.go | 4 +- pkg/cmd/registry_login.go | 2 +- pkg/cmd/root.go | 14 ++---- pkg/cmd/search_repo.go | 3 +- pkg/cmd/upgrade.go | 2 +- pkg/kube/client.go | 2 +- pkg/kube/client_test.go | 3 +- pkg/kube/ready.go | 7 +-- pkg/kube/ready_test.go | 5 +- pkg/kube/wait.go | 1 + pkg/storage/driver/cfgmaps.go | 4 +- pkg/storage/driver/mock_test.go | 1 - pkg/storage/driver/secrets.go | 4 +- pkg/storage/driver/sql.go | 6 +-- 23 files changed, 127 insertions(+), 82 deletions(-) rename {pkg/kube => internal/log}/logger.go (65%) create mode 100644 internal/log/slog.go diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index da6a5c54e..a617bce2e 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -23,6 +23,7 @@ import ( // Import to initialize client auth plugins. _ "k8s.io/client-go/plugin/pkg/client/auth" + logadapter "helm.sh/helm/v4/internal/log" helmcmd "helm.sh/helm/v4/pkg/cmd" "helm.sh/helm/v4/pkg/kube" ) @@ -37,10 +38,11 @@ func main() { // 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" + logger := logadapter.NewReadableTextLogger(os.Stderr, false) cmd, err := helmcmd.NewRootCmd(os.Stdout, os.Args[1:]) if err != nil { - helmcmd.Warning("%+v", err) + logger.Warn("%+v", err) os.Exit(1) } diff --git a/pkg/kube/logger.go b/internal/log/logger.go similarity index 65% rename from pkg/kube/logger.go rename to internal/log/logger.go index 616cdba7f..ff971bdb1 100644 --- a/pkg/kube/logger.go +++ b/internal/log/logger.go @@ -14,10 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package kube provides Kubernetes client utilities for Helm. -package kube - -import "log/slog" +package log // Logger defines a minimal logging interface compatible with structured logging. // It provides methods for different log levels with structured key-value pairs. @@ -27,6 +24,9 @@ type Logger interface { // Warn logs a message at warning level with structured key-value pairs. Warn(msg string, args ...any) + + // Error logs a message at error level with structured key-value pairs. + Error(msg string, args ...any) } // NopLogger is a logger implementation that discards all log messages. @@ -38,29 +38,9 @@ func (NopLogger) Debug(_ string, args ...any) {} // Warn implements Logger.Warn by doing nothing. func (NopLogger) Warn(_ string, args ...any) {} +// Error implements Logger.Error by doing nothing. +func (NopLogger) Error(_ string, args ...any) {} + // DefaultLogger provides a no-op logger that discards all messages. // It can be used as a default when no logger is provided. var DefaultLogger Logger = NopLogger{} - -// SlogAdapter adapts a standard library slog.Logger to the Logger interface. -type SlogAdapter struct { - logger *slog.Logger -} - -// Debug implements Logger.Debug by forwarding to the underlying slog.Logger. -func (a SlogAdapter) Debug(msg string, args ...any) { - a.logger.Debug(msg, args...) -} - -// Warn implements Logger.Warn by forwarding to the underlying slog.Logger. -func (a SlogAdapter) Warn(msg string, args ...any) { - a.logger.Warn(msg, args...) -} - -// NewSlogAdapter creates a Logger that forwards log messages to a slog.Logger. -func NewSlogAdapter(logger *slog.Logger) Logger { - if logger == nil { - return DefaultLogger - } - return SlogAdapter{logger: logger} -} diff --git a/internal/log/slog.go b/internal/log/slog.go new file mode 100644 index 000000000..7765545f9 --- /dev/null +++ b/internal/log/slog.go @@ -0,0 +1,71 @@ +/* +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 log + +import ( + "io" + "log/slog" +) + +// SlogAdapter adapts a standard library slog.Logger to the Logger interface. +type SlogAdapter struct { + logger *slog.Logger +} + +// Debug implements Logger.Debug by forwarding to the underlying slog.Logger. +func (a SlogAdapter) Debug(msg string, args ...any) { + a.logger.Debug(msg, args...) +} + +// Warn implements Logger.Warn by forwarding to the underlying slog.Logger. +func (a SlogAdapter) Warn(msg string, args ...any) { + a.logger.Warn(msg, args...) +} + +// Error implements Logger.Error by forwarding to the underlying slog.Logger. +func (a SlogAdapter) Error(msg string, args ...any) { + // TODO: Handle error with `slog.Any`: slog.Info("something went wrong", slog.Any("err", err)) + a.logger.Error(msg, args...) +} + +// NewSlogAdapter creates a Logger that forwards log messages to a slog.Logger. +func NewSlogAdapter(logger *slog.Logger) Logger { + if logger == nil { + return DefaultLogger + } + return SlogAdapter{logger: logger} +} + +// NewReadableTextLogger creates a Logger that outputs in a readable text format without timestamps +func NewReadableTextLogger(output io.Writer, debugEnabled bool) Logger { + level := slog.LevelInfo + if debugEnabled { + level = slog.LevelDebug + } + + handler := slog.NewTextHandler(output, &slog.HandlerOptions{ + Level: level, + ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + if a.Key == slog.TimeKey { + return slog.Attr{} + } + return a + }, + }) + + return NewSlogAdapter(slog.New(handler)) +} diff --git a/pkg/action/action.go b/pkg/action/action.go index edff0ea2c..778dc9ec5 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -33,6 +33,7 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" + logadapter "helm.sh/helm/v4/internal/log" chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/engine" @@ -95,7 +96,7 @@ type Configuration struct { // Capabilities describes the capabilities of the Kubernetes cluster. Capabilities *chartutil.Capabilities - Log kube.Logger + Log logadapter.Logger // HookOutputFunc called with container name and returns and expects writer that will receive the log output. HookOutputFunc func(namespace, pod, container string) io.Writer @@ -374,7 +375,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { } // Init initializes the action configuration -func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log kube.Logger) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log logadapter.Logger) error { kc := kube.New(getter) kc.Log = log diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index ec6e261db..efaebb3f9 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" fakeclientset "k8s.io/client-go/kubernetes/fake" + logadapter "helm.sh/helm/v4/internal/log" chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" @@ -49,12 +50,7 @@ func actionConfigFixture(t *testing.T) *Configuration { KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}}, Capabilities: chartutil.DefaultCapabilities, RegistryClient: registryClient, - Log: func(format string, v ...interface{}) { - t.Helper() - if *verbose { - t.Logf(format, v...) - } - }, + Log: logadapter.DefaultLogger, } } diff --git a/pkg/action/history.go b/pkg/action/history.go index 04743f4cd..289118592 100644 --- a/pkg/action/history.go +++ b/pkg/action/history.go @@ -53,6 +53,6 @@ func (h *History) Run(name string) ([]*release.Release, error) { return nil, errors.Errorf("release name is invalid: %s", name) } - h.cfg.Log("getting history for release %s", name) + h.cfg.Log.Debug("getting history for release", "release", name) return h.cfg.Releases.History(name) } diff --git a/pkg/action/install.go b/pkg/action/install.go index 735b8ac17..8b749b777 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -172,7 +172,7 @@ func (i *Install) installCRDs(crds []chart.CRD) error { // If the error is CRD already exists, continue. if apierrors.IsAlreadyExists(err) { crdName := res[0].Name - i.cfg.Log("CRD %s is already present. Skipping.", crdName) + i.cfg.Log.Debug("CRD is already present. Skipping", "crd", crdName) continue } return errors.Wrapf(err, "failed to install CRD %s", obj.Name) @@ -200,7 +200,7 @@ func (i *Install) installCRDs(crds []chart.CRD) error { return err } - i.cfg.Log("Clearing discovery cache") + i.cfg.Log.Debug("clearing discovery cache") discoveryClient.Invalidate() _, _ = discoveryClient.ServerGroups() @@ -213,7 +213,7 @@ func (i *Install) installCRDs(crds []chart.CRD) error { return err } if resettable, ok := restMapper.(meta.ResettableRESTMapper); ok { - i.cfg.Log("Clearing REST mapper cache") + i.cfg.Log.Debug("clearing REST mapper cache") resettable.Reset() } } @@ -237,24 +237,24 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // Check reachability of cluster unless in client-only mode (e.g. `helm template` without `--validate`) if !i.ClientOnly { if err := i.cfg.KubeClient.IsReachable(); err != nil { - i.cfg.Log(fmt.Sprintf("ERROR: Cluster reachability check failed: %v", err)) + i.cfg.Log.Error(fmt.Sprintf("cluster reachability check failed: %v", err)) return nil, errors.Wrap(err, "cluster reachability check failed") } } // HideSecret must be used with dry run. Otherwise, return an error. if !i.isDryRun() && i.HideSecret { - i.cfg.Log("ERROR: Hiding Kubernetes secrets requires a dry-run mode") + i.cfg.Log.Error("hiding Kubernetes secrets requires a dry-run mode") return nil, errors.New("Hiding Kubernetes secrets requires a dry-run mode") } if err := i.availableName(); err != nil { - i.cfg.Log(fmt.Sprintf("ERROR: Release name check failed: %v", err)) + i.cfg.Log.Error("release name check failed", "error", err) return nil, errors.Wrap(err, "release name check failed") } if err := chartutil.ProcessDependencies(chrt, vals); err != nil { - i.cfg.Log(fmt.Sprintf("ERROR: Processing chart dependencies failed: %v", err)) + i.cfg.Log.Error("chart dependencies processing failed", "error", err) return nil, errors.Wrap(err, "chart dependencies processing failed") } @@ -268,7 +268,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { // On dry run, bail here if i.isDryRun() { - i.cfg.Log("WARNING: This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") + i.cfg.Log.Warn("This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") } else if err := i.installCRDs(crds); err != nil { return nil, err } @@ -288,7 +288,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma mem.SetNamespace(i.Namespace) i.cfg.Releases = storage.Init(mem) } else if !i.ClientOnly && len(i.APIVersions) > 0 { - i.cfg.Log("API Version list given outside of client only mode, this list will be ignored") + i.cfg.Log.Debug("API Version list given outside of client only mode, this list will be ignored") } // Make sure if Atomic is set, that wait is set as well. This makes it so @@ -505,7 +505,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource // One possible strategy would be to do a timed retry to see if we can get // this stored in the future. if err := i.recordRelease(rel); err != nil { - i.cfg.Log("failed to record the release: %s", err) + i.cfg.Log.Error("failed to record the release", "error", err) } return rel, nil @@ -514,7 +514,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource func (i *Install) failRelease(rel *release.Release, err error) (*release.Release, error) { rel.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", i.ReleaseName, err.Error())) if i.Atomic { - i.cfg.Log("Install failed and atomic is set, uninstalling release") + i.cfg.Log.Debug("install failed, uninstalling release", "release", i.ReleaseName) uninstall := NewUninstall(i.cfg) uninstall.DisableHooks = i.DisableHooks uninstall.KeepHistory = false diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index effbc1673..1f597d7ba 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -26,6 +26,7 @@ import ( shellwords "github.com/mattn/go-shellwords" "github.com/spf13/cobra" + logadapter "helm.sh/helm/v4/internal/log" "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/action" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" @@ -92,7 +93,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) Releases: store, KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard}, Capabilities: chartutil.DefaultCapabilities, - Log: func(_ string, _ ...interface{}) {}, + Log: logadapter.DefaultLogger, } root, err := newRootCmdWithConfig(actionConfig, buf, args) diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 051612bb8..32a386ba0 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -265,7 +265,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options } if chartRequested.Metadata.Deprecated { - Warning("This chart is deprecated") + logger.Warn("this chart is deprecated") } if req := chartRequested.Metadata.Dependencies; req != nil { diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 1f1095f2b..10b70d7d9 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -26,10 +26,10 @@ import ( "github.com/gosuri/uitable" "github.com/spf13/cobra" + logadapter "helm.sh/helm/v4/internal/log" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cmd/require" - "helm.sh/helm/v4/pkg/kube" release "helm.sh/helm/v4/pkg/release/v1" ) @@ -64,7 +64,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewList(cfg) var outfmt output.Format slogger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) - adapter := kube.NewSlogAdapter(slogger) + adapter := logadapter.NewSlogAdapter(slogger) cmd := &cobra.Command{ Use: "list", diff --git a/pkg/cmd/registry_login.go b/pkg/cmd/registry_login.go index 1dfb3c798..bc6c1d13d 100644 --- a/pkg/cmd/registry_login.go +++ b/pkg/cmd/registry_login.go @@ -122,7 +122,7 @@ func getUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStd } } } else { - Warning("Using --password via the CLI is insecure. Use --password-stdin.") + logger.Warn("using --password via the CLI is insecure. Use --password-stdin") } return username, password, nil diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index ea686be7c..407e89139 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -31,6 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" + logadapter "helm.sh/helm/v4/internal/log" "helm.sh/helm/v4/internal/tlsutil" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli" @@ -95,16 +96,7 @@ By default, the default directories depend on the Operating System. The defaults ` var settings = cli.New() - -func Debug(format string, v ...interface{}) { - if settings.Debug { - log.Output(2, fmt.Sprintf("[debug] "+format+"\n", v...)) - } -} - -func Warning(format string, v ...interface{}) { - fmt.Fprintf(os.Stderr, "WARNING: "+format+"\n", v...) -} +var logger = logadapter.NewReadableTextLogger(os.Stderr, settings.Debug) func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { actionConfig := new(action.Configuration) @@ -114,7 +106,7 @@ func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { } cobra.OnInitialize(func() { helmDriver := os.Getenv("HELM_DRIVER") - if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, Debug); err != nil { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, logger); err != nil { log.Fatal(err) } if helmDriver == "memory" { diff --git a/pkg/cmd/search_repo.go b/pkg/cmd/search_repo.go index bc73e52b2..29bc19f6b 100644 --- a/pkg/cmd/search_repo.go +++ b/pkg/cmd/search_repo.go @@ -189,8 +189,7 @@ func (o *searchRepoOptions) buildIndex() (*search.Index, error) { 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) + logger.Warn("repo is corrupt or missing", "repo", n, "error", err) continue } diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index afbbde435..e61c9bc3b 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -225,7 +225,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if ch.Metadata.Deprecated { - Warning("This chart is deprecated") + logger.Warn("this chart is deprecated") } // Create context and prepare the handle of SIGTERM diff --git a/pkg/kube/client.go b/pkg/kube/client.go index a7279e40b..c176b3fb8 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -73,7 +73,7 @@ type Client struct { // needs. The smaller surface area of the interface means there is a lower // chance of it changing. Factory Factory - Log Logger + Log logadapter.Logger // Namespace allows to bypass the kubeconfig file for the choice of the namespace Namespace string diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 994b2be5c..abe841ea6 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/assert" + logadapter "helm.sh/helm/v4/internal/log" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -107,7 +108,7 @@ func newTestClient(t *testing.T) *Client { return &Client{ Factory: testFactory.WithNamespace("default"), - Log: DefaultLogger, + Log: logadapter.DefaultLogger, } } diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index 510576997..c128e31b0 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -32,6 +32,7 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" + logadapter "helm.sh/helm/v4/internal/log" deploymentutil "helm.sh/helm/v4/internal/third_party/k8s.io/kubernetes/deployment/util" ) @@ -57,13 +58,13 @@ func CheckJobs(checkJobs bool) ReadyCheckerOption { // NewReadyChecker creates a new checker. Passed ReadyCheckerOptions can // be used to override defaults. -func NewReadyChecker(cl kubernetes.Interface, logger Logger, opts ...ReadyCheckerOption) ReadyChecker { +func NewReadyChecker(cl kubernetes.Interface, logger logadapter.Logger, opts ...ReadyCheckerOption) ReadyChecker { c := ReadyChecker{ client: cl, log: logger, } if c.log == nil { - c.log = DefaultLogger + c.log = logadapter.DefaultLogger } for _, opt := range opts { opt(&c) @@ -74,7 +75,7 @@ func NewReadyChecker(cl kubernetes.Interface, logger Logger, opts ...ReadyChecke // ReadyChecker is a type that can check core Kubernetes types for readiness. type ReadyChecker struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index bd382a9c2..f022bf596 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -19,6 +19,7 @@ import ( "context" "testing" + logadapter "helm.sh/helm/v4/internal/log" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -37,7 +38,7 @@ const defaultNamespace = metav1.NamespaceDefault func Test_ReadyChecker_IsReady_Pod(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -661,7 +662,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 79a2df8cc..69779904f 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -25,6 +25,7 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/pkg/errors" + logadapter "helm.sh/helm/v4/internal/log" appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 8a70f5064..48198a9bd 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - "helm.sh/helm/v4/pkg/kube" + logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -44,7 +44,7 @@ const ConfigMapsDriverName = "ConfigMap" // ConfigMapsInterface. type ConfigMaps struct { impl corev1.ConfigMapInterface - Log kube.Logger + Log logadapter.Logger } // NewConfigMaps initializes a new ConfigMaps wrapping an implementation of diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index 53919b45d..54fda0542 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -262,7 +262,6 @@ func newTestFixtureSQL(t *testing.T, _ ...*rspb.Release) (*SQL, sqlmock.Sqlmock) sqlxDB := sqlx.NewDb(sqlDB, "sqlmock") return &SQL{ db: sqlxDB, - Log: func(_ string, _ ...interface{}) {}, namespace: "default", statementBuilder: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), }, mock diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index 816965b0c..bd1edcae1 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - "helm.sh/helm/v4/pkg/kube" + logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -44,7 +44,7 @@ const SecretsDriverName = "Secret" // SecretsInterface. type Secrets struct { impl corev1.SecretInterface - Log kube.Logger + Log logadapter.Logger } // NewSecrets initializes a new Secrets wrapping an implementation of diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index b9f9f534b..304503b0a 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -30,7 +30,7 @@ import ( // Import pq for postgres dialect _ "github.com/lib/pq" - "helm.sh/helm/v4/pkg/kube" + logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -88,7 +88,7 @@ type SQL struct { namespace string statementBuilder sq.StatementBuilderType - Log kube.Logger + Log logadapter.Logger } // Name returns the name of the driver. @@ -277,7 +277,7 @@ type SQLReleaseCustomLabelWrapper struct { } // NewSQL initializes a new sql driver. -func NewSQL(connectionString string, logger kube.Logger, namespace string) (*SQL, error) { +func NewSQL(connectionString string, logger logadapter.Logger, namespace string) (*SQL, error) { db, err := sqlx.Connect(postgreSQLDialect, connectionString) if err != nil { return nil, err From b42767be40ca2f364e7b1f54c8510b6c69e62f7f Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 31 Mar 2025 11:17:58 +0200 Subject: [PATCH 237/271] Migrate more code to log adapter Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 2 +- pkg/action/rollback.go | 24 ++++++------ pkg/action/uninstall.go | 14 +++---- pkg/action/upgrade.go | 30 +++++++-------- pkg/cmd/install.go | 6 +-- pkg/cmd/plugin.go | 2 +- pkg/cmd/plugin_install.go | 2 +- pkg/cmd/plugin_list.go | 2 +- pkg/cmd/plugin_uninstall.go | 2 +- pkg/cmd/plugin_update.go | 4 +- pkg/cmd/pull.go | 2 +- pkg/cmd/search_hub.go | 2 +- pkg/cmd/search_repo.go | 6 +-- pkg/cmd/show.go | 4 +- pkg/cmd/upgrade.go | 2 +- pkg/kube/client.go | 2 + pkg/kube/client_test.go | 3 +- pkg/kube/ready_test.go | 17 +++++---- pkg/kube/wait.go | 3 +- pkg/storage/driver/cfgmaps.go | 20 +++++----- pkg/storage/driver/sql.go | 70 +++++++++++++++++------------------ 21 files changed, 112 insertions(+), 107 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index a617bce2e..158118c06 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -47,7 +47,7 @@ func main() { } if err := cmd.Execute(); err != nil { - helmcmd.Debug("%+v", err) + logger.Debug("error", err) switch e := err.(type) { case helmcmd.PluginError: os.Exit(e.Code) diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 870f1e635..4e61fe872 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -63,26 +63,26 @@ func (r *Rollback) Run(name string) error { r.cfg.Releases.MaxHistory = r.MaxHistory - r.cfg.Log("preparing rollback of %s", name) + r.cfg.Log.Debug("preparing rollback", "name", name) currentRelease, targetRelease, err := r.prepareRollback(name) if err != nil { return err } if !r.DryRun { - r.cfg.Log("creating rolled back release for %s", name) + r.cfg.Log.Debug("creating rolled back release", "name", name) if err := r.cfg.Releases.Create(targetRelease); err != nil { return err } } - r.cfg.Log("performing rollback of %s", name) + r.cfg.Log.Debug("performing rollback", "name", name) if _, err := r.performRollback(currentRelease, targetRelease); err != nil { return err } if !r.DryRun { - r.cfg.Log("updating status for rolled back release for %s", name) + r.cfg.Log.Debug("updating status for rolled back release", "name", name) if err := r.cfg.Releases.Update(targetRelease); err != nil { return err } @@ -129,7 +129,7 @@ func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Rele return nil, nil, errors.Errorf("release has no %d version", previousVersion) } - r.cfg.Log("rolling back %s (current: v%d, target: v%d)", name, currentRelease.Version, previousVersion) + r.cfg.Log.Debug("rolling back", "name", name, "currentVersion", currentRelease.Version, "targetVersion", previousVersion) previousRelease, err := r.cfg.Releases.Get(name, previousVersion) if err != nil { @@ -162,7 +162,7 @@ func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Rele func (r *Rollback) performRollback(currentRelease, targetRelease *release.Release) (*release.Release, error) { if r.DryRun { - r.cfg.Log("dry run for %s", targetRelease.Name) + r.cfg.Log.Debug("dry run", "name", targetRelease.Name) return targetRelease, nil } @@ -181,7 +181,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas return targetRelease, err } } else { - r.cfg.Log("rollback hooks disabled for %s", targetRelease.Name) + r.cfg.Log.Debug("rollback hooks disabled", "name", targetRelease.Name) } // It is safe to use "force" here because these are resources currently rendered by the chart. @@ -193,14 +193,14 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas if err != nil { msg := fmt.Sprintf("Rollback %q failed: %s", targetRelease.Name, err) - r.cfg.Log("warning: %s", msg) + r.cfg.Log.Warn(msg) currentRelease.Info.Status = release.StatusSuperseded targetRelease.Info.Status = release.StatusFailed targetRelease.Info.Description = msg r.cfg.recordRelease(currentRelease) r.cfg.recordRelease(targetRelease) if r.CleanupOnFail { - r.cfg.Log("Cleanup on fail set, cleaning up %d resources", len(results.Created)) + r.cfg.Log.Debug("cleanup on fail set, cleaning up resources", "count", len(results.Created)) _, errs := r.cfg.KubeClient.Delete(results.Created) if errs != nil { var errorList []string @@ -209,7 +209,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas } return targetRelease, errors.Wrapf(fmt.Errorf("unable to cleanup resources: %s", strings.Join(errorList, ", ")), "an error occurred while cleaning up resources. original rollback error: %s", err) } - r.cfg.Log("Resource cleanup complete") + r.cfg.Log.Debug("resource cleanup complete") } return targetRelease, err } @@ -220,7 +220,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas // levels, we should make these error level logs so users are notified // that they'll need to go do the cleanup on their own if err := recreate(r.cfg, results.Updated); err != nil { - r.cfg.Log(err.Error()) + r.cfg.Log.Error(err.Error()) } } waiter, err := r.cfg.KubeClient.GetWaiter(r.WaitStrategy) @@ -256,7 +256,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas } // Supersede all previous deployments, see issue #2941. for _, rel := range deployed { - r.cfg.Log("superseding previous deployment %d", rel.Version) + r.cfg.Log.Debug("superseding previous deployment", "version", rel.Version) rel.Info.Status = release.StatusSuperseded r.cfg.recordRelease(rel) } diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index eeff997d3..4e959172c 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -104,7 +104,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) return nil, errors.Errorf("the release named %q is already deleted", name) } - u.cfg.Log("uninstall: Deleting %s", name) + u.cfg.Log.Debug("uninstall: deleting release", "name", name) rel.Info.Status = release.StatusUninstalling rel.Info.Deleted = helmtime.Now() rel.Info.Description = "Deletion in progress (or silently failed)" @@ -115,18 +115,18 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) return res, err } } else { - u.cfg.Log("delete hooks disabled for %s", name) + u.cfg.Log.Debug("delete hooks disabled", "release", name) } // From here on out, the release is currently considered to be in StatusUninstalling // state. if err := u.cfg.Releases.Update(rel); err != nil { - u.cfg.Log("uninstall: Failed to store updated release: %s", err) + u.cfg.Log.Debug("uninstall: Failed to store updated release", "error", err) } deletedResources, kept, errs := u.deleteRelease(rel) if errs != nil { - u.cfg.Log("uninstall: Failed to delete release: %s", errs) + u.cfg.Log.Debug("uninstall: Failed to delete release", "errors", errs) return nil, errors.Errorf("failed to delete release: %s", name) } @@ -153,7 +153,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } if !u.KeepHistory { - u.cfg.Log("purge requested for %s", name) + u.cfg.Log.Debug("purge requested", "release", name) err := u.purgeReleases(rels...) if err != nil { errs = append(errs, errors.Wrap(err, "uninstall: Failed to purge the release")) @@ -168,7 +168,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } if err := u.cfg.Releases.Update(rel); err != nil { - u.cfg.Log("uninstall: Failed to store updated release: %s", err) + u.cfg.Log.Debug("uninstall: Failed to store updated release", "error", err) } if len(errs) > 0 { @@ -242,7 +242,7 @@ func parseCascadingFlag(cfg *Configuration, cascadingFlag string) v1.DeletionPro case "background": return v1.DeletePropagationBackground default: - cfg.Log("uninstall: given cascade value: %s, defaulting to delete propagation background", cascadingFlag) + cfg.Log.Debug("uninstall: given cascade value, defaulting to delete propagation background", "value", cascadingFlag) return v1.DeletePropagationBackground } } diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index e3b775a25..147c0fe5a 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -163,7 +163,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. return nil, errors.Errorf("release name is invalid: %s", name) } - u.cfg.Log("preparing upgrade for %s", name) + u.cfg.Log.Debug("preparing upgrade", "name", name) currentRelease, upgradedRelease, err := u.prepareUpgrade(name, chart, vals) if err != nil { return nil, err @@ -171,7 +171,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. u.cfg.Releases.MaxHistory = u.MaxHistory - u.cfg.Log("performing update for %s", name) + u.cfg.Log.Debug("performing update", "name", name) res, err := u.performUpgrade(ctx, currentRelease, upgradedRelease) if err != nil { return res, err @@ -179,7 +179,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. // Do not update for dry runs if !u.isDryRun() { - u.cfg.Log("updating status for upgraded release for %s", name) + u.cfg.Log.Debug("updating status for upgraded release", "name", name) if err := u.cfg.Releases.Update(upgradedRelease); err != nil { return res, err } @@ -365,7 +365,7 @@ func (u *Upgrade) performUpgrade(ctx context.Context, originalRelease, upgradedR // Run if it is a dry run if u.isDryRun() { - u.cfg.Log("dry run for %s", upgradedRelease.Name) + u.cfg.Log.Debug("dry run for release", "name", upgradedRelease.Name) if len(u.Description) > 0 { upgradedRelease.Info.Description = u.Description } else { @@ -374,7 +374,7 @@ func (u *Upgrade) performUpgrade(ctx context.Context, originalRelease, upgradedR return upgradedRelease, nil } - u.cfg.Log("creating upgraded release for %s", upgradedRelease.Name) + u.cfg.Log.Debug("creating upgraded release", "name", upgradedRelease.Name) if err := u.cfg.Releases.Create(upgradedRelease); err != nil { return nil, err } @@ -425,7 +425,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele return } } else { - u.cfg.Log("upgrade hooks disabled for %s", upgradedRelease.Name) + u.cfg.Log.Debug("upgrade hooks disabled", "name", upgradedRelease.Name) } results, err := u.cfg.KubeClient.Update(current, target, u.Force) @@ -441,7 +441,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele // levels, we should make these error level logs so users are notified // that they'll need to go do the cleanup on their own if err := recreate(u.cfg, results.Updated); err != nil { - u.cfg.Log(err.Error()) + u.cfg.Log.Error(err.Error()) } } waiter, err := u.cfg.KubeClient.GetWaiter(u.WaitStrategy) @@ -486,13 +486,13 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, err error) (*release.Release, error) { msg := fmt.Sprintf("Upgrade %q failed: %s", rel.Name, err) - u.cfg.Log("warning: %s", msg) + u.cfg.Log.Warn("upgrade failed", "name", rel.Name, "error", err) rel.Info.Status = release.StatusFailed rel.Info.Description = msg u.cfg.recordRelease(rel) if u.CleanupOnFail && len(created) > 0 { - u.cfg.Log("Cleanup on fail set, cleaning up %d resources", len(created)) + u.cfg.Log.Debug("cleanup on fail set", "cleaning_resources", len(created)) _, errs := u.cfg.KubeClient.Delete(created) if errs != nil { var errorList []string @@ -501,10 +501,10 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e } return rel, errors.Wrapf(fmt.Errorf("unable to cleanup resources: %s", strings.Join(errorList, ", ")), "an error occurred while cleaning up resources. original upgrade error: %s", err) } - u.cfg.Log("Resource cleanup complete") + u.cfg.Log.Debug("resource cleanup complete") } if u.Atomic { - u.cfg.Log("Upgrade failed and atomic is set, rolling back to last successful release") + u.cfg.Log.Debug("upgrade failed and atomic is set, rolling back to last successful release") // As a protection, get the last successful release before rollback. // If there are no successful releases, bail out @@ -556,13 +556,13 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newVals map[string]interface{}) (map[string]interface{}, error) { if u.ResetValues { // If ResetValues is set, we completely ignore current.Config. - u.cfg.Log("resetting values to the chart's original version") + u.cfg.Log.Debug("resetting values to the chart's original version") return newVals, nil } // If the ReuseValues flag is set, we always copy the old values over the new config's values. if u.ReuseValues { - u.cfg.Log("reusing the old release's values") + u.cfg.Log.Debug("reusing the old release's values") // We have to regenerate the old coalesced values: oldVals, err := chartutil.CoalesceValues(current.Chart, current.Config) @@ -579,7 +579,7 @@ func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newV // If the ResetThenReuseValues flag is set, we use the new chart's values, but we copy the old config's values over the new config's values. if u.ResetThenReuseValues { - u.cfg.Log("merging values from old release to new values") + u.cfg.Log.Debug("merging values from old release to new values") newVals = chartutil.CoalesceTables(newVals, current.Config) @@ -587,7 +587,7 @@ func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newV } if len(newVals) == 0 && len(current.Config) > 0 { - u.cfg.Log("copying values from %s (v%d) to new release.", current.Name, current.Version) + u.cfg.Log.Debug("copying values from old release", "name", current.Name, "version", current.Version) newVals = current.Config } return newVals, nil diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 32a386ba0..566739bc3 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -229,9 +229,9 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal } func runInstall(args []string, client *action.Install, valueOpts *values.Options, out io.Writer) (*release.Release, error) { - Debug("Original chart version: %q", client.Version) + logger.Debug("Original chart version", "version", client.Version) if client.Version == "" && client.Devel { - Debug("setting version to >0.0.0-0") + logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -246,7 +246,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options return nil, err } - Debug("CHART PATH: %s\n", cp) + logger.Debug("Chart path", "path", cp) p := getter.All(settings) vals, err := valueOpts.MergeValues(p) diff --git a/pkg/cmd/plugin.go b/pkg/cmd/plugin.go index 3340e76e6..1bb7ffb57 100644 --- a/pkg/cmd/plugin.go +++ b/pkg/cmd/plugin.go @@ -66,7 +66,7 @@ func runHook(p *plugin.Plugin, event string) error { prog := exec.Command(main, argv...) - Debug("running %s hook: %s", event, prog) + logger.Debug("running hook", "event", event, "program", prog) prog.Stdout, prog.Stderr = os.Stdout, os.Stderr if err := prog.Run(); err != nil { diff --git a/pkg/cmd/plugin_install.go b/pkg/cmd/plugin_install.go index e17744cbb..ca3d4ed90 100644 --- a/pkg/cmd/plugin_install.go +++ b/pkg/cmd/plugin_install.go @@ -79,7 +79,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error { return err } - Debug("loading plugin from %s", i.Path()) + logger.Debug("loading plugin", "path", i.Path()) p, err := plugin.LoadDir(i.Path()) if err != nil { return errors.Wrap(err, "plugin is installed but unusable") diff --git a/pkg/cmd/plugin_list.go b/pkg/cmd/plugin_list.go index 9cca790ae..9eb6707db 100644 --- a/pkg/cmd/plugin_list.go +++ b/pkg/cmd/plugin_list.go @@ -32,7 +32,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command { Short: "list installed Helm plugins", ValidArgsFunction: noMoreArgsCompFunc, RunE: func(_ *cobra.Command, _ []string) error { - Debug("pluginDirs: %s", settings.PluginsDirectory) + logger.Debug("pluginDirs", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/pkg/cmd/plugin_uninstall.go b/pkg/cmd/plugin_uninstall.go index c1f90ca49..3db454ff9 100644 --- a/pkg/cmd/plugin_uninstall.go +++ b/pkg/cmd/plugin_uninstall.go @@ -60,7 +60,7 @@ func (o *pluginUninstallOptions) complete(args []string) error { } func (o *pluginUninstallOptions) run(out io.Writer) error { - Debug("loading installed plugins from %s", settings.PluginsDirectory) + logger.Debug("loading installer plugins", "dir", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/pkg/cmd/plugin_update.go b/pkg/cmd/plugin_update.go index cbbd8994c..38c451e2f 100644 --- a/pkg/cmd/plugin_update.go +++ b/pkg/cmd/plugin_update.go @@ -62,7 +62,7 @@ func (o *pluginUpdateOptions) complete(args []string) error { func (o *pluginUpdateOptions) run(out io.Writer) error { installer.Debug = settings.Debug - Debug("loading installed plugins from %s", settings.PluginsDirectory) + logger.Debug("loading installed plugins", "path", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err @@ -104,7 +104,7 @@ func updatePlugin(p *plugin.Plugin) error { return err } - Debug("loading plugin from %s", i.Path()) + logger.Debug("loading plugin", "path", i.Path()) updatedPlugin, err := plugin.LoadDir(i.Path()) if err != nil { return err diff --git a/pkg/cmd/pull.go b/pkg/cmd/pull.go index 5d188ee4f..65ad95947 100644 --- a/pkg/cmd/pull.go +++ b/pkg/cmd/pull.go @@ -60,7 +60,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { RunE: func(_ *cobra.Command, args []string) error { client.Settings = settings if client.Version == "" && client.Devel { - Debug("setting version to >0.0.0-0") + logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/cmd/search_hub.go b/pkg/cmd/search_hub.go index b7f25444e..a2d35f32b 100644 --- a/pkg/cmd/search_hub.go +++ b/pkg/cmd/search_hub.go @@ -89,7 +89,7 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error { q := strings.Join(args, " ") results, err := c.Search(q) if err != nil { - Debug("%s", err) + logger.Debug("search failed", "error", err) return fmt.Errorf("unable to perform search against %q", o.searchEndpoint) } diff --git a/pkg/cmd/search_repo.go b/pkg/cmd/search_repo.go index 29bc19f6b..610176dd6 100644 --- a/pkg/cmd/search_repo.go +++ b/pkg/cmd/search_repo.go @@ -130,17 +130,17 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error { } func (o *searchRepoOptions) setupSearchedVersion() { - Debug("Original chart version: %q", o.version) + logger.Debug("original chart version", "version", 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") + logger.Debug("setting version to >0.0.0-0") o.version = ">0.0.0-0" } else { // search only for stable releases, prerelease versions will be skipped - Debug("setting version to >0.0.0") + logger.Debug("setting version to >0.0.0") o.version = ">0.0.0" } } diff --git a/pkg/cmd/show.go b/pkg/cmd/show.go index a02af6f18..6aa322430 100644 --- a/pkg/cmd/show.go +++ b/pkg/cmd/show.go @@ -211,9 +211,9 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) { } func runShow(args []string, client *action.Show) (string, error) { - Debug("Original chart version: %q", client.Version) + logger.Debug("original chart version", "version", client.Version) if client.Version == "" && client.Devel { - Debug("setting version to >0.0.0-0") + logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index e61c9bc3b..a85eb5a41 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -173,7 +173,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if client.Version == "" && client.Devel { - Debug("setting version to >0.0.0-0") + logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index c176b3fb8..e82165486 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -51,6 +51,8 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" + + logadapter "helm.sh/helm/v4/internal/log" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index abe841ea6..11a3413e4 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -26,7 +26,6 @@ import ( "github.com/stretchr/testify/assert" - logadapter "helm.sh/helm/v4/internal/log" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -35,6 +34,8 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest/fake" cmdtesting "k8s.io/kubectl/pkg/cmd/testing" + + logadapter "helm.sh/helm/v4/internal/log" ) var unstructuredSerializer = resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index f022bf596..155d3d435 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -19,7 +19,6 @@ import ( "context" "testing" - logadapter "helm.sh/helm/v4/internal/log" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -31,6 +30,8 @@ import ( "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" + + logadapter "helm.sh/helm/v4/internal/log" ) const defaultNamespace = metav1.NamespaceDefault @@ -114,7 +115,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { func Test_ReadyChecker_IsReady_Job(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -189,7 +190,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -271,7 +272,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -346,7 +347,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { func Test_ReadyChecker_IsReady_Service(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -421,7 +422,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -496,7 +497,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } @@ -571,7 +572,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { type fields struct { client kubernetes.Interface - log Logger + log logadapter.Logger checkJobs bool pausedAsReady bool } diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 69779904f..e3d29d8a9 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -25,7 +25,6 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/pkg/errors" - logadapter "helm.sh/helm/v4/internal/log" appsv1 "k8s.io/api/apps/v1" appsv1beta1 "k8s.io/api/apps/v1beta1" appsv1beta2 "k8s.io/api/apps/v1beta2" @@ -45,6 +44,8 @@ import ( watchtools "k8s.io/client-go/tools/watch" "k8s.io/apimachinery/pkg/util/wait" + + logadapter "helm.sh/helm/v4/internal/log" ) // legacyWaiter is the legacy implementation of the Waiter interface. This logic was used by default in Helm 3 diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 48198a9bd..421d39ba8 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -70,13 +70,13 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) { return nil, ErrReleaseNotFound } - cfgmaps.Log("get: failed to get %q: %s", key, err) + cfgmaps.Log.Debug("failed to get release", "key", key, "error", err) return nil, err } // found the configmap, decode the base64 data string r, err := decodeRelease(obj.Data["release"]) if err != nil { - cfgmaps.Log("get: failed to decode data %q: %s", key, err) + cfgmaps.Log.Debug("failed to decode data", "key", key, "error", err) return nil, err } r.Labels = filterSystemLabels(obj.ObjectMeta.Labels) @@ -93,7 +93,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas list, err := cfgmaps.impl.List(context.Background(), opts) if err != nil { - cfgmaps.Log("list: failed to list: %s", err) + cfgmaps.Log.Debug("failed to list releases", "error", err) return nil, err } @@ -104,7 +104,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas for _, item := range list.Items { rls, err := decodeRelease(item.Data["release"]) if err != nil { - cfgmaps.Log("list: failed to decode release: %v: %s", item, err) + cfgmaps.Log.Debug("failed to decode release", "item", item, "error", err) continue } @@ -132,7 +132,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err list, err := cfgmaps.impl.List(context.Background(), opts) if err != nil { - cfgmaps.Log("query: failed to query with labels: %s", err) + cfgmaps.Log.Debug("failed to query with labels", "error", err) return nil, err } @@ -144,7 +144,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err for _, item := range list.Items { rls, err := decodeRelease(item.Data["release"]) if err != nil { - cfgmaps.Log("query: failed to decode release: %s", err) + cfgmaps.Log.Debug("failed to decode release", "error", err) continue } rls.Labels = item.ObjectMeta.Labels @@ -166,7 +166,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error { // create a new configmap to hold the release obj, err := newConfigMapsObject(key, rls, lbs) if err != nil { - cfgmaps.Log("create: failed to encode release %q: %s", rls.Name, err) + cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, "error", err) return err } // push the configmap object out into the kubiverse @@ -175,7 +175,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error { return ErrReleaseExists } - cfgmaps.Log("create: failed to create: %s", err) + cfgmaps.Log.Debug("failed to create release", "error", err) return err } return nil @@ -194,13 +194,13 @@ func (cfgmaps *ConfigMaps) Update(key string, rls *rspb.Release) error { // create a new configmap object to hold the release obj, err := newConfigMapsObject(key, rls, lbs) if err != nil { - cfgmaps.Log("update: failed to encode release %q: %s", rls.Name, err) + cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, "error", err) return err } // push the configmap object out into the kubiverse _, err = cfgmaps.impl.Update(context.Background(), obj, metav1.UpdateOptions{}) if err != nil { - cfgmaps.Log("update: failed to update: %s", err) + cfgmaps.Log.Debug("failed to update release", "error", err) return err } return nil diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index 304503b0a..9a4188d2d 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -109,13 +109,13 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool { records, err := migrate.GetMigrationRecords(s.db.DB, postgreSQLDialect) migrate.SetDisableCreateTable(false) if err != nil { - s.Log.Debug("checkAlreadyApplied: failed to get migration records: %v", err) + s.Log.Debug("failed to get migration records", "error", err) return false } for _, record := range records { if _, ok := migrationsIDs[record.Id]; ok { - s.Log.Debug("checkAlreadyApplied: found previous migration (Id: %v) applied at %v", record.Id, record.AppliedAt) + s.Log.Debug("found previous migration", "id", record.Id, "appliedAt", record.AppliedAt) delete(migrationsIDs, record.Id) } } @@ -123,7 +123,7 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool { // check if all migrations applied if len(migrationsIDs) != 0 { for id := range migrationsIDs { - s.Log("checkAlreadyApplied: find unapplied migration (id: %v)", id) + s.Log.Debug("find unapplied migration", "id", id) } return false } @@ -310,24 +310,24 @@ func (s *SQL) Get(key string) (*rspb.Release, error) { query, args, err := qb.ToSql() if err != nil { - s.Log("failed to build query: %v", err) + s.Log.Debug("failed to build query", "error", err) return nil, err } // Get will return an error if the result is empty if err := s.db.Get(&record, query, args...); err != nil { - s.Log("got SQL error when getting release %s: %v", key, err) + s.Log.Debug("got SQL error when getting release", "key", key, "error", err) return nil, ErrReleaseNotFound } release, err := decodeRelease(record.Body) if err != nil { - s.Log("get: failed to decode data %q: %v", key, err) + s.Log.Debug("failed to decode data", "key", key, "error", err) return nil, err } if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil { - s.Log("failed to get release %s/%s custom labels: %v", s.namespace, key, err) + s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, "error", err) return nil, err } @@ -348,13 +348,13 @@ func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) { query, args, err := sb.ToSql() if err != nil { - s.Log("failed to build query: %v", err) + s.Log.Debug("failed to build query", "error", err) return nil, err } var records = []SQLReleaseWrapper{} if err := s.db.Select(&records, query, args...); err != nil { - s.Log("list: failed to list: %v", err) + s.Log.Debug("failed to list", "error", err) return nil, err } @@ -362,12 +362,12 @@ func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) { for _, record := range records { release, err := decodeRelease(record.Body) if err != nil { - s.Log("list: failed to decode release: %v: %v", record, err) + s.Log.Debug("failed to decode release", "record", record, "error", err) continue } if release.Labels, err = s.getReleaseCustomLabels(record.Key, record.Namespace); err != nil { - s.Log("failed to get release %s/%s custom labels: %v", record.Namespace, record.Key, err) + s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, "error", err) return nil, err } for k, v := range getReleaseSystemLabels(release) { @@ -397,7 +397,7 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { if _, ok := labelMap[key]; ok { sb = sb.Where(sq.Eq{key: labels[key]}) } else { - s.Log("unknown label %s", key) + s.Log.Debug("unknown label", "key", key) return nil, fmt.Errorf("unknown label %s", key) } } @@ -410,13 +410,13 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { // Build our query query, args, err := sb.ToSql() if err != nil { - s.Log("failed to build query: %v", err) + s.Log.Debug("failed to build query", "error", err) return nil, err } var records = []SQLReleaseWrapper{} if err := s.db.Select(&records, query, args...); err != nil { - s.Log("list: failed to query with labels: %v", err) + s.Log.Debug("failed to query with labels", "error", err) return nil, err } @@ -428,12 +428,12 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { for _, record := range records { release, err := decodeRelease(record.Body) if err != nil { - s.Log("list: failed to decode release: %v: %v", record, err) + s.Log.Debug("failed to decode release", "record", record, "error", err) continue } if release.Labels, err = s.getReleaseCustomLabels(record.Key, record.Namespace); err != nil { - s.Log("failed to get release %s/%s custom labels: %v", record.Namespace, record.Key, err) + s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, "error", err) return nil, err } @@ -457,13 +457,13 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { body, err := encodeRelease(rls) if err != nil { - s.Log("failed to encode release: %v", err) + s.Log.Debug("failed to encode release", "error", err) return err } transaction, err := s.db.Beginx() if err != nil { - s.Log("failed to start SQL transaction: %v", err) + s.Log.Debug("failed to start SQL transaction", "error", err) return fmt.Errorf("error beginning transaction: %v", err) } @@ -492,7 +492,7 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { int(time.Now().Unix()), ).ToSql() if err != nil { - s.Log("failed to build insert query: %v", err) + s.Log.Debug("failed to build insert query", "error", err) return err } @@ -506,17 +506,17 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if buildErr != nil { - s.Log("failed to build select query: %v", buildErr) + s.Log.Debug("failed to build select query", "error", buildErr) return err } var record SQLReleaseWrapper if err := transaction.Get(&record, selectQuery, args...); err == nil { - s.Log("release %s already exists", key) + s.Log.Debug("release already exists", "key", key) return ErrReleaseExists } - s.Log("failed to store release %s in SQL database: %v", key, err) + s.Log.Debug("failed to store release in SQL database", "key", key, "error", err) return err } @@ -539,13 +539,13 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { if err != nil { defer transaction.Rollback() - s.Log("failed to build insert query: %v", err) + s.Log.Debug("failed to build insert query", "error", err) return err } if _, err := transaction.Exec(insertLabelsQuery, args...); err != nil { defer transaction.Rollback() - s.Log("failed to write Labels: %v", err) + s.Log.Debug("failed to write Labels", "error", err) return err } } @@ -564,7 +564,7 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { body, err := encodeRelease(rls) if err != nil { - s.Log("failed to encode release: %v", err) + s.Log.Debug("failed to encode release", "error", err) return err } @@ -581,12 +581,12 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { ToSql() if err != nil { - s.Log("failed to build update query: %v", err) + s.Log.Debug("failed to build update query", "error", err) return err } if _, err := s.db.Exec(query, args...); err != nil { - s.Log("failed to update release %s in SQL database: %v", key, err) + s.Log.Debug("failed to update release in SQL database", "key", key, "error", err) return err } @@ -597,7 +597,7 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { func (s *SQL) Delete(key string) (*rspb.Release, error) { transaction, err := s.db.Beginx() if err != nil { - s.Log("failed to start SQL transaction: %v", err) + s.Log.Debug("failed to start SQL transaction", "error", err) return nil, fmt.Errorf("error beginning transaction: %v", err) } @@ -608,20 +608,20 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if err != nil { - s.Log("failed to build select query: %v", err) + s.Log.Debug("failed to build select query", "error", err) return nil, err } var record SQLReleaseWrapper err = transaction.Get(&record, selectQuery, args...) if err != nil { - s.Log("release %s not found: %v", key, err) + s.Log.Debug("release not found", "key", key, "error", err) return nil, ErrReleaseNotFound } release, err := decodeRelease(record.Body) if err != nil { - s.Log("failed to decode release %s: %v", key, err) + s.Log.Debug("failed to decode release", "key", key, "error", err) transaction.Rollback() return nil, err } @@ -633,18 +633,18 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if err != nil { - s.Log("failed to build delete query: %v", err) + s.Log.Debug("failed to build delete query", "error", err) return nil, err } _, err = transaction.Exec(deleteQuery, args...) if err != nil { - s.Log("failed perform delete query: %v", err) + s.Log.Debug("failed perform delete query", "error", err) return release, err } if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil { - s.Log("failed to get release %s/%s custom labels: %v", s.namespace, key, err) + s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, "error", err) return nil, err } @@ -655,7 +655,7 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { ToSql() if err != nil { - s.Log("failed to build delete Labels query: %v", err) + s.Log.Debug("failed to build delete Labels query", "error", err) return nil, err } _, err = transaction.Exec(deleteCustomLabelsQuery, args...) From 15de13f9d2644a99d029fdb43070acff873599e4 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 31 Mar 2025 11:37:40 +0200 Subject: [PATCH 238/271] Fix linting issue and temporary removing logging in test acion Signed-off-by: Benoit Tigeot --- internal/log/logger.go | 6 +++--- internal/log/slog.go | 2 +- pkg/action/action_test.go | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/log/logger.go b/internal/log/logger.go index ff971bdb1..10351d476 100644 --- a/internal/log/logger.go +++ b/internal/log/logger.go @@ -33,13 +33,13 @@ type Logger interface { type NopLogger struct{} // Debug implements Logger.Debug by doing nothing. -func (NopLogger) Debug(_ string, args ...any) {} +func (NopLogger) Debug(_ string, _ ...any) {} // Warn implements Logger.Warn by doing nothing. -func (NopLogger) Warn(_ string, args ...any) {} +func (NopLogger) Warn(_ string, _ ...any) {} // Error implements Logger.Error by doing nothing. -func (NopLogger) Error(_ string, args ...any) {} +func (NopLogger) Error(_ string, _ ...any) {} // DefaultLogger provides a no-op logger that discards all messages. // It can be used as a default when no logger is provided. diff --git a/internal/log/slog.go b/internal/log/slog.go index 7765545f9..1cafd49b1 100644 --- a/internal/log/slog.go +++ b/internal/log/slog.go @@ -59,7 +59,7 @@ func NewReadableTextLogger(output io.Writer, debugEnabled bool) Logger { handler := slog.NewTextHandler(output, &slog.HandlerOptions{ Level: level, - ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { if a.Key == slog.TimeKey { return slog.Attr{} } diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index efaebb3f9..746a7e54b 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -16,7 +16,6 @@ limitations under the License. package action import ( - "flag" "fmt" "io" "testing" @@ -35,8 +34,6 @@ import ( "helm.sh/helm/v4/pkg/time" ) -var verbose = flag.Bool("test.log", false, "enable test logging") - func actionConfigFixture(t *testing.T) *Configuration { t.Helper() @@ -50,7 +47,7 @@ func actionConfigFixture(t *testing.T) *Configuration { KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}}, Capabilities: chartutil.DefaultCapabilities, RegistryClient: registryClient, - Log: logadapter.DefaultLogger, + Log: logadapter.DefaultLogger, // TODO: permit to log in test as before with `var verbose = flag.Bool("test.log", false, "enable test logging")`` } } From 3db7ebc59130fcc14fd176e746f7c65f4ec1f719 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 31 Mar 2025 11:51:32 +0200 Subject: [PATCH 239/271] Fix missing logger to SQL in test Signed-off-by: Benoit Tigeot --- pkg/storage/driver/mock_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index 54fda0542..c592ee634 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -31,6 +31,7 @@ import ( kblabels "k8s.io/apimachinery/pkg/labels" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" + logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -264,5 +265,6 @@ func newTestFixtureSQL(t *testing.T, _ ...*rspb.Release) (*SQL, sqlmock.Sqlmock) db: sqlxDB, namespace: "default", statementBuilder: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + Log: logadapter.DefaultLogger, }, mock } From 947658a96eee63ac1315c3e188775a430c0af6d5 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 31 Mar 2025 14:39:53 +0200 Subject: [PATCH 240/271] Explain why we ignore the timestamp Signed-off-by: Benoit Tigeot --- internal/log/slog.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/log/slog.go b/internal/log/slog.go index 1cafd49b1..e0fd35ac5 100644 --- a/internal/log/slog.go +++ b/internal/log/slog.go @@ -59,6 +59,7 @@ func NewReadableTextLogger(output io.Writer, debugEnabled bool) Logger { handler := slog.NewTextHandler(output, &slog.HandlerOptions{ Level: level, + // Ignore the time key to avoid cluttering the output with timestamps ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { if a.Key == slog.TimeKey { return slog.Attr{} From b2380720eb3fec55333a1b0cca9a6d188db631d9 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 16:45:21 +0200 Subject: [PATCH 241/271] Migrate to pure slog without a custom wrapper Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 6 +-- internal/log/logger.go | 46 --------------------- internal/log/slog.go | 72 --------------------------------- internal/monocular/client.go | 8 ++-- pkg/action/action.go | 6 +-- pkg/action/action_test.go | 4 +- pkg/cli/logger.go | 43 ++++++++++++++++++++ pkg/cmd/flags.go | 4 +- pkg/cmd/helpers_test.go | 4 +- pkg/cmd/install.go | 8 ++-- pkg/cmd/list.go | 6 +-- pkg/cmd/plugin.go | 2 +- pkg/cmd/plugin_install.go | 2 +- pkg/cmd/plugin_list.go | 2 +- pkg/cmd/plugin_uninstall.go | 2 +- pkg/cmd/plugin_update.go | 4 +- pkg/cmd/pull.go | 2 +- pkg/cmd/registry_login.go | 2 +- pkg/cmd/root.go | 5 +-- pkg/cmd/search_hub.go | 2 +- pkg/cmd/search_repo.go | 8 ++-- pkg/cmd/show.go | 4 +- pkg/cmd/upgrade.go | 4 +- pkg/kube/client.go | 7 ++-- pkg/kube/client_test.go | 5 +-- pkg/kube/ready.go | 9 +++-- pkg/kube/ready_test.go | 60 +++++++++++++-------------- pkg/kube/statuswait.go | 16 ++++---- pkg/kube/statuswait_test.go | 12 +++--- pkg/kube/wait.go | 41 ++++++++++--------- pkg/storage/driver/cfgmaps.go | 4 +- pkg/storage/driver/mock_test.go | 5 ++- pkg/storage/driver/secrets.go | 8 ++-- pkg/storage/driver/sql.go | 6 +-- 34 files changed, 169 insertions(+), 250 deletions(-) delete mode 100644 internal/log/logger.go delete mode 100644 internal/log/slog.go create mode 100644 pkg/cli/logger.go diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 158118c06..9bdd8e98c 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -23,7 +23,6 @@ import ( // Import to initialize client auth plugins. _ "k8s.io/client-go/plugin/pkg/client/auth" - logadapter "helm.sh/helm/v4/internal/log" helmcmd "helm.sh/helm/v4/pkg/cmd" "helm.sh/helm/v4/pkg/kube" ) @@ -38,16 +37,15 @@ func main() { // 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" - logger := logadapter.NewReadableTextLogger(os.Stderr, false) cmd, err := helmcmd.NewRootCmd(os.Stdout, os.Args[1:]) if err != nil { - logger.Warn("%+v", err) + helmcmd.Logger.Warn("%+v", err) os.Exit(1) } if err := cmd.Execute(); err != nil { - logger.Debug("error", err) + helmcmd.Logger.Debug("error", err) switch e := err.(type) { case helmcmd.PluginError: os.Exit(e.Code) diff --git a/internal/log/logger.go b/internal/log/logger.go deleted file mode 100644 index 10351d476..000000000 --- a/internal/log/logger.go +++ /dev/null @@ -1,46 +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 log - -// Logger defines a minimal logging interface compatible with structured logging. -// It provides methods for different log levels with structured key-value pairs. -type Logger interface { - // Debug logs a message at debug level with structured key-value pairs. - Debug(msg string, args ...any) - - // Warn logs a message at warning level with structured key-value pairs. - Warn(msg string, args ...any) - - // Error logs a message at error level with structured key-value pairs. - Error(msg string, args ...any) -} - -// NopLogger is a logger implementation that discards all log messages. -type NopLogger struct{} - -// Debug implements Logger.Debug by doing nothing. -func (NopLogger) Debug(_ string, _ ...any) {} - -// Warn implements Logger.Warn by doing nothing. -func (NopLogger) Warn(_ string, _ ...any) {} - -// Error implements Logger.Error by doing nothing. -func (NopLogger) Error(_ string, _ ...any) {} - -// DefaultLogger provides a no-op logger that discards all messages. -// It can be used as a default when no logger is provided. -var DefaultLogger Logger = NopLogger{} diff --git a/internal/log/slog.go b/internal/log/slog.go deleted file mode 100644 index e0fd35ac5..000000000 --- a/internal/log/slog.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 log - -import ( - "io" - "log/slog" -) - -// SlogAdapter adapts a standard library slog.Logger to the Logger interface. -type SlogAdapter struct { - logger *slog.Logger -} - -// Debug implements Logger.Debug by forwarding to the underlying slog.Logger. -func (a SlogAdapter) Debug(msg string, args ...any) { - a.logger.Debug(msg, args...) -} - -// Warn implements Logger.Warn by forwarding to the underlying slog.Logger. -func (a SlogAdapter) Warn(msg string, args ...any) { - a.logger.Warn(msg, args...) -} - -// Error implements Logger.Error by forwarding to the underlying slog.Logger. -func (a SlogAdapter) Error(msg string, args ...any) { - // TODO: Handle error with `slog.Any`: slog.Info("something went wrong", slog.Any("err", err)) - a.logger.Error(msg, args...) -} - -// NewSlogAdapter creates a Logger that forwards log messages to a slog.Logger. -func NewSlogAdapter(logger *slog.Logger) Logger { - if logger == nil { - return DefaultLogger - } - return SlogAdapter{logger: logger} -} - -// NewReadableTextLogger creates a Logger that outputs in a readable text format without timestamps -func NewReadableTextLogger(output io.Writer, debugEnabled bool) Logger { - level := slog.LevelInfo - if debugEnabled { - level = slog.LevelDebug - } - - handler := slog.NewTextHandler(output, &slog.HandlerOptions{ - Level: level, - // Ignore the time key to avoid cluttering the output with timestamps - ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { - if a.Key == slog.TimeKey { - return slog.Attr{} - } - return a - }, - }) - - return NewSlogAdapter(slog.New(handler)) -} diff --git a/internal/monocular/client.go b/internal/monocular/client.go index 88a2564b9..f4c9debca 100644 --- a/internal/monocular/client.go +++ b/internal/monocular/client.go @@ -18,6 +18,7 @@ package monocular import ( "errors" + "log/slog" "net/url" ) @@ -30,8 +31,7 @@ type Client struct { // The base URL for requests BaseURL string - // The internal logger to use - Log func(string, ...interface{}) + Log *slog.Logger } // New creates a new client @@ -44,12 +44,10 @@ func New(u string) (*Client, error) { return &Client{ BaseURL: u, - Log: nopLogger, + Log: slog.Default(), }, nil } -var nopLogger = func(_ string, _ ...interface{}) {} - // Validate if the base URL for monocular is valid. func validate(u string) error { diff --git a/pkg/action/action.go b/pkg/action/action.go index 778dc9ec5..1993e6241 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -20,6 +20,7 @@ import ( "bytes" "fmt" "io" + "log/slog" "os" "path" "path/filepath" @@ -33,7 +34,6 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" - logadapter "helm.sh/helm/v4/internal/log" chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/engine" @@ -96,7 +96,7 @@ type Configuration struct { // Capabilities describes the capabilities of the Kubernetes cluster. Capabilities *chartutil.Capabilities - Log logadapter.Logger + Log *slog.Logger // HookOutputFunc called with container name and returns and expects writer that will receive the log output. HookOutputFunc func(namespace, pod, container string) io.Writer @@ -375,7 +375,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { } // Init initializes the action configuration -func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log logadapter.Logger) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log *slog.Logger) error { kc := kube.New(getter) kc.Log = log diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 746a7e54b..ee32246af 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -18,12 +18,12 @@ package action import ( "fmt" "io" + "log/slog" "testing" "github.com/stretchr/testify/assert" fakeclientset "k8s.io/client-go/kubernetes/fake" - logadapter "helm.sh/helm/v4/internal/log" chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" @@ -47,7 +47,7 @@ func actionConfigFixture(t *testing.T) *Configuration { KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}}, Capabilities: chartutil.DefaultCapabilities, RegistryClient: registryClient, - Log: logadapter.DefaultLogger, // TODO: permit to log in test as before with `var verbose = flag.Bool("test.log", false, "enable test logging")`` + Log: slog.New(slog.NewTextHandler(io.Discard, nil)), // TODO: permit to log in test as before with `var verbose = flag.Bool("test.log", false, "enable test logging")`` } } diff --git a/pkg/cli/logger.go b/pkg/cli/logger.go new file mode 100644 index 000000000..243284d76 --- /dev/null +++ b/pkg/cli/logger.go @@ -0,0 +1,43 @@ +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cli + +import ( + "log/slog" + "os" +) + +func NewLogger(debug bool) *slog.Logger { + level := slog.LevelInfo + if debug { + level = slog.LevelDebug + } + + // Create a handler that removes timestamps + handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + Level: level, + ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + // Remove the time attribute + if a.Key == slog.TimeKey { + return slog.Attr{} + } + return a + }, + }) + + return slog.New(handler) +} diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index ed3b83a55..454bb13de 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -82,11 +82,11 @@ func (ws *waitValue) Set(s string) error { *ws = waitValue(s) return nil case "true": - Warning("--wait=true is deprecated (boolean value) and can be replaced with --wait=watcher") + Logger.Warn("--wait=true is deprecated (boolean value) and can be replaced with --wait=watcher") *ws = waitValue(kube.StatusWatcherStrategy) return nil case "false": - Warning("--wait=false is deprecated (boolean value) and can be replaced by omitting the --wait flag") + Logger.Warn("--wait=false is deprecated (boolean value) and can be replaced by omitting the --wait flag") *ws = waitValue(kube.HookOnlyStrategy) return nil default: diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index 1f597d7ba..38e0a5b3e 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -19,6 +19,7 @@ package cmd import ( "bytes" "io" + "log/slog" "os" "strings" "testing" @@ -26,7 +27,6 @@ import ( shellwords "github.com/mattn/go-shellwords" "github.com/spf13/cobra" - logadapter "helm.sh/helm/v4/internal/log" "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/action" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" @@ -93,7 +93,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) Releases: store, KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard}, Capabilities: chartutil.DefaultCapabilities, - Log: logadapter.DefaultLogger, + Log: slog.New(slog.NewTextHandler(io.Discard, nil)), } root, err := newRootCmdWithConfig(actionConfig, buf, args) diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 566739bc3..14746f8c3 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -229,9 +229,9 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal } func runInstall(args []string, client *action.Install, valueOpts *values.Options, out io.Writer) (*release.Release, error) { - logger.Debug("Original chart version", "version", client.Version) + Logger.Debug("Original chart version", "version", client.Version) if client.Version == "" && client.Devel { - logger.Debug("setting version to >0.0.0-0") + Logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -246,7 +246,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options return nil, err } - logger.Debug("Chart path", "path", cp) + Logger.Debug("Chart path", "path", cp) p := getter.All(settings) vals, err := valueOpts.MergeValues(p) @@ -265,7 +265,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options } if chartRequested.Metadata.Deprecated { - logger.Warn("this chart is deprecated") + Logger.Warn("this chart is deprecated") } if req := chartRequested.Metadata.Dependencies; req != nil { diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index 10b70d7d9..a4eb91aad 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -19,14 +19,12 @@ package cmd import ( "fmt" "io" - "log/slog" "os" "strconv" "github.com/gosuri/uitable" "github.com/spf13/cobra" - logadapter "helm.sh/helm/v4/internal/log" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cmd/require" @@ -63,8 +61,6 @@ 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 - slogger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) - adapter := logadapter.NewSlogAdapter(slogger) cmd := &cobra.Command{ Use: "list", @@ -75,7 +71,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(cmd *cobra.Command, _ []string) error { if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), adapter); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), Logger); err != nil { return err } } diff --git a/pkg/cmd/plugin.go b/pkg/cmd/plugin.go index 1bb7ffb57..05d7135dd 100644 --- a/pkg/cmd/plugin.go +++ b/pkg/cmd/plugin.go @@ -66,7 +66,7 @@ func runHook(p *plugin.Plugin, event string) error { prog := exec.Command(main, argv...) - logger.Debug("running hook", "event", event, "program", prog) + Logger.Debug("running hook", "event", event, "program", prog) prog.Stdout, prog.Stderr = os.Stdout, os.Stderr if err := prog.Run(); err != nil { diff --git a/pkg/cmd/plugin_install.go b/pkg/cmd/plugin_install.go index ca3d4ed90..2e8fd4d6a 100644 --- a/pkg/cmd/plugin_install.go +++ b/pkg/cmd/plugin_install.go @@ -79,7 +79,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error { return err } - logger.Debug("loading plugin", "path", i.Path()) + Logger.Debug("loading plugin", "path", i.Path()) p, err := plugin.LoadDir(i.Path()) if err != nil { return errors.Wrap(err, "plugin is installed but unusable") diff --git a/pkg/cmd/plugin_list.go b/pkg/cmd/plugin_list.go index 9eb6707db..3a1d0f2f5 100644 --- a/pkg/cmd/plugin_list.go +++ b/pkg/cmd/plugin_list.go @@ -32,7 +32,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command { Short: "list installed Helm plugins", ValidArgsFunction: noMoreArgsCompFunc, RunE: func(_ *cobra.Command, _ []string) error { - logger.Debug("pluginDirs", settings.PluginsDirectory) + Logger.Debug("pluginDirs", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/pkg/cmd/plugin_uninstall.go b/pkg/cmd/plugin_uninstall.go index 3db454ff9..18815b139 100644 --- a/pkg/cmd/plugin_uninstall.go +++ b/pkg/cmd/plugin_uninstall.go @@ -60,7 +60,7 @@ func (o *pluginUninstallOptions) complete(args []string) error { } func (o *pluginUninstallOptions) run(out io.Writer) error { - logger.Debug("loading installer plugins", "dir", settings.PluginsDirectory) + Logger.Debug("loading installer plugins", "dir", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/pkg/cmd/plugin_update.go b/pkg/cmd/plugin_update.go index 38c451e2f..16ac84066 100644 --- a/pkg/cmd/plugin_update.go +++ b/pkg/cmd/plugin_update.go @@ -62,7 +62,7 @@ func (o *pluginUpdateOptions) complete(args []string) error { func (o *pluginUpdateOptions) run(out io.Writer) error { installer.Debug = settings.Debug - logger.Debug("loading installed plugins", "path", settings.PluginsDirectory) + Logger.Debug("loading installed plugins", "path", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err @@ -104,7 +104,7 @@ func updatePlugin(p *plugin.Plugin) error { return err } - logger.Debug("loading plugin", "path", i.Path()) + Logger.Debug("loading plugin", "path", i.Path()) updatedPlugin, err := plugin.LoadDir(i.Path()) if err != nil { return err diff --git a/pkg/cmd/pull.go b/pkg/cmd/pull.go index 65ad95947..fca1c8b9b 100644 --- a/pkg/cmd/pull.go +++ b/pkg/cmd/pull.go @@ -60,7 +60,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { RunE: func(_ *cobra.Command, args []string) error { client.Settings = settings if client.Version == "" && client.Devel { - logger.Debug("setting version to >0.0.0-0") + Logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/cmd/registry_login.go b/pkg/cmd/registry_login.go index bc6c1d13d..7c853d786 100644 --- a/pkg/cmd/registry_login.go +++ b/pkg/cmd/registry_login.go @@ -122,7 +122,7 @@ func getUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStd } } } else { - logger.Warn("using --password via the CLI is insecure. Use --password-stdin") + Logger.Warn("using --password via the CLI is insecure. Use --password-stdin") } return username, password, nil diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 407e89139..0cbcfebaf 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -31,7 +31,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" - logadapter "helm.sh/helm/v4/internal/log" "helm.sh/helm/v4/internal/tlsutil" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli" @@ -96,7 +95,7 @@ By default, the default directories depend on the Operating System. The defaults ` var settings = cli.New() -var logger = logadapter.NewReadableTextLogger(os.Stderr, settings.Debug) +var Logger = cli.NewLogger(settings.Debug) func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { actionConfig := new(action.Configuration) @@ -106,7 +105,7 @@ func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { } cobra.OnInitialize(func() { helmDriver := os.Getenv("HELM_DRIVER") - if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, logger); err != nil { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, Logger); err != nil { log.Fatal(err) } if helmDriver == "memory" { diff --git a/pkg/cmd/search_hub.go b/pkg/cmd/search_hub.go index a2d35f32b..1a2848b25 100644 --- a/pkg/cmd/search_hub.go +++ b/pkg/cmd/search_hub.go @@ -89,7 +89,7 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error { q := strings.Join(args, " ") results, err := c.Search(q) if err != nil { - logger.Debug("search failed", "error", err) + Logger.Debug("search failed", "error", err) return fmt.Errorf("unable to perform search against %q", o.searchEndpoint) } diff --git a/pkg/cmd/search_repo.go b/pkg/cmd/search_repo.go index 610176dd6..a6aa755cd 100644 --- a/pkg/cmd/search_repo.go +++ b/pkg/cmd/search_repo.go @@ -130,17 +130,17 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error { } func (o *searchRepoOptions) setupSearchedVersion() { - logger.Debug("original chart version", "version", o.version) + Logger.Debug("original chart version", "version", o.version) if o.version != "" { return } if o.devel { // search for releases and prereleases (alpha, beta, and release candidate releases). - logger.Debug("setting version to >0.0.0-0") + Logger.Debug("setting version to >0.0.0-0") o.version = ">0.0.0-0" } else { // search only for stable releases, prerelease versions will be skipped - logger.Debug("setting version to >0.0.0") + Logger.Debug("setting version to >0.0.0") o.version = ">0.0.0" } } @@ -189,7 +189,7 @@ func (o *searchRepoOptions) buildIndex() (*search.Index, error) { f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n)) ind, err := repo.LoadIndexFile(f) if err != nil { - logger.Warn("repo is corrupt or missing", "repo", n, "error", err) + Logger.Warn("repo is corrupt or missing", "repo", n, "error", err) continue } diff --git a/pkg/cmd/show.go b/pkg/cmd/show.go index 6aa322430..c70ffa256 100644 --- a/pkg/cmd/show.go +++ b/pkg/cmd/show.go @@ -211,9 +211,9 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) { } func runShow(args []string, client *action.Show) (string, error) { - logger.Debug("original chart version", "version", client.Version) + Logger.Debug("original chart version", "version", client.Version) if client.Version == "" && client.Devel { - logger.Debug("setting version to >0.0.0-0") + Logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index a85eb5a41..e6b5c0409 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -173,7 +173,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if client.Version == "" && client.Devel { - logger.Debug("setting version to >0.0.0-0") + Logger.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -225,7 +225,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if ch.Metadata.Deprecated { - logger.Warn("this chart is deprecated") + Logger.Warn("this chart is deprecated") } // Create context and prepare the handle of SIGTERM diff --git a/pkg/kube/client.go b/pkg/kube/client.go index e82165486..be5214431 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "io" + "log/slog" "os" "path/filepath" "reflect" @@ -51,8 +52,6 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/util/retry" cmdutil "k8s.io/kubectl/pkg/cmd/util" - - logadapter "helm.sh/helm/v4/internal/log" ) // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. @@ -75,7 +74,7 @@ type Client struct { // needs. The smaller surface area of the interface means there is a lower // chance of it changing. Factory Factory - Log logadapter.Logger + Log *slog.Logger // Namespace allows to bypass the kubeconfig file for the choice of the namespace Namespace string @@ -164,7 +163,7 @@ func New(getter genericclioptions.RESTClientGetter) *Client { factory := cmdutil.NewFactory(getter) c := &Client{ Factory: factory, - Log: nopLogger, + Log: slog.Default(), } return c } diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 11a3413e4..6244e3ee5 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -19,6 +19,7 @@ package kube import ( "bytes" "io" + "log/slog" "net/http" "strings" "testing" @@ -34,8 +35,6 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest/fake" cmdtesting "k8s.io/kubectl/pkg/cmd/testing" - - logadapter "helm.sh/helm/v4/internal/log" ) var unstructuredSerializer = resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer @@ -109,7 +108,7 @@ func newTestClient(t *testing.T) *Client { return &Client{ Factory: testFactory.WithNamespace("default"), - Log: logadapter.DefaultLogger, + Log: slog.New(slog.NewTextHandler(io.Discard, nil)), } } diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index c128e31b0..745dd265e 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -19,6 +19,8 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" "fmt" + "io" + "log/slog" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" @@ -32,7 +34,6 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" - logadapter "helm.sh/helm/v4/internal/log" deploymentutil "helm.sh/helm/v4/internal/third_party/k8s.io/kubernetes/deployment/util" ) @@ -58,13 +59,13 @@ func CheckJobs(checkJobs bool) ReadyCheckerOption { // NewReadyChecker creates a new checker. Passed ReadyCheckerOptions can // be used to override defaults. -func NewReadyChecker(cl kubernetes.Interface, logger logadapter.Logger, opts ...ReadyCheckerOption) ReadyChecker { +func NewReadyChecker(cl kubernetes.Interface, logger *slog.Logger, opts ...ReadyCheckerOption) ReadyChecker { c := ReadyChecker{ client: cl, log: logger, } if c.log == nil { - c.log = logadapter.DefaultLogger + c.log = slog.New(slog.NewTextHandler(io.Discard, nil)) } for _, opt := range opts { opt(&c) @@ -75,7 +76,7 @@ func NewReadyChecker(cl kubernetes.Interface, logger logadapter.Logger, opts ... // ReadyChecker is a type that can check core Kubernetes types for readiness. type ReadyChecker struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index 155d3d435..d9dd8fb3d 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -17,6 +17,8 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" + "io" + "log/slog" "testing" appsv1 "k8s.io/api/apps/v1" @@ -30,8 +32,6 @@ import ( "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" - - logadapter "helm.sh/helm/v4/internal/log" ) const defaultNamespace = metav1.NamespaceDefault @@ -39,7 +39,7 @@ const defaultNamespace = metav1.NamespaceDefault func Test_ReadyChecker_IsReady_Pod(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -59,7 +59,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { name: "IsReady Pod", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -75,7 +75,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { name: "IsReady Pod returns error", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -115,7 +115,7 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { func Test_ReadyChecker_IsReady_Job(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -135,7 +135,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { name: "IsReady Job error while getting job", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -151,7 +151,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { name: "IsReady Job", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -190,7 +190,7 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -211,7 +211,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { name: "IsReady Deployments error while getting current Deployment", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -228,7 +228,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { name: "IsReady Deployments", //TODO fix this one fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -272,7 +272,7 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -292,7 +292,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { name: "IsReady PersistentVolumeClaim", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -308,7 +308,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { name: "IsReady PersistentVolumeClaim with error", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -347,7 +347,7 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { func Test_ReadyChecker_IsReady_Service(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -367,7 +367,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { name: "IsReady Service", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -383,7 +383,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { name: "IsReady Service with error", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -422,7 +422,7 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -442,7 +442,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { name: "IsReady DaemonSet", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -458,7 +458,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { name: "IsReady DaemonSet with error", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -497,7 +497,7 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -517,7 +517,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { name: "IsReady StatefulSet", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -533,7 +533,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { name: "IsReady StatefulSet with error", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -572,7 +572,7 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -592,7 +592,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { name: "IsReady ReplicationController", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -608,7 +608,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { name: "IsReady ReplicationController with error", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -624,7 +624,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { name: "IsReady ReplicationController and pods not ready for object", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -663,7 +663,7 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { type fields struct { client kubernetes.Interface - log logadapter.Logger + log *slog.Logger checkJobs bool pausedAsReady bool } @@ -683,7 +683,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { name: "IsReady ReplicaSet", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -699,7 +699,7 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { name: "IsReady ReplicaSet not ready", fields: fields{ client: fake.NewClientset(), - log: func(string, ...interface{}) {}, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index 22242b40f..bcb48155b 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "log/slog" "sort" "time" @@ -42,7 +43,7 @@ import ( type statusWaiter struct { client dynamic.Interface restMapper meta.RESTMapper - log func(string, ...interface{}) + log *slog.Logger } func alwaysReady(_ *unstructured.Unstructured) (*status.Result, error) { @@ -55,7 +56,7 @@ func alwaysReady(_ *unstructured.Unstructured) (*status.Result, error) { func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - w.log("waiting for %d pods and jobs to complete with a timeout of %s", len(resourceList), timeout) + w.log.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) jobSR := helmStatusReaders.NewCustomJobStatusReader(w.restMapper) podSR := helmStatusReaders.NewCustomPodStatusReader(w.restMapper) @@ -76,7 +77,7 @@ func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.D func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() - w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) + w.log.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) return w.wait(ctx, resourceList, sw) } @@ -84,7 +85,7 @@ func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) er func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() - w.log("beginning wait for %d resources with timeout of %s", len(resourceList), timeout) + w.log.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) newCustomJobStatusReader := helmStatusReaders.NewCustomJobStatusReader(w.restMapper) customSR := statusreaders.NewStatusReader(w.restMapper, newCustomJobStatusReader) @@ -95,7 +96,7 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() - w.log("beginning wait for %d resources to be deleted with timeout of %s", len(resourceList), timeout) + w.log.Debug("waiting for resources to be deleted", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) return w.waitForDelete(ctx, resourceList, sw) } @@ -179,7 +180,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw w return nil } -func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func(string, ...interface{})) collector.ObserverFunc { +func statusObserver(cancel context.CancelFunc, desired status.Status, logger *slog.Logger) collector.ObserverFunc { return func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { var rss []*event.ResourceStatus var nonDesiredResources []*event.ResourceStatus @@ -209,8 +210,7 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logFn func return nonDesiredResources[i].Identifier.Name < nonDesiredResources[j].Identifier.Name }) first := nonDesiredResources[0] - logFn("waiting for resource: name: %s, kind: %s, desired status: %s, actual status: %s \n", - first.Identifier.Name, first.Identifier.GroupKind.Kind, desired, first.Status) + logger.Debug("waiting for resource", "name", first.Identifier.Name, "kind", first.Identifier.GroupKind.Kind, "expectedStatus", desired, "actualStatus", first.Status) } } } diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index fee325ddc..7226058c4 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -18,6 +18,8 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "errors" + "io" + "log/slog" "testing" "time" @@ -217,7 +219,7 @@ func TestStatusWaitForDelete(t *testing.T) { statusWaiter := statusWaiter{ restMapper: fakeMapper, client: fakeClient, - log: t.Logf, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objsToCreate := getRuntimeObjFromManifests(t, tt.manifestsToCreate) for _, objToCreate := range objsToCreate { @@ -258,7 +260,7 @@ func TestStatusWaitForDeleteNonExistentObject(t *testing.T) { statusWaiter := statusWaiter{ restMapper: fakeMapper, client: fakeClient, - log: t.Logf, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), } // Don't create the object to test that the wait for delete works when the object doesn't exist objManifest := getRuntimeObjFromManifests(t, []string{podCurrentManifest}) @@ -317,7 +319,7 @@ func TestStatusWait(t *testing.T) { statusWaiter := statusWaiter{ client: fakeClient, restMapper: fakeMapper, - log: t.Logf, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { @@ -371,7 +373,7 @@ func TestWaitForJobComplete(t *testing.T) { statusWaiter := statusWaiter{ client: fakeClient, restMapper: fakeMapper, - log: t.Logf, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { @@ -431,7 +433,7 @@ func TestWatchForReady(t *testing.T) { statusWaiter := statusWaiter{ client: fakeClient, restMapper: fakeMapper, - log: t.Logf, + log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index e3d29d8a9..0751a7217 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -44,15 +44,13 @@ import ( watchtools "k8s.io/client-go/tools/watch" "k8s.io/apimachinery/pkg/util/wait" - - logadapter "helm.sh/helm/v4/internal/log" ) // legacyWaiter is the legacy implementation of the Waiter interface. This logic was used by default in Helm 3 // Helm 4 now uses the StatusWaiter implementation instead type legacyWaiter struct { c ReadyChecker - log func(string, ...interface{}) + log *slog.Logger kubeClient *kubernetes.Clientset } @@ -69,7 +67,7 @@ func (hw *legacyWaiter) WaitWithJobs(resources ResourceList, timeout time.Durati // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached func (hw *legacyWaiter) waitForResources(created ResourceList, timeout time.Duration) error { - hw.log("beginning wait for %d resources with timeout of %v", len(created), timeout) + hw.log.Debug("beginning wait for resources", "count", len(created), "timeout", timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() @@ -87,10 +85,10 @@ func (hw *legacyWaiter) waitForResources(created ResourceList, timeout time.Dura if waitRetries > 0 && hw.isRetryableError(err, v) { numberOfErrors[i]++ if numberOfErrors[i] > waitRetries { - hw.log("Max number of retries reached") + hw.log.Debug("max number of retries reached", "resource", v.Name, "retries", numberOfErrors[i]) return false, err } - hw.log("Retrying as current number of retries %d less than max number of retries %d", numberOfErrors[i]-1, waitRetries) + hw.log.Debug("retrying resource readiness", "resource", v.Name, "currentRetries", numberOfErrors[i]-1, "maxRetries", waitRetries) return false, nil } numberOfErrors[i] = 0 @@ -106,14 +104,14 @@ func (hw *legacyWaiter) isRetryableError(err error, resource *resource.Info) boo if err == nil { return false } - hw.log("Error received when checking status of resource %s. Error: '%s', Resource details: '%s'", resource.Name, err, resource) + hw.log.Debug("error received when checking resource status", "resource", resource.Name, "error", err) if ev, ok := err.(*apierrors.StatusError); ok { statusCode := ev.Status().Code retryable := hw.isRetryableHTTPStatusCode(statusCode) - hw.log("Status code received: %d. Retryable error? %t", statusCode, retryable) + hw.log.Debug("status code received", "resource", resource.Name, "statusCode", statusCode, "retryable", retryable) return retryable } - hw.log("Retryable error? %t", true) + hw.log.Debug("retryable error assumed", "resource", resource.Name) return true } @@ -123,7 +121,7 @@ func (hw *legacyWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { - slog.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", timeout) + hw.log.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", timeout) startTime := time.Now() ctx, cancel := context.WithTimeout(context.Background(), timeout) @@ -141,9 +139,9 @@ func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duratio elapsed := time.Since(startTime).Round(time.Second) if err != nil { - slog.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err)) + hw.log.Debug("wait for resources failed", "elapsed", elapsed, "error", err) } else { - slog.Debug("wait for resources succeeded", "elapsed", elapsed) + hw.log.Debug("wait for resources succeeded", "elapsed", elapsed) } return err @@ -251,7 +249,7 @@ func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.In return nil } - hw.log("Watching for changes to %s %s with timeout of %v", kind, info.Name, timeout) + hw.log.Debug("watching for resource changes", "kind", kind, "resource", info.Name, "timeout", timeout) // Use a selector on the name of the resource. This should be unique for the // given version and kind @@ -279,7 +277,8 @@ func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.In // we get. We care mostly about jobs, where what we want to see is // the status go into a good state. For other types, like ReplicaSet // we don't really do anything to support these as hooks. - hw.log("Add/Modify event for %s: %v", info.Name, e.Type) + hw.log.Debug("add/modify event received", "resource", info.Name, "eventType", e.Type) + switch kind { case "Job": return hw.waitForJob(obj, info.Name) @@ -288,11 +287,11 @@ func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.In } return true, nil case watch.Deleted: - hw.log("Deleted event for %s", info.Name) + hw.log.Debug("deleted event received", "resource", info.Name) return true, nil case watch.Error: // Handle error and return with an error. - hw.log("Error event for %s", info.Name) + hw.log.Error("error event received", "resource", info.Name) return true, errors.Errorf("failed to deploy %s", info.Name) default: return false, nil @@ -314,11 +313,12 @@ func (hw *legacyWaiter) waitForJob(obj runtime.Object, name string) (bool, error if c.Type == batchv1.JobComplete && c.Status == "True" { return true, nil } else if c.Type == batchv1.JobFailed && c.Status == "True" { + hw.log.Error("job failed", "job", name, "reason", c.Reason) return true, errors.Errorf("job %s failed: %s", name, c.Reason) } } - hw.log("%s: Jobs active: %d, jobs failed: %d, jobs succeeded: %d", name, o.Status.Active, o.Status.Failed, o.Status.Succeeded) + hw.log.Debug("job status update", "job", name, "active", o.Status.Active, "failed", o.Status.Failed, "succeeded", o.Status.Succeeded) return false, nil } @@ -333,14 +333,15 @@ func (hw *legacyWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool switch o.Status.Phase { case corev1.PodSucceeded: - hw.log("Pod %s succeeded", o.Name) + hw.log.Debug("pod succeeded", "pod", o.Name) return true, nil case corev1.PodFailed: + hw.log.Error("pod failed", "pod", o.Name) return true, errors.Errorf("pod %s failed", o.Name) case corev1.PodPending: - hw.log("Pod %s pending", o.Name) + hw.log.Debug("pod pending", "pod", o.Name) case corev1.PodRunning: - hw.log("Pod %s running", o.Name) + hw.log.Debug("pod running", "pod", o.Name) } return false, nil diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 421d39ba8..83715ac01 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -19,6 +19,7 @@ package driver // import "helm.sh/helm/v4/pkg/storage/driver" import ( "context" "fmt" + "log/slog" "strconv" "strings" "time" @@ -31,7 +32,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -44,7 +44,7 @@ const ConfigMapsDriverName = "ConfigMap" // ConfigMapsInterface. type ConfigMaps struct { impl corev1.ConfigMapInterface - Log logadapter.Logger + Log *slog.Logger } // NewConfigMaps initializes a new ConfigMaps wrapping an implementation of diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index c592ee634..b5bf08bf4 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -19,6 +19,8 @@ package driver // import "helm.sh/helm/v4/pkg/storage/driver" import ( "context" "fmt" + "io" + "log/slog" "testing" sqlmock "github.com/DATA-DOG/go-sqlmock" @@ -31,7 +33,6 @@ import ( kblabels "k8s.io/apimachinery/pkg/labels" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -265,6 +266,6 @@ func newTestFixtureSQL(t *testing.T, _ ...*rspb.Release) (*SQL, sqlmock.Sqlmock) db: sqlxDB, namespace: "default", statementBuilder: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), - Log: logadapter.DefaultLogger, + Log: slog.New(slog.NewTextHandler(io.Discard, nil)), }, mock } diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index bd1edcae1..af6e8591e 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -19,6 +19,7 @@ package driver // import "helm.sh/helm/v4/pkg/storage/driver" import ( "context" "fmt" + "log/slog" "strconv" "strings" "time" @@ -31,7 +32,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -44,7 +44,7 @@ const SecretsDriverName = "Secret" // SecretsInterface. type Secrets struct { impl corev1.SecretInterface - Log logadapter.Logger + Log *slog.Logger } // NewSecrets initializes a new Secrets wrapping an implementation of @@ -96,7 +96,7 @@ func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log.Debug("list: failed to decode release: %v: %s", item, err) + secrets.Log.Debug("list failed to decode release", "key", item.Name, "error", err) continue } @@ -135,7 +135,7 @@ func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error) for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log.Debug("query: failed to decode release: %s", err) + secrets.Log.Debug("failed to decode release", "key", item.Name, "error", err) continue } rls.Labels = item.ObjectMeta.Labels diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index 9a4188d2d..7ba317593 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -18,6 +18,7 @@ package driver // import "helm.sh/helm/v4/pkg/storage/driver" import ( "fmt" + "log/slog" "sort" "strconv" "time" @@ -30,7 +31,6 @@ import ( // Import pq for postgres dialect _ "github.com/lib/pq" - logadapter "helm.sh/helm/v4/internal/log" rspb "helm.sh/helm/v4/pkg/release/v1" ) @@ -88,7 +88,7 @@ type SQL struct { namespace string statementBuilder sq.StatementBuilderType - Log logadapter.Logger + Log *slog.Logger } // Name returns the name of the driver. @@ -277,7 +277,7 @@ type SQLReleaseCustomLabelWrapper struct { } // NewSQL initializes a new sql driver. -func NewSQL(connectionString string, logger logadapter.Logger, namespace string) (*SQL, error) { +func NewSQL(connectionString string, logger *slog.Logger, namespace string) (*SQL, error) { db, err := sqlx.Connect(postgreSQLDialect, connectionString) if err != nil { return nil, err From 83a5a14826894232bdf033fa40a1e996f00e5b86 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 16:47:26 +0200 Subject: [PATCH 242/271] Properly discard by default logs Signed-off-by: Benoit Tigeot --- internal/monocular/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/monocular/client.go b/internal/monocular/client.go index f4c9debca..452bc36e4 100644 --- a/internal/monocular/client.go +++ b/internal/monocular/client.go @@ -18,6 +18,7 @@ package monocular import ( "errors" + "io" "log/slog" "net/url" ) @@ -44,7 +45,7 @@ func New(u string) (*Client, error) { return &Client{ BaseURL: u, - Log: slog.Default(), + Log: slog.New(slog.NewTextHandler(io.Discard, nil)), }, nil } From b6adbbb227cfe5a097072eef37d4ef13d98000db Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 16:50:00 +0200 Subject: [PATCH 243/271] Enforce error style with others Signed-off-by: Benoit Tigeot --- pkg/action/action.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 1993e6241..1996e0ff8 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -244,9 +244,6 @@ type RESTClientGetter interface { ToRESTMapper() (meta.RESTMapper, error) } -// DebugLog sets the logger that writes debug strings -type DebugLog func(format string, v ...interface{}) - // capabilities builds a Capabilities from discovery information. func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { if cfg.Capabilities != nil { @@ -270,8 +267,8 @@ func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { apiVersions, err := GetVersionSet(dc) if err != nil { if discovery.IsGroupDiscoveryFailedError(err) { - cfg.Log.Warn("The Kubernetes server has an orphaned API service. Server reports: %s", err) - cfg.Log.Warn("To fix this, kubectl delete apiservice ") + cfg.Log.Warn("the kubernetes server has an orphaned API service", "errors", err) + cfg.Log.Warn("to fix this, kubectl delete apiservice ") } else { return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") } @@ -370,7 +367,7 @@ func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.Version // recordRelease with an update operation in case reuse has been set. func (cfg *Configuration) recordRelease(r *release.Release) { if err := cfg.Releases.Update(r); err != nil { - cfg.Log.Warn("Failed to update release %s: %s", r.Name, err) + cfg.Log.Warn("failed to update release", "name", r.Name, "revision", r.Version, "error", err) } } From baa597c5671f7b9f20a2ad204b762e36f1c05bdc Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 17:02:18 +0200 Subject: [PATCH 244/271] Do not remove the functionality to print log in test Signed-off-by: Benoit Tigeot --- pkg/action/action_test.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index ee32246af..815d1a0c8 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -16,9 +16,11 @@ limitations under the License. package action import ( + "flag" "fmt" "io" "log/slog" + "os" "testing" "github.com/stretchr/testify/assert" @@ -37,6 +39,24 @@ import ( func actionConfigFixture(t *testing.T) *Configuration { t.Helper() + var verbose = flag.Bool("test.log", false, "enable test logging (debug by default)") + + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + if *verbose { + // Create a handler that removes timestamps + handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + Level: slog.LevelDebug, + ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + // Remove the time attribute + if a.Key == slog.TimeKey { + return slog.Attr{} + } + return a + }, + }) + logger = slog.New(handler) + } + registryClient, err := registry.NewClient() if err != nil { t.Fatal(err) @@ -47,7 +67,7 @@ func actionConfigFixture(t *testing.T) *Configuration { KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}}, Capabilities: chartutil.DefaultCapabilities, RegistryClient: registryClient, - Log: slog.New(slog.NewTextHandler(io.Discard, nil)), // TODO: permit to log in test as before with `var verbose = flag.Bool("test.log", false, "enable test logging")`` + Log: logger, } } From 5580f6115767de0bd33e61dda18cef45ef661a5e Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 17:32:36 +0200 Subject: [PATCH 245/271] Properly reproduce the nopLogger as before Signed-off-by: Benoit Tigeot --- pkg/kube/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index be5214431..b38e12693 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -163,7 +163,7 @@ func New(getter genericclioptions.RESTClientGetter) *Client { factory := cmdutil.NewFactory(getter) c := &Client{ Factory: factory, - Log: slog.Default(), + Log: slog.New(slog.NewTextHandler(io.Discard, nil)), } return c } From 6ce967391d6a0264d0b41d05776d32974f057c7d Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 17:33:14 +0200 Subject: [PATCH 246/271] Trick slog to return the full error Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 9bdd8e98c..39d89b034 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -17,6 +17,7 @@ limitations under the License. package main // import "helm.sh/helm/v4/cmd/helm" import ( + "fmt" "log" "os" @@ -40,7 +41,7 @@ func main() { cmd, err := helmcmd.NewRootCmd(os.Stdout, os.Args[1:]) if err != nil { - helmcmd.Logger.Warn("%+v", err) + helmcmd.Logger.Warn(fmt.Sprintf("%+v", err)) os.Exit(1) } From 3e4e78378e77601dedf0751260e0996ff1265c6e Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 17:35:35 +0200 Subject: [PATCH 247/271] Go the slog way Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 39d89b034..c2605f377 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -17,8 +17,8 @@ limitations under the License. package main // import "helm.sh/helm/v4/cmd/helm" import ( - "fmt" "log" + "log/slog" "os" // Import to initialize client auth plugins. @@ -41,7 +41,7 @@ func main() { cmd, err := helmcmd.NewRootCmd(os.Stdout, os.Args[1:]) if err != nil { - helmcmd.Logger.Warn(fmt.Sprintf("%+v", err)) + helmcmd.Logger.Warn("command failed", slog.Any("error", err)) os.Exit(1) } From 710770eed4ffa97c1d29e34e6f661d0ab5ef4cd1 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 17:46:13 +0200 Subject: [PATCH 248/271] Linting Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 2 +- pkg/action/action_test.go | 2 +- pkg/cli/logger.go | 2 +- pkg/cmd/plugin_list.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index c2605f377..11c5e8769 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -46,7 +46,7 @@ func main() { } if err := cmd.Execute(); err != nil { - helmcmd.Logger.Debug("error", err) + helmcmd.Logger.Debug("error", slog.Any("error", err)) switch e := err.(type) { case helmcmd.PluginError: os.Exit(e.Code) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 815d1a0c8..c770f3920 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -46,7 +46,7 @@ func actionConfigFixture(t *testing.T) *Configuration { // Create a handler that removes timestamps handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ Level: slog.LevelDebug, - ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { // Remove the time attribute if a.Key == slog.TimeKey { return slog.Attr{} diff --git a/pkg/cli/logger.go b/pkg/cli/logger.go index 243284d76..d75622c37 100644 --- a/pkg/cli/logger.go +++ b/pkg/cli/logger.go @@ -30,7 +30,7 @@ func NewLogger(debug bool) *slog.Logger { // Create a handler that removes timestamps handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ Level: level, - ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { // Remove the time attribute if a.Key == slog.TimeKey { return slog.Attr{} diff --git a/pkg/cmd/plugin_list.go b/pkg/cmd/plugin_list.go index 3a1d0f2f5..52aefe8ef 100644 --- a/pkg/cmd/plugin_list.go +++ b/pkg/cmd/plugin_list.go @@ -32,7 +32,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command { Short: "list installed Helm plugins", ValidArgsFunction: noMoreArgsCompFunc, RunE: func(_ *cobra.Command, _ []string) error { - Logger.Debug("pluginDirs", settings.PluginsDirectory) + Logger.Debug("pluginDirs", "directory", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err From 5c746037b3ee8c5e23ce3932a31c942938a8b3a5 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 18:01:42 +0200 Subject: [PATCH 249/271] Prevent redefining verbose flags Signed-off-by: Benoit Tigeot --- pkg/action/action_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index c770f3920..ee967714c 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -36,11 +36,11 @@ import ( "helm.sh/helm/v4/pkg/time" ) +var verbose = flag.Bool("test.log", false, "enable test logging (debug by default)") + func actionConfigFixture(t *testing.T) *Configuration { t.Helper() - var verbose = flag.Bool("test.log", false, "enable test logging (debug by default)") - logger := slog.New(slog.NewTextHandler(io.Discard, nil)) if *verbose { // Create a handler that removes timestamps From 0c85456788dcc1f87ace736e208fe8008189bb21 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 7 Apr 2025 18:25:16 +0200 Subject: [PATCH 250/271] Leverage slog.Any for errors Signed-off-by: Benoit Tigeot --- pkg/action/action.go | 2 +- pkg/action/install.go | 7 ++-- pkg/action/uninstall.go | 5 +-- pkg/action/upgrade.go | 3 +- pkg/chart/v2/util/dependencies.go | 2 +- pkg/cmd/search_hub.go | 3 +- pkg/cmd/search_repo.go | 3 +- pkg/engine/lookup_func.go | 4 +-- pkg/ignore/rules.go | 6 ++-- pkg/kube/client.go | 12 +++---- pkg/kube/wait.go | 4 +-- pkg/storage/driver/cfgmaps.go | 20 +++++------ pkg/storage/driver/secrets.go | 4 +-- pkg/storage/driver/sql.go | 60 +++++++++++++++---------------- 14 files changed, 70 insertions(+), 65 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 1996e0ff8..d4f917b9f 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -367,7 +367,7 @@ func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.Version // recordRelease with an update operation in case reuse has been set. func (cfg *Configuration) recordRelease(r *release.Release) { if err := cfg.Releases.Update(r); err != nil { - cfg.Log.Warn("failed to update release", "name", r.Name, "revision", r.Version, "error", err) + cfg.Log.Warn("failed to update release", "name", r.Name, "revision", r.Version, slog.Any("error", err)) } } diff --git a/pkg/action/install.go b/pkg/action/install.go index 8b749b777..3f16969ae 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -21,6 +21,7 @@ import ( "context" "fmt" "io" + "log/slog" "net/url" "os" "path" @@ -249,12 +250,12 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma } if err := i.availableName(); err != nil { - i.cfg.Log.Error("release name check failed", "error", err) + i.cfg.Log.Error("release name check failed", slog.Any("error", err)) return nil, errors.Wrap(err, "release name check failed") } if err := chartutil.ProcessDependencies(chrt, vals); err != nil { - i.cfg.Log.Error("chart dependencies processing failed", "error", err) + i.cfg.Log.Error("chart dependencies processing failed", slog.Any("error", err)) return nil, errors.Wrap(err, "chart dependencies processing failed") } @@ -505,7 +506,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource // One possible strategy would be to do a timed retry to see if we can get // this stored in the future. if err := i.recordRelease(rel); err != nil { - i.cfg.Log.Error("failed to record the release", "error", err) + i.cfg.Log.Error("failed to record the release", slog.Any("error", err)) } return rel, nil diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 4e959172c..c3835042f 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -17,6 +17,7 @@ limitations under the License. package action import ( + "log/slog" "strings" "time" @@ -121,7 +122,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) // From here on out, the release is currently considered to be in StatusUninstalling // state. if err := u.cfg.Releases.Update(rel); err != nil { - u.cfg.Log.Debug("uninstall: Failed to store updated release", "error", err) + u.cfg.Log.Debug("uninstall: Failed to store updated release", slog.Any("error", err)) } deletedResources, kept, errs := u.deleteRelease(rel) @@ -168,7 +169,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } if err := u.cfg.Releases.Update(rel); err != nil { - u.cfg.Log.Debug("uninstall: Failed to store updated release", "error", err) + u.cfg.Log.Debug("uninstall: Failed to store updated release", slog.Any("error", err)) } if len(errs) > 0 { diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 147c0fe5a..429bac9d7 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -20,6 +20,7 @@ import ( "bytes" "context" "fmt" + "log/slog" "strings" "sync" "time" @@ -486,7 +487,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, err error) (*release.Release, error) { msg := fmt.Sprintf("Upgrade %q failed: %s", rel.Name, err) - u.cfg.Log.Warn("upgrade failed", "name", rel.Name, "error", err) + u.cfg.Log.Warn("upgrade failed", "name", rel.Name, slog.Any("error", err)) rel.Info.Status = release.StatusFailed rel.Info.Description = msg diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 72a08b2a9..b7f78010b 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Warn("ImportValues missing table from chart", "chart", r.Name, "error", err) + slog.Warn("ImportValues missing table from chart", "chart", r.Name, slog.Any("error", err)) continue } // create value map from child to be merged into parent diff --git a/pkg/cmd/search_hub.go b/pkg/cmd/search_hub.go index 1a2848b25..6aa5c10bd 100644 --- a/pkg/cmd/search_hub.go +++ b/pkg/cmd/search_hub.go @@ -19,6 +19,7 @@ package cmd import ( "fmt" "io" + "log/slog" "strings" "github.com/gosuri/uitable" @@ -89,7 +90,7 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error { q := strings.Join(args, " ") results, err := c.Search(q) if err != nil { - Logger.Debug("search failed", "error", err) + Logger.Debug("search failed", slog.Any("error", err)) return fmt.Errorf("unable to perform search against %q", o.searchEndpoint) } diff --git a/pkg/cmd/search_repo.go b/pkg/cmd/search_repo.go index a6aa755cd..850bcbe16 100644 --- a/pkg/cmd/search_repo.go +++ b/pkg/cmd/search_repo.go @@ -21,6 +21,7 @@ import ( "bytes" "fmt" "io" + "log/slog" "os" "path/filepath" "strings" @@ -189,7 +190,7 @@ func (o *searchRepoOptions) buildIndex() (*search.Index, error) { f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n)) ind, err := repo.LoadIndexFile(f) if err != nil { - Logger.Warn("repo is corrupt or missing", "repo", n, "error", err) + Logger.Warn("repo is corrupt or missing", "repo", n, slog.Any("error", err)) continue } diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index b7460850a..d7267f786 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,7 +101,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("unable to get apiresource", "groupVersionKind", gvk.String(), "error", err) + slog.Error("unable to get apiresource", "groupVersionKind", gvk.String(), slog.Any("error", err)) return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ @@ -127,7 +127,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("unable to retrieve resource list", "GroupVersion", gvk.GroupVersion().String(), "error", err) + slog.Error("unable to retrieve resource list", "GroupVersion", gvk.GroupVersion().String(), slog.Any("error", err)) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 3f672873c..02a3777ff 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile", "rule", rule, "error", err) + slog.Error("failed to compile", "rule", rule, slog.Any("error", err)) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile", "rule", rule, "error", err) + slog.Error("failed to compile", "rule", rule, slog.Any("error", err)) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile", "rule", rule, "error", err) + slog.Error("failed to compile", "rule", rule, slog.Any("error", err)) return false } return ok diff --git a/pkg/kube/client.go b/pkg/kube/client.go index b38e12693..bd4dbea91 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -249,7 +249,7 @@ func (c *Client) Get(resources ResourceList, related bool) (map[string][]runtime objs, err = c.getSelectRelationPod(info, objs, isTable, &podSelectors) if err != nil { - c.Log.Warn("get the relation pod is failed", "error", err) + c.Log.Warn("get the relation pod is failed", slog.Any("error", err)) } } } @@ -441,7 +441,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } if err := updateResource(c, info, originalInfo.Object, force); err != nil { - c.Log.Debug("error updating the resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) + c.Log.Debug("error updating the resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) updateErrors = append(updateErrors, err.Error()) } // Because we check for errors later, append the info regardless @@ -461,19 +461,19 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err c.Log.Debug("deleting resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) if err := info.Get(); err != nil { - c.Log.Debug("unable to get object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) + c.Log.Debug("unable to get object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) continue } annotations, err := metadataAccessor.Annotations(info.Object) if err != nil { - c.Log.Debug("unable to get annotations", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) + c.Log.Debug("unable to get annotations", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) } if annotations != nil && annotations[ResourcePolicyAnno] == KeepPolicy { c.Log.Debug("skipping delete due to annotation", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "annotation", ResourcePolicyAnno, "value", KeepPolicy) continue } if err := deleteResource(info, metav1.DeletePropagationBackground); err != nil { - c.Log.Debug("failed to delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) + c.Log.Debug("failed to delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) continue } res.Deleted = append(res.Deleted, info) @@ -506,7 +506,7 @@ func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropa err := deleteResource(info, propagation) if err == nil || apierrors.IsNotFound(err) { if err != nil { - c.Log.Debug("ignoring delete failure", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "error", err) + c.Log.Debug("ignoring delete failure", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) } mtx.Lock() defer mtx.Unlock() diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 0751a7217..75598542e 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -104,7 +104,7 @@ func (hw *legacyWaiter) isRetryableError(err error, resource *resource.Info) boo if err == nil { return false } - hw.log.Debug("error received when checking resource status", "resource", resource.Name, "error", err) + hw.log.Debug("error received when checking resource status", "resource", resource.Name, slog.Any("error", err)) if ev, ok := err.(*apierrors.StatusError); ok { statusCode := ev.Status().Code retryable := hw.isRetryableHTTPStatusCode(statusCode) @@ -139,7 +139,7 @@ func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duratio elapsed := time.Since(startTime).Round(time.Second) if err != nil { - hw.log.Debug("wait for resources failed", "elapsed", elapsed, "error", err) + hw.log.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err)) } else { hw.log.Debug("wait for resources succeeded", "elapsed", elapsed) } diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 83715ac01..dba9a138d 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -70,13 +70,13 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) { return nil, ErrReleaseNotFound } - cfgmaps.Log.Debug("failed to get release", "key", key, "error", err) + cfgmaps.Log.Debug("failed to get release", "key", key, slog.Any("error", err)) return nil, err } // found the configmap, decode the base64 data string r, err := decodeRelease(obj.Data["release"]) if err != nil { - cfgmaps.Log.Debug("failed to decode data", "key", key, "error", err) + cfgmaps.Log.Debug("failed to decode data", "key", key, slog.Any("error", err)) return nil, err } r.Labels = filterSystemLabels(obj.ObjectMeta.Labels) @@ -93,7 +93,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas list, err := cfgmaps.impl.List(context.Background(), opts) if err != nil { - cfgmaps.Log.Debug("failed to list releases", "error", err) + cfgmaps.Log.Debug("failed to list releases", slog.Any("error", err)) return nil, err } @@ -104,7 +104,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas for _, item := range list.Items { rls, err := decodeRelease(item.Data["release"]) if err != nil { - cfgmaps.Log.Debug("failed to decode release", "item", item, "error", err) + cfgmaps.Log.Debug("failed to decode release", "item", item, slog.Any("error", err)) continue } @@ -132,7 +132,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err list, err := cfgmaps.impl.List(context.Background(), opts) if err != nil { - cfgmaps.Log.Debug("failed to query with labels", "error", err) + cfgmaps.Log.Debug("failed to query with labels", slog.Any("error", err)) return nil, err } @@ -144,7 +144,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err for _, item := range list.Items { rls, err := decodeRelease(item.Data["release"]) if err != nil { - cfgmaps.Log.Debug("failed to decode release", "error", err) + cfgmaps.Log.Debug("failed to decode release", slog.Any("error", err)) continue } rls.Labels = item.ObjectMeta.Labels @@ -166,7 +166,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error { // create a new configmap to hold the release obj, err := newConfigMapsObject(key, rls, lbs) if err != nil { - cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, "error", err) + cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, slog.Any("error", err)) return err } // push the configmap object out into the kubiverse @@ -175,7 +175,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error { return ErrReleaseExists } - cfgmaps.Log.Debug("failed to create release", "error", err) + cfgmaps.Log.Debug("failed to create release", slog.Any("error", err)) return err } return nil @@ -194,13 +194,13 @@ func (cfgmaps *ConfigMaps) Update(key string, rls *rspb.Release) error { // create a new configmap object to hold the release obj, err := newConfigMapsObject(key, rls, lbs) if err != nil { - cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, "error", err) + cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, slog.Any("error", err)) return err } // push the configmap object out into the kubiverse _, err = cfgmaps.impl.Update(context.Background(), obj, metav1.UpdateOptions{}) if err != nil { - cfgmaps.Log.Debug("failed to update release", "error", err) + cfgmaps.Log.Debug("failed to update release", slog.Any("error", err)) return err } return nil diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index af6e8591e..5045774e6 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -96,7 +96,7 @@ func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log.Debug("list failed to decode release", "key", item.Name, "error", err) + secrets.Log.Debug("list failed to decode release", "key", item.Name, slog.Any("error", err)) continue } @@ -135,7 +135,7 @@ func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error) for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log.Debug("failed to decode release", "key", item.Name, "error", err) + secrets.Log.Debug("failed to decode release", "key", item.Name, slog.Any("error", err)) continue } rls.Labels = item.ObjectMeta.Labels diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index 7ba317593..9f54de7f8 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -109,7 +109,7 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool { records, err := migrate.GetMigrationRecords(s.db.DB, postgreSQLDialect) migrate.SetDisableCreateTable(false) if err != nil { - s.Log.Debug("failed to get migration records", "error", err) + s.Log.Debug("failed to get migration records", slog.Any("error", err)) return false } @@ -310,24 +310,24 @@ func (s *SQL) Get(key string) (*rspb.Release, error) { query, args, err := qb.ToSql() if err != nil { - s.Log.Debug("failed to build query", "error", err) + s.Log.Debug("failed to build query", slog.Any("error", err)) return nil, err } // Get will return an error if the result is empty if err := s.db.Get(&record, query, args...); err != nil { - s.Log.Debug("got SQL error when getting release", "key", key, "error", err) + s.Log.Debug("got SQL error when getting release", "key", key, slog.Any("error", err)) return nil, ErrReleaseNotFound } release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode data", "key", key, "error", err) + s.Log.Debug("failed to decode data", "key", key, slog.Any("error", err)) return nil, err } if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, "error", err) + s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, slog.Any("error", err)) return nil, err } @@ -348,13 +348,13 @@ func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) { query, args, err := sb.ToSql() if err != nil { - s.Log.Debug("failed to build query", "error", err) + s.Log.Debug("failed to build query", slog.Any("error", err)) return nil, err } var records = []SQLReleaseWrapper{} if err := s.db.Select(&records, query, args...); err != nil { - s.Log.Debug("failed to list", "error", err) + s.Log.Debug("failed to list", slog.Any("error", err)) return nil, err } @@ -362,12 +362,12 @@ func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) { for _, record := range records { release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode release", "record", record, "error", err) + s.Log.Debug("failed to decode release", "record", record, slog.Any("error", err)) continue } if release.Labels, err = s.getReleaseCustomLabels(record.Key, record.Namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, "error", err) + s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, slog.Any("error", err)) return nil, err } for k, v := range getReleaseSystemLabels(release) { @@ -410,13 +410,13 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { // Build our query query, args, err := sb.ToSql() if err != nil { - s.Log.Debug("failed to build query", "error", err) + s.Log.Debug("failed to build query", slog.Any("error", err)) return nil, err } var records = []SQLReleaseWrapper{} if err := s.db.Select(&records, query, args...); err != nil { - s.Log.Debug("failed to query with labels", "error", err) + s.Log.Debug("failed to query with labels", slog.Any("error", err)) return nil, err } @@ -428,12 +428,12 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { for _, record := range records { release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode release", "record", record, "error", err) + s.Log.Debug("failed to decode release", "record", record, slog.Any("error", err)) continue } if release.Labels, err = s.getReleaseCustomLabels(record.Key, record.Namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, "error", err) + s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, slog.Any("error", err)) return nil, err } @@ -457,13 +457,13 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { body, err := encodeRelease(rls) if err != nil { - s.Log.Debug("failed to encode release", "error", err) + s.Log.Debug("failed to encode release", slog.Any("error", err)) return err } transaction, err := s.db.Beginx() if err != nil { - s.Log.Debug("failed to start SQL transaction", "error", err) + s.Log.Debug("failed to start SQL transaction", slog.Any("error", err)) return fmt.Errorf("error beginning transaction: %v", err) } @@ -492,7 +492,7 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { int(time.Now().Unix()), ).ToSql() if err != nil { - s.Log.Debug("failed to build insert query", "error", err) + s.Log.Debug("failed to build insert query", slog.Any("error", err)) return err } @@ -516,7 +516,7 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { return ErrReleaseExists } - s.Log.Debug("failed to store release in SQL database", "key", key, "error", err) + s.Log.Debug("failed to store release in SQL database", "key", key, slog.Any("error", err)) return err } @@ -539,13 +539,13 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { if err != nil { defer transaction.Rollback() - s.Log.Debug("failed to build insert query", "error", err) + s.Log.Debug("failed to build insert query", slog.Any("error", err)) return err } if _, err := transaction.Exec(insertLabelsQuery, args...); err != nil { defer transaction.Rollback() - s.Log.Debug("failed to write Labels", "error", err) + s.Log.Debug("failed to write Labels", slog.Any("error", err)) return err } } @@ -564,7 +564,7 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { body, err := encodeRelease(rls) if err != nil { - s.Log.Debug("failed to encode release", "error", err) + s.Log.Debug("failed to encode release", slog.Any("error", err)) return err } @@ -581,12 +581,12 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { ToSql() if err != nil { - s.Log.Debug("failed to build update query", "error", err) + s.Log.Debug("failed to build update query", slog.Any("error", err)) return err } if _, err := s.db.Exec(query, args...); err != nil { - s.Log.Debug("failed to update release in SQL database", "key", key, "error", err) + s.Log.Debug("failed to update release in SQL database", "key", key, slog.Any("error", err)) return err } @@ -597,7 +597,7 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { func (s *SQL) Delete(key string) (*rspb.Release, error) { transaction, err := s.db.Beginx() if err != nil { - s.Log.Debug("failed to start SQL transaction", "error", err) + s.Log.Debug("failed to start SQL transaction", slog.Any("error", err)) return nil, fmt.Errorf("error beginning transaction: %v", err) } @@ -608,20 +608,20 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if err != nil { - s.Log.Debug("failed to build select query", "error", err) + s.Log.Debug("failed to build select query", slog.Any("error", err)) return nil, err } var record SQLReleaseWrapper err = transaction.Get(&record, selectQuery, args...) if err != nil { - s.Log.Debug("release not found", "key", key, "error", err) + s.Log.Debug("release not found", "key", key, slog.Any("error", err)) return nil, ErrReleaseNotFound } release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode release", "key", key, "error", err) + s.Log.Debug("failed to decode release", "key", key, slog.Any("error", err)) transaction.Rollback() return nil, err } @@ -633,18 +633,18 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if err != nil { - s.Log.Debug("failed to build delete query", "error", err) + s.Log.Debug("failed to build delete query", slog.Any("error", err)) return nil, err } _, err = transaction.Exec(deleteQuery, args...) if err != nil { - s.Log.Debug("failed perform delete query", "error", err) + s.Log.Debug("failed perform delete query", slog.Any("error", err)) return release, err } if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, "error", err) + s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, slog.Any("error", err)) return nil, err } @@ -655,7 +655,7 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { ToSql() if err != nil { - s.Log.Debug("failed to build delete Labels query", "error", err) + s.Log.Debug("failed to build delete Labels query", slog.Any("error", err)) return nil, err } _, err = transaction.Exec(deleteCustomLabelsQuery, args...) From 0740dfc7a96d65420426bd4607439f5794093dc9 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 7 Apr 2025 13:40:29 -0400 Subject: [PATCH 251/271] Unarchiving fix Signed-off-by: Matt Farina --- pkg/chart/v2/loader/archive.go | 32 +++++++++++++++++++++++++++++++- pkg/chart/v2/loader/directory.go | 4 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/pkg/chart/v2/loader/archive.go b/pkg/chart/v2/loader/archive.go index cb6d3bfe8..655fe87fa 100644 --- a/pkg/chart/v2/loader/archive.go +++ b/pkg/chart/v2/loader/archive.go @@ -33,6 +33,15 @@ import ( chart "helm.sh/helm/v4/pkg/chart/v2" ) +// MaxDecompressedChartSize is the maximum size of a chart archive that will be +// decompressed. This is the decompressed size of all the files. +// The default value is 100 MiB. +var MaxDecompressedChartSize int64 = 100 * 1024 * 1024 // Default 100 MiB + +// MaxDecompressedFileSize is the size of the largest file that Helm will attempt to load. +// The size of the file is the decompressed version of it when it is stored in an archive. +var MaxDecompressedFileSize int64 = 5 * 1024 * 1024 // Default 5 MiB + var drivePathPattern = regexp.MustCompile(`^[a-zA-Z]:/`) // FileLoader loads a chart from a file @@ -119,6 +128,7 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) { files := []*BufferedFile{} tr := tar.NewReader(unzipped) + remainingSize := MaxDecompressedChartSize for { b := bytes.NewBuffer(nil) hd, err := tr.Next() @@ -178,10 +188,30 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) { return nil, errors.New("chart yaml not in base directory") } - if _, err := io.Copy(b, tr); err != nil { + if hd.Size > remainingSize { + return nil, fmt.Errorf("decompressed chart is larger than the maximum size %d", MaxDecompressedChartSize) + } + + if hd.Size > MaxDecompressedFileSize { + return nil, fmt.Errorf("decompressed chart file %q is larger than the maximum file size %d", hd.Name, MaxDecompressedFileSize) + } + + limitedReader := io.LimitReader(tr, remainingSize) + + bytesWritten, err := io.Copy(b, limitedReader) + if err != nil { return nil, err } + remainingSize -= bytesWritten + // When the bytesWritten are less than the file size it means the limit reader ended + // copying early. Here we report that error. This is important if the last file extracted + // is the one that goes over the limit. It assumes the Size stored in the tar header + // is correct, something many applications do. + if bytesWritten < hd.Size || remainingSize <= 0 { + return nil, fmt.Errorf("decompressed chart is larger than the maximum size %d", MaxDecompressedChartSize) + } + data := bytes.TrimPrefix(b.Bytes(), utf8bom) files = append(files, &BufferedFile{Name: n, Data: data}) diff --git a/pkg/chart/v2/loader/directory.go b/pkg/chart/v2/loader/directory.go index 37b24d3f9..dbf3eb882 100644 --- a/pkg/chart/v2/loader/directory.go +++ b/pkg/chart/v2/loader/directory.go @@ -101,6 +101,10 @@ func LoadDir(dir string) (*chart.Chart, error) { return fmt.Errorf("cannot load irregular file %s as it has file mode type bits set", name) } + if fi.Size() > MaxDecompressedFileSize { + return fmt.Errorf("chart file %q is larger than the maximum file size %d", fi.Name(), MaxDecompressedFileSize) + } + data, err := os.ReadFile(name) if err != nil { return errors.Wrapf(err, "error reading %s", n) From 9b636902c6136d8624a1798b3c02b593d8b8b58a Mon Sep 17 00:00:00 2001 From: zanuka Date: Fri, 21 Mar 2025 16:03:37 -0700 Subject: [PATCH 252/271] updates mutate and validate web hook configs Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter.go | 4 ++++ pkg/release/util/kind_sorter_test.go | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 22795733c..72f99e115 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -65,12 +65,16 @@ var InstallOrder KindSortOrder = []string{ "IngressClass", "Ingress", "APIService", + "MutatingWebhookConfiguration", + "ValidatingWebhookConfiguration", } // UninstallOrder is the order in which manifests should be uninstalled (by Kind). // // Those occurring earlier in the list get uninstalled before those occurring later in the list. var UninstallOrder KindSortOrder = []string{ + "ValidatingWebhookConfiguration", + "MutatingWebhookConfiguration", "APIService", "Ingress", "IngressClass", diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index 00d80ecf2..919de24e5 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -173,6 +173,14 @@ func TestKindSorter(t *testing.T) { Name: "F", Head: &SimpleHead{Kind: "PriorityClass"}, }, + { + Name: "M", + Head: &SimpleHead{Kind: "MutatingWebhookConfiguration"}, + }, + { + Name: "V", + Head: &SimpleHead{Kind: "ValidatingWebhookConfiguration"}, + }, } for _, test := range []struct { @@ -180,8 +188,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvw!"}, - {"uninstall", UninstallOrder, "wvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, + {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvwMV!"}, + {"uninstall", UninstallOrder, "VMwvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { From c121b6b83ee5a8c4439a347704fcc61032d2dbe6 Mon Sep 17 00:00:00 2001 From: Mike Delucchi Date: Fri, 28 Mar 2025 13:32:09 -0700 Subject: [PATCH 253/271] changes order of operations Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 72f99e115..27b44cc36 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -64,18 +64,18 @@ var InstallOrder KindSortOrder = []string{ "CronJob", "IngressClass", "Ingress", - "APIService", "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", + "APIService", } // UninstallOrder is the order in which manifests should be uninstalled (by Kind). // // Those occurring earlier in the list get uninstalled before those occurring later in the list. var UninstallOrder KindSortOrder = []string{ + "APIService", "ValidatingWebhookConfiguration", "MutatingWebhookConfiguration", - "APIService", "Ingress", "IngressClass", "Service", From 1003a3c93f42b47293f3e53cacc51e09bf59278a Mon Sep 17 00:00:00 2001 From: Mike Delucchi Date: Mon, 31 Mar 2025 12:24:56 -0700 Subject: [PATCH 254/271] fixes kind_sorter_test to match new order Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index 919de24e5..2a607ddd8 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -188,8 +188,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvwMV!"}, - {"uninstall", UninstallOrder, "VMwvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, + {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvMVw!"}, + {"uninstall", UninstallOrder, "wVMvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { From e1425f1aa56dbe1d51d40a721bb302707a7c9041 Mon Sep 17 00:00:00 2001 From: Mike Delucchi Date: Fri, 4 Apr 2025 10:44:42 -0700 Subject: [PATCH 255/271] fix: correct webhook order to match Kubernetes admission flow Place APIService before webhooks, with MutatingWebhookConfiguration before ValidatingWebhookConfiguration to match standard admission control. Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter.go | 5 +++-- pkg/release/util/kind_sorter_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 27b44cc36..bc074340f 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -64,18 +64,19 @@ var InstallOrder KindSortOrder = []string{ "CronJob", "IngressClass", "Ingress", + "APIService", "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", - "APIService", } // UninstallOrder is the order in which manifests should be uninstalled (by Kind). // // Those occurring earlier in the list get uninstalled before those occurring later in the list. var UninstallOrder KindSortOrder = []string{ - "APIService", + // For uninstall, we remove validation before mutation to ensure webhooks don't block removal "ValidatingWebhookConfiguration", "MutatingWebhookConfiguration", + "APIService", "Ingress", "IngressClass", "Service", diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index 2a607ddd8..919de24e5 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -188,8 +188,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvMVw!"}, - {"uninstall", UninstallOrder, "wVMvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, + {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvwMV!"}, + {"uninstall", UninstallOrder, "VMwvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { From b29bc3a44d9af174d2cde2370bb09af103fdb32c Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 9 Apr 2025 09:43:19 -0400 Subject: [PATCH 256/271] manually updating go.mod file Signed-off-by: Robert Sirchia --- go.mod | 2 +- go.sum | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index bfc55057a..66bb60fb3 100644 --- a/go.mod +++ b/go.mod @@ -129,7 +129,7 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 // indirect - github.com/redis/go-redis/v9 v9.1.0 // indirect + github.com/redis/go-redis/v9 v9.6.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect diff --git a/go.sum b/go.sum index 1153931d8..a0e23b98b 100644 --- a/go.sum +++ b/go.sum @@ -37,10 +37,11 @@ github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2y github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= -github.com/bsm/ginkgo/v2 v2.9.5 h1:rtVBYPs3+TC5iLUVOis1B9tjLTup7Cj5IfzosKtvTJ0= -github.com/bsm/ginkgo/v2 v2.9.5/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= -github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= +github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= +github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= +github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -288,8 +289,8 @@ github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5/go.mod h1:fyalQWdtzDBECAQFBJu github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb27yVE+gIAfeqp8LUCc= github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ= github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= -github.com/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY= -github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH1cY3lZl4c= +github.com/redis/go-redis/v9 v9.6.3 h1:8Dr5ygF1QFXRxIH/m3Xg9MMG1rS8YCtAgosrsewT6i0= +github.com/redis/go-redis/v9 v9.6.3/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rubenv/sql-migrate v1.7.1 h1:f/o0WgfO/GqNuVg+6801K/KW3WdDSupzSjDYODmiUq4= From db76da32aca573380a406beeac6a5deff66d68a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 15:18:18 +0000 Subject: [PATCH 257/271] build(deps): bump golang.org/x/crypto from 0.36.0 to 0.37.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.36.0 to 0.37.0. - [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.37.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 66bb60fb3..aef4a656d 100644 --- a/go.mod +++ b/go.mod @@ -33,9 +33,9 @@ require ( github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 github.com/xeipuuv/gojsonschema v1.2.0 - golang.org/x/crypto v0.36.0 - golang.org/x/term v0.30.0 - golang.org/x/text v0.23.0 + golang.org/x/crypto v0.37.0 + golang.org/x/term v0.31.0 + golang.org/x/text v0.24.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.32.3 k8s.io/apiextensions-apiserver v0.32.3 @@ -164,8 +164,8 @@ require ( golang.org/x/mod v0.22.0 // indirect golang.org/x/net v0.37.0 // indirect golang.org/x/oauth2 v0.25.0 // indirect - golang.org/x/sync v0.12.0 // indirect - golang.org/x/sys v0.31.0 // indirect + golang.org/x/sync v0.13.0 // indirect + golang.org/x/sys v0.32.0 // indirect golang.org/x/time v0.9.0 // indirect golang.org/x/tools v0.29.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect diff --git a/go.sum b/go.sum index a0e23b98b..456e1cfcf 100644 --- a/go.sum +++ b/go.sum @@ -394,8 +394,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -431,8 +431,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -454,8 +454,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -463,8 +463,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= -golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= -golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= +golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= +golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -472,8 +472,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 55eb53e3a0ce1ccfb9f444adeac695df4d6513c9 Mon Sep 17 00:00:00 2001 From: Rostyslav Polishchuk Date: Thu, 10 Apr 2025 00:18:22 +0000 Subject: [PATCH 258/271] fix: order dependent test TestInstallRelease_Atomic_Interrupted needs the same wait as TestInstallRelease_Wait_Interrupted (see helm/helm#12088). The installation goroutine started by TestInstallRelease_Atomic_Interrupted proceeds in the background and may interfere with other tests (see helm/helm#30610) Also see helm/helm#12086 and helm/helm#12109 which are describe and address the root cause. Signed-off-by: Rostyslav Polishchuk --- pkg/action/install_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index aafda86c2..b2d147188 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -521,6 +521,8 @@ func TestInstallRelease_Atomic_Interrupted(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) time.AfterFunc(time.Second, cancel) + goroutines := runtime.NumGoroutine() + res, err := instAction.RunWithContext(ctx, buildChart(), vals) is.Error(err) is.Contains(err.Error(), "context canceled") @@ -531,6 +533,9 @@ func TestInstallRelease_Atomic_Interrupted(t *testing.T) { _, err = instAction.cfg.Releases.Get(res.Name, res.Version) is.Error(err) is.Equal(err, driver.ErrReleaseNotFound) + is.Equal(goroutines+1, runtime.NumGoroutine()) // installation goroutine still is in background + time.Sleep(10 * time.Second) // wait for goroutine to finish + is.Equal(goroutines, runtime.NumGoroutine()) } func TestNameTemplate(t *testing.T) { From 6b5fa336331a8cfa0d325632bea6fd60871cb747 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Apr 2025 09:56:47 +0200 Subject: [PATCH 259/271] debug log level is dynamic and set after Logger creation So we should use dynamic handler to set the log level after. With this patch we can clearly see the output. Before we were always stuck in log level "info" and not seeing debug log level ``` bin/helm upgrade --install --debug --wait frontend \ --namespace test \ --set replicaCount=2 \ --set backend=http://backend-podinfo:9898/echo \ podinfo/podinfo level=DEBUG msg="getting history for release" release=frontend level=DEBUG msg="preparing upgrade" name=frontend level=DEBUG msg="performing update" name=frontend level=DEBUG msg="creating upgraded release" name=frontend level=DEBUG msg="checking resources for changes" resources=2 level=DEBUG msg="no changes detected" kind=Service name=frontend-podinfo level=DEBUG msg="patching resource" kind=Deployment name=frontend-podinfo namespace=test level=DEBUG msg="waiting for resources" count=2 timeout=5m0s level=DEBUG msg="waiting for resource" name=frontend-podinfo kind=Deployment expectedStatus=Current actualStatus=Unknown level=DEBUG msg="updating status for upgraded release" name=frontend Release "frontend" has been upgraded. Happy Helming! NAME: frontend LAST DEPLOYED: Thu Apr 10 09:56:25 2025 NAMESPACE: test STATUS: deployed REVISION: 6 DESCRIPTION: Upgrade complete ``` Signed-off-by: Benoit Tigeot --- pkg/cli/logger.go | 56 +++++++++++++++--- pkg/cmd/root.go | 2 +- .../issue-7233/charts/alpine-0.1.0.tgz | Bin 0 -> 1167 bytes 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 pkg/cmd/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz diff --git a/pkg/cli/logger.go b/pkg/cli/logger.go index d75622c37..03a69be24 100644 --- a/pkg/cli/logger.go +++ b/pkg/cli/logger.go @@ -17,19 +17,53 @@ limitations under the License. package cli import ( + "context" "log/slog" "os" ) -func NewLogger(debug bool) *slog.Logger { - level := slog.LevelInfo - if debug { - level = slog.LevelDebug +// DebugCheckHandler checks settings.Debug at log time +type DebugCheckHandler struct { + handler slog.Handler + settings *EnvSettings +} + +// Enabled implements slog.Handler.Enabled +func (h *DebugCheckHandler) Enabled(_ context.Context, level slog.Level) bool { + if level == slog.LevelDebug { + return h.settings.Debug // Check settings.Debug at log time } + return true // Always log other levels +} - // Create a handler that removes timestamps - handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ - Level: level, +// Handle implements slog.Handler.Handle +func (h *DebugCheckHandler) Handle(ctx context.Context, r slog.Record) error { + return h.handler.Handle(ctx, r) +} + +// WithAttrs implements slog.Handler.WithAttrs +func (h *DebugCheckHandler) WithAttrs(attrs []slog.Attr) slog.Handler { + return &DebugCheckHandler{ + handler: h.handler.WithAttrs(attrs), + settings: h.settings, + } +} + +// WithGroup implements slog.Handler.WithGroup +func (h *DebugCheckHandler) WithGroup(name string) slog.Handler { + return &DebugCheckHandler{ + handler: h.handler.WithGroup(name), + settings: h.settings, + } +} + +// NewLogger creates a new logger with dynamic debug checking +func NewLogger(settings *EnvSettings) *slog.Logger { + // Create base handler that removes timestamps + baseHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + // Always use LevelDebug here to allow all messages through + // Our custom handler will do the filtering + Level: slog.LevelDebug, ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { // Remove the time attribute if a.Key == slog.TimeKey { @@ -39,5 +73,11 @@ func NewLogger(debug bool) *slog.Logger { }, }) - return slog.New(handler) + // Wrap with our dynamic debug-checking handler + dynamicHandler := &DebugCheckHandler{ + handler: baseHandler, + settings: settings, + } + + return slog.New(dynamicHandler) } diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 0cbcfebaf..cbef840b3 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -95,7 +95,7 @@ By default, the default directories depend on the Operating System. The defaults ` var settings = cli.New() -var Logger = cli.NewLogger(settings.Debug) +var Logger = cli.NewLogger(settings) func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { actionConfig := new(action.Configuration) diff --git a/pkg/cmd/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz b/pkg/cmd/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..afd021846ed6a2f7cc2cf023ed188a7cf2f9d189 GIT binary patch literal 1167 zcmV;A1aSKwiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI-XZsRr+&b6LmpuJto@*y$Scfr34{EN1WMOrLS6h%Fj#ugEZ zR7uK;>-D=AJjjWaZc?CYrw7fAAd37rGn{W`DC89rH2hzI$|PGX`Nh|lG)>d1>C`>b zH0?gq@#W>kXgZrsXS2~by}C$8dd9SW<{}927eIliq6m!^& zBCM*zYdlHb#8FN-#>=q*)TZUJG5nq_e9f(O23qP~Ml=20O_nnPhsrRT$8LA*?K z;hvE|`^kq}q-Cu#((`C=n7n4DsFz75OE=#y+O)c)$tX#qmv+{_Py+uq$ZOIkN&wIC zKOLuC{?F2@p8w~N4~~}Qb`Y5P()#prUJ3j+R8|}f>7gGOR5Jf++29%ek0;Y{hyRz; zY0v+&NT>eaGLg^Wqs*g{4CZKX9s&5;9q)F@4RJzEiA@{({b09CKKaVw2jU2T4eE)i2~P@50=~5F94>Y)|7*hU=(Jz&=f2yz(~mhRPLG& z$^l``HY6Z(O)I=NVezWwu#yTeFPYHL6cQQ~#zJZ$XbLm|N_jIhAXKOf%W96w?PZ}9 z=}HRCmYghJ;ubw+!yF#C=6g~bmJxi0Uu$Uy_WP$@!Gty_GKwLSVnf1qT2SIGX5n!u#05lSibC4@A1;IB5RBM25u)q{(pdm$&DMDkNr=7`uRo5Y3GPTw5$WVLa zT`M0iJ+yGU9VGsmaeZhqA3BHW$5vyVGvm)0YK`llVB1)_4?ZwG@_ktP_ppr*OaR~I zI3te2HqsSkHe!Pwx{!^ALN->1T3gR+R#u!mLgHsNjC0^p-uj?}3bm$uz=WUW;4+tHl)A88ky z+)*+DyRAVcNVz;Q2nnV^W=Oe{VkNF^%JJ1`{)O1_r<%#KM4PsLiib-khME&q@$2|a znx^s3eMj@8g!+H;?)vR_?~*b<#U9V~|Cd*@ZvUT-`}_Y{H$l1UW(C~L@2fGduigL&u(Z@M?PosbL<7QghdA0+Uf?u^1;PV^Vx z+57)w(&7JfG`j5he-1IEjjh4{KY$B^fe(YfPmK0*Itl!@&ETo%|0nq0z5h>UlS$A2 hbI39OZ5Z_Q@1>VsdigKN?*RY+|NrPaN*Dkj008|nJ|6%8 literal 0 HcmV?d00001 From cbaac7652d81917e99408fad1b7729d2a6a5e9f7 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Apr 2025 15:06:03 +0200 Subject: [PATCH 260/271] Call slog directly instead of using a wrapper Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 4 +- internal/monocular/client.go | 5 --- pkg/action/action.go | 17 +++----- pkg/action/action_test.go | 4 +- pkg/action/history.go | 4 +- pkg/action/install.go | 22 +++++----- pkg/action/rollback.go | 25 +++++------ pkg/action/uninstall.go | 18 ++++---- pkg/action/upgrade.go | 30 ++++++------- pkg/cmd/flags.go | 5 ++- pkg/cmd/helpers_test.go | 2 - pkg/cmd/install.go | 9 ++-- pkg/cmd/list.go | 2 +- pkg/cmd/plugin.go | 3 +- pkg/cmd/plugin_install.go | 3 +- pkg/cmd/plugin_list.go | 3 +- pkg/cmd/plugin_uninstall.go | 3 +- pkg/cmd/plugin_update.go | 5 ++- pkg/cmd/pull.go | 3 +- pkg/cmd/registry_login.go | 3 +- pkg/cmd/root.go | 7 ++- pkg/cmd/search_hub.go | 2 +- pkg/cmd/search_repo.go | 8 ++-- pkg/cmd/show.go | 5 ++- pkg/cmd/upgrade.go | 5 ++- pkg/kube/client.go | 41 +++++++++--------- pkg/kube/client_test.go | 2 - pkg/kube/ready.go | 48 +++++++++------------ pkg/kube/ready_test.go | 39 ----------------- pkg/kube/statuswait.go | 17 ++++---- pkg/kube/statuswait_test.go | 7 --- pkg/kube/wait.go | 43 +++++++++---------- pkg/storage/driver/cfgmaps.go | 21 +++++---- pkg/storage/driver/mock_test.go | 3 -- pkg/storage/driver/secrets.go | 5 +-- pkg/storage/driver/sql.go | 75 ++++++++++++++++----------------- pkg/storage/storage.go | 28 ++++++------ pkg/storage/storage_test.go | 3 -- 38 files changed, 231 insertions(+), 298 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 11c5e8769..273ead226 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -41,12 +41,12 @@ func main() { cmd, err := helmcmd.NewRootCmd(os.Stdout, os.Args[1:]) if err != nil { - helmcmd.Logger.Warn("command failed", slog.Any("error", err)) + slog.Warn("command failed", slog.Any("error", err)) os.Exit(1) } if err := cmd.Execute(); err != nil { - helmcmd.Logger.Debug("error", slog.Any("error", err)) + slog.Debug("error", slog.Any("error", err)) switch e := err.(type) { case helmcmd.PluginError: os.Exit(e.Code) diff --git a/internal/monocular/client.go b/internal/monocular/client.go index 452bc36e4..f4ef5d647 100644 --- a/internal/monocular/client.go +++ b/internal/monocular/client.go @@ -18,8 +18,6 @@ package monocular import ( "errors" - "io" - "log/slog" "net/url" ) @@ -31,8 +29,6 @@ type Client struct { // The base URL for requests BaseURL string - - Log *slog.Logger } // New creates a new client @@ -45,7 +41,6 @@ func New(u string) (*Client, error) { return &Client{ BaseURL: u, - Log: slog.New(slog.NewTextHandler(io.Discard, nil)), }, nil } diff --git a/pkg/action/action.go b/pkg/action/action.go index d4f917b9f..09c1887bb 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -96,8 +96,6 @@ type Configuration struct { // Capabilities describes the capabilities of the Kubernetes cluster. Capabilities *chartutil.Capabilities - Log *slog.Logger - // HookOutputFunc called with container name and returns and expects writer that will receive the log output. HookOutputFunc func(namespace, pod, container string) io.Writer } @@ -267,8 +265,8 @@ func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { apiVersions, err := GetVersionSet(dc) if err != nil { if discovery.IsGroupDiscoveryFailedError(err) { - cfg.Log.Warn("the kubernetes server has an orphaned API service", "errors", err) - cfg.Log.Warn("to fix this, kubectl delete apiservice ") + slog.Warn("the kubernetes server has an orphaned API service", "errors", err) + slog.Warn("to fix this, kubectl delete apiservice ") } else { return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") } @@ -367,29 +365,28 @@ func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.Version // recordRelease with an update operation in case reuse has been set. func (cfg *Configuration) recordRelease(r *release.Release) { if err := cfg.Releases.Update(r); err != nil { - cfg.Log.Warn("failed to update release", "name", r.Name, "revision", r.Version, slog.Any("error", err)) + slog.Warn("failed to update release", "name", r.Name, "revision", r.Version, slog.Any("error", err)) } } // Init initializes the action configuration -func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log *slog.Logger) error { +func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string) error { kc := kube.New(getter) - kc.Log = log lazyClient := &lazyClient{ namespace: namespace, clientFn: kc.Factory.KubernetesClientSet, } + // slog.SetDefault() + var store *storage.Storage switch helmDriver { case "secret", "secrets", "": d := driver.NewSecrets(newSecretClient(lazyClient)) - d.Log = log store = storage.Init(d) case "configmap", "configmaps": d := driver.NewConfigMaps(newConfigMapClient(lazyClient)) - d.Log = log store = storage.Init(d) case "memory": var d *driver.Memory @@ -409,7 +406,6 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp case "sql": d, err := driver.NewSQL( os.Getenv("HELM_DRIVER_SQL_CONNECTION_STRING"), - log, namespace, ) if err != nil { @@ -423,7 +419,6 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp cfg.RESTClientGetter = getter cfg.KubeClient = kc cfg.Releases = store - cfg.Log = log cfg.HookOutputFunc = func(_, _, _ string) io.Writer { return io.Discard } return nil diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index ee967714c..f544d3281 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -56,6 +56,7 @@ func actionConfigFixture(t *testing.T) *Configuration { }) logger = slog.New(handler) } + slog.SetDefault(logger) registryClient, err := registry.NewClient() if err != nil { @@ -67,7 +68,6 @@ func actionConfigFixture(t *testing.T) *Configuration { KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}}, Capabilities: chartutil.DefaultCapabilities, RegistryClient: registryClient, - Log: logger, } } @@ -347,7 +347,7 @@ func TestConfiguration_Init(t *testing.T) { t.Run(tt.name, func(t *testing.T) { cfg := &Configuration{} - actualErr := cfg.Init(nil, "default", tt.helmDriver, nil) + actualErr := cfg.Init(nil, "default", tt.helmDriver) if tt.expectErr { assert.Error(t, actualErr) assert.Contains(t, actualErr.Error(), tt.errMsg) diff --git a/pkg/action/history.go b/pkg/action/history.go index 289118592..b8e472195 100644 --- a/pkg/action/history.go +++ b/pkg/action/history.go @@ -17,6 +17,8 @@ limitations under the License. package action import ( + "log/slog" + "github.com/pkg/errors" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" @@ -53,6 +55,6 @@ func (h *History) Run(name string) ([]*release.Release, error) { return nil, errors.Errorf("release name is invalid: %s", name) } - h.cfg.Log.Debug("getting history for release", "release", name) + slog.Debug("getting history for release", "release", name) return h.cfg.Releases.History(name) } diff --git a/pkg/action/install.go b/pkg/action/install.go index 3f16969ae..25c48c762 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -173,7 +173,7 @@ func (i *Install) installCRDs(crds []chart.CRD) error { // If the error is CRD already exists, continue. if apierrors.IsAlreadyExists(err) { crdName := res[0].Name - i.cfg.Log.Debug("CRD is already present. Skipping", "crd", crdName) + slog.Debug("CRD is already present. Skipping", "crd", crdName) continue } return errors.Wrapf(err, "failed to install CRD %s", obj.Name) @@ -201,7 +201,7 @@ func (i *Install) installCRDs(crds []chart.CRD) error { return err } - i.cfg.Log.Debug("clearing discovery cache") + slog.Debug("clearing discovery cache") discoveryClient.Invalidate() _, _ = discoveryClient.ServerGroups() @@ -214,7 +214,7 @@ func (i *Install) installCRDs(crds []chart.CRD) error { return err } if resettable, ok := restMapper.(meta.ResettableRESTMapper); ok { - i.cfg.Log.Debug("clearing REST mapper cache") + slog.Debug("clearing REST mapper cache") resettable.Reset() } } @@ -238,24 +238,24 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // Check reachability of cluster unless in client-only mode (e.g. `helm template` without `--validate`) if !i.ClientOnly { if err := i.cfg.KubeClient.IsReachable(); err != nil { - i.cfg.Log.Error(fmt.Sprintf("cluster reachability check failed: %v", err)) + slog.Error(fmt.Sprintf("cluster reachability check failed: %v", err)) return nil, errors.Wrap(err, "cluster reachability check failed") } } // HideSecret must be used with dry run. Otherwise, return an error. if !i.isDryRun() && i.HideSecret { - i.cfg.Log.Error("hiding Kubernetes secrets requires a dry-run mode") + slog.Error("hiding Kubernetes secrets requires a dry-run mode") return nil, errors.New("Hiding Kubernetes secrets requires a dry-run mode") } if err := i.availableName(); err != nil { - i.cfg.Log.Error("release name check failed", slog.Any("error", err)) + slog.Error("release name check failed", slog.Any("error", err)) return nil, errors.Wrap(err, "release name check failed") } if err := chartutil.ProcessDependencies(chrt, vals); err != nil { - i.cfg.Log.Error("chart dependencies processing failed", slog.Any("error", err)) + slog.Error("chart dependencies processing failed", slog.Any("error", err)) return nil, errors.Wrap(err, "chart dependencies processing failed") } @@ -269,7 +269,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { // On dry run, bail here if i.isDryRun() { - i.cfg.Log.Warn("This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") + slog.Warn("This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") } else if err := i.installCRDs(crds); err != nil { return nil, err } @@ -289,7 +289,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma mem.SetNamespace(i.Namespace) i.cfg.Releases = storage.Init(mem) } else if !i.ClientOnly && len(i.APIVersions) > 0 { - i.cfg.Log.Debug("API Version list given outside of client only mode, this list will be ignored") + slog.Debug("API Version list given outside of client only mode, this list will be ignored") } // Make sure if Atomic is set, that wait is set as well. This makes it so @@ -506,7 +506,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource // One possible strategy would be to do a timed retry to see if we can get // this stored in the future. if err := i.recordRelease(rel); err != nil { - i.cfg.Log.Error("failed to record the release", slog.Any("error", err)) + slog.Error("failed to record the release", slog.Any("error", err)) } return rel, nil @@ -515,7 +515,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource func (i *Install) failRelease(rel *release.Release, err error) (*release.Release, error) { rel.SetStatus(release.StatusFailed, fmt.Sprintf("Release %q failed: %s", i.ReleaseName, err.Error())) if i.Atomic { - i.cfg.Log.Debug("install failed, uninstalling release", "release", i.ReleaseName) + slog.Debug("install failed, uninstalling release", "release", i.ReleaseName) uninstall := NewUninstall(i.cfg) uninstall.DisableHooks = i.DisableHooks uninstall.KeepHistory = false diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 4e61fe872..34bd0ac52 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -19,6 +19,7 @@ package action import ( "bytes" "fmt" + "log/slog" "strings" "time" @@ -63,26 +64,26 @@ func (r *Rollback) Run(name string) error { r.cfg.Releases.MaxHistory = r.MaxHistory - r.cfg.Log.Debug("preparing rollback", "name", name) + slog.Debug("preparing rollback", "name", name) currentRelease, targetRelease, err := r.prepareRollback(name) if err != nil { return err } if !r.DryRun { - r.cfg.Log.Debug("creating rolled back release", "name", name) + slog.Debug("creating rolled back release", "name", name) if err := r.cfg.Releases.Create(targetRelease); err != nil { return err } } - r.cfg.Log.Debug("performing rollback", "name", name) + slog.Debug("performing rollback", "name", name) if _, err := r.performRollback(currentRelease, targetRelease); err != nil { return err } if !r.DryRun { - r.cfg.Log.Debug("updating status for rolled back release", "name", name) + slog.Debug("updating status for rolled back release", "name", name) if err := r.cfg.Releases.Update(targetRelease); err != nil { return err } @@ -129,7 +130,7 @@ func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Rele return nil, nil, errors.Errorf("release has no %d version", previousVersion) } - r.cfg.Log.Debug("rolling back", "name", name, "currentVersion", currentRelease.Version, "targetVersion", previousVersion) + slog.Debug("rolling back", "name", name, "currentVersion", currentRelease.Version, "targetVersion", previousVersion) previousRelease, err := r.cfg.Releases.Get(name, previousVersion) if err != nil { @@ -162,7 +163,7 @@ func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Rele func (r *Rollback) performRollback(currentRelease, targetRelease *release.Release) (*release.Release, error) { if r.DryRun { - r.cfg.Log.Debug("dry run", "name", targetRelease.Name) + slog.Debug("dry run", "name", targetRelease.Name) return targetRelease, nil } @@ -181,7 +182,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas return targetRelease, err } } else { - r.cfg.Log.Debug("rollback hooks disabled", "name", targetRelease.Name) + slog.Debug("rollback hooks disabled", "name", targetRelease.Name) } // It is safe to use "force" here because these are resources currently rendered by the chart. @@ -193,14 +194,14 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas if err != nil { msg := fmt.Sprintf("Rollback %q failed: %s", targetRelease.Name, err) - r.cfg.Log.Warn(msg) + slog.Warn(msg) currentRelease.Info.Status = release.StatusSuperseded targetRelease.Info.Status = release.StatusFailed targetRelease.Info.Description = msg r.cfg.recordRelease(currentRelease) r.cfg.recordRelease(targetRelease) if r.CleanupOnFail { - r.cfg.Log.Debug("cleanup on fail set, cleaning up resources", "count", len(results.Created)) + slog.Debug("cleanup on fail set, cleaning up resources", "count", len(results.Created)) _, errs := r.cfg.KubeClient.Delete(results.Created) if errs != nil { var errorList []string @@ -209,7 +210,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas } return targetRelease, errors.Wrapf(fmt.Errorf("unable to cleanup resources: %s", strings.Join(errorList, ", ")), "an error occurred while cleaning up resources. original rollback error: %s", err) } - r.cfg.Log.Debug("resource cleanup complete") + slog.Debug("resource cleanup complete") } return targetRelease, err } @@ -220,7 +221,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas // levels, we should make these error level logs so users are notified // that they'll need to go do the cleanup on their own if err := recreate(r.cfg, results.Updated); err != nil { - r.cfg.Log.Error(err.Error()) + slog.Error(err.Error()) } } waiter, err := r.cfg.KubeClient.GetWaiter(r.WaitStrategy) @@ -256,7 +257,7 @@ func (r *Rollback) performRollback(currentRelease, targetRelease *release.Releas } // Supersede all previous deployments, see issue #2941. for _, rel := range deployed { - r.cfg.Log.Debug("superseding previous deployment", "version", rel.Version) + slog.Debug("superseding previous deployment", "version", rel.Version) rel.Info.Status = release.StatusSuperseded r.cfg.recordRelease(rel) } diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index c3835042f..b842d9933 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -105,7 +105,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) return nil, errors.Errorf("the release named %q is already deleted", name) } - u.cfg.Log.Debug("uninstall: deleting release", "name", name) + slog.Debug("uninstall: deleting release", "name", name) rel.Info.Status = release.StatusUninstalling rel.Info.Deleted = helmtime.Now() rel.Info.Description = "Deletion in progress (or silently failed)" @@ -116,18 +116,18 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) return res, err } } else { - u.cfg.Log.Debug("delete hooks disabled", "release", name) + slog.Debug("delete hooks disabled", "release", name) } // From here on out, the release is currently considered to be in StatusUninstalling // state. if err := u.cfg.Releases.Update(rel); err != nil { - u.cfg.Log.Debug("uninstall: Failed to store updated release", slog.Any("error", err)) + slog.Debug("uninstall: Failed to store updated release", slog.Any("error", err)) } deletedResources, kept, errs := u.deleteRelease(rel) if errs != nil { - u.cfg.Log.Debug("uninstall: Failed to delete release", "errors", errs) + slog.Debug("uninstall: Failed to delete release", "errors", errs) return nil, errors.Errorf("failed to delete release: %s", name) } @@ -154,7 +154,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } if !u.KeepHistory { - u.cfg.Log.Debug("purge requested", "release", name) + slog.Debug("purge requested", "release", name) err := u.purgeReleases(rels...) if err != nil { errs = append(errs, errors.Wrap(err, "uninstall: Failed to purge the release")) @@ -169,7 +169,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } if err := u.cfg.Releases.Update(rel); err != nil { - u.cfg.Log.Debug("uninstall: Failed to store updated release", slog.Any("error", err)) + slog.Debug("uninstall: Failed to store updated release", slog.Any("error", err)) } if len(errs) > 0 { @@ -226,7 +226,7 @@ func (u *Uninstall) deleteRelease(rel *release.Release) (kube.ResourceList, stri } if len(resources) > 0 { if kubeClient, ok := u.cfg.KubeClient.(kube.InterfaceDeletionPropagation); ok { - _, errs = kubeClient.DeleteWithPropagationPolicy(resources, parseCascadingFlag(u.cfg, u.DeletionPropagation)) + _, errs = kubeClient.DeleteWithPropagationPolicy(resources, parseCascadingFlag(u.DeletionPropagation)) return resources, kept, errs } _, errs = u.cfg.KubeClient.Delete(resources) @@ -234,7 +234,7 @@ func (u *Uninstall) deleteRelease(rel *release.Release) (kube.ResourceList, stri return resources, kept, errs } -func parseCascadingFlag(cfg *Configuration, cascadingFlag string) v1.DeletionPropagation { +func parseCascadingFlag(cascadingFlag string) v1.DeletionPropagation { switch cascadingFlag { case "orphan": return v1.DeletePropagationOrphan @@ -243,7 +243,7 @@ func parseCascadingFlag(cfg *Configuration, cascadingFlag string) v1.DeletionPro case "background": return v1.DeletePropagationBackground default: - cfg.Log.Debug("uninstall: given cascade value, defaulting to delete propagation background", "value", cascadingFlag) + slog.Debug("uninstall: given cascade value, defaulting to delete propagation background", "value", cascadingFlag) return v1.DeletePropagationBackground } } diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 429bac9d7..ea09c8ed0 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -164,7 +164,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. return nil, errors.Errorf("release name is invalid: %s", name) } - u.cfg.Log.Debug("preparing upgrade", "name", name) + slog.Debug("preparing upgrade", "name", name) currentRelease, upgradedRelease, err := u.prepareUpgrade(name, chart, vals) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. u.cfg.Releases.MaxHistory = u.MaxHistory - u.cfg.Log.Debug("performing update", "name", name) + slog.Debug("performing update", "name", name) res, err := u.performUpgrade(ctx, currentRelease, upgradedRelease) if err != nil { return res, err @@ -180,7 +180,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. // Do not update for dry runs if !u.isDryRun() { - u.cfg.Log.Debug("updating status for upgraded release", "name", name) + slog.Debug("updating status for upgraded release", "name", name) if err := u.cfg.Releases.Update(upgradedRelease); err != nil { return res, err } @@ -366,7 +366,7 @@ func (u *Upgrade) performUpgrade(ctx context.Context, originalRelease, upgradedR // Run if it is a dry run if u.isDryRun() { - u.cfg.Log.Debug("dry run for release", "name", upgradedRelease.Name) + slog.Debug("dry run for release", "name", upgradedRelease.Name) if len(u.Description) > 0 { upgradedRelease.Info.Description = u.Description } else { @@ -375,7 +375,7 @@ func (u *Upgrade) performUpgrade(ctx context.Context, originalRelease, upgradedR return upgradedRelease, nil } - u.cfg.Log.Debug("creating upgraded release", "name", upgradedRelease.Name) + slog.Debug("creating upgraded release", "name", upgradedRelease.Name) if err := u.cfg.Releases.Create(upgradedRelease); err != nil { return nil, err } @@ -426,7 +426,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele return } } else { - u.cfg.Log.Debug("upgrade hooks disabled", "name", upgradedRelease.Name) + slog.Debug("upgrade hooks disabled", "name", upgradedRelease.Name) } results, err := u.cfg.KubeClient.Update(current, target, u.Force) @@ -442,7 +442,7 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele // levels, we should make these error level logs so users are notified // that they'll need to go do the cleanup on their own if err := recreate(u.cfg, results.Updated); err != nil { - u.cfg.Log.Error(err.Error()) + slog.Error(err.Error()) } } waiter, err := u.cfg.KubeClient.GetWaiter(u.WaitStrategy) @@ -487,13 +487,13 @@ func (u *Upgrade) releasingUpgrade(c chan<- resultMessage, upgradedRelease *rele func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, err error) (*release.Release, error) { msg := fmt.Sprintf("Upgrade %q failed: %s", rel.Name, err) - u.cfg.Log.Warn("upgrade failed", "name", rel.Name, slog.Any("error", err)) + slog.Warn("upgrade failed", "name", rel.Name, slog.Any("error", err)) rel.Info.Status = release.StatusFailed rel.Info.Description = msg u.cfg.recordRelease(rel) if u.CleanupOnFail && len(created) > 0 { - u.cfg.Log.Debug("cleanup on fail set", "cleaning_resources", len(created)) + slog.Debug("cleanup on fail set", "cleaning_resources", len(created)) _, errs := u.cfg.KubeClient.Delete(created) if errs != nil { var errorList []string @@ -502,10 +502,10 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e } return rel, errors.Wrapf(fmt.Errorf("unable to cleanup resources: %s", strings.Join(errorList, ", ")), "an error occurred while cleaning up resources. original upgrade error: %s", err) } - u.cfg.Log.Debug("resource cleanup complete") + slog.Debug("resource cleanup complete") } if u.Atomic { - u.cfg.Log.Debug("upgrade failed and atomic is set, rolling back to last successful release") + slog.Debug("upgrade failed and atomic is set, rolling back to last successful release") // As a protection, get the last successful release before rollback. // If there are no successful releases, bail out @@ -557,13 +557,13 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newVals map[string]interface{}) (map[string]interface{}, error) { if u.ResetValues { // If ResetValues is set, we completely ignore current.Config. - u.cfg.Log.Debug("resetting values to the chart's original version") + slog.Debug("resetting values to the chart's original version") return newVals, nil } // If the ReuseValues flag is set, we always copy the old values over the new config's values. if u.ReuseValues { - u.cfg.Log.Debug("reusing the old release's values") + slog.Debug("reusing the old release's values") // We have to regenerate the old coalesced values: oldVals, err := chartutil.CoalesceValues(current.Chart, current.Config) @@ -580,7 +580,7 @@ func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newV // If the ResetThenReuseValues flag is set, we use the new chart's values, but we copy the old config's values over the new config's values. if u.ResetThenReuseValues { - u.cfg.Log.Debug("merging values from old release to new values") + slog.Debug("merging values from old release to new values") newVals = chartutil.CoalesceTables(newVals, current.Config) @@ -588,7 +588,7 @@ func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newV } if len(newVals) == 0 && len(current.Config) > 0 { - u.cfg.Log.Debug("copying values from old release", "name", current.Name, "version", current.Version) + slog.Debug("copying values from old release", "name", current.Name, "version", current.Version) newVals = current.Config } return newVals, nil diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index 454bb13de..eb829c21e 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -20,6 +20,7 @@ import ( "flag" "fmt" "log" + "log/slog" "path/filepath" "sort" "strings" @@ -82,11 +83,11 @@ func (ws *waitValue) Set(s string) error { *ws = waitValue(s) return nil case "true": - Logger.Warn("--wait=true is deprecated (boolean value) and can be replaced with --wait=watcher") + slog.Warn("--wait=true is deprecated (boolean value) and can be replaced with --wait=watcher") *ws = waitValue(kube.StatusWatcherStrategy) return nil case "false": - Logger.Warn("--wait=false is deprecated (boolean value) and can be replaced by omitting the --wait flag") + slog.Warn("--wait=false is deprecated (boolean value) and can be replaced by omitting the --wait flag") *ws = waitValue(kube.HookOnlyStrategy) return nil default: diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index 38e0a5b3e..b48f802b5 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -19,7 +19,6 @@ package cmd import ( "bytes" "io" - "log/slog" "os" "strings" "testing" @@ -93,7 +92,6 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) Releases: store, KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard}, Capabilities: chartutil.DefaultCapabilities, - Log: slog.New(slog.NewTextHandler(io.Discard, nil)), } root, err := newRootCmdWithConfig(actionConfig, buf, args) diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 14746f8c3..ee018c88a 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "log" + "log/slog" "os" "os/signal" "syscall" @@ -229,9 +230,9 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal } func runInstall(args []string, client *action.Install, valueOpts *values.Options, out io.Writer) (*release.Release, error) { - Logger.Debug("Original chart version", "version", client.Version) + slog.Debug("Original chart version", "version", client.Version) if client.Version == "" && client.Devel { - Logger.Debug("setting version to >0.0.0-0") + slog.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -246,7 +247,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options return nil, err } - Logger.Debug("Chart path", "path", cp) + slog.Debug("Chart path", "path", cp) p := getter.All(settings) vals, err := valueOpts.MergeValues(p) @@ -265,7 +266,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options } if chartRequested.Metadata.Deprecated { - Logger.Warn("this chart is deprecated") + slog.Warn("this chart is deprecated") } if req := chartRequested.Metadata.Dependencies; req != nil { diff --git a/pkg/cmd/list.go b/pkg/cmd/list.go index a4eb91aad..69a4ff36d 100644 --- a/pkg/cmd/list.go +++ b/pkg/cmd/list.go @@ -71,7 +71,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { ValidArgsFunction: noMoreArgsCompFunc, RunE: func(cmd *cobra.Command, _ []string) error { if client.AllNamespaces { - if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), Logger); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER")); err != nil { return err } } diff --git a/pkg/cmd/plugin.go b/pkg/cmd/plugin.go index 05d7135dd..355ed4349 100644 --- a/pkg/cmd/plugin.go +++ b/pkg/cmd/plugin.go @@ -17,6 +17,7 @@ package cmd import ( "io" + "log/slog" "os" "os/exec" @@ -66,7 +67,7 @@ func runHook(p *plugin.Plugin, event string) error { prog := exec.Command(main, argv...) - Logger.Debug("running hook", "event", event, "program", prog) + slog.Debug("running hook", "event", event, "program", prog) prog.Stdout, prog.Stderr = os.Stdout, os.Stderr if err := prog.Run(); err != nil { diff --git a/pkg/cmd/plugin_install.go b/pkg/cmd/plugin_install.go index 2e8fd4d6a..14469f5b4 100644 --- a/pkg/cmd/plugin_install.go +++ b/pkg/cmd/plugin_install.go @@ -18,6 +18,7 @@ package cmd import ( "fmt" "io" + "log/slog" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -79,7 +80,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error { return err } - Logger.Debug("loading plugin", "path", i.Path()) + slog.Debug("loading plugin", "path", i.Path()) p, err := plugin.LoadDir(i.Path()) if err != nil { return errors.Wrap(err, "plugin is installed but unusable") diff --git a/pkg/cmd/plugin_list.go b/pkg/cmd/plugin_list.go index 52aefe8ef..fdd66ec0a 100644 --- a/pkg/cmd/plugin_list.go +++ b/pkg/cmd/plugin_list.go @@ -18,6 +18,7 @@ package cmd import ( "fmt" "io" + "log/slog" "github.com/gosuri/uitable" "github.com/spf13/cobra" @@ -32,7 +33,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command { Short: "list installed Helm plugins", ValidArgsFunction: noMoreArgsCompFunc, RunE: func(_ *cobra.Command, _ []string) error { - Logger.Debug("pluginDirs", "directory", settings.PluginsDirectory) + slog.Debug("pluginDirs", "directory", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/pkg/cmd/plugin_uninstall.go b/pkg/cmd/plugin_uninstall.go index 18815b139..61bc3d724 100644 --- a/pkg/cmd/plugin_uninstall.go +++ b/pkg/cmd/plugin_uninstall.go @@ -18,6 +18,7 @@ package cmd import ( "fmt" "io" + "log/slog" "os" "strings" @@ -60,7 +61,7 @@ func (o *pluginUninstallOptions) complete(args []string) error { } func (o *pluginUninstallOptions) run(out io.Writer) error { - Logger.Debug("loading installer plugins", "dir", settings.PluginsDirectory) + slog.Debug("loading installer plugins", "dir", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err diff --git a/pkg/cmd/plugin_update.go b/pkg/cmd/plugin_update.go index 16ac84066..c9a8ca238 100644 --- a/pkg/cmd/plugin_update.go +++ b/pkg/cmd/plugin_update.go @@ -18,6 +18,7 @@ package cmd import ( "fmt" "io" + "log/slog" "path/filepath" "strings" @@ -62,7 +63,7 @@ func (o *pluginUpdateOptions) complete(args []string) error { func (o *pluginUpdateOptions) run(out io.Writer) error { installer.Debug = settings.Debug - Logger.Debug("loading installed plugins", "path", settings.PluginsDirectory) + slog.Debug("loading installed plugins", "path", settings.PluginsDirectory) plugins, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { return err @@ -104,7 +105,7 @@ func updatePlugin(p *plugin.Plugin) error { return err } - Logger.Debug("loading plugin", "path", i.Path()) + slog.Debug("loading plugin", "path", i.Path()) updatedPlugin, err := plugin.LoadDir(i.Path()) if err != nil { return err diff --git a/pkg/cmd/pull.go b/pkg/cmd/pull.go index fca1c8b9b..e3d93c049 100644 --- a/pkg/cmd/pull.go +++ b/pkg/cmd/pull.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "log" + "log/slog" "github.com/spf13/cobra" @@ -60,7 +61,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { RunE: func(_ *cobra.Command, args []string) error { client.Settings = settings if client.Version == "" && client.Devel { - Logger.Debug("setting version to >0.0.0-0") + slog.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/cmd/registry_login.go b/pkg/cmd/registry_login.go index 7c853d786..3719c1c17 100644 --- a/pkg/cmd/registry_login.go +++ b/pkg/cmd/registry_login.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "io" + "log/slog" "os" "strings" @@ -122,7 +123,7 @@ func getUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStd } } } else { - Logger.Warn("using --password via the CLI is insecure. Use --password-stdin") + slog.Warn("using --password via the CLI is insecure. Use --password-stdin") } return username, password, nil diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index cbef840b3..e9305206a 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "log" + "log/slog" "net/http" "os" "strings" @@ -95,7 +96,6 @@ By default, the default directories depend on the Operating System. The defaults ` var settings = cli.New() -var Logger = cli.NewLogger(settings) func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { actionConfig := new(action.Configuration) @@ -105,7 +105,7 @@ func NewRootCmd(out io.Writer, args []string) (*cobra.Command, error) { } cobra.OnInitialize(func() { helmDriver := os.Getenv("HELM_DRIVER") - if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, Logger); err != nil { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver); err != nil { log.Fatal(err) } if helmDriver == "memory" { @@ -139,6 +139,9 @@ func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, arg settings.AddFlags(flags) addKlogFlags(flags) + logger := cli.NewLogger(settings) + slog.SetDefault(logger) + // Setup shell completion for the namespace flag err := cmd.RegisterFlagCompletionFunc("namespace", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { if client, err := actionConfig.KubernetesClientSet(); err == nil { diff --git a/pkg/cmd/search_hub.go b/pkg/cmd/search_hub.go index 6aa5c10bd..380d1e394 100644 --- a/pkg/cmd/search_hub.go +++ b/pkg/cmd/search_hub.go @@ -90,7 +90,7 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error { q := strings.Join(args, " ") results, err := c.Search(q) if err != nil { - Logger.Debug("search failed", slog.Any("error", err)) + slog.Debug("search failed", slog.Any("error", err)) return fmt.Errorf("unable to perform search against %q", o.searchEndpoint) } diff --git a/pkg/cmd/search_repo.go b/pkg/cmd/search_repo.go index 850bcbe16..b93b871b1 100644 --- a/pkg/cmd/search_repo.go +++ b/pkg/cmd/search_repo.go @@ -131,17 +131,17 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error { } func (o *searchRepoOptions) setupSearchedVersion() { - Logger.Debug("original chart version", "version", o.version) + slog.Debug("original chart version", "version", o.version) if o.version != "" { return } if o.devel { // search for releases and prereleases (alpha, beta, and release candidate releases). - Logger.Debug("setting version to >0.0.0-0") + slog.Debug("setting version to >0.0.0-0") o.version = ">0.0.0-0" } else { // search only for stable releases, prerelease versions will be skipped - Logger.Debug("setting version to >0.0.0") + slog.Debug("setting version to >0.0.0") o.version = ">0.0.0" } } @@ -190,7 +190,7 @@ func (o *searchRepoOptions) buildIndex() (*search.Index, error) { f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n)) ind, err := repo.LoadIndexFile(f) if err != nil { - Logger.Warn("repo is corrupt or missing", "repo", n, slog.Any("error", err)) + slog.Warn("repo is corrupt or missing", "repo", n, slog.Any("error", err)) continue } diff --git a/pkg/cmd/show.go b/pkg/cmd/show.go index c70ffa256..22d8bee49 100644 --- a/pkg/cmd/show.go +++ b/pkg/cmd/show.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "log" + "log/slog" "github.com/spf13/cobra" @@ -211,9 +212,9 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) { } func runShow(args []string, client *action.Show) (string, error) { - Logger.Debug("original chart version", "version", client.Version) + slog.Debug("original chart version", "version", client.Version) if client.Version == "" && client.Devel { - Logger.Debug("setting version to >0.0.0-0") + slog.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index e6b5c0409..2e0f16212 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "log" + "log/slog" "os" "os/signal" "syscall" @@ -173,7 +174,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if client.Version == "" && client.Devel { - Logger.Debug("setting version to >0.0.0-0") + slog.Debug("setting version to >0.0.0-0") client.Version = ">0.0.0-0" } @@ -225,7 +226,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if ch.Metadata.Deprecated { - Logger.Warn("this chart is deprecated") + slog.Warn("this chart is deprecated") } // Create context and prepare the handle of SIGTERM diff --git a/pkg/kube/client.go b/pkg/kube/client.go index bd4dbea91..beac9ac7a 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -74,7 +74,6 @@ type Client struct { // needs. The smaller surface area of the interface means there is a lower // chance of it changing. Factory Factory - Log *slog.Logger // Namespace allows to bypass the kubeconfig file for the choice of the namespace Namespace string @@ -121,7 +120,6 @@ func (c *Client) newStatusWatcher() (*statusWaiter, error) { return &statusWaiter{ restMapper: restMapper, client: dynamicClient, - log: c.Log, }, nil } @@ -132,7 +130,7 @@ func (c *Client) GetWaiter(strategy WaitStrategy) (Waiter, error) { if err != nil { return nil, err } - return &legacyWaiter{kubeClient: kc, log: c.Log}, nil + return &legacyWaiter{kubeClient: kc}, nil case StatusWatcherStrategy: return c.newStatusWatcher() case HookOnlyStrategy: @@ -163,7 +161,6 @@ func New(getter genericclioptions.RESTClientGetter) *Client { factory := cmdutil.NewFactory(getter) c := &Client{ Factory: factory, - Log: slog.New(slog.NewTextHandler(io.Discard, nil)), } return c } @@ -197,7 +194,7 @@ func (c *Client) IsReachable() error { // Create creates Kubernetes resources specified in the resource list. func (c *Client) Create(resources ResourceList) (*Result, error) { - c.Log.Debug("creating resource(s)", "resources", len(resources)) + slog.Debug("creating resource(s)", "resources", len(resources)) if err := perform(resources, createResource); err != nil { return nil, err } @@ -249,7 +246,7 @@ func (c *Client) Get(resources ResourceList, related bool) (map[string][]runtime objs, err = c.getSelectRelationPod(info, objs, isTable, &podSelectors) if err != nil { - c.Log.Warn("get the relation pod is failed", slog.Any("error", err)) + slog.Warn("get the relation pod is failed", slog.Any("error", err)) } } } @@ -267,7 +264,7 @@ func (c *Client) getSelectRelationPod(info *resource.Info, objs map[string][]run if info == nil { return objs, nil } - c.Log.Debug("get relation pod of object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) + slog.Debug("get relation pod of object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) selector, ok, _ := getSelectorFromObject(info.Object) if !ok { return objs, nil @@ -409,7 +406,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err updateErrors := []string{} res := &Result{} - c.Log.Debug("checking resources for changes", "resources", len(target)) + slog.Debug("checking resources for changes", "resources", len(target)) err := target.Visit(func(info *resource.Info, err error) error { if err != nil { return err @@ -430,7 +427,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } kind := info.Mapping.GroupVersionKind.Kind - c.Log.Debug("created a new resource", "namespace", info.Namespace, "name", info.Name, "kind", kind) + slog.Debug("created a new resource", "namespace", info.Namespace, "name", info.Name, "kind", kind) return nil } @@ -441,7 +438,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } if err := updateResource(c, info, originalInfo.Object, force); err != nil { - c.Log.Debug("error updating the resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) + slog.Debug("error updating the resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) updateErrors = append(updateErrors, err.Error()) } // Because we check for errors later, append the info regardless @@ -458,22 +455,22 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } for _, info := range original.Difference(target) { - c.Log.Debug("deleting resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) + slog.Debug("deleting resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) if err := info.Get(); err != nil { - c.Log.Debug("unable to get object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) + slog.Debug("unable to get object", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) continue } annotations, err := metadataAccessor.Annotations(info.Object) if err != nil { - c.Log.Debug("unable to get annotations", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) + slog.Debug("unable to get annotations", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) } if annotations != nil && annotations[ResourcePolicyAnno] == KeepPolicy { - c.Log.Debug("skipping delete due to annotation", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "annotation", ResourcePolicyAnno, "value", KeepPolicy) + slog.Debug("skipping delete due to annotation", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, "annotation", ResourcePolicyAnno, "value", KeepPolicy) continue } if err := deleteResource(info, metav1.DeletePropagationBackground); err != nil { - c.Log.Debug("failed to delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) + slog.Debug("failed to delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) continue } res.Deleted = append(res.Deleted, info) @@ -497,16 +494,16 @@ func (c *Client) DeleteWithPropagationPolicy(resources ResourceList, policy meta return rdelete(c, resources, policy) } -func rdelete(c *Client, resources ResourceList, propagation metav1.DeletionPropagation) (*Result, []error) { +func rdelete(_ *Client, resources ResourceList, propagation metav1.DeletionPropagation) (*Result, []error) { var errs []error res := &Result{} mtx := sync.Mutex{} err := perform(resources, func(info *resource.Info) error { - c.Log.Debug("starting delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) + slog.Debug("starting delete resource", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind) err := deleteResource(info, propagation) if err == nil || apierrors.IsNotFound(err) { if err != nil { - c.Log.Debug("ignoring delete failure", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) + slog.Debug("ignoring delete failure", "namespace", info.Namespace, "name", info.Name, "kind", info.Mapping.GroupVersionKind.Kind, slog.Any("error", err)) } mtx.Lock() defer mtx.Unlock() @@ -640,7 +637,7 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P return patch, types.StrategicMergePatchType, err } -func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, force bool) error { +func updateResource(_ *Client, target *resource.Info, currentObj runtime.Object, force bool) error { var ( obj runtime.Object helper = resource.NewHelper(target.Client, target.Mapping).WithFieldManager(getManagedFieldsManager()) @@ -654,7 +651,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, if err != nil { return errors.Wrap(err, "failed to replace object") } - c.Log.Debug("replace succeeded", "name", target.Name, "initialKind", currentObj.GetObjectKind().GroupVersionKind().Kind, "kind", kind) + slog.Debug("replace succeeded", "name", target.Name, "initialKind", currentObj.GetObjectKind().GroupVersionKind().Kind, "kind", kind) } else { patch, patchType, err := createPatch(target, currentObj) if err != nil { @@ -662,7 +659,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, } if patch == nil || string(patch) == "{}" { - c.Log.Debug("no changes detected", "kind", kind, "name", target.Name) + slog.Debug("no changes detected", "kind", kind, "name", target.Name) // This needs to happen to make sure that Helm has the latest info from the API // Otherwise there will be no labels and other functions that use labels will panic if err := target.Get(); err != nil { @@ -671,7 +668,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, return nil } // send patch to server - c.Log.Debug("patching resource", "kind", kind, "name", target.Name, "namespace", target.Namespace) + slog.Debug("patching resource", "kind", kind, "name", target.Name, "namespace", target.Namespace) obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch, nil) if err != nil { return errors.Wrapf(err, "cannot patch %q with kind %s", target.Name, kind) diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 6244e3ee5..c755b490c 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -19,7 +19,6 @@ package kube import ( "bytes" "io" - "log/slog" "net/http" "strings" "testing" @@ -108,7 +107,6 @@ func newTestClient(t *testing.T) *Client { return &Client{ Factory: testFactory.WithNamespace("default"), - Log: slog.New(slog.NewTextHandler(io.Discard, nil)), } } diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index 745dd265e..9cbd89913 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -19,7 +19,6 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" "fmt" - "io" "log/slog" appsv1 "k8s.io/api/apps/v1" @@ -59,13 +58,9 @@ func CheckJobs(checkJobs bool) ReadyCheckerOption { // NewReadyChecker creates a new checker. Passed ReadyCheckerOptions can // be used to override defaults. -func NewReadyChecker(cl kubernetes.Interface, logger *slog.Logger, opts ...ReadyCheckerOption) ReadyChecker { +func NewReadyChecker(cl kubernetes.Interface, opts ...ReadyCheckerOption) ReadyChecker { c := ReadyChecker{ client: cl, - log: logger, - } - if c.log == nil { - c.log = slog.New(slog.NewTextHandler(io.Discard, nil)) } for _, opt := range opts { opt(&c) @@ -76,7 +71,6 @@ func NewReadyChecker(cl kubernetes.Interface, logger *slog.Logger, opts ...Ready // ReadyChecker is a type that can check core Kubernetes types for readiness. type ReadyChecker struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -232,18 +226,18 @@ func (c *ReadyChecker) isPodReady(pod *corev1.Pod) bool { return true } } - c.log.Debug("Pod is not ready", "namespace", pod.GetNamespace(), "name", pod.GetName()) + slog.Debug("Pod is not ready", "namespace", pod.GetNamespace(), "name", pod.GetName()) return false } func (c *ReadyChecker) jobReady(job *batchv1.Job) (bool, error) { if job.Status.Failed > *job.Spec.BackoffLimit { - c.log.Debug("Job is failed", "namespace", job.GetNamespace(), "name", job.GetName()) + slog.Debug("Job is failed", "namespace", job.GetNamespace(), "name", job.GetName()) // If a job is failed, it can't recover, so throw an error return false, fmt.Errorf("job is failed: %s/%s", job.GetNamespace(), job.GetName()) } if job.Spec.Completions != nil && job.Status.Succeeded < *job.Spec.Completions { - c.log.Debug("Job is not completed", "namespace", job.GetNamespace(), "name", job.GetName()) + slog.Debug("Job is not completed", "namespace", job.GetNamespace(), "name", job.GetName()) return false, nil } return true, nil @@ -257,7 +251,7 @@ func (c *ReadyChecker) serviceReady(s *corev1.Service) bool { // Ensure that the service cluster IP is not empty if s.Spec.ClusterIP == "" { - c.log.Debug("Service does not have cluster IP address", "namespace", s.GetNamespace(), "name", s.GetName()) + slog.Debug("Service does not have cluster IP address", "namespace", s.GetNamespace(), "name", s.GetName()) return false } @@ -265,12 +259,12 @@ func (c *ReadyChecker) serviceReady(s *corev1.Service) bool { if s.Spec.Type == corev1.ServiceTypeLoadBalancer { // do not wait when at least 1 external IP is set if len(s.Spec.ExternalIPs) > 0 { - c.log.Debug("Service has external IP addresses", "namespace", s.GetNamespace(), "name", s.GetName(), "externalIPs", s.Spec.ExternalIPs) + slog.Debug("Service has external IP addresses", "namespace", s.GetNamespace(), "name", s.GetName(), "externalIPs", s.Spec.ExternalIPs) return true } if s.Status.LoadBalancer.Ingress == nil { - c.log.Debug("Service does not have load balancer ingress IP address", "namespace", s.GetNamespace(), "name", s.GetName()) + slog.Debug("Service does not have load balancer ingress IP address", "namespace", s.GetNamespace(), "name", s.GetName()) return false } } @@ -280,7 +274,7 @@ func (c *ReadyChecker) serviceReady(s *corev1.Service) bool { func (c *ReadyChecker) volumeReady(v *corev1.PersistentVolumeClaim) bool { if v.Status.Phase != corev1.ClaimBound { - c.log.Debug("PersistentVolumeClaim is not bound", "namespace", v.GetNamespace(), "name", v.GetName()) + slog.Debug("PersistentVolumeClaim is not bound", "namespace", v.GetNamespace(), "name", v.GetName()) return false } return true @@ -293,13 +287,13 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy } // Verify the generation observed by the deployment controller matches the spec generation if dep.Status.ObservedGeneration != dep.ObjectMeta.Generation { - c.log.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "actualGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.ObjectMeta.Generation) + slog.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "actualGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.ObjectMeta.Generation) return false } expectedReady := *dep.Spec.Replicas - deploymentutil.MaxUnavailable(*dep) if !(rs.Status.ReadyReplicas >= expectedReady) { - c.log.Debug("Deployment does not have enough pods ready", "namespace", dep.GetNamespace(), "name", dep.GetName(), "readyPods", rs.Status.ReadyReplicas, "totalPods", expectedReady) + slog.Debug("Deployment does not have enough pods ready", "namespace", dep.GetNamespace(), "name", dep.GetName(), "readyPods", rs.Status.ReadyReplicas, "totalPods", expectedReady) return false } return true @@ -308,7 +302,7 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { // Verify the generation observed by the daemonSet controller matches the spec generation if ds.Status.ObservedGeneration != ds.ObjectMeta.Generation { - c.log.Debug("DaemonSet is not ready, observedGeneration does not match spec generation", "namespace", ds.GetNamespace(), "name", ds.GetName(), "observedGeneration", ds.Status.ObservedGeneration, "expectedGeneration", ds.ObjectMeta.Generation) + slog.Debug("DaemonSet is not ready, observedGeneration does not match spec generation", "namespace", ds.GetNamespace(), "name", ds.GetName(), "observedGeneration", ds.Status.ObservedGeneration, "expectedGeneration", ds.ObjectMeta.Generation) return false } @@ -319,7 +313,7 @@ func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { // Make sure all the updated pods have been scheduled if ds.Status.UpdatedNumberScheduled != ds.Status.DesiredNumberScheduled { - c.log.Debug("DaemonSet does not have enough Pods scheduled", "namespace", ds.GetNamespace(), "name", ds.GetName(), "scheduledPods", ds.Status.UpdatedNumberScheduled, "totalPods", ds.Status.DesiredNumberScheduled) + slog.Debug("DaemonSet does not have enough Pods scheduled", "namespace", ds.GetNamespace(), "name", ds.GetName(), "scheduledPods", ds.Status.UpdatedNumberScheduled, "totalPods", ds.Status.DesiredNumberScheduled) return false } maxUnavailable, err := intstr.GetScaledValueFromIntOrPercent(ds.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable, int(ds.Status.DesiredNumberScheduled), true) @@ -332,7 +326,7 @@ func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { expectedReady := int(ds.Status.DesiredNumberScheduled) - maxUnavailable if !(int(ds.Status.NumberReady) >= expectedReady) { - c.log.Debug("DaemonSet does not have enough Pods ready", "namespace", ds.GetNamespace(), "name", ds.GetName(), "readyPods", ds.Status.NumberReady, "totalPods", expectedReady) + slog.Debug("DaemonSet does not have enough Pods ready", "namespace", ds.GetNamespace(), "name", ds.GetName(), "readyPods", ds.Status.NumberReady, "totalPods", expectedReady) return false } return true @@ -384,13 +378,13 @@ func (c *ReadyChecker) crdReady(crd apiextv1.CustomResourceDefinition) bool { func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { // Verify the generation observed by the statefulSet controller matches the spec generation if sts.Status.ObservedGeneration != sts.ObjectMeta.Generation { - c.log.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "actualGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.ObjectMeta.Generation) + slog.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "actualGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.ObjectMeta.Generation) return false } // If the update strategy is not a rolling update, there will be nothing to wait for if sts.Spec.UpdateStrategy.Type != appsv1.RollingUpdateStatefulSetStrategyType { - c.log.Debug("StatefulSet skipped ready check", "namespace", sts.GetNamespace(), "name", sts.GetName(), "updateStrategy", sts.Spec.UpdateStrategy.Type) + slog.Debug("StatefulSet skipped ready check", "namespace", sts.GetNamespace(), "name", sts.GetName(), "updateStrategy", sts.Spec.UpdateStrategy.Type) return true } @@ -416,30 +410,30 @@ func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { // Make sure all the updated pods have been scheduled if int(sts.Status.UpdatedReplicas) < expectedReplicas { - c.log.Debug("StatefulSet does not have enough Pods scheduled", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.UpdatedReplicas, "totalPods", expectedReplicas) + slog.Debug("StatefulSet does not have enough Pods scheduled", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.UpdatedReplicas, "totalPods", expectedReplicas) return false } if int(sts.Status.ReadyReplicas) != replicas { - c.log.Debug("StatefulSet does not have enough Pods ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) + slog.Debug("StatefulSet does not have enough Pods ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) return false } // This check only makes sense when all partitions are being upgraded otherwise during a // partitioned rolling upgrade, this condition will never evaluate to true, leading to // error. if partition == 0 && sts.Status.CurrentRevision != sts.Status.UpdateRevision { - c.log.Debug("StatefulSet is not ready, currentRevision does not match updateRevision", "namespace", sts.GetNamespace(), "name", sts.GetName(), "currentRevision", sts.Status.CurrentRevision, "updateRevision", sts.Status.UpdateRevision) + slog.Debug("StatefulSet is not ready, currentRevision does not match updateRevision", "namespace", sts.GetNamespace(), "name", sts.GetName(), "currentRevision", sts.Status.CurrentRevision, "updateRevision", sts.Status.UpdateRevision) return false } - c.log.Debug("StatefulSet is ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) + slog.Debug("StatefulSet is ready", "namespace", sts.GetNamespace(), "name", sts.GetName(), "readyPods", sts.Status.ReadyReplicas, "totalPods", replicas) return true } func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationController) bool { // Verify the generation observed by the replicationController controller matches the spec generation if rc.Status.ObservedGeneration != rc.ObjectMeta.Generation { - c.log.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "actualGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.ObjectMeta.Generation) + slog.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "actualGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.ObjectMeta.Generation) return false } return true @@ -448,7 +442,7 @@ func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationControll func (c *ReadyChecker) replicaSetReady(rs *appsv1.ReplicaSet) bool { // Verify the generation observed by the replicaSet controller matches the spec generation if rs.Status.ObservedGeneration != rs.ObjectMeta.Generation { - c.log.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "actualGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.ObjectMeta.Generation) + slog.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "actualGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.ObjectMeta.Generation) return false } return true diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index d9dd8fb3d..64cf68749 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -17,8 +17,6 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" - "io" - "log/slog" "testing" appsv1 "k8s.io/api/apps/v1" @@ -39,7 +37,6 @@ const defaultNamespace = metav1.NamespaceDefault func Test_ReadyChecker_IsReady_Pod(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -59,7 +56,6 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { name: "IsReady Pod", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -75,7 +71,6 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { name: "IsReady Pod returns error", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -92,7 +87,6 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -115,7 +109,6 @@ func Test_ReadyChecker_IsReady_Pod(t *testing.T) { func Test_ReadyChecker_IsReady_Job(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -135,7 +128,6 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { name: "IsReady Job error while getting job", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -151,7 +143,6 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { name: "IsReady Job", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -168,7 +159,6 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -190,7 +180,6 @@ func Test_ReadyChecker_IsReady_Job(t *testing.T) { func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -211,7 +200,6 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { name: "IsReady Deployments error while getting current Deployment", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -228,7 +216,6 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { name: "IsReady Deployments", //TODO fix this one fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -246,7 +233,6 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -272,7 +258,6 @@ func Test_ReadyChecker_IsReady_Deployment(t *testing.T) { func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -292,7 +277,6 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { name: "IsReady PersistentVolumeClaim", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -308,7 +292,6 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { name: "IsReady PersistentVolumeClaim with error", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -325,7 +308,6 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -347,7 +329,6 @@ func Test_ReadyChecker_IsReady_PersistentVolumeClaim(t *testing.T) { func Test_ReadyChecker_IsReady_Service(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -367,7 +348,6 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { name: "IsReady Service", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -383,7 +363,6 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { name: "IsReady Service with error", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -400,7 +379,6 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -422,7 +400,6 @@ func Test_ReadyChecker_IsReady_Service(t *testing.T) { func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -442,7 +419,6 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { name: "IsReady DaemonSet", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -458,7 +434,6 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { name: "IsReady DaemonSet with error", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -475,7 +450,6 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -497,7 +471,6 @@ func Test_ReadyChecker_IsReady_DaemonSet(t *testing.T) { func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -517,7 +490,6 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { name: "IsReady StatefulSet", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -533,7 +505,6 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { name: "IsReady StatefulSet with error", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -550,7 +521,6 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -572,7 +542,6 @@ func Test_ReadyChecker_IsReady_StatefulSet(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -592,7 +561,6 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { name: "IsReady ReplicationController", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -608,7 +576,6 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { name: "IsReady ReplicationController with error", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -624,7 +591,6 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { name: "IsReady ReplicationController and pods not ready for object", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -641,7 +607,6 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } @@ -663,7 +628,6 @@ func Test_ReadyChecker_IsReady_ReplicationController(t *testing.T) { func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { type fields struct { client kubernetes.Interface - log *slog.Logger checkJobs bool pausedAsReady bool } @@ -683,7 +647,6 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { name: "IsReady ReplicaSet", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -699,7 +662,6 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { name: "IsReady ReplicaSet not ready", fields: fields{ client: fake.NewClientset(), - log: slog.New(slog.NewTextHandler(io.Discard, nil)), checkJobs: true, pausedAsReady: false, }, @@ -716,7 +678,6 @@ func Test_ReadyChecker_IsReady_ReplicaSet(t *testing.T) { t.Run(tt.name, func(t *testing.T) { c := &ReadyChecker{ client: tt.fields.client, - log: tt.fields.log, checkJobs: tt.fields.checkJobs, pausedAsReady: tt.fields.pausedAsReady, } diff --git a/pkg/kube/statuswait.go b/pkg/kube/statuswait.go index bcb48155b..2d7cfe971 100644 --- a/pkg/kube/statuswait.go +++ b/pkg/kube/statuswait.go @@ -43,7 +43,6 @@ import ( type statusWaiter struct { client dynamic.Interface restMapper meta.RESTMapper - log *slog.Logger } func alwaysReady(_ *unstructured.Unstructured) (*status.Result, error) { @@ -56,7 +55,7 @@ func alwaysReady(_ *unstructured.Unstructured) (*status.Result, error) { func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - w.log.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) + slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) jobSR := helmStatusReaders.NewCustomJobStatusReader(w.restMapper) podSR := helmStatusReaders.NewCustomPodStatusReader(w.restMapper) @@ -77,7 +76,7 @@ func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.D func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() - w.log.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) + slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) return w.wait(ctx, resourceList, sw) } @@ -85,7 +84,7 @@ func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) er func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() - w.log.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) + slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) newCustomJobStatusReader := helmStatusReaders.NewCustomJobStatusReader(w.restMapper) customSR := statusreaders.NewStatusReader(w.restMapper, newCustomJobStatusReader) @@ -96,7 +95,7 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { ctx, cancel := context.WithTimeout(context.TODO(), timeout) defer cancel() - w.log.Debug("waiting for resources to be deleted", "count", len(resourceList), "timeout", timeout) + slog.Debug("waiting for resources to be deleted", "count", len(resourceList), "timeout", timeout) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) return w.waitForDelete(ctx, resourceList, sw) } @@ -114,7 +113,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL } eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus, w.log)) + done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.NotFoundStatus)) <-done if statusCollector.Error != nil { @@ -157,7 +156,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw w eventCh := sw.Watch(cancelCtx, resources, watcher.Options{}) statusCollector := collector.NewResourceStatusCollector(resources) - done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus, w.log)) + done := statusCollector.ListenWithObserver(eventCh, statusObserver(cancel, status.CurrentStatus)) <-done if statusCollector.Error != nil { @@ -180,7 +179,7 @@ func (w *statusWaiter) wait(ctx context.Context, resourceList ResourceList, sw w return nil } -func statusObserver(cancel context.CancelFunc, desired status.Status, logger *slog.Logger) collector.ObserverFunc { +func statusObserver(cancel context.CancelFunc, desired status.Status) collector.ObserverFunc { return func(statusCollector *collector.ResourceStatusCollector, _ event.Event) { var rss []*event.ResourceStatus var nonDesiredResources []*event.ResourceStatus @@ -210,7 +209,7 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logger *sl return nonDesiredResources[i].Identifier.Name < nonDesiredResources[j].Identifier.Name }) first := nonDesiredResources[0] - logger.Debug("waiting for resource", "name", first.Identifier.Name, "kind", first.Identifier.GroupKind.Kind, "expectedStatus", desired, "actualStatus", first.Status) + slog.Debug("waiting for resource", "name", first.Identifier.Name, "kind", first.Identifier.GroupKind.Kind, "expectedStatus", desired, "actualStatus", first.Status) } } } diff --git a/pkg/kube/statuswait_test.go b/pkg/kube/statuswait_test.go index 7226058c4..0b309b22d 100644 --- a/pkg/kube/statuswait_test.go +++ b/pkg/kube/statuswait_test.go @@ -18,8 +18,6 @@ package kube // import "helm.sh/helm/v3/pkg/kube" import ( "errors" - "io" - "log/slog" "testing" "time" @@ -219,7 +217,6 @@ func TestStatusWaitForDelete(t *testing.T) { statusWaiter := statusWaiter{ restMapper: fakeMapper, client: fakeClient, - log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objsToCreate := getRuntimeObjFromManifests(t, tt.manifestsToCreate) for _, objToCreate := range objsToCreate { @@ -260,7 +257,6 @@ func TestStatusWaitForDeleteNonExistentObject(t *testing.T) { statusWaiter := statusWaiter{ restMapper: fakeMapper, client: fakeClient, - log: slog.New(slog.NewTextHandler(io.Discard, nil)), } // Don't create the object to test that the wait for delete works when the object doesn't exist objManifest := getRuntimeObjFromManifests(t, []string{podCurrentManifest}) @@ -319,7 +315,6 @@ func TestStatusWait(t *testing.T) { statusWaiter := statusWaiter{ client: fakeClient, restMapper: fakeMapper, - log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { @@ -373,7 +368,6 @@ func TestWaitForJobComplete(t *testing.T) { statusWaiter := statusWaiter{ client: fakeClient, restMapper: fakeMapper, - log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { @@ -433,7 +427,6 @@ func TestWatchForReady(t *testing.T) { statusWaiter := statusWaiter{ client: fakeClient, restMapper: fakeMapper, - log: slog.New(slog.NewTextHandler(io.Discard, nil)), } objs := getRuntimeObjFromManifests(t, tt.objManifests) for _, obj := range objs { diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 75598542e..f384193e6 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -50,24 +50,23 @@ import ( // Helm 4 now uses the StatusWaiter implementation instead type legacyWaiter struct { c ReadyChecker - log *slog.Logger kubeClient *kubernetes.Clientset } func (hw *legacyWaiter) Wait(resources ResourceList, timeout time.Duration) error { - hw.c = NewReadyChecker(hw.kubeClient, hw.log, PausedAsReady(true)) + hw.c = NewReadyChecker(hw.kubeClient, PausedAsReady(true)) return hw.waitForResources(resources, timeout) } func (hw *legacyWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error { - hw.c = NewReadyChecker(hw.kubeClient, hw.log, PausedAsReady(true), CheckJobs(true)) + hw.c = NewReadyChecker(hw.kubeClient, PausedAsReady(true), CheckJobs(true)) return hw.waitForResources(resources, timeout) } // waitForResources polls to get the current status of all pods, PVCs, Services and // Jobs(optional) until all are ready or a timeout is reached func (hw *legacyWaiter) waitForResources(created ResourceList, timeout time.Duration) error { - hw.log.Debug("beginning wait for resources", "count", len(created), "timeout", timeout) + slog.Debug("beginning wait for resources", "count", len(created), "timeout", timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() @@ -85,10 +84,10 @@ func (hw *legacyWaiter) waitForResources(created ResourceList, timeout time.Dura if waitRetries > 0 && hw.isRetryableError(err, v) { numberOfErrors[i]++ if numberOfErrors[i] > waitRetries { - hw.log.Debug("max number of retries reached", "resource", v.Name, "retries", numberOfErrors[i]) + slog.Debug("max number of retries reached", "resource", v.Name, "retries", numberOfErrors[i]) return false, err } - hw.log.Debug("retrying resource readiness", "resource", v.Name, "currentRetries", numberOfErrors[i]-1, "maxRetries", waitRetries) + slog.Debug("retrying resource readiness", "resource", v.Name, "currentRetries", numberOfErrors[i]-1, "maxRetries", waitRetries) return false, nil } numberOfErrors[i] = 0 @@ -104,14 +103,14 @@ func (hw *legacyWaiter) isRetryableError(err error, resource *resource.Info) boo if err == nil { return false } - hw.log.Debug("error received when checking resource status", "resource", resource.Name, slog.Any("error", err)) + slog.Debug("error received when checking resource status", "resource", resource.Name, slog.Any("error", err)) if ev, ok := err.(*apierrors.StatusError); ok { statusCode := ev.Status().Code retryable := hw.isRetryableHTTPStatusCode(statusCode) - hw.log.Debug("status code received", "resource", resource.Name, "statusCode", statusCode, "retryable", retryable) + slog.Debug("status code received", "resource", resource.Name, "statusCode", statusCode, "retryable", retryable) return retryable } - hw.log.Debug("retryable error assumed", "resource", resource.Name) + slog.Debug("retryable error assumed", "resource", resource.Name) return true } @@ -121,7 +120,7 @@ func (hw *legacyWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { - hw.log.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", timeout) + slog.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", timeout) startTime := time.Now() ctx, cancel := context.WithTimeout(context.Background(), timeout) @@ -139,9 +138,9 @@ func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duratio elapsed := time.Since(startTime).Round(time.Second) if err != nil { - hw.log.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err)) + slog.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err)) } else { - hw.log.Debug("wait for resources succeeded", "elapsed", elapsed) + slog.Debug("wait for resources succeeded", "elapsed", elapsed) } return err @@ -249,7 +248,7 @@ func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.In return nil } - hw.log.Debug("watching for resource changes", "kind", kind, "resource", info.Name, "timeout", timeout) + slog.Debug("watching for resource changes", "kind", kind, "resource", info.Name, "timeout", timeout) // Use a selector on the name of the resource. This should be unique for the // given version and kind @@ -277,7 +276,7 @@ func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.In // we get. We care mostly about jobs, where what we want to see is // the status go into a good state. For other types, like ReplicaSet // we don't really do anything to support these as hooks. - hw.log.Debug("add/modify event received", "resource", info.Name, "eventType", e.Type) + slog.Debug("add/modify event received", "resource", info.Name, "eventType", e.Type) switch kind { case "Job": @@ -287,11 +286,11 @@ func (hw *legacyWaiter) watchUntilReady(timeout time.Duration, info *resource.In } return true, nil case watch.Deleted: - hw.log.Debug("deleted event received", "resource", info.Name) + slog.Debug("deleted event received", "resource", info.Name) return true, nil case watch.Error: // Handle error and return with an error. - hw.log.Error("error event received", "resource", info.Name) + slog.Error("error event received", "resource", info.Name) return true, errors.Errorf("failed to deploy %s", info.Name) default: return false, nil @@ -313,12 +312,12 @@ func (hw *legacyWaiter) waitForJob(obj runtime.Object, name string) (bool, error if c.Type == batchv1.JobComplete && c.Status == "True" { return true, nil } else if c.Type == batchv1.JobFailed && c.Status == "True" { - hw.log.Error("job failed", "job", name, "reason", c.Reason) + slog.Error("job failed", "job", name, "reason", c.Reason) return true, errors.Errorf("job %s failed: %s", name, c.Reason) } } - hw.log.Debug("job status update", "job", name, "active", o.Status.Active, "failed", o.Status.Failed, "succeeded", o.Status.Succeeded) + slog.Debug("job status update", "job", name, "active", o.Status.Active, "failed", o.Status.Failed, "succeeded", o.Status.Succeeded) return false, nil } @@ -333,15 +332,15 @@ func (hw *legacyWaiter) waitForPodSuccess(obj runtime.Object, name string) (bool switch o.Status.Phase { case corev1.PodSucceeded: - hw.log.Debug("pod succeeded", "pod", o.Name) + slog.Debug("pod succeeded", "pod", o.Name) return true, nil case corev1.PodFailed: - hw.log.Error("pod failed", "pod", o.Name) + slog.Error("pod failed", "pod", o.Name) return true, errors.Errorf("pod %s failed", o.Name) case corev1.PodPending: - hw.log.Debug("pod pending", "pod", o.Name) + slog.Debug("pod pending", "pod", o.Name) case corev1.PodRunning: - hw.log.Debug("pod running", "pod", o.Name) + slog.Debug("pod running", "pod", o.Name) } return false, nil diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index dba9a138d..3e4acfd81 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -44,7 +44,6 @@ const ConfigMapsDriverName = "ConfigMap" // ConfigMapsInterface. type ConfigMaps struct { impl corev1.ConfigMapInterface - Log *slog.Logger } // NewConfigMaps initializes a new ConfigMaps wrapping an implementation of @@ -70,13 +69,13 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) { return nil, ErrReleaseNotFound } - cfgmaps.Log.Debug("failed to get release", "key", key, slog.Any("error", err)) + slog.Debug("failed to get release", "key", key, slog.Any("error", err)) return nil, err } // found the configmap, decode the base64 data string r, err := decodeRelease(obj.Data["release"]) if err != nil { - cfgmaps.Log.Debug("failed to decode data", "key", key, slog.Any("error", err)) + slog.Debug("failed to decode data", "key", key, slog.Any("error", err)) return nil, err } r.Labels = filterSystemLabels(obj.ObjectMeta.Labels) @@ -93,7 +92,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas list, err := cfgmaps.impl.List(context.Background(), opts) if err != nil { - cfgmaps.Log.Debug("failed to list releases", slog.Any("error", err)) + slog.Debug("failed to list releases", slog.Any("error", err)) return nil, err } @@ -104,7 +103,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas for _, item := range list.Items { rls, err := decodeRelease(item.Data["release"]) if err != nil { - cfgmaps.Log.Debug("failed to decode release", "item", item, slog.Any("error", err)) + slog.Debug("failed to decode release", "item", item, slog.Any("error", err)) continue } @@ -132,7 +131,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err list, err := cfgmaps.impl.List(context.Background(), opts) if err != nil { - cfgmaps.Log.Debug("failed to query with labels", slog.Any("error", err)) + slog.Debug("failed to query with labels", slog.Any("error", err)) return nil, err } @@ -144,7 +143,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err for _, item := range list.Items { rls, err := decodeRelease(item.Data["release"]) if err != nil { - cfgmaps.Log.Debug("failed to decode release", slog.Any("error", err)) + slog.Debug("failed to decode release", slog.Any("error", err)) continue } rls.Labels = item.ObjectMeta.Labels @@ -166,7 +165,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error { // create a new configmap to hold the release obj, err := newConfigMapsObject(key, rls, lbs) if err != nil { - cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, slog.Any("error", err)) + slog.Debug("failed to encode release", "name", rls.Name, slog.Any("error", err)) return err } // push the configmap object out into the kubiverse @@ -175,7 +174,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error { return ErrReleaseExists } - cfgmaps.Log.Debug("failed to create release", slog.Any("error", err)) + slog.Debug("failed to create release", slog.Any("error", err)) return err } return nil @@ -194,13 +193,13 @@ func (cfgmaps *ConfigMaps) Update(key string, rls *rspb.Release) error { // create a new configmap object to hold the release obj, err := newConfigMapsObject(key, rls, lbs) if err != nil { - cfgmaps.Log.Debug("failed to encode release", "name", rls.Name, slog.Any("error", err)) + slog.Debug("failed to encode release", "name", rls.Name, slog.Any("error", err)) return err } // push the configmap object out into the kubiverse _, err = cfgmaps.impl.Update(context.Background(), obj, metav1.UpdateOptions{}) if err != nil { - cfgmaps.Log.Debug("failed to update release", slog.Any("error", err)) + slog.Debug("failed to update release", slog.Any("error", err)) return err } return nil diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index b5bf08bf4..54fda0542 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -19,8 +19,6 @@ package driver // import "helm.sh/helm/v4/pkg/storage/driver" import ( "context" "fmt" - "io" - "log/slog" "testing" sqlmock "github.com/DATA-DOG/go-sqlmock" @@ -266,6 +264,5 @@ func newTestFixtureSQL(t *testing.T, _ ...*rspb.Release) (*SQL, sqlmock.Sqlmock) db: sqlxDB, namespace: "default", statementBuilder: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), - Log: slog.New(slog.NewTextHandler(io.Discard, nil)), }, mock } diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index 5045774e6..a69f1ed65 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -44,7 +44,6 @@ const SecretsDriverName = "Secret" // SecretsInterface. type Secrets struct { impl corev1.SecretInterface - Log *slog.Logger } // NewSecrets initializes a new Secrets wrapping an implementation of @@ -96,7 +95,7 @@ func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log.Debug("list failed to decode release", "key", item.Name, slog.Any("error", err)) + slog.Debug("list failed to decode release", "key", item.Name, slog.Any("error", err)) continue } @@ -135,7 +134,7 @@ func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error) for _, item := range list.Items { rls, err := decodeRelease(string(item.Data["release"])) if err != nil { - secrets.Log.Debug("failed to decode release", "key", item.Name, slog.Any("error", err)) + slog.Debug("failed to decode release", "key", item.Name, slog.Any("error", err)) continue } rls.Labels = item.ObjectMeta.Labels diff --git a/pkg/storage/driver/sql.go b/pkg/storage/driver/sql.go index 9f54de7f8..c3740b9a3 100644 --- a/pkg/storage/driver/sql.go +++ b/pkg/storage/driver/sql.go @@ -87,8 +87,6 @@ type SQL struct { db *sqlx.DB namespace string statementBuilder sq.StatementBuilderType - - Log *slog.Logger } // Name returns the name of the driver. @@ -109,13 +107,13 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool { records, err := migrate.GetMigrationRecords(s.db.DB, postgreSQLDialect) migrate.SetDisableCreateTable(false) if err != nil { - s.Log.Debug("failed to get migration records", slog.Any("error", err)) + slog.Debug("failed to get migration records", slog.Any("error", err)) return false } for _, record := range records { if _, ok := migrationsIDs[record.Id]; ok { - s.Log.Debug("found previous migration", "id", record.Id, "appliedAt", record.AppliedAt) + slog.Debug("found previous migration", "id", record.Id, "appliedAt", record.AppliedAt) delete(migrationsIDs, record.Id) } } @@ -123,7 +121,7 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool { // check if all migrations applied if len(migrationsIDs) != 0 { for id := range migrationsIDs { - s.Log.Debug("find unapplied migration", "id", id) + slog.Debug("find unapplied migration", "id", id) } return false } @@ -277,7 +275,7 @@ type SQLReleaseCustomLabelWrapper struct { } // NewSQL initializes a new sql driver. -func NewSQL(connectionString string, logger *slog.Logger, namespace string) (*SQL, error) { +func NewSQL(connectionString string, namespace string) (*SQL, error) { db, err := sqlx.Connect(postgreSQLDialect, connectionString) if err != nil { return nil, err @@ -285,7 +283,6 @@ func NewSQL(connectionString string, logger *slog.Logger, namespace string) (*SQ driver := &SQL{ db: db, - Log: logger, statementBuilder: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), } @@ -310,24 +307,24 @@ func (s *SQL) Get(key string) (*rspb.Release, error) { query, args, err := qb.ToSql() if err != nil { - s.Log.Debug("failed to build query", slog.Any("error", err)) + slog.Debug("failed to build query", slog.Any("error", err)) return nil, err } // Get will return an error if the result is empty if err := s.db.Get(&record, query, args...); err != nil { - s.Log.Debug("got SQL error when getting release", "key", key, slog.Any("error", err)) + slog.Debug("got SQL error when getting release", "key", key, slog.Any("error", err)) return nil, ErrReleaseNotFound } release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode data", "key", key, slog.Any("error", err)) + slog.Debug("failed to decode data", "key", key, slog.Any("error", err)) return nil, err } if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, slog.Any("error", err)) + slog.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, slog.Any("error", err)) return nil, err } @@ -348,13 +345,13 @@ func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) { query, args, err := sb.ToSql() if err != nil { - s.Log.Debug("failed to build query", slog.Any("error", err)) + slog.Debug("failed to build query", slog.Any("error", err)) return nil, err } var records = []SQLReleaseWrapper{} if err := s.db.Select(&records, query, args...); err != nil { - s.Log.Debug("failed to list", slog.Any("error", err)) + slog.Debug("failed to list", slog.Any("error", err)) return nil, err } @@ -362,12 +359,12 @@ func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) { for _, record := range records { release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode release", "record", record, slog.Any("error", err)) + slog.Debug("failed to decode release", "record", record, slog.Any("error", err)) continue } if release.Labels, err = s.getReleaseCustomLabels(record.Key, record.Namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, slog.Any("error", err)) + slog.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, slog.Any("error", err)) return nil, err } for k, v := range getReleaseSystemLabels(release) { @@ -397,7 +394,7 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { if _, ok := labelMap[key]; ok { sb = sb.Where(sq.Eq{key: labels[key]}) } else { - s.Log.Debug("unknown label", "key", key) + slog.Debug("unknown label", "key", key) return nil, fmt.Errorf("unknown label %s", key) } } @@ -410,13 +407,13 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { // Build our query query, args, err := sb.ToSql() if err != nil { - s.Log.Debug("failed to build query", slog.Any("error", err)) + slog.Debug("failed to build query", slog.Any("error", err)) return nil, err } var records = []SQLReleaseWrapper{} if err := s.db.Select(&records, query, args...); err != nil { - s.Log.Debug("failed to query with labels", slog.Any("error", err)) + slog.Debug("failed to query with labels", slog.Any("error", err)) return nil, err } @@ -428,12 +425,12 @@ func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error) { for _, record := range records { release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode release", "record", record, slog.Any("error", err)) + slog.Debug("failed to decode release", "record", record, slog.Any("error", err)) continue } if release.Labels, err = s.getReleaseCustomLabels(record.Key, record.Namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, slog.Any("error", err)) + slog.Debug("failed to get release custom labels", "namespace", record.Namespace, "key", record.Key, slog.Any("error", err)) return nil, err } @@ -457,13 +454,13 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { body, err := encodeRelease(rls) if err != nil { - s.Log.Debug("failed to encode release", slog.Any("error", err)) + slog.Debug("failed to encode release", slog.Any("error", err)) return err } transaction, err := s.db.Beginx() if err != nil { - s.Log.Debug("failed to start SQL transaction", slog.Any("error", err)) + slog.Debug("failed to start SQL transaction", slog.Any("error", err)) return fmt.Errorf("error beginning transaction: %v", err) } @@ -492,7 +489,7 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { int(time.Now().Unix()), ).ToSql() if err != nil { - s.Log.Debug("failed to build insert query", slog.Any("error", err)) + slog.Debug("failed to build insert query", slog.Any("error", err)) return err } @@ -506,17 +503,17 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if buildErr != nil { - s.Log.Debug("failed to build select query", "error", buildErr) + slog.Debug("failed to build select query", "error", buildErr) return err } var record SQLReleaseWrapper if err := transaction.Get(&record, selectQuery, args...); err == nil { - s.Log.Debug("release already exists", "key", key) + slog.Debug("release already exists", "key", key) return ErrReleaseExists } - s.Log.Debug("failed to store release in SQL database", "key", key, slog.Any("error", err)) + slog.Debug("failed to store release in SQL database", "key", key, slog.Any("error", err)) return err } @@ -539,13 +536,13 @@ func (s *SQL) Create(key string, rls *rspb.Release) error { if err != nil { defer transaction.Rollback() - s.Log.Debug("failed to build insert query", slog.Any("error", err)) + slog.Debug("failed to build insert query", slog.Any("error", err)) return err } if _, err := transaction.Exec(insertLabelsQuery, args...); err != nil { defer transaction.Rollback() - s.Log.Debug("failed to write Labels", slog.Any("error", err)) + slog.Debug("failed to write Labels", slog.Any("error", err)) return err } } @@ -564,7 +561,7 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { body, err := encodeRelease(rls) if err != nil { - s.Log.Debug("failed to encode release", slog.Any("error", err)) + slog.Debug("failed to encode release", slog.Any("error", err)) return err } @@ -581,12 +578,12 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { ToSql() if err != nil { - s.Log.Debug("failed to build update query", slog.Any("error", err)) + slog.Debug("failed to build update query", slog.Any("error", err)) return err } if _, err := s.db.Exec(query, args...); err != nil { - s.Log.Debug("failed to update release in SQL database", "key", key, slog.Any("error", err)) + slog.Debug("failed to update release in SQL database", "key", key, slog.Any("error", err)) return err } @@ -597,7 +594,7 @@ func (s *SQL) Update(key string, rls *rspb.Release) error { func (s *SQL) Delete(key string) (*rspb.Release, error) { transaction, err := s.db.Beginx() if err != nil { - s.Log.Debug("failed to start SQL transaction", slog.Any("error", err)) + slog.Debug("failed to start SQL transaction", slog.Any("error", err)) return nil, fmt.Errorf("error beginning transaction: %v", err) } @@ -608,20 +605,20 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if err != nil { - s.Log.Debug("failed to build select query", slog.Any("error", err)) + slog.Debug("failed to build select query", slog.Any("error", err)) return nil, err } var record SQLReleaseWrapper err = transaction.Get(&record, selectQuery, args...) if err != nil { - s.Log.Debug("release not found", "key", key, slog.Any("error", err)) + slog.Debug("release not found", "key", key, slog.Any("error", err)) return nil, ErrReleaseNotFound } release, err := decodeRelease(record.Body) if err != nil { - s.Log.Debug("failed to decode release", "key", key, slog.Any("error", err)) + slog.Debug("failed to decode release", "key", key, slog.Any("error", err)) transaction.Rollback() return nil, err } @@ -633,18 +630,18 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { Where(sq.Eq{sqlReleaseTableNamespaceColumn: s.namespace}). ToSql() if err != nil { - s.Log.Debug("failed to build delete query", slog.Any("error", err)) + slog.Debug("failed to build delete query", slog.Any("error", err)) return nil, err } _, err = transaction.Exec(deleteQuery, args...) if err != nil { - s.Log.Debug("failed perform delete query", slog.Any("error", err)) + slog.Debug("failed perform delete query", slog.Any("error", err)) return release, err } if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil { - s.Log.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, slog.Any("error", err)) + slog.Debug("failed to get release custom labels", "namespace", s.namespace, "key", key, slog.Any("error", err)) return nil, err } @@ -655,7 +652,7 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) { ToSql() if err != nil { - s.Log.Debug("failed to build delete Labels query", slog.Any("error", err)) + slog.Debug("failed to build delete Labels query", slog.Any("error", err)) return nil, err } _, err = transaction.Exec(deleteCustomLabelsQuery, args...) diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 5e8718ea0..f98daeba6 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -18,6 +18,7 @@ package storage // import "helm.sh/helm/v4/pkg/storage" import ( "fmt" + "log/slog" "strings" "github.com/pkg/errors" @@ -42,15 +43,13 @@ type Storage struct { // be retained, including the most recent release. Values of 0 or less are // ignored (meaning no limits are imposed). MaxHistory int - - Log func(string, ...interface{}) } // Get retrieves the release from storage. An error is returned // if the storage driver failed to fetch the release, or the // release identified by the key, version pair does not exist. func (s *Storage) Get(name string, version int) (*rspb.Release, error) { - s.Log("getting release %q", makeKey(name, version)) + slog.Debug("getting release", "key", makeKey(name, version)) return s.Driver.Get(makeKey(name, version)) } @@ -58,7 +57,7 @@ func (s *Storage) Get(name string, version int) (*rspb.Release, error) { // error is returned if the storage driver fails to store the // release, or a release with an identical key already exists. func (s *Storage) Create(rls *rspb.Release) error { - s.Log("creating release %q", makeKey(rls.Name, rls.Version)) + slog.Debug("creating release", "key", makeKey(rls.Name, rls.Version)) if s.MaxHistory > 0 { // Want to make space for one more release. if err := s.removeLeastRecent(rls.Name, s.MaxHistory-1); err != nil && @@ -73,7 +72,7 @@ func (s *Storage) Create(rls *rspb.Release) error { // storage backend fails to update the release or if the release // does not exist. func (s *Storage) Update(rls *rspb.Release) error { - s.Log("updating release %q", makeKey(rls.Name, rls.Version)) + slog.Debug("updating release", "key", makeKey(rls.Name, rls.Version)) return s.Driver.Update(makeKey(rls.Name, rls.Version), rls) } @@ -81,21 +80,21 @@ func (s *Storage) Update(rls *rspb.Release) error { // the storage backend fails to delete the release or if the release // does not exist. func (s *Storage) Delete(name string, version int) (*rspb.Release, error) { - s.Log("deleting release %q", makeKey(name, version)) + slog.Debug("deleting release", "key", makeKey(name, version)) return s.Driver.Delete(makeKey(name, version)) } // ListReleases returns all releases from storage. An error is returned if the // storage backend fails to retrieve the releases. func (s *Storage) ListReleases() ([]*rspb.Release, error) { - s.Log("listing all releases in storage") + slog.Debug("listing all releases in storage") return s.Driver.List(func(_ *rspb.Release) bool { return true }) } // ListUninstalled returns all releases with Status == UNINSTALLED. An error is returned // if the storage backend fails to retrieve the releases. func (s *Storage) ListUninstalled() ([]*rspb.Release, error) { - s.Log("listing uninstalled releases in storage") + slog.Debug("listing uninstalled releases in storage") return s.Driver.List(func(rls *rspb.Release) bool { return relutil.StatusFilter(rspb.StatusUninstalled).Check(rls) }) @@ -104,7 +103,7 @@ func (s *Storage) ListUninstalled() ([]*rspb.Release, error) { // ListDeployed returns all releases with Status == DEPLOYED. An error is returned // if the storage backend fails to retrieve the releases. func (s *Storage) ListDeployed() ([]*rspb.Release, error) { - s.Log("listing all deployed releases in storage") + slog.Debug("listing all deployed releases in storage") return s.Driver.List(func(rls *rspb.Release) bool { return relutil.StatusFilter(rspb.StatusDeployed).Check(rls) }) @@ -132,7 +131,7 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) { // DeployedAll returns all deployed releases with the provided name, or // returns driver.NewErrNoDeployedReleases if not found. func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) { - s.Log("getting deployed releases from %q history", name) + slog.Debug("getting deployed releases", "name", name) ls, err := s.Driver.Query(map[string]string{ "name": name, @@ -151,7 +150,7 @@ func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) { // History returns the revision history for the release with the provided name, or // returns driver.ErrReleaseNotFound if no such release name exists. func (s *Storage) History(name string) ([]*rspb.Release, error) { - s.Log("getting release history for %q", name) + slog.Debug("getting release history", "name", name) return s.Driver.Query(map[string]string{"name": name, "owner": "helm"}) } @@ -206,7 +205,7 @@ func (s *Storage) removeLeastRecent(name string, maximum int) error { } } - s.Log("Pruned %d record(s) from %s with %d error(s)", len(toDelete), name, len(errs)) + slog.Debug("pruned records", "count", len(toDelete), "release", name, "errors", len(errs)) switch c := len(errs); c { case 0: return nil @@ -221,7 +220,7 @@ func (s *Storage) deleteReleaseVersion(name string, version int) error { key := makeKey(name, version) _, err := s.Delete(name, version) if err != nil { - s.Log("error pruning %s from release history: %s", key, err) + slog.Debug("error pruning release", "key", key, slog.Any("error", err)) return err } return nil @@ -229,7 +228,7 @@ func (s *Storage) deleteReleaseVersion(name string, version int) error { // Last fetches the last revision of the named release. func (s *Storage) Last(name string) (*rspb.Release, error) { - s.Log("getting last revision of %q", name) + slog.Debug("getting last revision", "name", name) h, err := s.History(name) if err != nil { return nil, err @@ -261,6 +260,5 @@ func Init(d driver.Driver) *Storage { } return &Storage{ Driver: d, - Log: func(_ string, _ ...interface{}) {}, } } diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index 1dadc9c93..f99d10214 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -312,7 +312,6 @@ func (d *MaxHistoryMockDriver) Name() string { func TestMaxHistoryErrorHandling(t *testing.T) { //func TestStorageRemoveLeastRecentWithError(t *testing.T) { storage := Init(NewMaxHistoryMockDriver(driver.NewMemory())) - storage.Log = t.Logf storage.MaxHistory = 1 @@ -338,7 +337,6 @@ func TestMaxHistoryErrorHandling(t *testing.T) { func TestStorageRemoveLeastRecent(t *testing.T) { storage := Init(driver.NewMemory()) - storage.Log = t.Logf // Make sure that specifying this at the outset doesn't cause any bugs. storage.MaxHistory = 10 @@ -395,7 +393,6 @@ func TestStorageRemoveLeastRecent(t *testing.T) { func TestStorageDoNotDeleteDeployed(t *testing.T) { storage := Init(driver.NewMemory()) - storage.Log = t.Logf storage.MaxHistory = 3 const name = "angry-bird" From e7eedae97cb8ea9050ec220a7cb33445c0b791f9 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Apr 2025 16:01:12 +0200 Subject: [PATCH 261/271] Use the logger with proper handling of dynamic debug on 2 locations Signed-off-by: Benoit Tigeot --- .../logger.go => internal/logging/logging.go | 26 +++++++++++-------- pkg/action/action.go | 2 -- pkg/action/action_test.go | 20 +++----------- pkg/cmd/root.go | 3 ++- 4 files changed, 21 insertions(+), 30 deletions(-) rename pkg/cli/logger.go => internal/logging/logging.go (76%) diff --git a/pkg/cli/logger.go b/internal/logging/logging.go similarity index 76% rename from pkg/cli/logger.go rename to internal/logging/logging.go index 03a69be24..946a211ef 100644 --- a/pkg/cli/logger.go +++ b/internal/logging/logging.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cli +package logging import ( "context" @@ -22,16 +22,20 @@ import ( "os" ) +// DebugEnabledFunc is a function type that determines if debug logging is enabled +// We use a function because we want to check the setting at log time, not when the logger is created +type DebugEnabledFunc func() bool + // DebugCheckHandler checks settings.Debug at log time type DebugCheckHandler struct { - handler slog.Handler - settings *EnvSettings + handler slog.Handler + debugEnabled DebugEnabledFunc } // Enabled implements slog.Handler.Enabled func (h *DebugCheckHandler) Enabled(_ context.Context, level slog.Level) bool { if level == slog.LevelDebug { - return h.settings.Debug // Check settings.Debug at log time + return h.debugEnabled() } return true // Always log other levels } @@ -44,21 +48,21 @@ func (h *DebugCheckHandler) Handle(ctx context.Context, r slog.Record) error { // WithAttrs implements slog.Handler.WithAttrs func (h *DebugCheckHandler) WithAttrs(attrs []slog.Attr) slog.Handler { return &DebugCheckHandler{ - handler: h.handler.WithAttrs(attrs), - settings: h.settings, + handler: h.handler.WithAttrs(attrs), + debugEnabled: h.debugEnabled, } } // WithGroup implements slog.Handler.WithGroup func (h *DebugCheckHandler) WithGroup(name string) slog.Handler { return &DebugCheckHandler{ - handler: h.handler.WithGroup(name), - settings: h.settings, + handler: h.handler.WithGroup(name), + debugEnabled: h.debugEnabled, } } // NewLogger creates a new logger with dynamic debug checking -func NewLogger(settings *EnvSettings) *slog.Logger { +func NewLogger(debugEnabled DebugEnabledFunc) *slog.Logger { // Create base handler that removes timestamps baseHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ // Always use LevelDebug here to allow all messages through @@ -75,8 +79,8 @@ func NewLogger(settings *EnvSettings) *slog.Logger { // Wrap with our dynamic debug-checking handler dynamicHandler := &DebugCheckHandler{ - handler: baseHandler, - settings: settings, + handler: baseHandler, + debugEnabled: debugEnabled, } return slog.New(dynamicHandler) diff --git a/pkg/action/action.go b/pkg/action/action.go index 09c1887bb..47a7da99c 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -378,8 +378,6 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp clientFn: kc.Factory.KubernetesClientSet, } - // slog.SetDefault() - var store *storage.Storage switch helmDriver { case "secret", "secrets", "": diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index f544d3281..4a0691afb 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -20,12 +20,12 @@ import ( "fmt" "io" "log/slog" - "os" "testing" "github.com/stretchr/testify/assert" fakeclientset "k8s.io/client-go/kubernetes/fake" + "helm.sh/helm/v4/internal/logging" chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" kubefake "helm.sh/helm/v4/pkg/kube/fake" @@ -41,21 +41,9 @@ var verbose = flag.Bool("test.log", false, "enable test logging (debug by defaul func actionConfigFixture(t *testing.T) *Configuration { t.Helper() - logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - if *verbose { - // Create a handler that removes timestamps - handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ - Level: slog.LevelDebug, - ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { - // Remove the time attribute - if a.Key == slog.TimeKey { - return slog.Attr{} - } - return a - }, - }) - logger = slog.New(handler) - } + logger := logging.NewLogger(func() bool { + return *verbose + }) slog.SetDefault(logger) registryClient, err := registry.NewClient() diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index e9305206a..ee22533f0 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -32,6 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" + "helm.sh/helm/v4/internal/logging" "helm.sh/helm/v4/internal/tlsutil" "helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/cli" @@ -139,7 +140,7 @@ func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, arg settings.AddFlags(flags) addKlogFlags(flags) - logger := cli.NewLogger(settings) + logger := logging.NewLogger(func() bool { return settings.Debug }) slog.SetDefault(logger) // Setup shell completion for the namespace flag From 7f02e89a7a3c88120c424f46471dd11ac9650db5 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Apr 2025 16:12:52 +0200 Subject: [PATCH 262/271] No longer log call location using flag, it will need to be done in slog Some ideas here: https://www.reddit.com/r/golang/comments/15nwnkl/achieve_lshortfile_with_slog/ Signed-off-by: Benoit Tigeot --- cmd/helm/helm.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 273ead226..eefce5158 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -17,7 +17,6 @@ limitations under the License. package main // import "helm.sh/helm/v4/cmd/helm" import ( - "log" "log/slog" "os" @@ -28,10 +27,6 @@ import ( "helm.sh/helm/v4/pkg/kube" ) -func init() { - log.SetFlags(log.Lshortfile) -} - 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 From c05bcbd498d62fc5c5794aef9279582dab8c8285 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Apr 2025 16:32:52 +0200 Subject: [PATCH 263/271] Fix nil pointer dereference in ready test Signed-off-by: Benoit Tigeot --- pkg/kube/ready_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index 64cf68749..9d1dfd272 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -754,7 +754,7 @@ func Test_ReadyChecker_deploymentReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) if got := c.deploymentReady(tt.args.rs, tt.args.dep); got != tt.want { t.Errorf("deploymentReady() = %v, want %v", got, tt.want) } @@ -788,7 +788,7 @@ func Test_ReadyChecker_replicaSetReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) if got := c.replicaSetReady(tt.args.rs); got != tt.want { t.Errorf("replicaSetReady() = %v, want %v", got, tt.want) } @@ -822,7 +822,7 @@ func Test_ReadyChecker_replicationControllerReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) if got := c.replicationControllerReady(tt.args.rc); got != tt.want { t.Errorf("replicationControllerReady() = %v, want %v", got, tt.want) } @@ -877,7 +877,7 @@ func Test_ReadyChecker_daemonSetReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) if got := c.daemonSetReady(tt.args.ds); got != tt.want { t.Errorf("daemonSetReady() = %v, want %v", got, tt.want) } @@ -953,7 +953,7 @@ func Test_ReadyChecker_statefulSetReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) if got := c.statefulSetReady(tt.args.sts); got != tt.want { t.Errorf("statefulSetReady() = %v, want %v", got, tt.want) } @@ -1012,7 +1012,7 @@ func Test_ReadyChecker_podsReadyForObject(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) for _, pod := range tt.existPods { if _, err := c.client.CoreV1().Pods(defaultNamespace).Create(context.TODO(), &pod, metav1.CreateOptions{}); err != nil { t.Errorf("Failed to create Pod error: %v", err) @@ -1091,7 +1091,7 @@ func Test_ReadyChecker_jobReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) got, err := c.jobReady(tt.args.job) if (err != nil) != tt.wantErr { t.Errorf("jobReady() error = %v, wantErr %v", err, tt.wantErr) @@ -1130,7 +1130,7 @@ func Test_ReadyChecker_volumeReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) if got := c.volumeReady(tt.args.v); got != tt.want { t.Errorf("volumeReady() = %v, want %v", got, tt.want) } @@ -1175,7 +1175,7 @@ func Test_ReadyChecker_serviceReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) got := c.serviceReady(tt.args.service) if got != tt.want { t.Errorf("serviceReady() = %v, want %v", got, tt.want) @@ -1244,7 +1244,7 @@ func Test_ReadyChecker_crdBetaReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) got := c.crdBetaReady(tt.args.crdBeta) if got != tt.want { t.Errorf("crdBetaReady() = %v, want %v", got, tt.want) @@ -1313,7 +1313,7 @@ func Test_ReadyChecker_crdReady(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c := NewReadyChecker(fake.NewClientset(), nil) + c := NewReadyChecker(fake.NewClientset()) got := c.crdReady(tt.args.crdBeta) if got != tt.want { t.Errorf("crdBetaReady() = %v, want %v", got, tt.want) From 68440d7b2908342687a30daf4677732c0ce5478b Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Thu, 10 Apr 2025 17:38:32 +0200 Subject: [PATCH 264/271] Prefer using slog.Any when displaying errors Signed-off-by: Benoit Tigeot --- pkg/action/action.go | 2 +- pkg/action/uninstall.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 47a7da99c..4b90b2d5c 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -265,7 +265,7 @@ func (cfg *Configuration) getCapabilities() (*chartutil.Capabilities, error) { apiVersions, err := GetVersionSet(dc) if err != nil { if discovery.IsGroupDiscoveryFailedError(err) { - slog.Warn("the kubernetes server has an orphaned API service", "errors", err) + slog.Warn("the kubernetes server has an orphaned API service", slog.Any("error", err)) slog.Warn("to fix this, kubectl delete apiservice ") } else { return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index b842d9933..fa69d2a48 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -127,7 +127,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) deletedResources, kept, errs := u.deleteRelease(rel) if errs != nil { - slog.Debug("uninstall: Failed to delete release", "errors", errs) + slog.Debug("uninstall: Failed to delete release", slog.Any("error", errs)) return nil, errors.Errorf("failed to delete release: %s", name) } From 7938662f959011d9fa6763f6124834ea446ae424 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 19 Mar 2025 13:54:00 -0400 Subject: [PATCH 265/271] Remove ValidName regex This regex was already deprecated. Validation happens inside the Metadata Validate function for the name instead of using this regex. Signed-off-by: Matt Farina --- pkg/action/action.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index ea2dc0dd7..187df5412 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -23,7 +23,6 @@ import ( "os" "path" "path/filepath" - "regexp" "strings" "github.com/pkg/errors" @@ -63,21 +62,6 @@ var ( errPending = errors.New("another operation (install/upgrade/rollback) is in progress") ) -// ValidName is a regular expression for resource names. -// -// DEPRECATED: This will be removed in Helm 4, and is no longer used here. See -// pkg/lint/rules.validateMetadataNameFunc for the replacement. -// -// According to the Kubernetes help text, the regular expression it uses is: -// -// [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)* -// -// This follows the above regular expression (but requires a full string match, not partial). -// -// The Kubernetes documentation is here, though it is not entirely correct: -// https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names -var ValidName = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`) - // Configuration injects the dependencies that all actions share. type Configuration struct { // RESTClientGetter is an interface that loads Kubernetes clients. From ed005f5c320c2059da3528f967e556d5123496b3 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 10 Apr 2025 13:45:02 -0400 Subject: [PATCH 266/271] Removing deprecation notice for this function. While the constructor is not used by Helm itself, it is used by SDK users and there is currently no alternative way to expose this. Signed-off-by: Matt Farina --- pkg/engine/lookup_func.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index b7460850a..5b96dd386 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -35,9 +35,6 @@ type lookupFunc = func(apiversion string, resource string, namespace string, nam // NewLookupFunction returns a function for looking up objects in the cluster. // // If the resource does not exist, no error is raised. -// -// This function is considered deprecated, and will be renamed in Helm 4. It will no -// longer be a public function. func NewLookupFunction(config *rest.Config) lookupFunc { return newLookupFunction(clientProviderFromConfig{config: config}) } From 483789ac860985a183529bb4988bc2b7d01134c0 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 11 Apr 2025 10:56:41 +0200 Subject: [PATCH 267/271] Bumps github.com/distribution/distribution/v3 from 3.0.0-rc.3 to 3.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` ยป go mod download go: module github.com/distribution/distribution/v3@v3.0.0 requires go >= 1.23.7; switching to go1.23.8 ``` We need to update Go, because of https://github.com/distribution/distribution/pull/4601 Signed-off-by: Benoit Tigeot --- go.mod | 10 ++++++---- go.sum | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index aef4a656d..7d7447040 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module helm.sh/helm/v4 -go 1.23.0 +go 1.23.7 + +toolchain go1.23.8 require ( github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 @@ -12,7 +14,7 @@ require ( github.com/Masterminds/vcs v1.13.3 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 github.com/cyphar/filepath-securejoin v0.4.1 - github.com/distribution/distribution/v3 v3.0.0-rc.3 + github.com/distribution/distribution/v3 v3.0.0 github.com/evanphx/json-patch v5.9.11+incompatible github.com/fluxcd/cli-utils v0.36.0-flux.12 github.com/foxcpp/go-mockdns v1.1.0 @@ -129,7 +131,7 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 // indirect - github.com/redis/go-redis/v9 v9.6.3 // indirect + github.com/redis/go-redis/v9 v9.7.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect @@ -163,7 +165,7 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect golang.org/x/mod v0.22.0 // indirect golang.org/x/net v0.37.0 // indirect - golang.org/x/oauth2 v0.25.0 // indirect + golang.org/x/oauth2 v0.28.0 // indirect golang.org/x/sync v0.13.0 // indirect golang.org/x/sys v0.32.0 // indirect golang.org/x/time v0.9.0 // indirect diff --git a/go.sum b/go.sum index 456e1cfcf..4438b96ac 100644 --- a/go.sum +++ b/go.sum @@ -65,6 +65,7 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/distribution/distribution/v3 v3.0.0-rc.3 h1:JRJso9IVLoooKX76oWR+DWCCdZlK5m4nRtDWvzB1ITg= github.com/distribution/distribution/v3 v3.0.0-rc.3/go.mod h1:offoOgrnYs+CFwis8nE0hyzYZqRCZj5EFc5kgfszwiE= +github.com/distribution/distribution/v3 v3.0.0/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= @@ -291,6 +292,7 @@ github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnA github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= github.com/redis/go-redis/v9 v9.6.3 h1:8Dr5ygF1QFXRxIH/m3Xg9MMG1rS8YCtAgosrsewT6i0= github.com/redis/go-redis/v9 v9.6.3/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA= +github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rubenv/sql-migrate v1.7.1 h1:f/o0WgfO/GqNuVg+6801K/KW3WdDSupzSjDYODmiUq4= @@ -421,6 +423,7 @@ golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 00db8d6d96b788598603765600b9458d3a39c6e1 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 11 Apr 2025 11:01:29 +0200 Subject: [PATCH 268/271] Go mod tidy Signed-off-by: Benoit Tigeot --- go.sum | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/go.sum b/go.sum index 4438b96ac..675bed1d8 100644 --- a/go.sum +++ b/go.sum @@ -63,8 +63,7 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/distribution/distribution/v3 v3.0.0-rc.3 h1:JRJso9IVLoooKX76oWR+DWCCdZlK5m4nRtDWvzB1ITg= -github.com/distribution/distribution/v3 v3.0.0-rc.3/go.mod h1:offoOgrnYs+CFwis8nE0hyzYZqRCZj5EFc5kgfszwiE= +github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN6UX90KJc4HjyM= github.com/distribution/distribution/v3 v3.0.0/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= @@ -290,8 +289,7 @@ github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5/go.mod h1:fyalQWdtzDBECAQFBJu github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb27yVE+gIAfeqp8LUCc= github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ= github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= -github.com/redis/go-redis/v9 v9.6.3 h1:8Dr5ygF1QFXRxIH/m3Xg9MMG1rS8YCtAgosrsewT6i0= -github.com/redis/go-redis/v9 v9.6.3/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA= +github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM= github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= @@ -421,8 +419,7 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= -golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc= golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 0d43534ab76e4c285f6a797e8644d4e23d200552 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 11 Apr 2025 15:58:11 +0200 Subject: [PATCH 269/271] Testing without bump go version Signed-off-by: Benoit Tigeot --- go.mod | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7d7447040..f198aa17d 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module helm.sh/helm/v4 -go 1.23.7 - -toolchain go1.23.8 +go 1.23.0 require ( github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 From 365340b09242cb2d2339043fbdc40dc8dc0a060c Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 11 Apr 2025 16:04:50 +0200 Subject: [PATCH 270/271] Follow distribution package requirement go: github.com/distribution/distribution/v3@v3.0.0 requires go >= 1.23.7; switching to go1.23.8 Signed-off-by: Benoit Tigeot --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f198aa17d..190fcff0f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module helm.sh/helm/v4 -go 1.23.0 +go 1.23.7 require ( github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 From 91ecb56355d1560ad6e6dbf0464042badca70ddb Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 11 Apr 2025 15:57:53 -0400 Subject: [PATCH 271/271] Removing the alpine test chart A .gitignore was previously setup to ignore this file. When pkg/cmd was setup the .gitignore was not updated. The change adds the new location to continue to ignore this file. Note, the previous location is still included in the .gitignore because developers will have a file there and we do not want that accidently included in a commit. Signed-off-by: Matt Farina --- .gitignore | 1 + .../issue-7233/charts/alpine-0.1.0.tgz | Bin 1167 -> 0 bytes 2 files changed, 1 insertion(+) delete mode 100644 pkg/cmd/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz diff --git a/.gitignore b/.gitignore index 75698e993..7ea0717ed 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ bin/ vendor/ # Ignores charts pulled for dependency build tests cmd/helm/testdata/testcharts/issue-7233/charts/* +pkg/cmd/testdata/testcharts/issue-7233/charts/* .pre-commit-config.yaml diff --git a/pkg/cmd/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz b/pkg/cmd/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz deleted file mode 100644 index afd021846ed6a2f7cc2cf023ed188a7cf2f9d189..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1167 zcmV;A1aSKwiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI-XZsRr+&b6LmpuJto@*y$Scfr34{EN1WMOrLS6h%Fj#ugEZ zR7uK;>-D=AJjjWaZc?CYrw7fAAd37rGn{W`DC89rH2hzI$|PGX`Nh|lG)>d1>C`>b zH0?gq@#W>kXgZrsXS2~by}C$8dd9SW<{}927eIliq6m!^& zBCM*zYdlHb#8FN-#>=q*)TZUJG5nq_e9f(O23qP~Ml=20O_nnPhsrRT$8LA*?K z;hvE|`^kq}q-Cu#((`C=n7n4DsFz75OE=#y+O)c)$tX#qmv+{_Py+uq$ZOIkN&wIC zKOLuC{?F2@p8w~N4~~}Qb`Y5P()#prUJ3j+R8|}f>7gGOR5Jf++29%ek0;Y{hyRz; zY0v+&NT>eaGLg^Wqs*g{4CZKX9s&5;9q)F@4RJzEiA@{({b09CKKaVw2jU2T4eE)i2~P@50=~5F94>Y)|7*hU=(Jz&=f2yz(~mhRPLG& z$^l``HY6Z(O)I=NVezWwu#yTeFPYHL6cQQ~#zJZ$XbLm|N_jIhAXKOf%W96w?PZ}9 z=}HRCmYghJ;ubw+!yF#C=6g~bmJxi0Uu$Uy_WP$@!Gty_GKwLSVnf1qT2SIGX5n!u#05lSibC4@A1;IB5RBM25u)q{(pdm$&DMDkNr=7`uRo5Y3GPTw5$WVLa zT`M0iJ+yGU9VGsmaeZhqA3BHW$5vyVGvm)0YK`llVB1)_4?ZwG@_ktP_ppr*OaR~I zI3te2HqsSkHe!Pwx{!^ALN->1T3gR+R#u!mLgHsNjC0^p-uj?}3bm$uz=WUW;4+tHl)A88ky z+)*+DyRAVcNVz;Q2nnV^W=Oe{VkNF^%JJ1`{)O1_r<%#KM4PsLiib-khME&q@$2|a znx^s3eMj@8g!+H;?)vR_?~*b<#U9V~|Cd*@ZvUT-`}_Y{H$l1UW(C~L@2fGduigL&u(Z@M?PosbL<7QghdA0+Uf?u^1;PV^Vx z+57)w(&7JfG`j5he-1IEjjh4{KY$B^fe(YfPmK0*Itl!@&ETo%|0nq0z5h>UlS$A2 hbI39OZ5Z_Q@1>VsdigKN?*RY+|NrPaN*Dkj008|nJ|6%8