diff --git a/cmd/oci-image-tool/create.go b/cmd/oci-image-tool/create.go index 7be454b..56de186 100644 --- a/cmd/oci-image-tool/create.go +++ b/cmd/oci-image-tool/create.go @@ -31,7 +31,7 @@ var bundleTypes = []string{ type bundleCmd struct { typ string // the type to bundle, can be empty string - refs []string + selects []string root string platform string } @@ -43,19 +43,19 @@ func createAction(context *cli.Context) error { v := bundleCmd{ typ: context.String("type"), - refs: context.StringSlice("ref"), + selects: context.StringSlice("select"), root: context.String("rootfs"), platform: context.String("platform"), } - if len(v.refs) == 0 { - return fmt.Errorf("ref must be provided") + if len(v.selects) == 0 { + return fmt.Errorf("select must be provided") } - for index, ref := range v.refs { - for i := index + 1; i < len(v.refs); i++ { - if ref == v.refs[i] { - fmt.Printf("WARNING: refs contains duplicate reference %q.\n", v.refs[i]) + for index, sel := range v.selects { + for i := index + 1; i < len(v.selects); i++ { + if sel == v.selects[i] { + fmt.Printf("WARNING: selects contains duplicate selection %q.\n", v.selects[i]) } } } @@ -71,13 +71,13 @@ func createAction(context *cli.Context) error { var err error switch v.typ { case image.TypeImageLayout: - err = image.CreateRuntimeBundleLayout(context.Args()[0], context.Args()[1], v.root, v.platform, v.refs) + err = image.CreateRuntimeBundleLayout(context.Args()[0], context.Args()[1], v.root, v.platform, v.selects) case image.TypeImageZip: - err = image.CreateRuntimeBundleZip(context.Args()[0], context.Args()[1], v.root, v.platform, v.refs) + err = image.CreateRuntimeBundleZip(context.Args()[0], context.Args()[1], v.root, v.platform, v.selects) case image.TypeImage: - err = image.CreateRuntimeBundleFile(context.Args()[0], context.Args()[1], v.root, v.platform, v.refs) + err = image.CreateRuntimeBundleFile(context.Args()[0], context.Args()[1], v.root, v.platform, v.selects) default: err = fmt.Errorf("cannot create %q", v.typ) @@ -100,8 +100,8 @@ var createCommand = cli.Command{ ), }, cli.StringSliceFlag{ - Name: "ref", - Usage: "A set of ref specify the search criteria for the validated reference, format is A=B. Only support 'name', 'platform.os' and 'digest' three cases.", + Name: "select", + Usage: "Select the search criteria for the validated reference, format is A=B. Only support 'org.opencontainers.ref.name', 'platform.os' and 'digest' three cases.", }, cli.StringFlag{ Name: "rootfs", diff --git a/cmd/oci-image-tool/unpack.go b/cmd/oci-image-tool/unpack.go index 7e0c64a..8e31b58 100644 --- a/cmd/oci-image-tool/unpack.go +++ b/cmd/oci-image-tool/unpack.go @@ -31,7 +31,7 @@ var unpackTypes = []string{ type unpackCmd struct { typ string // the type to unpack, can be empty string - refs []string + selects []string platform string } @@ -42,18 +42,18 @@ func unpackAction(context *cli.Context) error { v := unpackCmd{ typ: context.String("type"), - refs: context.StringSlice("ref"), + selects: context.StringSlice("select"), platform: context.String("platform"), } - if len(v.refs) == 0 { - return fmt.Errorf("ref must be provided") + if len(v.selects) == 0 { + return fmt.Errorf("select must be provided") } - for index, ref := range v.refs { - for i := index + 1; i < len(v.refs); i++ { - if ref == v.refs[i] { - fmt.Printf("WARNING: refs contains duplicate reference %q.\n", v.refs[i]) + for index, sel := range v.selects { + for i := index + 1; i < len(v.selects); i++ { + if sel == v.selects[i] { + fmt.Printf("WARNING: selects contains duplicate selection %q.\n", v.selects[i]) } } } @@ -69,13 +69,13 @@ func unpackAction(context *cli.Context) error { var err error switch v.typ { case image.TypeImageLayout: - err = image.UnpackLayout(context.Args()[0], context.Args()[1], v.platform, v.refs) + err = image.UnpackLayout(context.Args()[0], context.Args()[1], v.platform, v.selects) case image.TypeImageZip: - err = image.UnpackZip(context.Args()[0], context.Args()[1], v.platform, v.refs) + err = image.UnpackZip(context.Args()[0], context.Args()[1], v.platform, v.selects) case image.TypeImage: - err = image.UnpackFile(context.Args()[0], context.Args()[1], v.platform, v.refs) + err = image.UnpackFile(context.Args()[0], context.Args()[1], v.platform, v.selects) default: err = fmt.Errorf("cannot unpack %q", v.typ) @@ -97,8 +97,8 @@ var unpackCommand = cli.Command{ ), }, cli.StringSliceFlag{ - Name: "ref", - Usage: "A set of ref specify the search criteria for the validated reference, format is A=B. Only support 'name', 'platform.os' and 'digest' three cases.", + Name: "select", + Usage: "Select the search criteria for the validated reference, format is A=B. Only support 'org.opencontainers.ref.name', 'platform.os' and 'digest' three cases.", }, cli.StringFlag{ Name: "platform", diff --git a/cmd/oci-image-tool/validate.go b/cmd/oci-image-tool/validate.go index 2873aef..68e3abf 100644 --- a/cmd/oci-image-tool/validate.go +++ b/cmd/oci-image-tool/validate.go @@ -35,9 +35,9 @@ var validateTypes = []string{ } type validateCmd struct { - stdout *log.Logger - typ string // the type to validate, can be empty string - refs []string + stdout *log.Logger + typ string // the type to validate, can be empty string + selects []string } var v validateCmd @@ -48,18 +48,18 @@ func validateAction(context *cli.Context) error { } v = validateCmd{ - typ: context.String("type"), - refs: context.StringSlice("ref"), + typ: context.String("type"), + selects: context.StringSlice("select"), } if v.typ == "" { return fmt.Errorf("--type must be set") } - for index, ref := range v.refs { - for i := index + 1; i < len(v.refs); i++ { - if ref == v.refs[i] { - fmt.Printf("WARNING: refs contains duplicate reference %q.\n", v.refs[i]) + for index, sel := range v.selects { + for i := index + 1; i < len(v.selects); i++ { + if sel == v.selects[i] { + fmt.Printf("WARNING: selects contains duplicate selection %q.\n", v.selects[i]) } } } @@ -109,16 +109,16 @@ func validatePath(name string) error { fmt.Println("autodetected image file type is:", imageType) switch imageType { case image.TypeImageLayout: - return image.ValidateLayout(name, v.refs, v.stdout) + return image.ValidateLayout(name, v.selects, v.stdout) case image.TypeImageZip: - return image.ValidateZip(name, v.refs, v.stdout) + return image.ValidateZip(name, v.selects, v.stdout) case image.TypeImage: - return image.ValidateFile(name, v.refs, v.stdout) + return image.ValidateFile(name, v.selects, v.stdout) } } - if len(v.refs) != 0 { - fmt.Println("WARNING: refs are only appropriate if type is image") + if len(v.selects) != 0 { + fmt.Println("WARNING: selects are only appropriate if type is image") } f, err := os.Open(name) if err != nil { @@ -151,8 +151,8 @@ var validateCommand = cli.Command{ ), }, cli.StringSliceFlag{ - Name: "ref", - Usage: "A set of ref specify the search criteria for the validated reference. Format is A=B. Only support 'name', 'platform.os' and 'digest' three cases. Only applicable if type is image", + Name: "select", + Usage: "Select the search criteria for the validated reference, format is A=B. Only support 'org.opencontainers.ref.name', 'platform.os' and 'digest' three cases. Only applicable if type is image", }, }, } diff --git a/image/descriptor.go b/image/descriptor.go index 5bf19ac..290d778 100644 --- a/image/descriptor.go +++ b/image/descriptor.go @@ -68,7 +68,7 @@ func findDescriptor(w walker, names []string) ([]v1.Descriptor, error) { } switch argsParts[0] { - case "name": + case "org.opencontainers.ref.name": for i := 0; i < len(descs); i++ { if descs[i].Annotations[v1.AnnotationRefName] != argsParts[1] { descs = append(descs[:i], descs[i+1:]...) @@ -97,9 +97,9 @@ func findDescriptor(w walker, names []string) ([]v1.Descriptor, error) { } if len(descs) == 0 { - return nil, fmt.Errorf("index.json: descriptor retrieved by refs %v is not match", names) + return nil, fmt.Errorf("index.json: descriptor retrieved by selects %v is not match", names) } else if len(descs) > 1 { - return nil, fmt.Errorf("index.json: descriptor retrieved by refs %v is not unique", names) + return nil, fmt.Errorf("index.json: descriptor retrieved by selects %v is not unique", names) } return descs, nil diff --git a/image/image_test.go b/image/image_test.go index 7141d98..9c99ae8 100644 --- a/image/image_test.go +++ b/image/image_test.go @@ -88,13 +88,13 @@ const ( ) var ( - ref1 = []string{ - "name=latest", + select1 = []string{ + "org.opencontainers.ref.name=latest", "platform.os=linux", } - ref2 = []string{ - "name=v1.0", + select2 = []string{ + "org.opencontainers.ref.name=v1.0", "platform.os=linux", } @@ -184,7 +184,7 @@ type tarContent struct { type imageLayout struct { rootDir string layout string - ref []string + selects []string manifest string index string config string @@ -226,7 +226,7 @@ func TestImageLayout(t *testing.T) { il := imageLayout{ rootDir: root, layout: layoutStr, - ref: ref1, + selects: select1, manifest: manifestStr, index: indexStr, indexjson: indexJSON, @@ -242,24 +242,24 @@ func TestImageLayout(t *testing.T) { t.Fatal(err) } - err = ValidateLayout(root, ref1, nil) + err = ValidateLayout(root, select1, nil) if err != nil { t.Fatal(err) } - err = UnpackLayout(root, dest1, "", ref1) + err = UnpackLayout(root, dest1, "", select1) if err != nil { t.Fatal(err) } - err = UnpackLayout(root, dest2, "linux:amd64", ref2) + err = UnpackLayout(root, dest2, "linux:amd64", select2) if err != nil { t.Fatal(err) } - err = CreateRuntimeBundleLayout(root, dest3, "rootfs", "", ref1) + err = CreateRuntimeBundleLayout(root, dest3, "rootfs", "", select1) if err != nil { t.Fatal(err) } - err = CreateRuntimeBundleLayout(root, dest4, "rootfs", "linux:amd64", ref2) + err = CreateRuntimeBundleLayout(root, dest4, "rootfs", "linux:amd64", select2) if err != nil { t.Fatal(err) } diff --git a/man/oci-image-tool-create.1.md b/man/oci-image-tool-create.1.md index fbd5ed7..2a989e7 100644 --- a/man/oci-image-tool-create.1.md +++ b/man/oci-image-tool-create.1.md @@ -17,11 +17,11 @@ runtime-spec-compatible `dest/config.json`. **--help** Print usage statement -**--ref**=[] - Specify the search criteria for the validated reference, format is A=B. +**--select**=[] + Select the search criteria for the validated reference, format is A=B. Reference should point to a manifest or index. - e.g. --ref name=v1.0 --ref platform.os=latest - Only support `name`, `platform.os` and `digest` three cases. + e.g. --select org.opencontainers.ref.name=v1.0 --select platform.os=latest + Only support `org.opencontainers.ref.name`, `platform.os` and `digest` three cases. **--rootfs**="" A directory representing the root filesystem of the container in the OCI runtime bundle. It is strongly recommended to keep the default value. (default "rootfs") @@ -38,7 +38,7 @@ runtime-spec-compatible `dest/config.json`. ``` $ skopeo copy docker://busybox oci:busybox-oci:latest $ mkdir busybox-bundle -$ oci-image-tool create --ref name=latest busybox-oci busybox-bundle +$ oci-image-tool create --select org.opencontainers.ref.name=latest busybox-oci busybox-bundle $ cd busybox-bundle && sudo runc run busybox [...] ``` diff --git a/man/oci-image-tool-unpack.1.md b/man/oci-image-tool-unpack.1.md index d43f574..eccfe15 100644 --- a/man/oci-image-tool-unpack.1.md +++ b/man/oci-image-tool-unpack.1.md @@ -14,11 +14,11 @@ oci-image-tool unpack \- Unpack an image or image source layout **--help** Print usage statement -**--ref**=[] - Specify the search criteria for the validated reference, format is A=B. +**--select**=[] + Select the search criteria for the validated reference, format is A=B. Reference should point to a manifest or index. - e.g. --ref name=v1.0 --ref platform.os=latest - Only support `name`, `platform.os` and `digest` three cases. + e.g. --select org.opencontainers.ref.name=v1.0 --select platform.os=latest + Only support `org.opencontainers.ref.name`, `platform.os` and `digest` three cases. **--type**="" Type of the file to unpack. If unset, oci-image-tool will try to auto-detect the type. One of "imageLayout,image,imageZip" @@ -32,7 +32,7 @@ oci-image-tool unpack \- Unpack an image or image source layout ``` $ skopeo copy docker://busybox oci:busybox-oci:latest $ mkdir busybox-bundle -$ oci-image-tool unpack --ref name=latest busybox-oci busybox-bundle +$ oci-image-tool unpack --select org.opencontainers.ref.name=latest busybox-oci busybox-bundle $ tree busybox-bundle busybox-bundle ├── bin diff --git a/man/oci-image-tool-validate.1.md b/man/oci-image-tool-validate.1.md index 6ae22ed..eda8a65 100644 --- a/man/oci-image-tool-validate.1.md +++ b/man/oci-image-tool-validate.1.md @@ -16,10 +16,10 @@ oci-image-tool validate \- Validate one or more image files Print usage statement **--ref**=[] - Specify the search criteria for the validated reference, format is A=B. + Select the search criteria for the validated reference, format is A=B. Reference should point to a manifest or index. - e.g. --ref name=v1.0 --ref platform.os=latest - Only support `name`, `platform.os` and `digest` three cases. + e.g. --select org.opencontainers.ref.name=v1.0 --select platform.os=latest + Only support `org.opencontainers.ref.name`, `platform.os` and `digest` three cases. Only applicable if type is image. **--type**="" @@ -28,7 +28,7 @@ oci-image-tool validate \- Validate one or more image files # EXAMPLES ``` $ skopeo copy docker://busybox oci:busybox-oci:latest -$ oci-image-tool validate --type image --ref name=latest busybox-oci +$ oci-image-tool validate --type image --select org.opencontainers.ref.name=latest busybox-oci busybox-oci: OK ```