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

Add imagelayout validator and ImageLayoutFile const #519

Merged
merged 3 commits into from
Feb 10, 2017
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
2 changes: 1 addition & 1 deletion schema/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestConfig(t *testing.T) {
},
} {
r := strings.NewReader(tt.config)
err := schema.MediaTypeImageConfig.Validate(r)
err := schema.ValidatorMediaTypeImageConfig.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down
2 changes: 1 addition & 1 deletion schema/descriptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestDescriptor(t *testing.T) {
},
} {
r := strings.NewReader(tt.descriptor)
err := schema.MediaTypeDescriptor.Validate(r)
err := schema.ValidatorMediaTypeDescriptor.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down
6 changes: 3 additions & 3 deletions schema/manifest_backwards_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestBackwardsCompatibilityManifestList(t *testing.T) {

manifestlist := convertFormats(tt.manifestlist)
r := strings.NewReader(manifestlist)
err := schema.MediaTypeManifestList.Validate(r)
err := schema.ValidatorMediaTypeManifestList.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestBackwardsCompatibilityManifest(t *testing.T) {

manifest := convertFormats(tt.manifest)
r := strings.NewReader(manifest)
err := schema.MediaTypeManifest.Validate(r)
err := schema.ValidatorMediaTypeManifest.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestBackwardsCompatibilityConfig(t *testing.T) {

config := convertFormats(tt.config)
r := strings.NewReader(config)
err := schema.MediaTypeImageConfig.Validate(r)
err := schema.ValidatorMediaTypeImageConfig.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down
2 changes: 1 addition & 1 deletion schema/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func TestManifest(t *testing.T) {
},
} {
r := strings.NewReader(tt.manifest)
err := schema.MediaTypeManifest.Validate(r)
err := schema.ValidatorMediaTypeManifest.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down
2 changes: 1 addition & 1 deletion schema/manifestlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestManifestList(t *testing.T) {
},
} {
r := strings.NewReader(tt.manifestList)
err := schema.MediaTypeManifestList.Validate(r)
err := schema.ValidatorMediaTypeManifestList.Validate(r)

if got := err != nil; tt.fail != got {
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)
Expand Down
20 changes: 11 additions & 9 deletions schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import (

// Media types for the OCI image formats
const (
MediaTypeDescriptor Validator = v1.MediaTypeDescriptor
MediaTypeManifest Validator = v1.MediaTypeImageManifest
MediaTypeManifestList Validator = v1.MediaTypeImageManifestList
MediaTypeImageConfig Validator = v1.MediaTypeImageConfig
MediaTypeImageLayer unimplemented = v1.MediaTypeImageLayer
ValidatorMediaTypeDescriptor Validator = v1.MediaTypeDescriptor
ValidatorMediaTypeManifest Validator = v1.MediaTypeImageManifest
ValidatorMediaTypeManifestList Validator = v1.MediaTypeImageManifestList
ValidatorMediaTypeImageConfig Validator = v1.MediaTypeImageConfig
ValidatorTypeImageLayout Validator = v1.ImageLayoutFile
ValidatorMediaTypeImageLayer unimplemented = v1.MediaTypeImageLayer
)

var (
Expand All @@ -36,10 +37,11 @@ var (

// specs maps OCI schema media types to schema files.
specs = map[Validator]string{
MediaTypeDescriptor: "content-descriptor.json",
MediaTypeManifest: "image-manifest-schema.json",
MediaTypeManifestList: "manifest-list-schema.json",
MediaTypeImageConfig: "config-schema.json",
ValidatorMediaTypeDescriptor: "content-descriptor.json",
ValidatorMediaTypeManifest: "image-manifest-schema.json",
ValidatorMediaTypeManifestList: "manifest-list-schema.json",
ValidatorMediaTypeImageConfig: "config-schema.json",
ValidatorTypeImageLayout: "image-layout-schema.json",
}
)

Expand Down
2 changes: 1 addition & 1 deletion schema/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Validator string
type validateDescendantsFunc func(r io.Reader) error

var mapValidateDescendants = map[Validator]validateDescendantsFunc{
MediaTypeManifest: validateManifestDescendants,
ValidatorMediaTypeManifest: validateManifestDescendants,
}

// ValidationError contains all the errors that happened during validation.
Expand Down
8 changes: 6 additions & 2 deletions specs-go/v1/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

package v1

// ImageLayoutVersion is the version of ImageLayout
const ImageLayoutVersion = "1.0.0"
const (
// ImageLayoutFile is the file name of oci image layout file
ImageLayoutFile = "oci-layout"
// ImageLayoutVersion is the version of ImageLayout
ImageLayoutVersion = "1.0.0"
)

// ImageLayout is the structure in the "oci-layout" file, found in the root
// of an OCI Image-layout directory.
Expand Down