fix(sync): fix dry-run failing consecutive runs by creating directories in target dir#2660
fix(sync): fix dry-run failing consecutive runs by creating directories in target dir#2660frq-asgard-josi wants to merge 2 commits intocontainers:mainfrom
Conversation
|
Ephemeral COPR build failed. @containers/packit-build please check. |
8dab1c6 to
aa1ea15
Compare
|
Tests failed. @containers/packit-build please check. |
aa1ea15 to
8b71882
Compare
mtrmac
left a comment
There was a problem hiding this comment.
Thanks!
attempts to create directories even when running in dry-run mode
That’s clearly undesirable.
and fails if these already exist.
I can’t see how? MkdirAll is not supposed to fail in that situation. What is failing exactly?
| return nil, fmt.Errorf("Error creating directory for image %s: %w", destination, err) | ||
| if !dryRun { | ||
| // the directory holding the image must be created here | ||
| if err = os.MkdirAll(destination, 0755); err != nil { |
There was a problem hiding this comment.
I’m afraid I don’t think this works, in general: below, directory.Transport.ParseReference requires the parent directory to exist. We’d need to defer the parsing into a typed ImageReference, and deal with untyped strings in the meantime :/
There was a problem hiding this comment.
My personal preference would be to expect the parent directory to already exist since this would avoid creating unwanted directories due to mistyping (not that I ever did this 😆) but we should check that the directory exists here and provide a proper error message instead of relying on ParseReference to catch this.
There was a problem hiding this comment.
The parent directory is not always user-specified: with --scoped, trailing paths of the path come from the source repository name.
8b71882 to
cbefcd4
Compare
Since the destination exists, |
Signed-off-by: Jonas Switala <[email protected]>
…es in target dir Signed-off-by: Jonas Switala <[email protected]>
cbefcd4 to
efbac99
Compare
|
A friendly reminder that this PR had no activity for 30 days. |
skopeo sync --dry-run --dest dircurrently fails consecutive executions since thefunc destinationReferenceattempts to create directories even when running in dry-run mode and fails if these already exist.