diff --git a/pkg/kubectl/kubectl.go b/pkg/kubectl/kubectl.go index 1f125e9f..aad8a6c0 100644 --- a/pkg/kubectl/kubectl.go +++ b/pkg/kubectl/kubectl.go @@ -144,7 +144,7 @@ func (k kubectl) Apply(input string) error { return err } - args := append(k.defaultArgs(), "apply", "--server-side", "-f", file) + args := append(k.defaultArgs(), "apply", "--server-side", "--force-conflicts", "-f", file) c := newKubectlCmd(os.Stdin, k.out, k.out, args) return c.Execute() } diff --git a/pkg/kubectl/kubectl_test.go b/pkg/kubectl/kubectl_test.go index fff1ea82..2ba62759 100644 --- a/pkg/kubectl/kubectl_test.go +++ b/pkg/kubectl/kubectl_test.go @@ -68,7 +68,7 @@ func TestNew_NoNamespace(t *testing.T) { err := k.Apply("") assert.NoError(t, err) assert.Equal(t, 1, len(calls)) - assert.Equal(t, []string{"apply", "--context", "missing", "--file", fmt.Sprintf("%s/content.yaml", tempDir), "--v=6", "--server-side"}, calls[0]) + assert.Equal(t, []string{"apply", "--context", "missing", "--file", fmt.Sprintf("%s/content.yaml", tempDir), "--v=6", "--server-side", "--force-conflicts"}, calls[0]) logMock.Check(t, []string{}) } func TestNew_NoContext(t *testing.T) { @@ -84,7 +84,7 @@ func TestNew_NoContext(t *testing.T) { err := k.Apply("") assert.NoError(t, err) assert.Equal(t, 1, len(calls)) - assert.Equal(t, []string{"apply", "--namespace", "namespace", "--file", fmt.Sprintf("%s/content.yaml", tempDir), "--server-side"}, calls[0]) + assert.Equal(t, []string{"apply", "--namespace", "namespace", "--file", fmt.Sprintf("%s/content.yaml", tempDir), "--server-side", "--force-conflicts"}, calls[0]) logMock.Check(t, []string{}) } @@ -101,7 +101,7 @@ func TestKubectl_Apply(t *testing.T) { err := k.Apply("") assert.NoError(t, err) assert.Equal(t, 1, len(calls)) - assert.Equal(t, []string{"apply", "--context", "missing", "--namespace", "default", "--file", fmt.Sprintf("%s/content.yaml", tempDir), "--server-side"}, calls[0]) + assert.Equal(t, []string{"apply", "--context", "missing", "--namespace", "default", "--file", fmt.Sprintf("%s/content.yaml", tempDir), "--server-side", "--force-conflicts"}, calls[0]) logMock.Check(t, []string{}) } @@ -433,6 +433,7 @@ func mockCmd(_ io.Reader, out, _ io.Writer, args []string) *cobra.Command { var kubeconfig *string var verbose *string var serverSide *bool + var forceConflicts *bool cmd := cobra.Command{ Use: "kubectl", @@ -468,6 +469,9 @@ func mockCmd(_ io.Reader, out, _ io.Writer, args []string) *cobra.Command { if *serverSide { call = append(call, "--server-side") } + if *forceConflicts { + call = append(call, "--force-conflicts") + } calls = append(calls, call) return nil }, @@ -495,6 +499,7 @@ func mockCmd(_ io.Reader, out, _ io.Writer, args []string) *cobra.Command { kubeconfig = cmd.Flags().StringP("kubeconfig", "", "", "") verbose = cmd.Flags().StringP("v", "v", "0", "") serverSide = cmd.Flags().BoolP("server-side", "", false, "") + forceConflicts = cmd.Flags().BoolP("force-conflicts", "", false, "") cmd.SetArgs(args) return &cmd }