jozu-ai / kitops

Tools for easing the handoff between AI/ML and App/SRE teams.
https://KitOps.ml
Apache License 2.0
267 stars 26 forks source link

`kit unpack` doesn't create target directory if unpacking only config #204

Closed bbrowning closed 2 months ago

bbrowning commented 2 months ago

Describe the bug kit unpack --help says: -d, --dir string The target directory to unpack components into. This directory will be created if it does not exist. However, the target directory does have to already exist, at least in my case.

To Reproduce kit unpack remote_host/remote_repo:latest --config -d foo and you'll see an error trying to write the config file to the non-existent directory foo

Unpacking to foo
Unpacking config to foo/Kitfile
failed to write config file: open foo/Kitfile: no such file or directory

Try it again after making the directory foo and everything works.

Version Built from source commit f9ef9ab983e453b96e1b77f06190c4421c19790d (latest as of opening this bug report)

bbrowning commented 2 months ago

Testing this a bit more, it appears to only trigger when you use the --config option. Looking at the code, it looks like the os.MkdirAll call at https://github.com/jozu-ai/kitops/blob/6267c0d35dcfb34c29f593f3e5bb18eba5a18b5b/pkg/cmd/unpack/unpack.go#L154 only happens when unpacking layers. When I unpack only the config, we're not actually unpacking any layers so we don't make the directory.

gorkem commented 2 months ago

@amisevsk FYI. In case you are changing these parts of the code at the moment

amisevsk commented 2 months ago

Good catch, thanks @bbrowning!