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
197206func main () {
0 commit comments