From a6863a64ce1f4d9e538b787d2afaa0266d79afd7 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Thu, 4 Apr 2024 11:14:23 +0200 Subject: [PATCH 1/2] Drop unused field. Signed-off-by: Marcin Owsiany --- pkg/action/action.go | 2 +- pkg/action/uninstall.go | 6 +----- pkg/chartutil/capabilities.go | 3 ++- pkg/releaseutil/manifest_sorter.go | 4 +--- pkg/releaseutil/manifest_sorter_test.go | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 863c48f07..26981033a 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -165,7 +165,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu // Sort hooks, manifests, and partials. Only hooks and manifests are returned, // as partials are not used after renderer.Render. Empty manifests are also // removed here. - hs, manifests, err := releaseutil.SortManifests(files, caps.APIVersions, releaseutil.InstallOrder) + hs, manifests, err := releaseutil.SortManifests(files, nil, releaseutil.InstallOrder) if err != nil { // By catching parse errors here, we can prevent bogus releases from going // to Kubernetes. diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 40d82243e..ac0c4fee8 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -196,13 +196,9 @@ func joinErrors(errs []error) string { // deleteRelease deletes the release and returns list of delete resources and manifests that were kept in the deletion process func (u *Uninstall) deleteRelease(rel *release.Release) (kube.ResourceList, string, []error) { var errs []error - caps, err := u.cfg.getCapabilities() - if err != nil { - return nil, rel.Manifest, []error{errors.Wrap(err, "could not get apiVersions from Kubernetes")} - } manifests := releaseutil.SplitManifests(rel.Manifest) - _, files, err := releaseutil.SortManifests(manifests, caps.APIVersions, releaseutil.UninstallOrder) + _, files, err := releaseutil.SortManifests(manifests, nil, releaseutil.UninstallOrder) if err != nil { // We could instead just delete everything in no particular order. // FIXME: One way to delete at this point would be to try a label-based diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index 5f57e11a5..bcc4a8c24 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -53,7 +53,8 @@ var ( type Capabilities struct { // KubeVersion is the Kubernetes version. KubeVersion KubeVersion - // APIversions are supported Kubernetes API versions. + // APIVersions are supported Kubernetes API versions. + // This field is unused. APIVersions VersionSet // HelmVersion is the build information for this helm version HelmVersion helmversion.BuildInfo diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/releaseutil/manifest_sorter.go index 413de30e2..4b6109929 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/releaseutil/manifest_sorter.go @@ -41,7 +41,6 @@ type Manifest struct { type manifestFile struct { entries map[string]string path string - apis chartutil.VersionSet } // result is an intermediate structure used during sorting. @@ -75,7 +74,7 @@ var events = map[string]release.HookEvent{ // // Files that do not parse into the expected format are simply placed into a map and // returned. -func SortManifests(files map[string]string, apis chartutil.VersionSet, ordering KindSortOrder) ([]*release.Hook, []Manifest, error) { +func SortManifests(files map[string]string, _ chartutil.VersionSet, ordering KindSortOrder) ([]*release.Hook, []Manifest, error) { result := &result{} var sortedFilePaths []string @@ -100,7 +99,6 @@ func SortManifests(files map[string]string, apis chartutil.VersionSet, ordering manifestFile := &manifestFile{ entries: SplitManifests(content), path: filePath, - apis: apis, } if err := manifestFile.sort(result); err != nil { diff --git a/pkg/releaseutil/manifest_sorter_test.go b/pkg/releaseutil/manifest_sorter_test.go index 20d809317..020ff4516 100644 --- a/pkg/releaseutil/manifest_sorter_test.go +++ b/pkg/releaseutil/manifest_sorter_test.go @@ -22,7 +22,6 @@ import ( "sigs.k8s.io/yaml" - "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/release" ) @@ -139,7 +138,7 @@ metadata: manifests[o.path] = o.manifest } - hs, generic, err := SortManifests(manifests, chartutil.VersionSet{"v1", "v1beta1"}, InstallOrder) + hs, generic, err := SortManifests(manifests, nil, InstallOrder) if err != nil { t.Fatalf("Unexpected error: %s", err) } From f5d2ac070db449e623d336ac56ef5130d6ba5e16 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Mon, 15 Apr 2024 21:24:22 +0200 Subject: [PATCH 2/2] Remove somewhat incorrect comment. While no longer used by the helm code, this field is part of the API exposed to helm charts as part of the .Capabilities struct. Signed-off-by: Marcin Owsiany --- pkg/chartutil/capabilities.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index bcc4a8c24..48fab0ea4 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -54,7 +54,6 @@ type Capabilities struct { // KubeVersion is the Kubernetes version. KubeVersion KubeVersion // APIVersions are supported Kubernetes API versions. - // This field is unused. APIVersions VersionSet // HelmVersion is the build information for this helm version HelmVersion helmversion.BuildInfo