generate

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

umoci/oci/config/generate

This intends to be a library like runtime-tools/generate which allows you to generate modifications to an OCI image configuration blob (of type application/vnd.oci.image.config.v1+json). It's a bit of a shame that this is necessary, but it shouldn't be that bad to implement

The hope is that this library (or some form of it) will become an upstream library so I don't have to maintain this for any extended period of time.

Documentation

Index

Constants

View Source
const ISO8601 = time.RFC3339Nano

ISO8601 represents the format of an ISO-8601 time string, which is identical to Go's RFC3339 specification.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator allows you to generate a mutable OCI image-spec configuration which can be written to a file (and its digest computed). It is the recommended way of handling modification and generation of image-spec configuration blobs.

func New

func New() *Generator

New creates a new Generator with the initial template set to a default. It is not recommended to leave any of the options as their default values (they may change in the future without warning and may be invalid images).

func NewFromImage

func NewFromImage(image ispec.Image) (*Generator, error)

NewFromImage generates a new generator with the initial template being the given ispec.Image.

func (*Generator) AddConfigEnv

func (g *Generator) AddConfigEnv(name, value string)

AddConfigEnv appends to the list of environment variables to be used in a container.

func (*Generator) AddConfigExposedPort

func (g *Generator) AddConfigExposedPort(port string)

AddConfigExposedPort adds a port the set of ports to expose from a container running this image.

func (*Generator) AddConfigLabel

func (g *Generator) AddConfigLabel(label, value string)

AddConfigLabel adds a label to the set of arbitrary metadata for the container.

func (*Generator) AddConfigVolume

func (g *Generator) AddConfigVolume(volume string)

AddConfigVolume adds a volume to the set of directories which should be created as data volumes in a container running this image.

func (*Generator) AddHistory

func (g *Generator) AddHistory(history ispec.History)

AddHistory appends to the history of the layers.

func (*Generator) AddRootfsDiffID

func (g *Generator) AddRootfsDiffID(diffid digest.Digest)

AddRootfsDiffID appends to the array of layer content hashes (DiffIDs), in order from bottom-most to top-most.

func (*Generator) Architecture

func (g *Generator) Architecture() string

Architecture returns the CPU architecture which the binaries in this image are built to run on.

func (*Generator) Author

func (g *Generator) Author() string

Author returns the name and/or email address of the person or entity which created and is responsible for maintaining the image.

func (*Generator) ClearConfigCmd added in v0.3.0

func (g *Generator) ClearConfigCmd()

ClearConfigCmd clears the list of default arguments to the entrypoint of the container.

func (*Generator) ClearConfigEntrypoint added in v0.3.0

func (g *Generator) ClearConfigEntrypoint()

ClearConfigEntrypoint clears the list of arguments to use as the command to execute when the container starts.

func (*Generator) ClearConfigEnv

func (g *Generator) ClearConfigEnv()

ClearConfigEnv clears the list of environment variables to be used in a container.

func (*Generator) ClearConfigExposedPorts

func (g *Generator) ClearConfigExposedPorts()

ClearConfigExposedPorts clears the set of ports to expose from a container running this image.

func (*Generator) ClearConfigLabels

func (g *Generator) ClearConfigLabels()

ClearConfigLabels clears the set of arbitrary metadata for the container.

func (*Generator) ClearConfigVolumes

func (g *Generator) ClearConfigVolumes()

ClearConfigVolumes clears the set of directories which should be created as data volumes in a container running this image.

func (*Generator) ClearHistory

func (g *Generator) ClearHistory()

ClearHistory clears the history of each layer.

func (*Generator) ClearRootfsDiffIDs

func (g *Generator) ClearRootfsDiffIDs()

ClearRootfsDiffIDs clears the array of layer content hashes (DiffIDs), in order from bottom-most to top-most.

func (*Generator) ConfigCmd

func (g *Generator) ConfigCmd() []string

ConfigCmd returns the list of default arguments to the entrypoint of the container.

func (*Generator) ConfigEntrypoint

func (g *Generator) ConfigEntrypoint() []string

ConfigEntrypoint returns the list of arguments to use as the command to execute when the container starts.

func (*Generator) ConfigEnv

func (g *Generator) ConfigEnv() []string

ConfigEnv returns the list of environment variables to be used in a container.

func (*Generator) ConfigExposedPorts

func (g *Generator) ConfigExposedPorts() map[string]struct{}

ConfigExposedPorts returns the set of ports to expose from a container running this image.

func (*Generator) ConfigExposedPortsArray added in v0.3.0

func (g *Generator) ConfigExposedPortsArray() []string

ConfigExposedPortsArray returns a sorted array of ports to expose from a container running this image.

func (*Generator) ConfigLabels

func (g *Generator) ConfigLabels() map[string]string

ConfigLabels returns the set of arbitrary metadata for the container.

func (*Generator) ConfigStopSignal added in v0.3.0

func (g *Generator) ConfigStopSignal() string

ConfigStopSignal returns the system call signal that will be sent to the container to exit.

func (*Generator) ConfigUser

func (g *Generator) ConfigUser() string

ConfigUser returns the username or UID which the process in the container should run as.

func (*Generator) ConfigVolumes

func (g *Generator) ConfigVolumes() map[string]struct{}

ConfigVolumes returns the set of directories which should be created as data volumes in a container running this image.

func (*Generator) ConfigWorkingDir

func (g *Generator) ConfigWorkingDir() string

ConfigWorkingDir returns the current working directory of the entrypoint process in the container.

func (*Generator) Created

func (g *Generator) Created() time.Time

Created gets the combined date and time at which the image was created.

func (*Generator) History

func (g *Generator) History() []ispec.History

History returns the history of each layer.

func (*Generator) Image

func (g *Generator) Image() ispec.Image

Image returns a copy of the current state of the generated image.

func (*Generator) OS

func (g *Generator) OS() string

OS returns the name of the operating system which the image is built to run on.

func (*Generator) RemoveConfigExposedPort

func (g *Generator) RemoveConfigExposedPort(port string)

RemoveConfigExposedPort removes a port the set of ports to expose from a container running this image.

func (*Generator) RemoveConfigLabel

func (g *Generator) RemoveConfigLabel(label string)

RemoveConfigLabel removes a label from the set of arbitrary metadata for the container.

func (*Generator) RemoveConfigVolume

func (g *Generator) RemoveConfigVolume(volume string)

RemoveConfigVolume removes a volume from the set of directories which should be created as data volumes in a container running this image.

func (*Generator) RootfsDiffIDs

func (g *Generator) RootfsDiffIDs() []digest.Digest

RootfsDiffIDs returns the the array of layer content hashes (DiffIDs), in order from bottom-most to top-most.

func (*Generator) RootfsType

func (g *Generator) RootfsType() string

RootfsType returns the type of the rootfs.

func (*Generator) SetArchitecture

func (g *Generator) SetArchitecture(arch string)

SetArchitecture is the CPU architecture which the binaries in this image are built to run on.

func (*Generator) SetAuthor

func (g *Generator) SetAuthor(author string)

SetAuthor sets the name and/or email address of the person or entity which created and is responsible for maintaining the image.

func (*Generator) SetConfigCmd

func (g *Generator) SetConfigCmd(cmd []string)

SetConfigCmd sets the list of default arguments to the entrypoint of the container.

func (*Generator) SetConfigEntrypoint

func (g *Generator) SetConfigEntrypoint(entrypoint []string)

SetConfigEntrypoint sets the list of arguments to use as the command to execute when the container starts.

func (*Generator) SetConfigStopSignal added in v0.3.0

func (g *Generator) SetConfigStopSignal(stopSignal string)

SetConfigStopSignal sets the system call signal that will be sent to the container to exit.

func (*Generator) SetConfigUser

func (g *Generator) SetConfigUser(user string)

SetConfigUser sets the username or UID which the process in the container should run as.

func (*Generator) SetConfigWorkingDir

func (g *Generator) SetConfigWorkingDir(workingDir string)

SetConfigWorkingDir sets the current working directory of the entrypoint process in the container.

func (*Generator) SetCreated

func (g *Generator) SetCreated(created time.Time)

SetCreated sets the combined date and time at which the image was created.

func (*Generator) SetOS

func (g *Generator) SetOS(os string)

SetOS sets the name of the operating system which the image is built to run on.

func (*Generator) SetRootfsType

func (g *Generator) SetRootfsType(rootfsType string)

SetRootfsType sets the type of the rootfs.

func (*Generator) WriteTo

func (g *Generator) WriteTo(w io.Writer) (n int64, err error)

WriteTo outputs a JSON-marshalled version of the current state of the generator. It is not guaranteed that the generator will produce the same output given the same state, so it's recommended to only call this function once. The JSON is not pretty-printed.

Jump to

Keyboard shortcuts

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