warn users about --dest-compress and --dest-decompress misuse

Signed-off-by: Erol Keskin <erolkeskin.dev@gmail.com>
This commit is contained in:
Erol Keskin 2022-09-07 03:38:28 +03:00
parent 06cf25fb53
commit d3ff6e2635
2 changed files with 11 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import (
"github.com/containers/image/v5/transports/alltransports" "github.com/containers/image/v5/transports/alltransports"
encconfig "github.com/containers/ocicrypt/config" encconfig "github.com/containers/ocicrypt/config"
enchelpers "github.com/containers/ocicrypt/helpers" enchelpers "github.com/containers/ocicrypt/helpers"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -260,6 +261,15 @@ func (opts *copyOptions) run(args []string, stdout io.Writer) (retErr error) {
} }
} }
if destRef.Transport().Name() != "dir" {
if opts.destImage.dirForceCompression {
logrus.Warn("--dest-compress can only be used if the destination transport is 'dir'")
}
if opts.destImage.dirForceDecompression {
logrus.Warn("--dest-decompress can only be used if the destination transport is 'dir'")
}
}
return retry.IfNecessary(ctx, func() error { return retry.IfNecessary(ctx, func() error {
manifestBytes, err := copy.Image(ctx, policyContext, destRef, srcRef, &copy.Options{ manifestBytes, err := copy.Image(ctx, policyContext, destRef, srcRef, &copy.Options{
RemoveSignatures: opts.removeSignatures, RemoveSignatures: opts.removeSignatures,

View File

@ -50,7 +50,7 @@ function setup() {
local dir=$TESTDIR/dir local dir=$TESTDIR/dir
run_skopeo copy --dest-compress --dest-compress-format=zstd $remote_image oci:$dir:latest run_skopeo copy --dest-compress-format=zstd $remote_image oci:$dir:latest
# zstd magic number # zstd magic number
local magic=$(printf "\x28\xb5\x2f\xfd") local magic=$(printf "\x28\xb5\x2f\xfd")