project-stacker / stacker

Build OCI images natively from a declarative format
https://stackerbuild.io
Apache License 2.0
208 stars 34 forks source link

Feat: better error message when you pass --oci-dir a directory that exists but is not an OCI layout. #638

Closed mikemccracken closed 2 months ago

mikemccracken commented 2 months ago

Is your feature request related to a problem? Please describe.

if you

mkdir ocidir
stacker --oci-dir ocidir build 

you will get something like

error: open CAS: validate: read oci-layout: invalid image detected
error: exit status 1

but no info about what it's trying to do or what path the problem is at.

if you pass an oci-dir that is already an oci layout, it's fine. or if it doesnt' yet exist, stacker just creates it and you're fine.

this can be confusing.

Describe the solution you'd like

I think either stacker should at least tell you the path of what it's trying to open as an OCI layout (the oci-dir), and that it's expecting oci-dir to either be a valid layout or a nonexistent path.

even better, stacker should allow passing empty dirs and just create the layout there as if it was a nonexistent path.

if it's a directory that is not empty, but is also not an OCI layout, a nice error message explaining what's expected seems OK in that case.

Describe alternatives you've considered

No response

Additional context

No response