Skip to content

Commit 21384b9

Browse files
authored
Merge pull request #304 from tianouya-db/convertor-digest-input
Support digest for input image in convertor
2 parents f5593f5 + 43ab209 commit 21384b9

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

.github/workflows/ci-userspace-convertor.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ jobs:
5050
shell: bash
5151
run: |
5252
bash new_registry.sh
53-
bash prepare_image.sh registry.hub.docker.com/overlaybd/centos:centos7.9.2009 localhost:5000/centos:centos7.9.2009 && \
54-
bash prepare_image.sh registry.hub.docker.com/overlaybd/ubuntu:22.04 localhost:5000/ubuntu:22.04 && \
55-
bash prepare_image.sh registry.hub.docker.com/overlaybd/redis:7.2.3 localhost:5000/redis:7.2.3 && \
56-
bash prepare_image.sh registry.hub.docker.com/overlaybd/wordpress:6.4.2 localhost:5000/wordpress:6.4.2 && \
57-
bash prepare_image.sh registry.hub.docker.com/overlaybd/nginx:1.25.3 localhost:5000/nginx:1.25.3
53+
bash prepare_image.sh registry.hub.docker.com/overlaybd/centos:centos7.9.2009 localhost:5000/centos:centos7.9.2009 && \
54+
bash prepare_image.sh registry.hub.docker.com/overlaybd/ubuntu:22.04 localhost:5000/ubuntu:22.04 && \
55+
bash prepare_image.sh registry.hub.docker.com/overlaybd/redis:7.2.3 localhost:5000/redis:7.2.3 && \
56+
bash prepare_image.sh registry.hub.docker.com/overlaybd/redis@sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc localhost:5000/redis@sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc && \
57+
bash prepare_image.sh registry.hub.docker.com/overlaybd/wordpress:6.4.2 localhost:5000/wordpress:6.4.2 && \
58+
bash prepare_image.sh registry.hub.docker.com/overlaybd/nginx:1.25.3 localhost:5000/nginx:1.25.3
5859
5960
- name: CI - uconv reproduce
6061
working-directory: ci/uconv_reproduce
@@ -70,6 +71,14 @@ jobs:
7071
bash run_container.sh localhost:5000/redis:7.2.3_overlaybd
7172
bash run_container.sh localhost:5000/redis:7.2.3_turbo
7273
74+
- name: CI - uconv E2E with digest input
75+
working-directory: ci/scripts
76+
shell: bash
77+
run: |
78+
/opt/overlaybd/snapshotter/convertor -r localhost:5000/redis -g sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc --overlaybd 309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_overlaybd --turboOCI sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_turbo
79+
bash run_container.sh localhost:5000/redis:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_overlaybd
80+
bash run_container.sh localhost:5000/redis:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_turbo
81+
7382
- name: install Go
7483
uses: actions/setup-go@v5
7584
with:

cmd/convertor/main.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var (
3636
user string
3737
plain bool
3838
tagInput string
39+
digestInput string
3940
tagOutput string
4041
dir string
4142
oci bool
@@ -74,6 +75,10 @@ Version: ` + commitID,
7475
logrus.SetLevel(logrus.DebugLevel)
7576
}
7677
tb := ""
78+
if digestInput == "" && tagInput == "" {
79+
logrus.Error("one of input-tag [-i] or input-digest [-g] is required")
80+
os.Exit(1)
81+
}
7782
if overlaybd == "" && fastoci == "" && turboOCI == "" {
7883
if tagOutput == "" {
7984
logrus.Error("output-tag is required, you can specify it by [-o|--overlaybd|--turboOCI]")
@@ -93,8 +98,12 @@ Version: ` + commitID,
9398
}
9499

95100
ctx := context.Background()
101+
ref := repo + ":" + tagInput
102+
if tagInput == "" {
103+
ref = repo + "@" + digestInput
104+
}
96105
opt := builder.BuilderOptions{
97-
Ref: repo + ":" + tagInput,
106+
Ref: ref,
98107
Auth: user,
99108
PlainHTTP: plain,
100109
WorkDir: dir,
@@ -163,7 +172,8 @@ func init() {
163172
rootCmd.Flags().StringVarP(&user, "username", "u", "", "user[:password] Registry user and password")
164173
rootCmd.Flags().BoolVarP(&plain, "plain", "", false, "connections using plain HTTP")
165174
rootCmd.Flags().BoolVarP(&verbose, "verbose", "", false, "show debug log")
166-
rootCmd.Flags().StringVarP(&tagInput, "input-tag", "i", "", "tag for image converting from (required)")
175+
rootCmd.Flags().StringVarP(&tagInput, "input-tag", "i", "", "tag for image converting from (required when input-digest is not set)")
176+
rootCmd.Flags().StringVarP(&digestInput, "input-digest", "g", "", "digest for image converting from (required when input-tag is not set)")
167177
rootCmd.Flags().StringVarP(&tagOutput, "output-tag", "o", "", "tag for image converting to")
168178
rootCmd.Flags().StringVarP(&dir, "dir", "d", "tmp_conv", "directory used for temporary data")
169179
rootCmd.Flags().BoolVarP(&oci, "oci", "", false, "export image with oci spec")
@@ -191,7 +201,6 @@ func init() {
191201
rootCmd.Flags().BoolVar(&dumpManifest, "dump-manifest", false, "dump manifest")
192202

193203
rootCmd.MarkFlagRequired("repository")
194-
rootCmd.MarkFlagRequired("input-tag")
195204
}
196205

197206
func main() {

docs/USERSPACE_CONVERTOR.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Flags:
3838
-u, --username string user[:password] Registry user and password
3939
--plain connections using plain HTTP
4040
--verbose show debug log
41-
-i, --input-tag string tag for image converting from (required)
41+
-i, --input-tag string tag for image converting from (required when input-digest is not set)
42+
-g, --input-digest string digest for image converting from (required when input-tag is not set)
4243
-o, --output-tag string tag for image converting to
4344
-d, --dir string directory used for temporary data (default "tmp_conv")
4445
--oci export image with oci spec
@@ -64,6 +65,7 @@ Flags:
6465
6566
# examples
6667
$ bin/convertor -r docker.io/overlaybd/redis -u user:pass -i 6.2.6 -o 6.2.6_obd
68+
$ bin/convertor -r docker.io/overlaybd/redis -u user:pass -g sha256:309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc -o 309f99718ff2424f4ae5ebf0e46f7f0ce03058bf47d9061d1d66e4af53b70ffc_obd
6769
$ bin/convertor -r docker.io/overlaybd/redis -u user:pass -i 6.2.6 --overlaybd 6.2.6_obd --fastoci 6.2.6_foci
6870
$ bin/convertor -r docker.io/overlaybd/redis -u user:pass -i 6.2.6 -o 6.2.6_obd --vsize 256
6971

0 commit comments

Comments
 (0)