kpt
kpt copied to clipboard
Bug: kpt pkg get has inconsistent behavior when LOCAL_DEST_DIRECTORY is the current directory
When you run kpt pkg get ${PKG_URL}.git/${PKG_PATH} ., it creates a new directory using the name of the package, which is inconsistent with both kpt cfg set . key value and git clone ${REPO_URL}.
I would expect passing the current directory to kpt pkg get to not create a new directory and instead place the package files directly in the specified directory.
@phanimarupaka @mortent
Good point. Accepting this as a feature request. But it will be delivered as part of long term changes as it would break backwards compatibility.
While you're at it, this documented behavior is super un-intuitive:
* If the directory does NOT exist: create the specified directory
and write the package contents to it
* If the directory DOES exist: create a NEW directory under the
specified one, defaulting the name to the Base of REPO/PKG_PATH
I would much rather have it always write to the directory specified. Maybe just error if there's already a Kptfile in it.
I just lost about an hour trying to debug why my script was checking out to somewhere different than the command did when i ran in manually, and it was become in the script the directory already existed.
@phanimarupaka is this what you are working on right now? Should we mark it as in progress?
@mikebz This is slightly different from what I am working on. I am tracking this issue and update it accordingly.
@mortent also would love to hear your opinion for why we decided to go this way. I wouldn't expect there to be another directory.
Repro steps:
~/src/sandbox » cd mysql
~/src/sandbox/mysql » kpt pkg get sso://user/mikebz/blueprints.git/mysql .
Package "mysql":
Fetching sso://user/mikebz/blueprints@main.
From sso://user/mikebz/blueprints
* branch main -> FETCH_HEAD
Adding package "mysql".
Fetched 1 package(s).
~/src/sandbox/mysql » ls
mysql
My expectation would be that the items are in that directory not a subdirectory.
I don't know the history behind this behavior. I agree this is non-intuitive and we should change it.
is there appetite to address this? Should we just clone the package into the specified directory. I agree with @karlkfi here, but we might have some content out there already.