diff --git a/.github/workflows/ci-userspace-convertor.yml b/.github/workflows/ci-userspace-convertor.yml index 9877abb0..828ff21c 100644 --- a/.github/workflows/ci-userspace-convertor.yml +++ b/.github/workflows/ci-userspace-convertor.yml @@ -50,11 +50,12 @@ jobs: shell: bash run: | bash new_registry.sh - bash prepare_image.sh registry.hub.docker.com/overlaybd/centos:centos7.9.2009 localhost:5000/centos:centos7.9.2009 && \ - bash prepare_image.sh registry.hub.docker.com/overlaybd/ubuntu:22.04 localhost:5000/ubuntu:22.04 && \ - bash prepare_image.sh registry.hub.docker.com/overlaybd/redis:7.2.3 localhost:5000/redis:7.2.3 && \ - bash prepare_image.sh registry.hub.docker.com/overlaybd/wordpress:6.4.2 localhost:5000/wordpress:6.4.2 && \ - bash prepare_image.sh registry.hub.docker.com/overlaybd/nginx:1.25.3 localhost:5000/nginx:1.25.3 + bash prepare_image.sh registry.hub.docker.com/overlaybd/centos:centos7.9.2009 localhost:5000/centos:centos7.9.2009 && \ + bash prepare_image.sh registry.hub.docker.com/overlaybd/ubuntu:22.04 localhost:5000/ubuntu:22.04 && \ + bash prepare_image.sh registry.hub.docker.com/overlaybd/redis:7.2.3 localhost:5000/redis:7.2.3 && \ + bash prepare_image.sh registry.hub.docker.com/overlaybd/redis@sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc localhost:5000/redis@sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc && \ + bash prepare_image.sh registry.hub.docker.com/overlaybd/wordpress:6.4.2 localhost:5000/wordpress:6.4.2 && \ + bash prepare_image.sh registry.hub.docker.com/overlaybd/nginx:1.25.3 localhost:5000/nginx:1.25.3 - name: CI - uconv reproduce working-directory: ci/uconv_reproduce @@ -70,6 +71,14 @@ jobs: bash run_container.sh localhost:5000/redis:7.2.3_overlaybd bash run_container.sh localhost:5000/redis:7.2.3_turbo + - name: CI - uconv E2E with digest input + working-directory: ci/scripts + shell: bash + run: | + /opt/overlaybd/snapshotter/convertor -r localhost:5000/redis -g sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc --overlaybd 309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_overlaybd --turboOCI sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_turbo + bash run_container.sh localhost:5000/redis:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_overlaybd + bash run_container.sh localhost:5000/redis:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_turbo + - name: install Go uses: actions/setup-go@v5 with: diff --git a/cmd/convertor/main.go b/cmd/convertor/main.go index a1edd44a..8a071b49 100644 --- a/cmd/convertor/main.go +++ b/cmd/convertor/main.go @@ -36,6 +36,7 @@ var ( user string plain bool tagInput string + digestInput string tagOutput string dir string oci bool @@ -74,6 +75,10 @@ Version: ` + commitID, logrus.SetLevel(logrus.DebugLevel) } tb := "" + if digestInput == "" && tagInput == "" { + logrus.Error("one of input-tag [-i] or input-digest [-g] is required") + os.Exit(1) + } if overlaybd == "" && fastoci == "" && turboOCI == "" { if tagOutput == "" { logrus.Error("output-tag is required, you can specify it by [-o|--overlaybd|--turboOCI]") @@ -93,8 +98,12 @@ Version: ` + commitID, } ctx := context.Background() + ref := repo + ":" + tagInput + if tagInput == "" { + ref = repo + "@" + digestInput + } opt := builder.BuilderOptions{ - Ref: repo + ":" + tagInput, + Ref: ref, Auth: user, PlainHTTP: plain, WorkDir: dir, @@ -163,7 +172,8 @@ func init() { rootCmd.Flags().StringVarP(&user, "username", "u", "", "user[:password] Registry user and password") rootCmd.Flags().BoolVarP(&plain, "plain", "", false, "connections using plain HTTP") rootCmd.Flags().BoolVarP(&verbose, "verbose", "", false, "show debug log") - rootCmd.Flags().StringVarP(&tagInput, "input-tag", "i", "", "tag for image converting from (required)") + rootCmd.Flags().StringVarP(&tagInput, "input-tag", "i", "", "tag for image converting from (required when input-digest is not set)") + rootCmd.Flags().StringVarP(&digestInput, "input-digest", "g", "", "digest for image converting from (required when input-tag is not set)") rootCmd.Flags().StringVarP(&tagOutput, "output-tag", "o", "", "tag for image converting to") rootCmd.Flags().StringVarP(&dir, "dir", "d", "tmp_conv", "directory used for temporary data") rootCmd.Flags().BoolVarP(&oci, "oci", "", false, "export image with oci spec") @@ -191,7 +201,6 @@ func init() { rootCmd.Flags().BoolVar(&dumpManifest, "dump-manifest", false, "dump manifest") rootCmd.MarkFlagRequired("repository") - rootCmd.MarkFlagRequired("input-tag") } func main() { diff --git a/docs/USERSPACE_CONVERTOR.md b/docs/USERSPACE_CONVERTOR.md index 3d2777aa..d0cae0c4 100644 --- a/docs/USERSPACE_CONVERTOR.md +++ b/docs/USERSPACE_CONVERTOR.md @@ -38,7 +38,8 @@ Flags: -u, --username string user[:password] Registry user and password --plain connections using plain HTTP --verbose show debug log - -i, --input-tag string tag for image converting from (required) + -i, --input-tag string tag for image converting from (required when input-digest is not set) + -g, --input-digest string digest for image converting from (required when input-tag is not set) -o, --output-tag string tag for image converting to -d, --dir string directory used for temporary data (default "tmp_conv") --oci export image with oci spec @@ -64,6 +65,7 @@ Flags: # examples $ bin/convertor -r docker.io/overlaybd/redis -u user:pass -i 6.2.6 -o 6.2.6_obd +$ bin/convertor -r docker.io/overlaybd/redis -u user:pass -g sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc -o 309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_obd $ bin/convertor -r docker.io/overlaybd/redis -u user:pass -i 6.2.6 --overlaybd 6.2.6_obd --fastoci 6.2.6_foci $ bin/convertor -r docker.io/overlaybd/redis -u user:pass -i 6.2.6 -o 6.2.6_obd --vsize 256