...

Package schema

import "github.com/opencontainers/image-spec/schema"
Overview
Index

Overview ▾

Package schema defines the OCI image media types, schema definitions and validation functions.

Constants

Media types for the OCI image formats

const (
    ValidatorMediaTypeDescriptor   Validator     = v1.MediaTypeDescriptor
    ValidatorMediaTypeLayoutHeader Validator     = v1.MediaTypeLayoutHeader
    ValidatorMediaTypeManifest     Validator     = v1.MediaTypeImageManifest
    ValidatorMediaTypeImageIndex   Validator     = v1.MediaTypeImageIndex
    ValidatorMediaTypeImageConfig  Validator     = v1.MediaTypeImageConfig
    ValidatorMediaTypeImageLayer   unimplemented = v1.MediaTypeImageLayer
)

func FileSystem

func FileSystem() http.FileSystem

FileSystem returns an in-memory filesystem including the schema files. The schema files are located at the root directory.

func WrapSyntaxError

func WrapSyntaxError(r io.Reader, err error) error

WrapSyntaxError checks whether the given error is a *json.SyntaxError and converts it into a *schema.SyntaxError containing line/col information using the given reader. If the given error is not a *json.SyntaxError it is returned unchanged.

type SyntaxError

A SyntaxError is a description of a JSON syntax error including line, column and offset in the JSON file.

type SyntaxError struct {
    Line, Col int
    Offset    int64
    // contains filtered or unexported fields
}

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type ValidationError

ValidationError contains all the errors that happened during validation.

type ValidationError struct {
    Errs []error
}

func (ValidationError) Error

func (e ValidationError) Error() string

type Validator

Validator wraps a media type string identifier and implements validation against a JSON schema.

type Validator string

func (Validator) Validate

func (v Validator) Validate(src io.Reader) error

Validate validates the given reader against the schema of the wrapped media type.