mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-21 11:20:23 +02:00
fix(oci): clean dead code (#290)
fix(oci): remove dead code Signed-off-by: Jean-Yves CAMIER <jycamier@gmail.com> Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
co-authored by
Yusuke Kuoka
parent
d4e4d10fa1
commit
b8cf0f156e
+13
-19
@@ -458,21 +458,15 @@ func (helm *execer) Fetch(chart string, flags ...string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (helm *execer) ChartPull(chart string, flags ...string) error {
|
||||
helm.logger.Infof("Pulling %v", chart)
|
||||
helm.logger.Infof("Exporting %v", chart)
|
||||
helmVersionConstraint, _ := semver.NewConstraint(">= 3.7.0")
|
||||
func (helm *execer) ChartPull(chart string, path string, flags ...string) error {
|
||||
var helmArgs []string
|
||||
helm.logger.Infof("Pulling %v", chart)
|
||||
helmVersionConstraint, _ := semver.NewConstraint(">= 3.7.0")
|
||||
if helmVersionConstraint.Check(&helm.version) {
|
||||
// in the 3.7.0 version, the chart pull has been replaced with helm pull
|
||||
// https://github.com/helm/helm/releases/tag/v3.7.0
|
||||
ociChartURL, ociChartTag := resolveOciChart(chart)
|
||||
tempDir, err := os.MkdirTemp("", "chart*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = os.RemoveAll(tempDir)
|
||||
}()
|
||||
helmArgs = []string{"fetch", ociChartURL, "--version", ociChartTag, "--destination", tempDir}
|
||||
helmArgs = []string{"pull", ociChartURL, "--version", ociChartTag, "--destination", path}
|
||||
} else {
|
||||
helmArgs = []string{"chart", "pull", chart}
|
||||
}
|
||||
@@ -482,16 +476,16 @@ func (helm *execer) ChartPull(chart string, flags ...string) error {
|
||||
}
|
||||
|
||||
func (helm *execer) ChartExport(chart string, path string, flags ...string) error {
|
||||
helm.logger.Infof("Exporting %v", chart)
|
||||
helmVersionConstraint, _ := semver.NewConstraint(">= 3.7.0")
|
||||
var helmArgs []string
|
||||
if helmVersionConstraint.Check(&helm.version) {
|
||||
ociChartURL, ociChartTag := resolveOciChart(chart)
|
||||
helmArgs = []string{"pull", ociChartURL, "--version", ociChartTag, "--untar"}
|
||||
} else {
|
||||
helmArgs = []string{"chart", "export", chart}
|
||||
// in the 3.7.0 version, the chart export has been removed
|
||||
// https://github.com/helm/helm/releases/tag/v3.7.0
|
||||
return nil
|
||||
}
|
||||
out, err := helm.exec(append(append(helmArgs, "--destination", path), flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}, nil)
|
||||
var helmArgs []string
|
||||
helm.logger.Infof("Exporting %v", chart)
|
||||
helmArgs = []string{"chart", "export", chart, "--destination", path}
|
||||
out, err := helm.exec(append(helmArgs, flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}, nil)
|
||||
helm.info(out)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -710,6 +710,7 @@ func Test_ChartPull(t *testing.T) {
|
||||
helmBin string
|
||||
helmVersion string
|
||||
chartName string
|
||||
chartPath string
|
||||
chartFlags []string
|
||||
listResult string
|
||||
}{
|
||||
@@ -718,9 +719,9 @@ func Test_ChartPull(t *testing.T) {
|
||||
helmBin: "helm",
|
||||
helmVersion: "v3.6.0",
|
||||
chartName: "chart",
|
||||
chartPath: "path1",
|
||||
chartFlags: []string{"--untar", "--untardir", "/tmp/dir"},
|
||||
listResult: `Pulling chart
|
||||
Exporting chart
|
||||
exec: helm --kube-context dev chart pull chart --untar --untardir /tmp/dir
|
||||
`,
|
||||
},
|
||||
@@ -729,10 +730,10 @@ exec: helm --kube-context dev chart pull chart --untar --untardir /tmp/dir
|
||||
helmBin: "helm",
|
||||
helmVersion: "v3.9.0",
|
||||
chartName: "repo/helm-charts:0.14.0",
|
||||
chartPath: "path1",
|
||||
chartFlags: []string{"--untardir", "/tmp/dir"},
|
||||
listResult: `Pulling repo/helm-charts:0.14.0
|
||||
Exporting repo/helm-charts:0.14.0
|
||||
exec: helm --kube-context dev fetch oci://repo/helm-charts --version 0.14.0 --destination [\w/]+ --untardir /tmp/dir
|
||||
exec: helm --kube-context dev pull oci://repo/helm-charts --version 0.14.0 --destination path1 --untardir /tmp/dir
|
||||
`,
|
||||
},
|
||||
}
|
||||
@@ -747,7 +748,7 @@ exec: helm --kube-context dev fetch oci://repo/helm-charts --version 0.14.0 --de
|
||||
kubeContext: "dev",
|
||||
runner: &mockRunner{},
|
||||
}
|
||||
err := helm.ChartPull(tt.chartName, tt.chartFlags...)
|
||||
err := helm.ChartPull(tt.chartName, tt.chartPath, tt.chartFlags...)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -781,18 +782,6 @@ func Test_ChartExport(t *testing.T) {
|
||||
chartFlags: []string{"--untar", "--untardir", "/tmp/dir"},
|
||||
listResult: `Exporting chart
|
||||
exec: helm --kube-context dev chart export chart --destination path1 --untar --untardir /tmp/dir
|
||||
`,
|
||||
expectedError: "",
|
||||
},
|
||||
{
|
||||
name: "",
|
||||
helmBin: "helm",
|
||||
helmVersion: "v3.9.0",
|
||||
chartName: "repo/helm-charts:0.14.0",
|
||||
chartPath: "path1",
|
||||
chartFlags: []string{"--untardir", "/tmp/dir"},
|
||||
listResult: `Exporting repo/helm-charts:0.14.0
|
||||
exec: helm --kube-context dev pull oci://repo/helm-charts --version 0.14.0 --untar --destination path1 --untardir /tmp/dir
|
||||
`,
|
||||
expectedError: "",
|
||||
},
|
||||
|
||||
@@ -22,7 +22,7 @@ type Interface interface {
|
||||
DiffRelease(context HelmContext, name, chart string, suppressDiff bool, flags ...string) error
|
||||
TemplateRelease(name, chart string, flags ...string) error
|
||||
Fetch(chart string, flags ...string) error
|
||||
ChartPull(chart string, flags ...string) error
|
||||
ChartPull(chart string, path string, flags ...string) error
|
||||
ChartExport(chart string, path string, flags ...string) error
|
||||
Lint(name, chart string, flags ...string) error
|
||||
ReleaseStatus(context HelmContext, name string, flags ...string) error
|
||||
|
||||
Reference in New Issue
Block a user