moby

package
v0.0.0-...-8afecd5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 37 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// PaxRecordLinuxkitSource report the package source for a specific file
	PaxRecordLinuxkitSource = "LINUXKIT.source"
	// PaxRecordLinuxkitLocation report the location of the file in the linuxkit.yaml
	// that led to this file being in this location
	PaxRecordLinuxkitLocation = "LINUXKIT.location"
)

Variables

View Source
var (
	// MobyDir is the location of the cache directory, defaults to ~/.moby
	MobyDir = defaultMobyConfigDir()
)

Functions

func Build

func Build(m Moby, w io.Writer, opts BuildOpts) error

Build performs the actual build process. The output is the filesystem in a tar stream written to w.

func Formats

func Formats(base string, image string, formats []string, size int, arch, cache string) error

Formats generates all the specified output formats

func ImageBundle

func ImageBundle(prefix, location string, ref *reference.Spec, config []byte, runtime Runtime, tw tarWriter, readonly bool, dupMap map[string]string, opts BuildOpts) error

ImageBundle produces an OCI bundle at the given path in a tarball, given an image and a config.json

func ImageTar

func ImageTar(location string, ref *reference.Spec, prefix string, tw tarWriter, resolv string, opts BuildOpts) (e error)

ImageTar takes a Docker image and outputs it to a tar stream location is where it is in the linuxkit.yaml file

func OutputTypes

func OutputTypes() []string

OutputTypes returns a list of the valid output types

func Streamable

func Streamable(t string) bool

Streamable returns true if an output can be streamed

func ValidateFormats

func ValidateFormats(formats []string, cache string) error

ValidateFormats checks if the format type is known

Types

type BuildOpts

type BuildOpts struct {
	Pull             bool
	BuilderType      string
	DecompressKernel bool
	CacheDir         string
	DockerCache      bool
	Arch             string
	SbomGenerator    *SbomGenerator
	InputTar         string
}

BuildOpts options that control the linuxkit build process

type Device

type Device struct {
	Path  string `yaml:"path" json:"path"`
	Type  string `yaml:"type" json:"type"`
	Major int64  `yaml:"major" json:"major"`
	Minor int64  `yaml:"minor" json:"minor"`
	Mode  string `yaml:"mode,omitempty" json:"mode,omitempty"`
}

Device specifies a device to be exposed to the container.

type File

type File struct {
	Path      string      `yaml:"path" json:"path"`
	Directory bool        `yaml:"directory" json:"directory"`
	Symlink   string      `yaml:"symlink,omitempty" json:"symlink,omitempty"`
	Contents  *string     `yaml:"contents,omitempty" json:"contents,omitempty"`
	Source    string      `yaml:"source,omitempty" json:"source,omitempty"`
	Metadata  string      `yaml:"metadata,omitempty" json:"metadata,omitempty"`
	Optional  bool        `yaml:"optional" json:"optional"`
	Mode      string      `yaml:"mode,omitempty" json:"mode,omitempty"`
	UID       interface{} `yaml:"uid,omitempty" json:"uid,omitempty"`
	GID       interface{} `yaml:"gid,omitempty" json:"gid,omitempty"`
}

File is the type of a file specification

type Image

type Image struct {
	Name        string `yaml:"name" json:"name"`
	Image       string `yaml:"image" json:"image"`
	ImageConfig `yaml:",inline"`
}

Image is the type of an image config

func NewImage

func NewImage(config []byte) (Image, error)

NewImage validates an parses yaml or json for a Image

func (*Image) Equal

func (i *Image) Equal(o *Image) bool

Equal check if another Image is functionally equal to this one. Takes the easy path by marshaling both into yaml and then comparing the yaml. There may be a more efficient way to do this, but this is simplest.

type ImageConfig

type ImageConfig struct {
	Capabilities      *[]string               `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`
	CapabilitiesAdd   *[]string               `yaml:"capabilities.add,omitempty" json:"capabilities.add,omitempty"`
	Ambient           *[]string               `yaml:"ambient,omitempty" json:"ambient,omitempty"`
	Mounts            *[]specs.Mount          `yaml:"mounts,omitempty" json:"mounts,omitempty"`
	Binds             *[]string               `yaml:"binds,omitempty" json:"binds,omitempty"`
	BindsAdd          *[]string               `yaml:"binds.add,omitempty" json:"binds.add,omitempty"`
	Devices           *[]Device               `yaml:"devices,omitempty" json:"devices,omitempty"`
	Tmpfs             *[]string               `yaml:"tmpfs,omitempty" json:"tmpfs,omitempty"`
	Command           *[]string               `yaml:"command,omitempty" json:"command,omitempty"`
	Env               *[]string               `yaml:"env,omitempty" json:"env,omitempty"`
	Cwd               string                  `yaml:"cwd,omitempty" json:"cwd,omitempty"`
	Net               string                  `yaml:"net,omitempty" json:"net,omitempty"`
	Pid               string                  `yaml:"pid,omitempty" json:"pid,omitempty"`
	Ipc               string                  `yaml:"ipc,omitempty" json:"ipc,omitempty"`
	Uts               string                  `yaml:"uts,omitempty" json:"uts,omitempty"`
	Userns            string                  `yaml:"userns,omitempty" json:"userns,omitempty"`
	Hostname          string                  `yaml:"hostname,omitempty" json:"hostname,omitempty"`
	Readonly          *bool                   `yaml:"readonly,omitempty" json:"readonly,omitempty"`
	MaskedPaths       *[]string               `yaml:"maskedPaths,omitempty" json:"maskedPaths,omitempty"`
	ReadonlyPaths     *[]string               `yaml:"readonlyPaths,omitempty" json:"readonlyPaths,omitempty"`
	UID               *interface{}            `yaml:"uid,omitempty" json:"uid,omitempty"`
	GID               *interface{}            `yaml:"gid,omitempty" json:"gid,omitempty"`
	AdditionalGids    *[]interface{}          `yaml:"additionalGids,omitempty" json:"additionalGids,omitempty"`
	NoNewPrivileges   *bool                   `yaml:"noNewPrivileges,omitempty" json:"noNewPrivileges,omitempty"`
	OOMScoreAdj       *int                    `yaml:"oomScoreAdj,omitempty" json:"oomScoreAdj,omitempty"`
	RootfsPropagation *string                 `yaml:"rootfsPropagation,omitempty" json:"rootfsPropagation,omitempty"`
	CgroupsPath       *string                 `yaml:"cgroupsPath,omitempty" json:"cgroupsPath,omitempty"`
	Resources         *specs.LinuxResources   `yaml:"resources,omitempty" json:"resources,omitempty"`
	Sysctl            *map[string]string      `yaml:"sysctl,omitempty" json:"sysctl,omitempty"`
	Rlimits           *[]string               `yaml:"rlimits,omitempty" json:"rlimits,omitempty"`
	UIDMappings       *[]specs.LinuxIDMapping `yaml:"uidMappings,omitempty" json:"uidMappings,omitempty"`
	GIDMappings       *[]specs.LinuxIDMapping `yaml:"gidMappings,omitempty" json:"gidMappings,omitempty"`
	Annotations       *map[string]string      `yaml:"annotations,omitempty" json:"annotations,omitempty"`

	Runtime *Runtime `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	// contains filtered or unexported fields
}

ImageConfig is the configuration part of Image, it is the subset which is valid in a "org.mobyproject.config" label on an image. Everything except Runtime and ref is used to build the OCI spec

type Interface

type Interface struct {
	Name         string `yaml:"name,omitempty" json:"name,omitempty"`
	Add          string `yaml:"add,omitempty" json:"add,omitempty"`
	Peer         string `yaml:"peer,omitempty" json:"peer,omitempty"`
	CreateInRoot bool   `yaml:"createInRoot" json:"createInRoot"`
}

Interface is the runtime config for network interfaces

type KernelConfig

type KernelConfig struct {
	Image   string  `yaml:"image" json:"image"`
	Cmdline string  `yaml:"cmdline,omitempty" json:"cmdline,omitempty"`
	Binary  string  `yaml:"binary,omitempty" json:"binary,omitempty"`
	Tar     *string `yaml:"tar,omitempty" json:"tar,omitempty"`
	UCode   *string `yaml:"ucode,omitempty" json:"ucode,omitempty"`
	// contains filtered or unexported fields
}

KernelConfig is the type of the config for a kernel

type Moby

type Moby struct {
	Kernel     KernelConfig `kernel:"cmdline,omitempty" json:"kernel,omitempty"`
	Init       []string     `init:"cmdline" json:"init"`
	Onboot     []*Image     `yaml:"onboot" json:"onboot"`
	Onshutdown []*Image     `yaml:"onshutdown" json:"onshutdown"`
	Services   []*Image     `yaml:"services" json:"services"`
	Files      []File       `yaml:"files" json:"files"`
	// contains filtered or unexported fields
}

Moby is the type of a Moby config file

func AppendConfig

func AppendConfig(m0, m1 Moby) (Moby, error)

AppendConfig appends two configs.

func NewConfig

func NewConfig(config []byte, packageFinder spec.PackageResolver) (Moby, error)

NewConfig parses a config file

type Namespaces

type Namespaces struct {
	Cgroup *string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	Ipc    *string `yaml:"ipc,omitempty" json:"ipc,omitempty"`
	Mnt    *string `yaml:"mnt,omitempty" json:"mnt,omitempty"`
	Net    *string `yaml:"net,omitempty" json:"net,omitempty"`
	Pid    *string `yaml:"pid,omitempty" json:"pid,omitempty"`
	User   *string `yaml:"user,omitempty" json:"user,omitempty"`
	Uts    *string `yaml:"uts,omitempty" json:"uts,omitempty"`
}

Namespaces is the type for configuring paths to bind namespaces

type Runtime

type Runtime struct {
	Cgroups    *[]string      `yaml:"cgroups,omitempty" json:"cgroups,omitempty"`
	Mounts     *[]specs.Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
	Mkdir      *[]string      `yaml:"mkdir,omitempty" json:"mkdir,omitempty"`
	Interfaces *[]Interface   `yaml:"interfaces,omitempty,omitempty" json:"interfaces,omitempty"`
	BindNS     Namespaces     `yaml:"bindNS,omitempty" json:"bindNS,omitempty"`
	Namespace  *string        `yaml:"namespace,omitempty" json:"namespace,omitempty"`
}

Runtime is the type of config processed at runtime, not used to build the OCI spec

func ConfigToOCI

func ConfigToOCI(yaml *Image, config imagespec.ImageConfig, idMap map[string]uint32) (specs.Spec, Runtime, error)

ConfigToOCI converts a config and the output of image inspect to an OCI config

type SbomGenerator

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

SbomGenerator handler for generating sbom

func NewSbomGenerator

func NewSbomGenerator(filename string, currentBuildTime bool) (*SbomGenerator, error)

func (*SbomGenerator) Add

func (s *SbomGenerator) Add(prefix string, sbom io.ReadCloser) error

func (*SbomGenerator) Close

func (s *SbomGenerator) Close(tw *tar.Writer) error

Close finalize generation of the sbom, including merging any together and writing the output file to a tar stream, and cleaning up any temporary files.

Jump to

Keyboard shortcuts

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