@@ -20,7 +20,6 @@ import (
20
20
"errors"
21
21
"fmt"
22
22
"io"
23
- "os"
24
23
"regexp"
25
24
26
25
digest "github.com/opencontainers/go-digest"
@@ -93,7 +92,8 @@ func (v Validator) validateSchema(src io.Reader) error {
93
92
return fmt .Errorf ("failed to add spec file %s: %w" , file .Name (), err )
94
93
}
95
94
if len (specURLs [file .Name ()]) == 0 {
96
- fmt .Fprintf (os .Stderr , "warning: spec file has no aliases: %s" , file .Name ())
95
+ // this would be a bug in the validation code itself, add any missing entry to schema.go
96
+ return fmt .Errorf ("spec file has no aliases: %s" , file .Name ())
97
97
}
98
98
for _ , specURL := range specURLs [file .Name ()] {
99
99
err = c .AddResource (specURL , bytes .NewReader (specBuf ))
@@ -139,20 +139,6 @@ func validateManifest(buf []byte) error {
139
139
return fmt .Errorf ("manifest format mismatch: %w" , err )
140
140
}
141
141
142
- if header .Config .MediaType != string (v1 .MediaTypeImageConfig ) {
143
- fmt .Printf ("warning: config %s has an unknown media type: %s\n " , header .Config .Digest , header .Config .MediaType )
144
- }
145
-
146
- for _ , layer := range header .Layers {
147
- if layer .MediaType != string (v1 .MediaTypeImageLayer ) &&
148
- layer .MediaType != string (v1 .MediaTypeImageLayerGzip ) &&
149
- layer .MediaType != string (v1 .MediaTypeImageLayerZstd ) &&
150
- layer .MediaType != string (v1 .MediaTypeImageLayerNonDistributable ) && //nolint:staticcheck
151
- layer .MediaType != string (v1 .MediaTypeImageLayerNonDistributableGzip ) && //nolint:staticcheck
152
- layer .MediaType != string (v1 .MediaTypeImageLayerNonDistributableZstd ) { //nolint:staticcheck
153
- fmt .Printf ("warning: layer %s has an unknown media type: %s\n " , layer .Digest , layer .MediaType )
154
- }
155
- }
156
142
return nil
157
143
}
158
144
@@ -167,7 +153,6 @@ func validateDescriptor(buf []byte) error {
167
153
err = header .Digest .Validate ()
168
154
if errors .Is (err , digest .ErrDigestUnsupported ) {
169
155
// we ignore unsupported algorithms
170
- fmt .Printf ("warning: unsupported digest: %q: %v\n " , header .Digest , err )
171
156
return nil
172
157
}
173
158
return err
@@ -181,17 +166,6 @@ func validateIndex(buf []byte) error {
181
166
return fmt .Errorf ("index format mismatch: %w" , err )
182
167
}
183
168
184
- for _ , manifest := range header .Manifests {
185
- if manifest .MediaType != string (v1 .MediaTypeImageManifest ) {
186
- fmt .Printf ("warning: manifest %s has an unknown media type: %s\n " , manifest .Digest , manifest .MediaType )
187
- }
188
- if manifest .Platform != nil {
189
- checkPlatform (manifest .Platform .OS , manifest .Platform .Architecture )
190
- checkArchitecture (manifest .Platform .Architecture , manifest .Platform .Variant )
191
- }
192
-
193
- }
194
-
195
169
return nil
196
170
}
197
171
@@ -203,9 +177,6 @@ func validateConfig(buf []byte) error {
203
177
return fmt .Errorf ("config format mismatch: %w" , err )
204
178
}
205
179
206
- checkPlatform (header .OS , header .Architecture )
207
- checkArchitecture (header .Architecture , header .Variant )
208
-
209
180
envRegexp := regexp .MustCompile (`^[^=]+=.*$` )
210
181
for _ , e := range header .Config .Env {
211
182
if ! envRegexp .MatchString (e ) {
@@ -215,54 +186,3 @@ func validateConfig(buf []byte) error {
215
186
216
187
return nil
217
188
}
218
-
219
- func checkArchitecture (Architecture string , Variant string ) {
220
- validCombins := map [string ][]string {
221
- "arm" : {"" , "v6" , "v7" , "v8" },
222
- "arm64" : {"" , "v8" },
223
- "386" : {"" },
224
- "amd64" : {"" },
225
- "ppc64" : {"" },
226
- "ppc64le" : {"" },
227
- "mips64" : {"" },
228
- "mips64le" : {"" },
229
- "s390x" : {"" },
230
- "riscv64" : {"" },
231
- }
232
- for arch , variants := range validCombins {
233
- if arch == Architecture {
234
- for _ , variant := range variants {
235
- if variant == Variant {
236
- return
237
- }
238
- }
239
- fmt .Printf ("warning: combination of architecture %q and variant %q is not valid.\n " , Architecture , Variant )
240
- }
241
- }
242
- fmt .Printf ("warning: architecture %q is not supported yet.\n " , Architecture )
243
- }
244
-
245
- func checkPlatform (OS string , Architecture string ) {
246
- validCombins := map [string ][]string {
247
- "android" : {"arm" },
248
- "darwin" : {"386" , "amd64" , "arm" , "arm64" },
249
- "dragonfly" : {"amd64" },
250
- "freebsd" : {"386" , "amd64" , "arm" },
251
- "linux" : {"386" , "amd64" , "arm" , "arm64" , "ppc64" , "ppc64le" , "mips64" , "mips64le" , "s390x" , "riscv64" },
252
- "netbsd" : {"386" , "amd64" , "arm" },
253
- "openbsd" : {"386" , "amd64" , "arm" },
254
- "plan9" : {"386" , "amd64" },
255
- "solaris" : {"amd64" },
256
- "windows" : {"386" , "amd64" }}
257
- for os , archs := range validCombins {
258
- if os == OS {
259
- for _ , arch := range archs {
260
- if arch == Architecture {
261
- return
262
- }
263
- }
264
- fmt .Printf ("warning: combination of os %q and architecture %q is invalid.\n " , OS , Architecture )
265
- }
266
- }
267
- fmt .Printf ("warning: operating system %q of the bundle is not supported yet.\n " , OS )
268
- }
0 commit comments