fix validate options

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2025-11-09 12:10:51 +08:00
parent c506caa33f
commit a38b07bd4a
8 changed files with 19 additions and 15 deletions
+1 -1
View File
@@ -646,7 +646,7 @@ func (helm *execer) write(w io.Writer, out []byte) {
}
}
func (helm *execer) IsHelm3() bool {
func (helm *execer) IsOverHelm3() bool {
return helm.version.Major() >= 3
}
+5 -5
View File
@@ -1063,14 +1063,14 @@ exec: helm --kubeconfig config --kube-context dev template release https://examp
}
}
func Test_IsHelm3(t *testing.T) {
func Test_IsOverHelm3(t *testing.T) {
helm2Runner := mockRunner{output: []byte("Client: v2.16.0+ge13bc94\n")}
helm, err := New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "", "dev", &helm2Runner)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if helm.IsHelm3() {
t.Error("helmexec.IsHelm3() - Detected Helm 3 with Helm 2 version")
if helm.IsOverHelm3() {
t.Error("helmexec.IsOverHelm3() - Detected Helm 3 with Helm 2 version")
}
helm3Runner := mockRunner{output: []byte("v3.0.0+ge29ce2a\n")}
@@ -1078,8 +1078,8 @@ func Test_IsHelm3(t *testing.T) {
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !helm.IsHelm3() {
t.Error("helmexec.IsHelm3() - Failed to detect Helm 3")
if !helm.IsOverHelm3() {
t.Error("helmexec.IsOverHelm3() - Failed to detect Helm 3")
}
}
+2 -2
View File
@@ -33,7 +33,7 @@ type Interface interface {
TestRelease(context HelmContext, name string, flags ...string) error
List(context HelmContext, filter string, flags ...string) (string, error)
DecryptSecret(context HelmContext, name string, flags ...string) (string, error)
IsHelm3() bool
IsOverHelm3() bool
GetVersion() Version
IsVersionAtLeast(versionStr string) bool
ShowChart(chart string) (chart.Metadata, error)
@@ -41,5 +41,5 @@ type Interface interface {
type DependencyUpdater interface {
UpdateDeps(chart string) error
IsHelm3() bool
IsOverHelm3() bool
}