Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions e2e/testdata/live-apply/crd-and-cr/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ stdOut: |
custom.kpt.dev/cr apply successful
apply phase finished
reconcile phase started
custom.kpt.dev/cr reconcile successful
reconcile phase finished
inventory update started
inventory update finished
apply result: 2 attempted, 2 successful, 0 skipped, 0 failed
reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out

optionalStdOut:
- customresourcedefinition.apiextensions.k8s.io/customs.kpt.dev reconcile pending
- custom.kpt.dev/cr reconcile pending
- custom.kpt.dev/cr reconcile successful
- custom.kpt.dev/cr reconcile timeout
- "reconcile result: 2 attempted, 2 successful, 0 skipped, 0 failed, 0 timed out"
- "reconcile result: 2 attempted, 1 successful, 0 skipped, 0 failed, 1 timed out"

inventory:
- group: apiextensions.k8s.io
kind: CustomResourceDefinition
name: customs.kpt.dev
- group: kpt.dev
kind: Custom
name: cr
name: cr
5 changes: 4 additions & 1 deletion internal/builtins/pkg_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
utilstrings "github.com/kptdev/kpt/internal/util/strings"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -62,7 +63,9 @@ func TestPkgContextGenerator(t *testing.T) {
if err != test.expErr {
t.Errorf("exp: %v got: %v", test.expErr, err)
}
if diff := cmp.Diff(string(exp), out.String()); diff != "" {
expected := utilstrings.NormalizeLineEndings(string(exp))
actual := utilstrings.NormalizeLineEndings(out.String())
if diff := cmp.Diff(expected, actual); diff != "" {
t.Errorf("pkg context mistmach (-want +got):\n%s", diff)
}
})
Expand Down
27 changes: 23 additions & 4 deletions internal/util/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/printer/fake"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/kio/filters"
"sigs.k8s.io/kustomize/kyaml/yaml"
Expand Down Expand Up @@ -213,15 +214,33 @@ func TestCommand_Run_subdir_symlinks(t *testing.T) {
}.Run(fake.CtxWithPrinter(cliOutput, cliOutput))
assert.NoError(t, err)

// ensure warning for symlink is printed on the CLI
assert.Contains(t, cliOutput.String(), `[Warn] Ignoring symlink "config-symlink"`)
sourceSymlinkPath := filepath.Join(g.DatasetDirectory, testutil.Dataset6, subdir, "config-symlink")
info, statErr := os.Lstat(sourceSymlinkPath)
isSymlinkInSource := false
if statErr == nil {
isSymlinkInSource = info.Mode()&os.ModeSymlink != 0
} else if !os.IsNotExist(statErr) {
require.NoError(t, statErr)
}

if isSymlinkInSource {
// ensure warning for symlink is printed on the CLI
assert.Contains(t, cliOutput.String(), `[Warn] Ignoring symlink "config-symlink"`)
} else {
// on environments without symlink materialization, there is no ignore warning
assert.NotContains(t, cliOutput.String(), `[Warn] Ignoring symlink "config-symlink"`)
}

// verify the cloned contents do not contains symlinks
diff, err := testutil.Diff(filepath.Join(g.DatasetDirectory, testutil.Dataset6, subdir), absPath, true)
assert.NoError(t, err)
diff = diff.Difference(testutil.KptfileSet)
// original repo contains symlink and cloned doesn't, so the difference
assert.Contains(t, diff.List(), "config-symlink")
if isSymlinkInSource {
// original repo contains symlink and cloned doesn't, so the difference
assert.Contains(t, diff.List(), "config-symlink")
} else {
assert.NotContains(t, diff.List(), "config-symlink")
}

// verify the KptFile contains the expected values
commit, err := g.GetCommit()
Expand Down
Loading
Loading