kpt icon indicating copy to clipboard operation
kpt copied to clipboard

Bug: kpt pkg get has inconsistent behavior when LOCAL_DEST_DIRECTORY is the current directory

Open karlkfi opened this issue 4 years ago • 8 comments

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.

karlkfi avatar Feb 01 '21 20:02 karlkfi

@phanimarupaka @mortent

Shell32-Natsu avatar Feb 01 '21 20:02 Shell32-Natsu

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.

phanimarupaka avatar Feb 02 '21 08:02 phanimarupaka

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.

karlkfi avatar Feb 04 '21 06:02 karlkfi

@phanimarupaka is this what you are working on right now? Should we mark it as in progress?

mikebz avatar Mar 10 '21 18:03 mikebz

@mikebz This is slightly different from what I am working on. I am tracking this issue and update it accordingly.

phanimarupaka avatar Mar 11 '21 00:03 phanimarupaka

@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.

mikebz avatar May 19 '21 19:05 mikebz

I don't know the history behind this behavior. I agree this is non-intuitive and we should change it.

mortent avatar Jun 17 '21 22:06 mortent

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.

mikebz avatar Aug 15 '22 15:08 mikebz