1
0
mirror of synced 2026-07-04 08:50:49 +00:00

Fix breaking change in-memory kustomization build

Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
This commit is contained in:
Matheus Pimenta
2026-07-01 23:20:01 +01:00
parent c1f7f0b86a
commit 93174b454f
4 changed files with 152 additions and 16 deletions
+36
View File
@@ -22,6 +22,7 @@ package main
import (
"context"
"os"
"strconv"
"strings"
"testing"
@@ -180,6 +181,41 @@ func TestDiffKustomizationNotDeployed(t *testing.T) {
}
}
func TestDiffKustomizationDefaultBuildsAbsolutePathOutsideCwd(t *testing.T) {
fluxNS := allocateNamespace("flux-system")
targetNS := allocateNamespace("target")
setupTestNamespace(fluxNS, t)
setupTestNamespace(targetNS, t)
cwdDir, sourceDir, kustomizationFile := newOutsideCwdKustomization(t, fluxNS, targetNS)
restore := chdirForTest(t, cwdDir)
defer restore()
flag := diffKsCmd.Flags().Lookup("in-memory-build")
if flag == nil {
t.Fatal("missing in-memory-build flag")
}
defaultValue, err := strconv.ParseBool(flag.DefValue)
if err != nil {
t.Fatal(err)
}
diffKsArgs.inMemoryBuild = defaultValue
output, err := executeCommand("diff kustomization app --path " + sourceDir +
" --kustomization-file " + kustomizationFile +
" --ignore-not-found --progress-bar=false -n " + fluxNS)
if isChangeError(err) {
err = nil
}
if err != nil {
t.Fatalf("expected diff to build with default backend, got: %v", err)
}
if !strings.Contains(output, "ConfigMap/"+targetNS+"/outside-cwd created") {
t.Fatalf("expected created ConfigMap in diff output, got:\n%s", output)
}
}
// TestDiffKustomizationTakeOwnership tests `flux diff ks` when taking ownership
// of existing resources on the cluster. A "pre-existing" configmap is applied
// to the cluster, and the kustomization contains a matching configmap; the