* fix #1095 Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
1fb1da270f
commit
0c3951097e
|
|
@ -1322,7 +1322,7 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
|||
st := r.state
|
||||
helm := r.helm
|
||||
|
||||
helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, nil)...)
|
||||
helm.SetExtraArgs(GetArgs(c.Args(), r.state)...)
|
||||
|
||||
selectedReleases, selectedAndNeededReleases, err := a.getSelectedReleases(r, c.IncludeTransitiveNeeds())
|
||||
if err != nil {
|
||||
|
|
@ -1368,21 +1368,15 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
|||
SkipDiffOnInstall: c.SkipDiffOnInstall(),
|
||||
ReuseValues: c.ReuseValues(),
|
||||
ResetValues: c.ResetValues(),
|
||||
DiffArgs: c.DiffArgs(),
|
||||
PostRenderer: c.PostRenderer(),
|
||||
}
|
||||
|
||||
// join --args and --diff-args together to one string.
|
||||
args := strings.Join([]string{c.Args(), c.DiffArgs()}, " ")
|
||||
argsOpts := &argparser.GetArgsOptions{WithDiffArgs: true}
|
||||
helm.SetExtraArgs(argparser.GetArgs(args, r.state, argsOpts)...)
|
||||
|
||||
infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts)
|
||||
if len(errs) > 0 {
|
||||
return false, false, errs
|
||||
}
|
||||
|
||||
helm.SetExtraArgs()
|
||||
|
||||
var toDelete []state.ReleaseSpec
|
||||
for _, r := range releasesToBeDeleted {
|
||||
toDelete = append(toDelete, r)
|
||||
|
|
@ -1570,7 +1564,7 @@ Do you really want to delete?
|
|||
`, strings.Join(names, "\n"))
|
||||
interactive := c.Interactive()
|
||||
if !interactive || interactive && r.askForConfirmation(msg) {
|
||||
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, nil)...)
|
||||
r.helm.SetExtraArgs(GetArgs(c.Args(), r.state)...)
|
||||
|
||||
if len(releasesToDelete) > 0 {
|
||||
_, deletionErrs := withDAG(st, helm, a.Logger, state.PlanOptions{SelectedReleases: toDelete, Reverse: true, SkipNeeds: true}, a.WrapWithoutSelector(func(subst *state.HelmState, helm helmexec.Interface) []error {
|
||||
|
|
@ -1595,10 +1589,6 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error)
|
|||
ok, errs := a.withNeeds(r, c, true, func(st *state.HelmState) []error {
|
||||
helm := r.helm
|
||||
|
||||
args := strings.Join([]string{c.Args(), c.DiffArgs()}, " ")
|
||||
argsOpts := &argparser.GetArgsOptions{WithDiffArgs: true}
|
||||
helm.SetExtraArgs(argparser.GetArgs(args, r.state, argsOpts)...)
|
||||
|
||||
var errs []error
|
||||
|
||||
opts := &state.DiffOpts{
|
||||
|
|
@ -1607,6 +1597,7 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error)
|
|||
Color: c.Color(),
|
||||
NoColor: c.NoColor(),
|
||||
Set: c.Set(),
|
||||
DiffArgs: c.DiffArgs(),
|
||||
SkipDiffOnInstall: c.SkipDiffOnInstall(),
|
||||
ReuseValues: c.ReuseValues(),
|
||||
ResetValues: c.ResetValues(),
|
||||
|
|
@ -1621,7 +1612,6 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error)
|
|||
}
|
||||
infoMsg, updated, deleted, errs = filtered.diff(true, c.DetailedExitcode(), c, opts)
|
||||
|
||||
helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, argsOpts)...)
|
||||
return errs
|
||||
})
|
||||
|
||||
|
|
@ -1634,7 +1624,7 @@ func (a *App) lint(r *Run, c LintConfigProvider) (bool, []error, []error) {
|
|||
ok, errs := a.withNeeds(r, c, false, func(st *state.HelmState) []error {
|
||||
helm := r.helm
|
||||
|
||||
args := argparser.GetArgs(c.Args(), st, nil)
|
||||
args := GetArgs(c.Args(), st)
|
||||
|
||||
// Reset the extra args if already set, not to break `helm fetch` by adding the args intended for `lint`
|
||||
helm.SetExtraArgs()
|
||||
|
|
@ -1695,7 +1685,7 @@ func (a *App) status(r *Run, c StatusesConfigProvider) (bool, []error) {
|
|||
// Traverse DAG of all the releases so that we don't suffer from false-positive missing dependencies
|
||||
st.Releases = allReleases
|
||||
|
||||
args := argparser.GetArgs(c.Args(), st, nil)
|
||||
args := GetArgs(c.Args(), st)
|
||||
|
||||
// Reset the extra args if already set, not to break `helm fetch` by adding the args intended for `lint`
|
||||
helm.SetExtraArgs()
|
||||
|
|
@ -1828,7 +1818,7 @@ Do you really want to sync?
|
|||
|
||||
var errs []error
|
||||
|
||||
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, nil)...)
|
||||
r.helm.SetExtraArgs(GetArgs(c.Args(), r.state)...)
|
||||
|
||||
// Traverse DAG of all the releases so that we don't suffer from false-positive missing dependencies
|
||||
st.Releases = selectedAndNeededReleases
|
||||
|
|
@ -1895,7 +1885,7 @@ func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) {
|
|||
return a.withNeeds(r, c, false, func(st *state.HelmState) []error {
|
||||
helm := r.helm
|
||||
|
||||
args := argparser.GetArgs(c.Args(), st, nil)
|
||||
args := GetArgs(c.Args(), st)
|
||||
|
||||
// Reset the extra args if already set, not to break `helm fetch` by adding the args intended for `lint`
|
||||
helm.SetExtraArgs()
|
||||
|
|
@ -2018,7 +2008,7 @@ func (a *App) test(r *Run, c TestConfigProvider) []error {
|
|||
// with conditions and selectors
|
||||
st.Releases = toTest
|
||||
|
||||
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, nil)...)
|
||||
r.helm.SetExtraArgs(GetArgs(c.Args(), r.state)...)
|
||||
|
||||
return st.TestReleases(r.helm, cleanup, timeout, concurrency, state.Logs(c.Logs()))
|
||||
}
|
||||
|
|
@ -2223,3 +2213,18 @@ func (a *App) CleanCacheDir(c CacheConfigProvider) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetArgs(args string, state *state.HelmState) []string {
|
||||
baseArgs := []string{}
|
||||
stateArgs := []string{}
|
||||
if len(args) > 0 {
|
||||
baseArgs = argparser.CollectArgs(args)
|
||||
}
|
||||
|
||||
if len(state.HelmDefaults.Args) > 0 {
|
||||
stateArgs = argparser.CollectArgs(strings.Join(state.HelmDefaults.Args, " "))
|
||||
}
|
||||
state.HelmDefaults.Args = append(baseArgs, stateArgs...)
|
||||
|
||||
return state.HelmDefaults.Args
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/helmfile/vals"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
"helm.sh/helm/v3/pkg/chart"
|
||||
|
||||
|
|
@ -4269,3 +4270,42 @@ func location() string {
|
|||
_, fn, line, _ := goruntime.Caller(1)
|
||||
return fmt.Sprintf("%s:%d", filepath.Base(fn), line)
|
||||
}
|
||||
|
||||
func TestGetArgs(t *testing.T) {
|
||||
tests := []struct {
|
||||
args string
|
||||
expected string
|
||||
defaultArgs []string
|
||||
}{
|
||||
{
|
||||
args: "-f a.yaml -f b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
defaultArgs: []string{"--recreate-pods", "--force"},
|
||||
expected: "-f a.yaml -f b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false --recreate-pods --force",
|
||||
},
|
||||
{
|
||||
args: "-e a.yaml -d b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
defaultArgs: []string{"-q www", "-w"},
|
||||
expected: "-e a.yaml -d b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false -q www -w",
|
||||
},
|
||||
{
|
||||
args: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
expected: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
},
|
||||
{
|
||||
args: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true",
|
||||
defaultArgs: []string{"--recreate-pods", "--force"},
|
||||
expected: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true --recreate-pods --force",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
Helmdefaults := state.HelmSpec{KubeContext: "test", Args: test.defaultArgs}
|
||||
testState := &state.HelmState{
|
||||
ReleaseSetSpec: state.ReleaseSetSpec{
|
||||
HelmDefaults: Helmdefaults,
|
||||
},
|
||||
}
|
||||
receivedArgs := GetArgs(test.args, testState)
|
||||
|
||||
require.Equalf(t, test.expected, strings.Join(receivedArgs, " "), "expected args %s, received args %s", test.expected, strings.Join(receivedArgs, " "))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/argparser"
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/state"
|
||||
)
|
||||
|
|
@ -105,13 +104,13 @@ func (r *Run) withPreparedCharts(helmfileCommand string, opts state.ChartPrepare
|
|||
}
|
||||
|
||||
func (r *Run) Deps(c DepsConfigProvider) []error {
|
||||
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, nil)...)
|
||||
r.helm.SetExtraArgs(GetArgs(c.Args(), r.state)...)
|
||||
|
||||
return r.state.UpdateDeps(r.helm, c.IncludeTransitiveNeeds())
|
||||
}
|
||||
|
||||
func (r *Run) Repos(c ReposConfigProvider) error {
|
||||
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state, nil)...)
|
||||
r.helm.SetExtraArgs(GetArgs(c.Args(), r.state)...)
|
||||
|
||||
return r.ctx.SyncReposOnce(r.state, r.helm)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package argparser
|
|||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/state"
|
||||
)
|
||||
|
||||
type keyVal struct {
|
||||
|
|
@ -16,9 +14,6 @@ type argMap struct {
|
|||
m map[string][]*keyVal
|
||||
flags []string
|
||||
}
|
||||
type GetArgsOptions struct {
|
||||
WithDiffArgs bool
|
||||
}
|
||||
|
||||
// isNewFlag checks if the given arg is a new flag
|
||||
func isNewFlag(flag string) bool {
|
||||
|
|
@ -86,23 +81,10 @@ func analyzeArgs(am *argMap, args string) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetArgs(args string, state *state.HelmState, opts *GetArgsOptions) []string {
|
||||
func CollectArgs(args string) []string {
|
||||
argsMap := newArgMap()
|
||||
|
||||
if len(args) > 0 {
|
||||
analyzeArgs(argsMap, args)
|
||||
}
|
||||
|
||||
if len(state.HelmDefaults.Args) > 0 {
|
||||
analyzeArgs(argsMap, strings.Join(state.HelmDefaults.Args, " "))
|
||||
}
|
||||
|
||||
if len(state.HelmDefaults.DiffArgs) > 0 && opts != nil && opts.WithDiffArgs {
|
||||
analyzeArgs(argsMap, strings.Join(state.HelmDefaults.DiffArgs, " "))
|
||||
}
|
||||
|
||||
analyzeArgs(argsMap, args)
|
||||
var argArr []string
|
||||
|
||||
for _, flag := range argsMap.flags {
|
||||
val := argsMap.m[flag]
|
||||
|
||||
|
|
@ -118,8 +100,5 @@ func GetArgs(args string, state *state.HelmState, opts *GetArgsOptions) []string
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
state.HelmDefaults.Args = argArr
|
||||
|
||||
return state.HelmDefaults.Args
|
||||
return argArr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,11 @@
|
|||
package argparser
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/state"
|
||||
)
|
||||
|
||||
// TestGetArgs tests the GetArgs function
|
||||
func TestGetArgs(t *testing.T) {
|
||||
tests := []struct {
|
||||
args string
|
||||
expected string
|
||||
defaultArgs []string
|
||||
defaultDiffArgs []string
|
||||
opts *GetArgsOptions
|
||||
}{
|
||||
{
|
||||
args: "-f a.yaml -f b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
defaultArgs: []string{"--recreate-pods", "--force"},
|
||||
defaultDiffArgs: []string{"--suppress", "Deployment"},
|
||||
opts: &GetArgsOptions{WithDiffArgs: true},
|
||||
expected: "-f a.yaml -f b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false --recreate-pods --force --suppress Deployment",
|
||||
},
|
||||
{
|
||||
args: "-e a.yaml -d b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
defaultArgs: []string{"-q www", "-w"},
|
||||
defaultDiffArgs: []string{},
|
||||
expected: "-e a.yaml -d b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false -q www -w",
|
||||
},
|
||||
{
|
||||
args: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
expected: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
},
|
||||
{
|
||||
args: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true",
|
||||
defaultArgs: []string{"--recreate-pods", "--force"},
|
||||
defaultDiffArgs: []string{"--suppress", "Deployment"},
|
||||
opts: &GetArgsOptions{},
|
||||
expected: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true --recreate-pods --force",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
Helmdefaults := state.HelmSpec{KubeContext: "test", Args: test.defaultArgs, DiffArgs: test.defaultDiffArgs}
|
||||
testState := &state.HelmState{
|
||||
ReleaseSetSpec: state.ReleaseSetSpec{
|
||||
HelmDefaults: Helmdefaults,
|
||||
},
|
||||
}
|
||||
receivedArgs := GetArgs(test.args, testState, test.opts)
|
||||
|
||||
require.Equalf(t, test.expected, strings.Join(receivedArgs, " "), "expected args %s, received args %s", test.expected, strings.Join(receivedArgs, " "))
|
||||
}
|
||||
}
|
||||
|
||||
// TestIsNewFlag tests the isNewFlag function
|
||||
func TestIsNewFlag(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
"helm.sh/helm/v3/pkg/cli"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/argparser"
|
||||
"github.com/helmfile/helmfile/pkg/environment"
|
||||
"github.com/helmfile/helmfile/pkg/event"
|
||||
"github.com/helmfile/helmfile/pkg/filesystem"
|
||||
|
|
@ -2446,6 +2447,16 @@ func (st *HelmState) appendConnectionFlags(flags []string, release *ReleaseSpec)
|
|||
return flags
|
||||
}
|
||||
|
||||
func (st *HelmState) appendExtraDiffFlags(flags []string, opt *DiffOpts) []string {
|
||||
switch {
|
||||
case opt != nil && opt.DiffArgs != "":
|
||||
flags = append(flags, argparser.CollectArgs(opt.DiffArgs)...)
|
||||
case st.HelmDefaults.DiffArgs != nil:
|
||||
flags = append(flags, argparser.CollectArgs(strings.Join(st.HelmDefaults.DiffArgs, " "))...)
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
||||
// appendKeyringFlags append all the helm command-line flags related to keyring
|
||||
func (st *HelmState) appendKeyringFlags(flags []string, release *ReleaseSpec) []string {
|
||||
switch {
|
||||
|
|
@ -2646,6 +2657,8 @@ func (st *HelmState) flagsForDiff(helm helmexec.Interface, release *ReleaseSpec,
|
|||
if err != nil {
|
||||
return nil, files, err
|
||||
}
|
||||
flags = st.appendExtraDiffFlags(flags, opt)
|
||||
|
||||
return append(flags, common...), files, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,12 +76,13 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes
|
|||
|
||||
# TEST CASES----------------------------------------------------------------------------------------------------------
|
||||
|
||||
. ${dir}/test-cases/happypath.sh
|
||||
. ${dir}/test-cases/chartify-with-non-chart-dir.sh
|
||||
. ${dir}/test-cases/diff-args.sh
|
||||
. ${dir}/test-cases/helmfile-double-fetch.sh
|
||||
. ${dir}/test-cases/skip-diff-output.sh
|
||||
. ${dir}/test-cases/v1-subhelmfile-multi-bases-with-array-values.sh
|
||||
. ${dir}/test-cases/kustomized-fetch.sh
|
||||
. ${dir}/test-cases/happypath.sh
|
||||
. ${dir}/test-cases/regression.sh
|
||||
. ${dir}/test-cases/secretssops.sh
|
||||
. ${dir}/test-cases/yaml-overwrite.sh
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
cli-overwrite-environment-values_input_dir="${cases_dir}/cli-overwrite-environment-values/input"
|
||||
cli-overwrite-environment-values_output_dir="${cases_dir}/cli-overwrite-environment-values/output"
|
||||
cli_overwrite_environment_values_input_dir="${cases_dir}/cli-overwrite-environment-values/input"
|
||||
cli_overwrite_environment_values_output_dir="${cases_dir}/cli-overwrite-environment-values/output"
|
||||
|
||||
cli_overwrite_environment_values_tmp=$(mktemp -d)
|
||||
cli_overwrite_environment_values_reverse=${cli_overwrite_environment_values_tmp}/cli.environment.override.build.yaml
|
||||
|
|
@ -8,21 +8,21 @@ case_title="cli overwrite environment values"
|
|||
|
||||
if [[ ${HELMFILE_V1MODE} = true ]]; then
|
||||
test_start "$case_title for v1"
|
||||
info "Comparing ${case_title} for v1 output ${cli_overwrite_environment_values_reverse} with ${cli-overwrite-environment-values_output_dir}/overwritten.yaml"
|
||||
info "Comparing ${case_title} for v1 output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml"
|
||||
for i in $(seq 10); do
|
||||
info "Comparing build/cli-overwrite-environment-values #$i"
|
||||
${helmfile} -f ${cli-overwrite-environment-values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
diff -u ${cli-overwrite-environment-values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
echo code=$?
|
||||
done
|
||||
test_pass "cli overwrite environment values for v1"
|
||||
else
|
||||
test_start "${case_title}"
|
||||
info "Comparing ${case_title} output ${cli_overwrite_environment_values_reverse} with ${cli-overwrite-environment-values_output_dir}/overwritten.yaml"
|
||||
info "Comparing ${case_title} output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml"
|
||||
for i in $(seq 10); do
|
||||
info "Comparing build/cli-overwrite-environment-values #$i"
|
||||
${helmfile} -f ${cli-overwrite-environment-values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
diff -u ${cli-overwrite-environment-values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
echo code=$?
|
||||
done
|
||||
test_pass "${case_title}"
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
chartifyTempDir: environment_overwrite_values
|
||||
helmfileArgs:
|
||||
- template
|
||||
- --state-values-set
|
||||
- ns=test3
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
diff_args_input_dir="${cases_dir}/diff-args/input"
|
||||
diff_args_output_dir="${cases_dir}/diff-args/output"
|
||||
|
||||
diff_args_tmp=$(mktemp -d)
|
||||
diff_args_reverse=${diff_args_tmp}/diff.args.build.yaml
|
||||
|
||||
case_title="diff args"
|
||||
diff_out_file=${diff_args_output_dir}/diff
|
||||
apply_out_file=${diff_args_output_dir}/apply
|
||||
if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]]; then
|
||||
apply_out_file=${diff_args_output_dir}/apply-live
|
||||
diff_out_file=${diff_args_output_dir}/diff-live
|
||||
fi
|
||||
|
||||
test_start "$case_title"
|
||||
info "Comparing ${case_title} diff for output ${diff_args_reverse} with ${diff_out_file}"
|
||||
for i in $(seq 10); do
|
||||
info "Comparing diff-args diff log #$i"
|
||||
${helmfile} -f ${diff_args_input_dir}/helmfile.yaml diff > ${diff_args_reverse} || fail "\"helmfile diff\" shouldn't fail"
|
||||
diff -u ${diff_out_file} ${diff_args_reverse} || fail "\"helmfile diff\" should be consistent"
|
||||
echo code=$?
|
||||
done
|
||||
info "Comparing ${case_title} apply for output ${diff_args_reverse} with ${apply_out_file}"
|
||||
${helmfile} -f ${diff_args_input_dir}/helmfile.yaml apply | grep -vE "^(LAST DEPLOYED|installed)" > ${diff_args_reverse} || fail "\"helmfile apply\" shouldn't fail"
|
||||
diff -u ${apply_out_file} ${diff_args_reverse} || fail "\"helmfile apply\" should be consistent"
|
||||
echo "clean up diff args resources"
|
||||
${helmfile} -f ${diff_args_input_dir}/helmfile.yaml destroy || fail "\"helmfile destroy\" shouldn't fail"
|
||||
test_pass "$case_title"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
helmDefaults:
|
||||
diffArgs:
|
||||
- "--three-way-merge"
|
||||
releases:
|
||||
- name: uninstalled
|
||||
chart: ../../../charts/httpbin
|
||||
installed: false
|
||||
- name: installed
|
||||
chart: ../../../charts/httpbin
|
||||
installed: true
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
Comparing release=installed, chart=../../../charts/httpbin
|
||||
********************
|
||||
|
||||
Release was not present in Helm. Diff will show entire contents as new.
|
||||
|
||||
********************
|
||||
helmfile-tests, installed-httpbin, Deployment (apps) has been added:
|
||||
-
|
||||
+ apiVersion: apps/v1
|
||||
+ kind: Deployment
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ replicas: 1
|
||||
+ selector:
|
||||
+ matchLabels:
|
||||
+ app: httpbin
|
||||
+ strategy: {}
|
||||
+ template:
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ spec:
|
||||
+ containers:
|
||||
+ - image: docker.io/citizenstig/httpbin:latest
|
||||
+ imagePullPolicy: IfNotPresent
|
||||
+ livenessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ name: httpbin
|
||||
+ ports:
|
||||
+ - containerPort: 8000
|
||||
+ readinessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ resources: {}
|
||||
+ status: {}
|
||||
helmfile-tests, installed-httpbin, Service (v1) has been added:
|
||||
-
|
||||
+ apiVersion: v1
|
||||
+ kind: Service
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ ports:
|
||||
+ - name: httpbin
|
||||
+ port: 8000
|
||||
+ protocol: TCP
|
||||
+ targetPort: 8000
|
||||
+ selector:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ type: LoadBalancer
|
||||
|
||||
Release "installed" does not exist. Installing it now.
|
||||
NAME: installed
|
||||
NAMESPACE: helmfile-tests
|
||||
STATUS: deployed
|
||||
REVISION: 1
|
||||
TEST SUITE: None
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
********************
|
||||
|
||||
Release was not present in Helm. Diff will show entire contents as new.
|
||||
|
||||
********************
|
||||
helmfile-tests, installed-httpbin, Deployment (apps) has been added:
|
||||
-
|
||||
+ apiVersion: apps/v1
|
||||
+ kind: Deployment
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ replicas: 1
|
||||
+ selector:
|
||||
+ matchLabels:
|
||||
+ app: httpbin
|
||||
+ strategy: {}
|
||||
+ template:
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ spec:
|
||||
+ containers:
|
||||
+ - image: docker.io/citizenstig/httpbin:latest
|
||||
+ imagePullPolicy: IfNotPresent
|
||||
+ livenessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ name: httpbin
|
||||
+ ports:
|
||||
+ - containerPort: 8000
|
||||
+ readinessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ resources: {}
|
||||
+ status: {}
|
||||
helmfile-tests, installed-httpbin, Service (v1) has been added:
|
||||
-
|
||||
+ apiVersion: v1
|
||||
+ kind: Service
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ ports:
|
||||
+ - name: httpbin
|
||||
+ port: 8000
|
||||
+ protocol: TCP
|
||||
+ targetPort: 8000
|
||||
+ selector:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ type: LoadBalancer
|
||||
Error: identified at least one change, exiting with non-zero exit code (detailed-exitcode parameter enabled)
|
||||
Error: plugin "diff" exited with error
|
||||
Comparing release=installed, chart=../../../charts/httpbin
|
||||
Release "installed" does not exist. Installing it now.
|
||||
NAME: installed
|
||||
NAMESPACE: helmfile-tests
|
||||
STATUS: deployed
|
||||
REVISION: 1
|
||||
TEST SUITE: None
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
Comparing release=installed, chart=../../../charts/httpbin
|
||||
********************
|
||||
|
||||
Release was not present in Helm. Diff will show entire contents as new.
|
||||
|
||||
********************
|
||||
helmfile-tests, installed-httpbin, Deployment (apps) has been added:
|
||||
-
|
||||
+ apiVersion: apps/v1
|
||||
+ kind: Deployment
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ replicas: 1
|
||||
+ selector:
|
||||
+ matchLabels:
|
||||
+ app: httpbin
|
||||
+ strategy: {}
|
||||
+ template:
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ spec:
|
||||
+ containers:
|
||||
+ - image: docker.io/citizenstig/httpbin:latest
|
||||
+ imagePullPolicy: IfNotPresent
|
||||
+ livenessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ name: httpbin
|
||||
+ ports:
|
||||
+ - containerPort: 8000
|
||||
+ readinessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ resources: {}
|
||||
+ status: {}
|
||||
helmfile-tests, installed-httpbin, Service (v1) has been added:
|
||||
-
|
||||
+ apiVersion: v1
|
||||
+ kind: Service
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ ports:
|
||||
+ - name: httpbin
|
||||
+ port: 8000
|
||||
+ protocol: TCP
|
||||
+ targetPort: 8000
|
||||
+ selector:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ type: LoadBalancer
|
||||
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
********************
|
||||
|
||||
Release was not present in Helm. Diff will show entire contents as new.
|
||||
|
||||
********************
|
||||
helmfile-tests, installed-httpbin, Deployment (apps) has been added:
|
||||
-
|
||||
+ apiVersion: apps/v1
|
||||
+ kind: Deployment
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ replicas: 1
|
||||
+ selector:
|
||||
+ matchLabels:
|
||||
+ app: httpbin
|
||||
+ strategy: {}
|
||||
+ template:
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ spec:
|
||||
+ containers:
|
||||
+ - image: docker.io/citizenstig/httpbin:latest
|
||||
+ imagePullPolicy: IfNotPresent
|
||||
+ livenessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ name: httpbin
|
||||
+ ports:
|
||||
+ - containerPort: 8000
|
||||
+ readinessProbe:
|
||||
+ httpGet:
|
||||
+ path: /
|
||||
+ port: 8000
|
||||
+ resources: {}
|
||||
+ status: {}
|
||||
helmfile-tests, installed-httpbin, Service (v1) has been added:
|
||||
-
|
||||
+ apiVersion: v1
|
||||
+ kind: Service
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+ app: httpbin
|
||||
+ chart: httpbin-0.1.0
|
||||
+ heritage: Helm
|
||||
+ release: installed
|
||||
+ name: installed-httpbin
|
||||
+ namespace: helmfile-tests
|
||||
+ spec:
|
||||
+ ports:
|
||||
+ - name: httpbin
|
||||
+ port: 8000
|
||||
+ protocol: TCP
|
||||
+ targetPort: 8000
|
||||
+ selector:
|
||||
+ app: httpbin
|
||||
+ release: installed
|
||||
+ type: LoadBalancer
|
||||
Comparing release=installed, chart=../../../charts/httpbin
|
||||
|
|
@ -0,0 +1 @@
|
|||
https://github.com/helmfile/helmfile/issues/1095
|
||||
Loading…
Reference in New Issue