manifest

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DockerV2Schema1MediaType MIME type represents Docker manifest schema 1
	DockerV2Schema1MediaType = "application/vnd.docker.distribution.manifest.v1+json"
	// DockerV2Schema1MediaType MIME type represents Docker manifest schema 1 with a JWS signature
	DockerV2Schema1SignedMediaType = "application/vnd.docker.distribution.manifest.v1+prettyjws"
	// DockerV2Schema2MediaType MIME type represents Docker manifest schema 2
	DockerV2Schema2MediaType = "application/vnd.docker.distribution.manifest.v2+json"
	// DockerV2Schema2ConfigMediaType is the MIME type used for schema 2 config blobs.
	DockerV2Schema2ConfigMediaType = "application/vnd.docker.container.image.v1+json"
	// DockerV2Schema2LayerMediaType is the MIME type used for schema 2 layers.
	DockerV2Schema2LayerMediaType = "application/vnd.docker.image.rootfs.diff.tar.gzip"
	// DockerV2ListMediaType MIME type represents Docker manifest schema 2 list
	DockerV2ListMediaType = "application/vnd.docker.distribution.manifest.list.v2+json"
	// DockerV2Schema2ForeignLayerMediaType is the MIME type used for schema 2 foreign layers.
	DockerV2Schema2ForeignLayerMediaType = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"
)

FIXME(runcom, mitr): should we havea mediatype pkg??

Variables

DefaultRequestedManifestMIMETypes is a list of MIME types a types.ImageSource should request from the backend unless directed otherwise.

Functions

func AddDummyV2S1Signature

func AddDummyV2S1Signature(manifest []byte) ([]byte, error)

AddDummyV2S1Signature adds an JWS signature with a temporary key (i.e. useless) to a v2s1 manifest. This is useful to make the manifest acceptable to a Docker Registry (even though nothing needs or wants the JWS signature).

func BlobInfoFromOCI1Descriptor

func BlobInfoFromOCI1Descriptor(desc imgspecv1.Descriptor) types.BlobInfo

BlobInfoFromOCI1Descriptor returns a types.BlobInfo based on the input OCI1 descriptor.

func BlobInfoFromSchema2Descriptor

func BlobInfoFromSchema2Descriptor(desc Schema2Descriptor) types.BlobInfo

BlobInfoFromSchema2Descriptor returns a types.BlobInfo based on the input schema 2 descriptor.

func Digest

func Digest(manifest []byte) (digest.Digest, error)

Digest returns the a digest of a docker manifest, with any necessary implied transformations like stripping v1s1 signatures.

func GuessMIMEType

func GuessMIMEType(manifest []byte) string

GuessMIMEType guesses MIME type of a manifest and returns it _if it is recognized_, or "" if unknown or unrecognized. FIXME? We should, in general, prefer out-of-band MIME type instead of blindly parsing the manifest, but we may not have such metadata available (e.g. when the manifest is a local file).

func MIMETypeIsMultiImage

func MIMETypeIsMultiImage(mimeType string) bool

MIMETypeIsMultiImage returns true if mimeType is a list of images

func MatchesDigest

func MatchesDigest(manifest []byte, expectedDigest digest.Digest) (bool, error)

MatchesDigest returns true iff the manifest matches expectedDigest. Error may be set if this returns false. Note that this is not doing ConstantTimeCompare; by the time we get here, the cryptographic signature must already have been verified, or we are not using a cryptographic channel and the attacker can modify the digest along with the manifest blob.

func NormalizedMIMEType

func NormalizedMIMEType(input string) string

NormalizedMIMEType returns the effective MIME type of a manifest MIME type returned by a server, centralizing various workarounds.

Types

type LayerInfo

type LayerInfo struct {
	types.BlobInfo
	EmptyLayer bool // The layer is an “empty”/“throwaway” one, and may or may not be physically represented in various transport / storage systems.  false if the manifest type does not have the concept.
}

LayerInfo is an extended version of types.BlobInfo for low-level users of Manifest.LayerInfos.

type Manifest

type Manifest interface {
	// ConfigInfo returns a complete BlobInfo for the separate config object, or a BlobInfo{Digest:""} if there isn't a separate object.
	ConfigInfo() types.BlobInfo
	// LayerInfos returns a list of LayerInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers).
	// The Digest field is guaranteed to be provided; Size may be -1.
	// WARNING: The list may contain duplicates, and they are semantically relevant.
	LayerInfos() []LayerInfo
	// UpdateLayerInfos replaces the original layers with the specified BlobInfos (size+digest+urls), in order (the root layer first, and then successive layered layers)
	UpdateLayerInfos(layerInfos []types.BlobInfo) error

	// ImageID computes an ID which can uniquely identify this image by its contents, irrespective
	// of which (of possibly more than one simultaneously valid) reference was used to locate the
	// image, and unchanged by whether or how the layers are compressed.  The result takes the form
	// of the hexadecimal portion of a digest.Digest.
	ImageID(diffIDs []digest.Digest) (string, error)

	// Inspect returns various information for (skopeo inspect) parsed from the manifest,
	// incorporating information from a configuration blob returned by configGetter, if
	// the underlying image format is expected to include a configuration blob.
	Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*types.ImageInspectInfo, error)

	// Serialize returns the manifest in a blob format.
	// NOTE: Serialize() does not in general reproduce the original blob if this object was loaded from one, even if no modifications were made!
	Serialize() ([]byte, error)
}

Manifest is an interface for parsing, modifying image manifests in isolation. Callers can either use this abstract interface without understanding the details of the formats, or instantiate a specific implementation (e.g. manifest.OCI1) and access the public members directly.

See types.Image for functionality not limited to manifests, including format conversions and config parsing. This interface is similar to, but not strictly equivalent to, the equivalent methods in types.Image.

func FromBlob

func FromBlob(manblob []byte, mt string) (Manifest, error)

FromBlob returns a Manifest instance for the specified manifest blob and the corresponding MIME type

type OCI1

type OCI1 struct {
	imgspecv1.Manifest
}

OCI1 is a manifest.Manifest implementation for OCI images. The underlying data from imgspecv1.Manifest is also available.

func OCI1Clone

func OCI1Clone(src *OCI1) *OCI1

OCI1Clone creates a copy of the supplied OCI1 manifest.

func OCI1FromComponents

func OCI1FromComponents(config imgspecv1.Descriptor, layers []imgspecv1.Descriptor) *OCI1

OCI1FromComponents creates an OCI1 manifest instance from the supplied data.

func OCI1FromManifest

func OCI1FromManifest(manifest []byte) (*OCI1, error)

OCI1FromManifest creates an OCI1 manifest instance from a manifest blob.

func (*OCI1) ConfigInfo

func (m *OCI1) ConfigInfo() types.BlobInfo

ConfigInfo returns a complete BlobInfo for the separate config object, or a BlobInfo{Digest:""} if there isn't a separate object.

func (*OCI1) ImageID

func (m *OCI1) ImageID([]digest.Digest) (string, error)

ImageID computes an ID which can uniquely identify this image by its contents.

func (*OCI1) Inspect

func (m *OCI1) Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*types.ImageInspectInfo, error)

Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.

func (*OCI1) LayerInfos

func (m *OCI1) LayerInfos() []LayerInfo

LayerInfos returns a list of LayerInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers). The Digest field is guaranteed to be provided; Size may be -1. WARNING: The list may contain duplicates, and they are semantically relevant.

func (*OCI1) Serialize

func (m *OCI1) Serialize() ([]byte, error)

Serialize returns the manifest in a blob format. NOTE: Serialize() does not in general reproduce the original blob if this object was loaded from one, even if no modifications were made!

func (*OCI1) UpdateLayerInfos

func (m *OCI1) UpdateLayerInfos(layerInfos []types.BlobInfo) error

UpdateLayerInfos replaces the original layers with the specified BlobInfos (size+digest+urls), in order (the root layer first, and then successive layered layers)

type Schema1

type Schema1 struct {
	Name                     string                   `json:"name"`
	Tag                      string                   `json:"tag"`
	Architecture             string                   `json:"architecture"`
	FSLayers                 []Schema1FSLayers        `json:"fsLayers"`
	History                  []Schema1History         `json:"history"` // Keep this in sync with ExtractedV1Compatibility!
	ExtractedV1Compatibility []Schema1V1Compatibility `json:"-"`       // Keep this in sync with History! Does not contain the full config (Schema2V1Image)
	SchemaVersion            int                      `json:"schemaVersion"`
}

Schema1 is a manifest in docker/distribution schema 1.

func Schema1Clone

func Schema1Clone(src *Schema1) *Schema1

Schema1Clone creates a copy of the supplied Schema1 manifest.

func Schema1FromComponents

func Schema1FromComponents(ref reference.Named, fsLayers []Schema1FSLayers, history []Schema1History, architecture string) (*Schema1, error)

Schema1FromComponents creates an Schema1 manifest instance from the supplied data.

func Schema1FromManifest

func Schema1FromManifest(manifest []byte) (*Schema1, error)

Schema1FromManifest creates a Schema1 manifest instance from a manifest blob. (NOTE: The instance is not necessary a literal representation of the original blob, layers with duplicate IDs are eliminated.)

func (*Schema1) ConfigInfo

func (m *Schema1) ConfigInfo() types.BlobInfo

ConfigInfo returns a complete BlobInfo for the separate config object, or a BlobInfo{Digest:""} if there isn't a separate object.

func (*Schema1) ImageID

func (m *Schema1) ImageID(diffIDs []digest.Digest) (string, error)

ImageID computes an ID which can uniquely identify this image by its contents.

func (*Schema1) Inspect

func (m *Schema1) Inspect(_ func(types.BlobInfo) ([]byte, error)) (*types.ImageInspectInfo, error)

Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.

func (*Schema1) LayerInfos

func (m *Schema1) LayerInfos() []LayerInfo

LayerInfos returns a list of LayerInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers). The Digest field is guaranteed to be provided; Size may be -1. WARNING: The list may contain duplicates, and they are semantically relevant.

func (*Schema1) Serialize

func (m *Schema1) Serialize() ([]byte, error)

Serialize returns the manifest in a blob format. NOTE: Serialize() does not in general reproduce the original blob if this object was loaded from one, even if no modifications were made!

func (*Schema1) ToSchema2Config

func (m *Schema1) ToSchema2Config(diffIDs []digest.Digest) ([]byte, error)

ToSchema2Config builds a schema2-style configuration blob using the supplied diffIDs.

func (*Schema1) UpdateLayerInfos

func (m *Schema1) UpdateLayerInfos(layerInfos []types.BlobInfo) error

UpdateLayerInfos replaces the original layers with the specified BlobInfos (size+digest+urls), in order (the root layer first, and then successive layered layers)

type Schema1FSLayers

type Schema1FSLayers struct {
	BlobSum digest.Digest `json:"blobSum"`
}

Schema1FSLayers is an entry of the "fsLayers" array in docker/distribution schema 1.

type Schema1History

type Schema1History struct {
	V1Compatibility string `json:"v1Compatibility"`
}

Schema1History is an entry of the "history" array in docker/distribution schema 1.

type Schema1V1Compatibility

type Schema1V1Compatibility struct {
	ID              string                                `json:"id"`
	Parent          string                                `json:"parent,omitempty"`
	Comment         string                                `json:"comment,omitempty"`
	Created         time.Time                             `json:"created"`
	ContainerConfig schema1V1CompatibilityContainerConfig `json:"container_config,omitempty"`
	Author          string                                `json:"author,omitempty"`
	ThrowAway       bool                                  `json:"throwaway,omitempty"`
}

Schema1V1Compatibility is a v1Compatibility in docker/distribution schema 1.

type Schema2

type Schema2 struct {
	SchemaVersion     int                 `json:"schemaVersion"`
	MediaType         string              `json:"mediaType"`
	ConfigDescriptor  Schema2Descriptor   `json:"config"`
	LayersDescriptors []Schema2Descriptor `json:"layers"`
}

Schema2 is a manifest in docker/distribution schema 2.

func Schema2Clone

func Schema2Clone(src *Schema2) *Schema2

Schema2Clone creates a copy of the supplied Schema2 manifest.

func Schema2FromComponents

func Schema2FromComponents(config Schema2Descriptor, layers []Schema2Descriptor) *Schema2

Schema2FromComponents creates an Schema2 manifest instance from the supplied data.

func Schema2FromManifest

func Schema2FromManifest(manifest []byte) (*Schema2, error)

Schema2FromManifest creates a Schema2 manifest instance from a manifest blob.

func (*Schema2) ConfigInfo

func (m *Schema2) ConfigInfo() types.BlobInfo

ConfigInfo returns a complete BlobInfo for the separate config object, or a BlobInfo{Digest:""} if there isn't a separate object.

func (*Schema2) ImageID

func (m *Schema2) ImageID([]digest.Digest) (string, error)

ImageID computes an ID which can uniquely identify this image by its contents.

func (*Schema2) Inspect

func (m *Schema2) Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*types.ImageInspectInfo, error)

Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.

func (*Schema2) LayerInfos

func (m *Schema2) LayerInfos() []LayerInfo

LayerInfos returns a list of LayerInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers). The Digest field is guaranteed to be provided; Size may be -1. WARNING: The list may contain duplicates, and they are semantically relevant.

func (*Schema2) Serialize

func (m *Schema2) Serialize() ([]byte, error)

Serialize returns the manifest in a blob format. NOTE: Serialize() does not in general reproduce the original blob if this object was loaded from one, even if no modifications were made!

func (*Schema2) UpdateLayerInfos

func (m *Schema2) UpdateLayerInfos(layerInfos []types.BlobInfo) error

UpdateLayerInfos replaces the original layers with the specified BlobInfos (size+digest+urls), in order (the root layer first, and then successive layered layers)

type Schema2Config

type Schema2Config struct {
	Hostname        string               // Hostname
	Domainname      string               // Domainname
	User            string               // User that will run the command(s) inside the container, also support user:group
	AttachStdin     bool                 // Attach the standard input, makes possible user interaction
	AttachStdout    bool                 // Attach the standard output
	AttachStderr    bool                 // Attach the standard error
	ExposedPorts    Schema2PortSet       `json:",omitempty"` // List of exposed ports
	Tty             bool                 // Attach standard streams to a tty, including stdin if it is not closed.
	OpenStdin       bool                 // Open stdin
	StdinOnce       bool                 // If true, close stdin after the 1 attached client disconnects.
	Env             []string             // List of environment variable to set in the container
	Cmd             strslice.StrSlice    // Command to run when starting the container
	Healthcheck     *Schema2HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
	ArgsEscaped     bool                 `json:",omitempty"` // True if command is already escaped (Windows specific)
	Image           string               // Name of the image as it was passed by the operator (e.g. could be symbolic)
	Volumes         map[string]struct{}  // List of volumes (mounts) used for the container
	WorkingDir      string               // Current directory (PWD) in the command will be launched
	Entrypoint      strslice.StrSlice    // Entrypoint to run when starting the container
	NetworkDisabled bool                 `json:",omitempty"` // Is network disabled
	MacAddress      string               `json:",omitempty"` // Mac Address of the container
	OnBuild         []string             // ONBUILD metadata that were defined on the image Dockerfile
	Labels          map[string]string    // List of labels set to this container
	StopSignal      string               `json:",omitempty"` // Signal to stop a container
	StopTimeout     *int                 `json:",omitempty"` // Timeout (in seconds) to stop a container
	Shell           strslice.StrSlice    `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
}

Schema2Config is a Config in docker/docker/api/types/container.

type Schema2Descriptor

type Schema2Descriptor struct {
	MediaType string        `json:"mediaType"`
	Size      int64         `json:"size"`
	Digest    digest.Digest `json:"digest"`
	URLs      []string      `json:"urls,omitempty"`
}

Schema2Descriptor is a “descriptor” in docker/distribution schema 2.

type Schema2HealthConfig

type Schema2HealthConfig struct {
	// Test is the test to perform to check that the container is healthy.
	// An empty slice means to inherit the default.
	// The options are:
	// {} : inherit healthcheck
	// {"NONE"} : disable healthcheck
	// {"CMD", args...} : exec arguments directly
	// {"CMD-SHELL", command} : run command with system's default shell
	Test []string `json:",omitempty"`

	// Zero means to inherit. Durations are expressed as integer nanoseconds.
	StartPeriod time.Duration `json:",omitempty"` // StartPeriod is the time to wait after starting before running the first check.
	Interval    time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
	Timeout     time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.

	// Retries is the number of consecutive failures needed to consider a container as unhealthy.
	// Zero means inherit.
	Retries int `json:",omitempty"`
}

Schema2HealthConfig is a HealthConfig, which holds configuration settings for the HEALTHCHECK feature, from docker/docker/api/types/container.

type Schema2History

type Schema2History struct {
	// Created is the timestamp at which the image was created
	Created time.Time `json:"created"`
	// Author is the name of the author that was specified when committing the image
	Author string `json:"author,omitempty"`
	// CreatedBy keeps the Dockerfile command used while building the image
	CreatedBy string `json:"created_by,omitempty"`
	// Comment is the commit message that was set when committing the image
	Comment string `json:"comment,omitempty"`
	// EmptyLayer is set to true if this history item did not generate a
	// layer. Otherwise, the history item is associated with the next
	// layer in the RootFS section.
	EmptyLayer bool `json:"empty_layer,omitempty"`
}

Schema2History stores build commands that were used to create an image, from docker/docker/image.

type Schema2Image

type Schema2Image struct {
	Schema2V1Image
	Parent     digest.Digest    `json:"parent,omitempty"`
	RootFS     *Schema2RootFS   `json:"rootfs,omitempty"`
	History    []Schema2History `json:"history,omitempty"`
	OSVersion  string           `json:"os.version,omitempty"`
	OSFeatures []string         `json:"os.features,omitempty"`
}

Schema2Image is an Image in docker/docker/image.

type Schema2Port

type Schema2Port string

Schema2Port is a Port, a string containing port number and protocol in the format "80/tcp", from docker/go-connections/nat.

type Schema2PortSet

type Schema2PortSet map[Schema2Port]struct{}

Schema2PortSet is a PortSet, a collection of structs indexed by Port, from docker/go-connections/nat.

type Schema2RootFS

type Schema2RootFS struct {
	Type    string          `json:"type"`
	DiffIDs []digest.Digest `json:"diff_ids,omitempty"`
}

Schema2RootFS is a description of how to build up an image's root filesystem, from docker/docker/image.

type Schema2V1Image

type Schema2V1Image struct {
	// ID is a unique 64 character identifier of the image
	ID string `json:"id,omitempty"`
	// Parent is the ID of the parent image
	Parent string `json:"parent,omitempty"`
	// Comment is the commit message that was set when committing the image
	Comment string `json:"comment,omitempty"`
	// Created is the timestamp at which the image was created
	Created time.Time `json:"created"`
	// Container is the id of the container used to commit
	Container string `json:"container,omitempty"`
	// ContainerConfig is the configuration of the container that is committed into the image
	ContainerConfig Schema2Config `json:"container_config,omitempty"`
	// DockerVersion specifies the version of Docker that was used to build the image
	DockerVersion string `json:"docker_version,omitempty"`
	// Author is the name of the author that was specified when committing the image
	Author string `json:"author,omitempty"`
	// Config is the configuration of the container received from the client
	Config *Schema2Config `json:"config,omitempty"`
	// Architecture is the hardware that the image is build and runs on
	Architecture string `json:"architecture,omitempty"`
	// OS is the operating system used to build and run the image
	OS string `json:"os,omitempty"`
	// Size is the total size of the image including all layers it is composed of
	Size int64 `json:",omitempty"`
}

Schema2V1Image is a V1Image in docker/docker/image.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL