You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When kpt pkg get REPO dest is called and dest already exists as a directory, getDest() in pkg/lib/util/parse/parse.go silently appends the package name as a subdirectory (e.g.dest/nginx). This was an intentional design from v0.1.0 mimicking cp semantics, but it creates confusing behaviour:
If dest doesn't exist: package is written directly to dest
If dest exists: package is written to dest/<pkg-name>
Same command, same explicit argument, different interpretation depending on filesystem state at invocation time.
Steps
# Setup
mkdir -p /tmp/kpt-container-test &&cd /tmp/kpt-container-test
git init
# Case 1: destination does NOT exist# Package is written directly to "my-package"
kpt pkg get https://github.com/kptdev/kpt.git/package-examples/nginx@main my-package
ls my-package/
# Output: Kptfile deployment.yaml svc.yaml# Cleanup
rm -rf my-package
# Case 2: destination DOES exist (empty directory)# Package is NOT written to "my-package" — instead it goes to "my-package/nginx"
mkdir my-package
kpt pkg get https://github.com/kptdev/kpt.git/package-examples/nginx@main my-package
ls my-package/
# Output: nginx/
ls my-package/nginx/
# Output: Kptfile deployment.yaml svc.yaml
The user typed the same destination (my-package) in both cases, but got different results based on whether the directory existed beforehand.
Problems
User intent is ambiguous. When a user explicitly types dest, they most likely mean "put the package here", not "use this as a parent directory". The meaning shouldn't change based on whether they ran mkdir first.
Undocumented. The original v0.1.0 docs explained the three cases clearly, but the current documentation at reference/cli/pkg/get/_index.md only says "The local directory to write the package to" - the container behaviour is not mentioned.
Background
When
kpt pkg get REPO destis called anddestalready exists as a directory,getDest()inpkg/lib/util/parse/parse.gosilently appends the package name as a subdirectory (e.g.dest/nginx). This was an intentional design from v0.1.0 mimickingcpsemantics, but it creates confusing behaviour:destdoesn't exist: package is written directly todestdestexists: package is written todest/<pkg-name>Same command, same explicit argument, different interpretation depending on filesystem state at invocation time.
Steps
The user typed the same destination (my-package) in both cases, but got different results based on whether the directory existed beforehand.
Problems
Proposal
Consider deprecating the container pattern for explicit destinations:
This would align pkg get with the rest of kpt and with git clone semantics.