Skip to content

Commit c16fa01

Browse files
authored
Merge pull request #519 from coolljt0725/validate_layout
Add imagelayout validator and ImageLayoutFile const
2 parents 87410cf + 88d41e8 commit c16fa01

8 files changed

+25
-19
lines changed

schema/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func TestConfig(t *testing.T) {
211211
},
212212
} {
213213
r := strings.NewReader(tt.config)
214-
err := schema.MediaTypeImageConfig.Validate(r)
214+
err := schema.ValidatorMediaTypeImageConfig.Validate(r)
215215

216216
if got := err != nil; tt.fail != got {
217217
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)

schema/descriptor_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func TestDescriptor(t *testing.T) {
204204
},
205205
} {
206206
r := strings.NewReader(tt.descriptor)
207-
err := schema.MediaTypeDescriptor.Validate(r)
207+
err := schema.ValidatorMediaTypeDescriptor.Validate(r)
208208

209209
if got := err != nil; tt.fail != got {
210210
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)

schema/manifest_backwards_compatibility_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestBackwardsCompatibilityManifestList(t *testing.T) {
116116

117117
manifestlist := convertFormats(tt.manifestlist)
118118
r := strings.NewReader(manifestlist)
119-
err := schema.MediaTypeManifestList.Validate(r)
119+
err := schema.ValidatorMediaTypeManifestList.Validate(r)
120120

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

179179
manifest := convertFormats(tt.manifest)
180180
r := strings.NewReader(manifest)
181-
err := schema.MediaTypeManifest.Validate(r)
181+
err := schema.ValidatorMediaTypeManifest.Validate(r)
182182

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

218218
config := convertFormats(tt.config)
219219
r := strings.NewReader(config)
220-
err := schema.MediaTypeImageConfig.Validate(r)
220+
err := schema.ValidatorMediaTypeImageConfig.Validate(r)
221221

222222
if got := err != nil; tt.fail != got {
223223
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)

schema/manifest_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TestManifest(t *testing.T) {
193193
},
194194
} {
195195
r := strings.NewReader(tt.manifest)
196-
err := schema.MediaTypeManifest.Validate(r)
196+
err := schema.ValidatorMediaTypeManifest.Validate(r)
197197

198198
if got := err != nil; tt.fail != got {
199199
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)

schema/manifestlist_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func TestManifestList(t *testing.T) {
239239
},
240240
} {
241241
r := strings.NewReader(tt.manifestList)
242-
err := schema.MediaTypeManifestList.Validate(r)
242+
err := schema.ValidatorMediaTypeManifestList.Validate(r)
243243

244244
if got := err != nil; tt.fail != got {
245245
t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err)

schema/schema.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import (
2222

2323
// Media types for the OCI image formats
2424
const (
25-
MediaTypeDescriptor Validator = v1.MediaTypeDescriptor
26-
MediaTypeManifest Validator = v1.MediaTypeImageManifest
27-
MediaTypeManifestList Validator = v1.MediaTypeImageManifestList
28-
MediaTypeImageConfig Validator = v1.MediaTypeImageConfig
29-
MediaTypeImageLayer unimplemented = v1.MediaTypeImageLayer
25+
ValidatorMediaTypeDescriptor Validator = v1.MediaTypeDescriptor
26+
ValidatorMediaTypeManifest Validator = v1.MediaTypeImageManifest
27+
ValidatorMediaTypeManifestList Validator = v1.MediaTypeImageManifestList
28+
ValidatorMediaTypeImageConfig Validator = v1.MediaTypeImageConfig
29+
ValidatorTypeImageLayout Validator = v1.ImageLayoutFile
30+
ValidatorMediaTypeImageLayer unimplemented = v1.MediaTypeImageLayer
3031
)
3132

3233
var (
@@ -36,10 +37,11 @@ var (
3637

3738
// specs maps OCI schema media types to schema files.
3839
specs = map[Validator]string{
39-
MediaTypeDescriptor: "content-descriptor.json",
40-
MediaTypeManifest: "image-manifest-schema.json",
41-
MediaTypeManifestList: "manifest-list-schema.json",
42-
MediaTypeImageConfig: "config-schema.json",
40+
ValidatorMediaTypeDescriptor: "content-descriptor.json",
41+
ValidatorMediaTypeManifest: "image-manifest-schema.json",
42+
ValidatorMediaTypeManifestList: "manifest-list-schema.json",
43+
ValidatorMediaTypeImageConfig: "config-schema.json",
44+
ValidatorTypeImageLayout: "image-layout-schema.json",
4345
}
4446
)
4547

schema/validator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type Validator string
3333
type validateDescendantsFunc func(r io.Reader) error
3434

3535
var mapValidateDescendants = map[Validator]validateDescendantsFunc{
36-
MediaTypeManifest: validateManifestDescendants,
36+
ValidatorMediaTypeManifest: validateManifestDescendants,
3737
}
3838

3939
// ValidationError contains all the errors that happened during validation.

specs-go/v1/layout.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414

1515
package v1
1616

17-
// ImageLayoutVersion is the version of ImageLayout
18-
const ImageLayoutVersion = "1.0.0"
17+
const (
18+
// ImageLayoutFile is the file name of oci image layout file
19+
ImageLayoutFile = "oci-layout"
20+
// ImageLayoutVersion is the version of ImageLayout
21+
ImageLayoutVersion = "1.0.0"
22+
)
1923

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

0 commit comments

Comments
 (0)