From 0ab3d089c207586f56c2c9ecf4fe29ed5a644078 Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Tue, 7 Feb 2017 01:20:01 -0500 Subject: [PATCH] Let media type validator start with validator Signed-off-by: Lei Jitang --- schema/config_test.go | 2 +- .../manifest_backwards_compatibility_test.go | 6 ++--- schema/manifest_test.go | 2 +- schema/schema.go | 22 +++++++++---------- schema/validator.go | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/schema/config_test.go b/schema/config_test.go index 69ae067c0..f31d14117 100644 --- a/schema/config_test.go +++ b/schema/config_test.go @@ -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) diff --git a/schema/manifest_backwards_compatibility_test.go b/schema/manifest_backwards_compatibility_test.go index ad94fd3a8..149da1880 100644 --- a/schema/manifest_backwards_compatibility_test.go +++ b/schema/manifest_backwards_compatibility_test.go @@ -118,7 +118,7 @@ func TestBackwardsCompatibilityManifestList(t *testing.T) { manifest := convertFormats(tt.manifest) r := strings.NewReader(manifest) - 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) @@ -181,7 +181,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) @@ -221,7 +221,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) diff --git a/schema/manifest_test.go b/schema/manifest_test.go index 02b4ad34b..c6e7f7157 100644 --- a/schema/manifest_test.go +++ b/schema/manifest_test.go @@ -183,7 +183,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) diff --git a/schema/schema.go b/schema/schema.go index 5e23ef51c..bdc5873d5 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -22,12 +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 - TypeImageLayout Validator = v1.ImageLayoutFile - 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 ( @@ -37,11 +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", - TypeImageLayout: "image-layout-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", } ) diff --git a/schema/validator.go b/schema/validator.go index 432e7b992..6a3385779 100644 --- a/schema/validator.go +++ b/schema/validator.go @@ -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.