Skip to content
Open
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
26 changes: 13 additions & 13 deletions cmd/oci-image-tool/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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])
}
}
}
Expand All @@ -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)
Expand All @@ -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",
Expand Down
26 changes: 13 additions & 13 deletions cmd/oci-image-tool/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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])
}
}
}
Expand All @@ -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)
Expand All @@ -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",
Expand Down
32 changes: 16 additions & 16 deletions cmd/oci-image-tool/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
},
},
}
6 changes: 3 additions & 3 deletions image/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:]...)
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down Expand Up @@ -184,7 +184,7 @@ type tarContent struct {
type imageLayout struct {
rootDir string
layout string
ref []string
selects []string
manifest string
index string
config string
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions man/oci-image-tool-create.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
[...]
```
Expand Down
10 changes: 5 additions & 5 deletions man/oci-image-tool-unpack.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions man/oci-image-tool-validate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**=""
Expand All @@ -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
```

Expand Down