mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 08:32:48 +02:00
* fix(state): honor skipSchemaValidation in chartify template args Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/a695cbff-c37a-403a-9658-09f4fdaa65d0 Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> * test(state): harden chartify skip-schema flag detection Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/a695cbff-c37a-403a-9658-09f4fdaa65d0 Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> * fix(state): propagate cli skip-schema-validation to chartify Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/70ebf027-0ab5-4bdb-a4b4-5a77c822ee95 Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
87 lines
2.1 KiB
Go
87 lines
2.1 KiB
Go
package state
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAppendSkipSchemaValidationFlagToChartifyTemplateArgs(t *testing.T) {
|
|
enable := true
|
|
|
|
tests := []struct {
|
|
name string
|
|
defaults HelmSpec
|
|
release *ReleaseSpec
|
|
fromCLI bool
|
|
templateArgs string
|
|
want string
|
|
}{
|
|
{
|
|
name: "adds flag from release setting",
|
|
release: &ReleaseSpec{
|
|
SkipSchemaValidation: &enable,
|
|
},
|
|
want: "--skip-schema-validation",
|
|
},
|
|
{
|
|
name: "adds flag from helm defaults",
|
|
defaults: HelmSpec{
|
|
SkipSchemaValidation: &enable,
|
|
},
|
|
release: &ReleaseSpec{},
|
|
want: "--skip-schema-validation",
|
|
},
|
|
{
|
|
name: "appends flag to existing args",
|
|
release: &ReleaseSpec{
|
|
SkipSchemaValidation: &enable,
|
|
},
|
|
templateArgs: "--kube-context default",
|
|
want: "--kube-context default --skip-schema-validation",
|
|
},
|
|
{
|
|
name: "does not duplicate existing flag",
|
|
release: &ReleaseSpec{
|
|
SkipSchemaValidation: &enable,
|
|
},
|
|
templateArgs: "--skip-schema-validation --kube-context default",
|
|
want: "--skip-schema-validation --kube-context default",
|
|
},
|
|
{
|
|
name: "does not treat similar flag values as existing flag",
|
|
release: &ReleaseSpec{
|
|
SkipSchemaValidation: &enable,
|
|
},
|
|
templateArgs: "--set name=foo--skip-schema-validation",
|
|
want: "--set name=foo--skip-schema-validation --skip-schema-validation",
|
|
},
|
|
{
|
|
name: "adds flag from cli setting",
|
|
release: &ReleaseSpec{},
|
|
fromCLI: true,
|
|
templateArgs: "--kube-context default",
|
|
want: "--kube-context default --skip-schema-validation",
|
|
},
|
|
{
|
|
name: "does not add flag when disabled",
|
|
release: &ReleaseSpec{},
|
|
templateArgs: "--kube-context default",
|
|
want: "--kube-context default",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
st := &HelmState{
|
|
ReleaseSetSpec: ReleaseSetSpec{
|
|
HelmDefaults: tt.defaults,
|
|
},
|
|
}
|
|
|
|
got := st.appendSkipSchemaValidationFlagToChartifyTemplateArgs(tt.templateArgs, tt.release, tt.fromCLI)
|
|
require.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|