Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support digest for input image in convertor #304

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/ci-userspace-convertor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions cmd/convertor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
user string
plain bool
tagInput string
digestInput string
tagOutput string
dir string
oci bool
Expand Down Expand Up @@ -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]")
Expand All @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -191,7 +201,6 @@ func init() {
rootCmd.Flags().BoolVar(&dumpManifest, "dump-manifest", false, "dump manifest")

rootCmd.MarkFlagRequired("repository")
rootCmd.MarkFlagRequired("input-tag")
}

func main() {
Expand Down
4 changes: 3 additions & 1 deletion docs/USERSPACE_CONVERTOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading