fix validate options
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
c506caa33f
commit
a38b07bd4a
|
|
@ -2588,7 +2588,7 @@ func (helm *mockHelmExec) Fetch(chart string, flags ...string) error {
|
||||||
func (helm *mockHelmExec) Lint(name, chart string, flags ...string) error {
|
func (helm *mockHelmExec) Lint(name, chart string, flags ...string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (helm *mockHelmExec) IsHelm3() bool {
|
func (helm *mockHelmExec) IsOverHelm3() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func NewRun(st *state.HelmState, helm helmexec.Interface, ctx Context) (*Run, er
|
||||||
return nil, fmt.Errorf("Assertion failed: helmexec.Interface must not be nil")
|
return nil, fmt.Errorf("Assertion failed: helmexec.Interface must not be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !helm.IsHelm3() {
|
if !helm.IsOverHelm3() {
|
||||||
return nil, fmt.Errorf("helmfile has deprecated helm2 since v0.150.0")
|
return nil, fmt.Errorf("helmfile has deprecated helm2 since v0.150.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ func (helm *Helm) ChartPull(chart string, path string, flags ...string) error {
|
||||||
func (helm *Helm) ChartExport(chart string, path string) error {
|
func (helm *Helm) ChartExport(chart string, path string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (helm *Helm) IsHelm3() bool {
|
func (helm *Helm) IsOverHelm3() bool {
|
||||||
if helm.Version == nil {
|
if helm.Version == nil {
|
||||||
return helm.Helm3
|
return helm.Helm3
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
return helm.version.Major() >= 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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")}
|
helm2Runner := mockRunner{output: []byte("Client: v2.16.0+ge13bc94\n")}
|
||||||
helm, err := New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "", "dev", &helm2Runner)
|
helm, err := New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "", "dev", &helm2Runner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
if helm.IsHelm3() {
|
if helm.IsOverHelm3() {
|
||||||
t.Error("helmexec.IsHelm3() - Detected Helm 3 with Helm 2 version")
|
t.Error("helmexec.IsOverHelm3() - Detected Helm 3 with Helm 2 version")
|
||||||
}
|
}
|
||||||
|
|
||||||
helm3Runner := mockRunner{output: []byte("v3.0.0+ge29ce2a\n")}
|
helm3Runner := mockRunner{output: []byte("v3.0.0+ge29ce2a\n")}
|
||||||
|
|
@ -1078,8 +1078,8 @@ func Test_IsHelm3(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
if !helm.IsHelm3() {
|
if !helm.IsOverHelm3() {
|
||||||
t.Error("helmexec.IsHelm3() - Failed to detect Helm 3")
|
t.Error("helmexec.IsOverHelm3() - Failed to detect Helm 3")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ type Interface interface {
|
||||||
TestRelease(context HelmContext, name string, flags ...string) error
|
TestRelease(context HelmContext, name string, flags ...string) error
|
||||||
List(context HelmContext, filter string, flags ...string) (string, error)
|
List(context HelmContext, filter string, flags ...string) (string, error)
|
||||||
DecryptSecret(context HelmContext, name string, flags ...string) (string, error)
|
DecryptSecret(context HelmContext, name string, flags ...string) (string, error)
|
||||||
IsHelm3() bool
|
IsOverHelm3() bool
|
||||||
GetVersion() Version
|
GetVersion() Version
|
||||||
IsVersionAtLeast(versionStr string) bool
|
IsVersionAtLeast(versionStr string) bool
|
||||||
ShowChart(chart string) (chart.Metadata, error)
|
ShowChart(chart string) (chart.Metadata, error)
|
||||||
|
|
@ -41,5 +41,5 @@ type Interface interface {
|
||||||
|
|
||||||
type DependencyUpdater interface {
|
type DependencyUpdater interface {
|
||||||
UpdateDeps(chart string) error
|
UpdateDeps(chart string) error
|
||||||
IsHelm3() bool
|
IsOverHelm3() bool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -576,7 +576,7 @@ func (st *HelmState) ApplyOverrides(spec *ReleaseSpec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RepoUpdater interface {
|
type RepoUpdater interface {
|
||||||
IsHelm3() bool
|
IsOverHelm3() bool
|
||||||
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials, skipTLSVerify bool) error
|
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials, skipTLSVerify bool) error
|
||||||
UpdateRepo() error
|
UpdateRepo() error
|
||||||
RegistryLogin(name, username, password, caFile, certFile, keyFile string, skipTLSVerify bool) error
|
RegistryLogin(name, username, password, caFile, certFile, keyFile string, skipTLSVerify bool) error
|
||||||
|
|
@ -1640,7 +1640,11 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string,
|
||||||
}
|
}
|
||||||
|
|
||||||
if validate {
|
if validate {
|
||||||
flags = append(flags, "--validate")
|
if helm.IsVersionAtLeast("4.0.0") {
|
||||||
|
flags = append(flags, "--dry-run=server")
|
||||||
|
} else {
|
||||||
|
flags = append(flags, "--validate")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.IncludeCRDs {
|
if opts.IncludeCRDs {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func NewVersionHelmExec(version string) *VersionHelmExec {
|
||||||
return &VersionHelmExec{noCallHelmExec: &noCallHelmExec{}, version: version}
|
return &VersionHelmExec{noCallHelmExec: &noCallHelmExec{}, version: version}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (helm *V3HelmExec) IsHelm3() bool {
|
func (helm *V3HelmExec) IsOverHelm3() bool {
|
||||||
return helm.isHelm3
|
return helm.isHelm3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,7 +127,7 @@ func (helm *noCallHelmExec) Lint(name, chart string, flags ...string) error {
|
||||||
helm.doPanic()
|
helm.doPanic()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (helm *noCallHelmExec) IsHelm3() bool {
|
func (helm *noCallHelmExec) IsOverHelm3() bool {
|
||||||
helm.doPanic()
|
helm.doPanic()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue