mirror of
https://github.com/opencontainers/image-spec.git
synced 2025-04-18 03:24:01 +03:00
Remove validation warnings to stdout
Signed-off-by: Brandon Mitchell <git@bmitch.net>
This commit is contained in:
parent
036563a4a2
commit
a977bd3228
@ -20,7 +20,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
@ -93,7 +92,8 @@ func (v Validator) validateSchema(src io.Reader) error {
|
||||
return fmt.Errorf("failed to add spec file %s: %w", file.Name(), err)
|
||||
}
|
||||
if len(specURLs[file.Name()]) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "warning: spec file has no aliases: %s", file.Name())
|
||||
// this would be a bug in the validation code itself, add any missing entry to schema.go
|
||||
return fmt.Errorf("spec file has no aliases: %s", file.Name())
|
||||
}
|
||||
for _, specURL := range specURLs[file.Name()] {
|
||||
err = c.AddResource(specURL, bytes.NewReader(specBuf))
|
||||
@ -139,20 +139,6 @@ func validateManifest(buf []byte) error {
|
||||
return fmt.Errorf("manifest format mismatch: %w", err)
|
||||
}
|
||||
|
||||
if header.Config.MediaType != string(v1.MediaTypeImageConfig) {
|
||||
fmt.Printf("warning: config %s has an unknown media type: %s\n", header.Config.Digest, header.Config.MediaType)
|
||||
}
|
||||
|
||||
for _, layer := range header.Layers {
|
||||
if layer.MediaType != string(v1.MediaTypeImageLayer) &&
|
||||
layer.MediaType != string(v1.MediaTypeImageLayerGzip) &&
|
||||
layer.MediaType != string(v1.MediaTypeImageLayerZstd) &&
|
||||
layer.MediaType != string(v1.MediaTypeImageLayerNonDistributable) && //nolint:staticcheck
|
||||
layer.MediaType != string(v1.MediaTypeImageLayerNonDistributableGzip) && //nolint:staticcheck
|
||||
layer.MediaType != string(v1.MediaTypeImageLayerNonDistributableZstd) { //nolint:staticcheck
|
||||
fmt.Printf("warning: layer %s has an unknown media type: %s\n", layer.Digest, layer.MediaType)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -167,7 +153,6 @@ func validateDescriptor(buf []byte) error {
|
||||
err = header.Digest.Validate()
|
||||
if errors.Is(err, digest.ErrDigestUnsupported) {
|
||||
// we ignore unsupported algorithms
|
||||
fmt.Printf("warning: unsupported digest: %q: %v\n", header.Digest, err)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
@ -181,17 +166,6 @@ func validateIndex(buf []byte) error {
|
||||
return fmt.Errorf("index format mismatch: %w", err)
|
||||
}
|
||||
|
||||
for _, manifest := range header.Manifests {
|
||||
if manifest.MediaType != string(v1.MediaTypeImageManifest) {
|
||||
fmt.Printf("warning: manifest %s has an unknown media type: %s\n", manifest.Digest, manifest.MediaType)
|
||||
}
|
||||
if manifest.Platform != nil {
|
||||
checkPlatform(manifest.Platform.OS, manifest.Platform.Architecture)
|
||||
checkArchitecture(manifest.Platform.Architecture, manifest.Platform.Variant)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -203,9 +177,6 @@ func validateConfig(buf []byte) error {
|
||||
return fmt.Errorf("config format mismatch: %w", err)
|
||||
}
|
||||
|
||||
checkPlatform(header.OS, header.Architecture)
|
||||
checkArchitecture(header.Architecture, header.Variant)
|
||||
|
||||
envRegexp := regexp.MustCompile(`^[^=]+=.*$`)
|
||||
for _, e := range header.Config.Env {
|
||||
if !envRegexp.MatchString(e) {
|
||||
@ -215,54 +186,3 @@ func validateConfig(buf []byte) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkArchitecture(Architecture string, Variant string) {
|
||||
validCombins := map[string][]string{
|
||||
"arm": {"", "v6", "v7", "v8"},
|
||||
"arm64": {"", "v8"},
|
||||
"386": {""},
|
||||
"amd64": {""},
|
||||
"ppc64": {""},
|
||||
"ppc64le": {""},
|
||||
"mips64": {""},
|
||||
"mips64le": {""},
|
||||
"s390x": {""},
|
||||
"riscv64": {""},
|
||||
}
|
||||
for arch, variants := range validCombins {
|
||||
if arch == Architecture {
|
||||
for _, variant := range variants {
|
||||
if variant == Variant {
|
||||
return
|
||||
}
|
||||
}
|
||||
fmt.Printf("warning: combination of architecture %q and variant %q is not valid.\n", Architecture, Variant)
|
||||
}
|
||||
}
|
||||
fmt.Printf("warning: architecture %q is not supported yet.\n", Architecture)
|
||||
}
|
||||
|
||||
func checkPlatform(OS string, Architecture string) {
|
||||
validCombins := map[string][]string{
|
||||
"android": {"arm"},
|
||||
"darwin": {"386", "amd64", "arm", "arm64"},
|
||||
"dragonfly": {"amd64"},
|
||||
"freebsd": {"386", "amd64", "arm"},
|
||||
"linux": {"386", "amd64", "arm", "arm64", "ppc64", "ppc64le", "mips64", "mips64le", "s390x", "riscv64"},
|
||||
"netbsd": {"386", "amd64", "arm"},
|
||||
"openbsd": {"386", "amd64", "arm"},
|
||||
"plan9": {"386", "amd64"},
|
||||
"solaris": {"amd64"},
|
||||
"windows": {"386", "amd64"}}
|
||||
for os, archs := range validCombins {
|
||||
if os == OS {
|
||||
for _, arch := range archs {
|
||||
if arch == Architecture {
|
||||
return
|
||||
}
|
||||
}
|
||||
fmt.Printf("warning: combination of os %q and architecture %q is invalid.\n", OS, Architecture)
|
||||
}
|
||||
}
|
||||
fmt.Printf("warning: operating system %q of the bundle is not supported yet.\n", OS)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user