backend

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerdClient

type ContainerdClient interface {
	GetClient() *containerd.Client
	GetContainerStatus(ctx context.Context, c containerd.Container) containerd.ProcessStatus
	SearchContainer(ctx context.Context, searchText string) (containers []containerd.Container, err error)
	GetImage(ctx context.Context, ref string) (containerd.Image, error)
	SearchImage(ctx context.Context, searchText string) ([]images.Image, error)
	ParsePlatform(platform string) (ocispec.Platform, error)
	DefaultPlatformSpec() ocispec.Platform
	DefaultPlatformStrict() platforms.MatchComparer
	ParseDockerRef(rawRef string) (ref, refDomain string, err error)
	DefaultDockerHost(refDomain string) (string, error)
	GetContainerTaskWait(ctx context.Context, attach cio.Attach, c containerd.Container) (task containerd.Task, waitCh <-chan containerd.ExitStatus, err error)
	GetContainerRemoveEvent(ctx context.Context, c containerd.Container) (<-chan *events.Envelope, <-chan error)
	ListSnapshotMounts(ctx context.Context, cid string) ([]mount.Mount, error)
	MountAll(mounts []mount.Mount, mPath string) error
	Unmount(mPath string, flags int) error
	ImageService() images.Store
	ConvertImage(ctx context.Context, dstRef, srcRef string, opts ...converter.Opt) (*images.Image, error)
	DeleteImage(ctx context.Context, img string) error
	GetImageDigests(ctx context.Context, img *images.Image) (digests []digest.Digest, err error)
	GetUsedImages(ctx context.Context) (stopped, running map[string]string, err error)
	OCISpecWithUser(user string) oci.SpecOpts
	OCISpecWithAdditionalGIDs(user string) oci.SpecOpts
	GetCurrentCapabilities() ([]string, error)
	NewFIFOSetInDir(root, id string, terminal bool) (*cio.FIFOSet, error)
	NewDirectCIO(ctx context.Context, fifos *cio.FIFOSet) (*cio.DirectIO, error)
	SubscribeToEvents(ctx context.Context, filters ...string) (<-chan *events.Envelope, <-chan error)
	PublishEvent(ctx context.Context, topic string, event events.Event) error
}

type ContainerdClientWrapper

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

func NewContainerdClientWrapper

func NewContainerdClientWrapper(client *containerd.Client) *ContainerdClientWrapper

NewContainerdClientWrapper creates a new instance of ContainerdClientWrapper.

func (*ContainerdClientWrapper) ConvertImage

func (w *ContainerdClientWrapper) ConvertImage(ctx context.Context, dstRef, srcRef string, opts ...converter.Opt) (*images.Image, error)

func (*ContainerdClientWrapper) DefaultDockerHost

func (w *ContainerdClientWrapper) DefaultDockerHost(refDomain string) (string, error)

DefaultDockerHost converts "docker.io" to "registry-1.docker.io".

func (*ContainerdClientWrapper) DefaultPlatformSpec

func (w *ContainerdClientWrapper) DefaultPlatformSpec() ocispec.Platform

DefaultPlatformSpec returns the current platform's default platform specification.

func (*ContainerdClientWrapper) DefaultPlatformStrict

func (w *ContainerdClientWrapper) DefaultPlatformStrict() platforms.MatchComparer

DefaultPlatformStrict returns the strict form of current platform's default platform specification.

func (*ContainerdClientWrapper) DeleteImage

func (w *ContainerdClientWrapper) DeleteImage(ctx context.Context, img string) error

DeleteImage deletes an image.

func (*ContainerdClientWrapper) GetClient

func (w *ContainerdClientWrapper) GetClient() *containerd.Client

func (*ContainerdClientWrapper) GetContainerRemoveEvent

func (w *ContainerdClientWrapper) GetContainerRemoveEvent(ctx context.Context, c containerd.Container) (<-chan *events.Envelope, <-chan error)

GetContainerRemoveEvent subscribes to the remove event for the given container and returns its channel.

func (*ContainerdClientWrapper) GetContainerStatus

GetContainerStatus wraps the containerd function to get the status of a container.

func (*ContainerdClientWrapper) GetContainerTaskWait

func (*ContainerdClientWrapper) GetContainerTaskWait(ctx context.Context, attach cio.Attach, c containerd.Container) (task containerd.Task, waitCh <-chan containerd.ExitStatus, err error)

GetContainerTaskWait gets the wait channel for a container in the process of doing a task.

func (*ContainerdClientWrapper) GetCurrentCapabilities

func (*ContainerdClientWrapper) GetCurrentCapabilities() ([]string, error)

func (*ContainerdClientWrapper) GetImage

GetImage returns an image with given reference.

func (*ContainerdClientWrapper) GetImageDigests

func (w *ContainerdClientWrapper) GetImageDigests(ctx context.Context, img *images.Image) (digests []digest.Digest, err error)

GetImageDigests returns the list of digests for a given image.

func (*ContainerdClientWrapper) GetUsedImages

func (w *ContainerdClientWrapper) GetUsedImages(ctx context.Context) (stopped, running map[string]string, err error)

GetUsedImages returns the list of images that are used by containers. `stopped` contains the images used by stopped containers, `running` contains the images used by running containers.

func (*ContainerdClientWrapper) ImageService

func (w *ContainerdClientWrapper) ImageService() images.Store

func (*ContainerdClientWrapper) ListSnapshotMounts

func (w *ContainerdClientWrapper) ListSnapshotMounts(ctx context.Context, key string) ([]mount.Mount, error)

func (*ContainerdClientWrapper) MountAll

func (*ContainerdClientWrapper) MountAll(mounts []mount.Mount, mPath string) error

func (*ContainerdClientWrapper) NewDirectCIO

func (*ContainerdClientWrapper) NewDirectCIO(ctx context.Context, fifos *cio.FIFOSet) (*cio.DirectIO, error)

func (*ContainerdClientWrapper) NewFIFOSetInDir

func (*ContainerdClientWrapper) NewFIFOSetInDir(root, id string, terminal bool) (*cio.FIFOSet, error)

func (*ContainerdClientWrapper) OCISpecWithAdditionalGIDs

func (*ContainerdClientWrapper) OCISpecWithAdditionalGIDs(user string) oci.SpecOpts

func (*ContainerdClientWrapper) OCISpecWithUser

func (*ContainerdClientWrapper) OCISpecWithUser(user string) oci.SpecOpts

func (*ContainerdClientWrapper) ParseDockerRef

func (w *ContainerdClientWrapper) ParseDockerRef(rawRef string) (ref, refDomain string, err error)

ParseDockerRef normalizes the image reference following the docker convention.

func (*ContainerdClientWrapper) ParsePlatform

func (*ContainerdClientWrapper) ParsePlatform(platform string) (ocispec.Platform, error)

ParsePlatform parses a platform text into an ocispec Platform type.

func (*ContainerdClientWrapper) PublishEvent

func (w *ContainerdClientWrapper) PublishEvent(ctx context.Context, topic string, event events.Event) error

func (*ContainerdClientWrapper) SearchContainer

func (w *ContainerdClientWrapper) SearchContainer(ctx context.Context, searchText string) (containers []containerd.Container, err error)

SearchContainer returns the list of containers that match the prefix.

func (*ContainerdClientWrapper) SearchImage

func (w *ContainerdClientWrapper) SearchImage(ctx context.Context, searchText string) ([]images.Image, error)

SearchImage returns a list of images that match the search prefix.

func (*ContainerdClientWrapper) SubscribeToEvents

func (w *ContainerdClientWrapper) SubscribeToEvents(ctx context.Context, filters ...string) (<-chan *events.Envelope, <-chan error)

func (*ContainerdClientWrapper) Unmount

func (*ContainerdClientWrapper) Unmount(mPath string, flags int) error

type NerdctlBuilderSvc

type NerdctlBuilderSvc interface {
	Build(ctx context.Context, client ContainerdClient, options types.BuilderBuildOptions) error
	GetBuildkitHost() (string, error)
}

type NerdctlContainerSvc

type NerdctlContainerSvc interface {
	RemoveContainer(ctx context.Context, c containerd.Container, force bool, removeAnonVolumes bool) error
	StartContainer(ctx context.Context, container containerd.Container) error
	StopContainer(ctx context.Context, container containerd.Container, timeout *time.Duration) error
	CreateContainer(ctx context.Context, args []string, netManager containerutil.NetworkOptionsManager, options types.ContainerCreateOptions) (containerd.Container, func(), error)
	InspectContainer(ctx context.Context, c containerd.Container) (*dockercompat.Container, error)
	InspectNetNS(ctx context.Context, pid int) (*native.NetNS, error)
	NewNetworkingOptionsManager(types.NetworkOptions) (containerutil.NetworkOptionsManager, error)
	ListContainers(ctx context.Context, options types.ContainerListOptions) ([]container.ListItem, error)
	RenameContainer(ctx context.Context, container containerd.Container, newName string, options types.ContainerRenameOptions) error

	// Mocked functions for container attach
	GetDataStore() (string, error)
	LoggingInitContainerLogViewer(containerLabels map[string]string, lvopts logging.LogViewOptions, stopChannel chan os.Signal, experimental bool) (contlv *logging.ContainerLogViewer, err error)
	LoggingPrintLogsTo(stdout, stderr io.Writer, clv *logging.ContainerLogViewer) error

	// GetNerdctlExe returns a path to the nerdctl binary, which is required for setting up OCI hooks and logging
	GetNerdctlExe() (string, error)
}

type NerdctlImageSvc

type NerdctlImageSvc interface {
	InspectImage(ctx context.Context, image images.Image) (*dockercompat.Image, error)
	GetDockerResolver(ctx context.Context, refDomain string, creds dockerconfigresolver.AuthCreds) (remotes.Resolver, docker.StatusTracker, error)
	PullImage(ctx context.Context, stdout, stderr io.Writer, resolver remotes.Resolver, ref string, platforms []ocispec.Platform) (*imgutil.EnsuredImage, error)
	PushImage(ctx context.Context, resolver remotes.Resolver, tracker docker.StatusTracker, stdout io.Writer, pushRef, ref string, platMC platforms.MatchComparer) error
	SearchImage(ctx context.Context, name string) (int, int, []*images.Image, error)
	LoadImage(ctx context.Context, img string, stdout io.Writer, quiet bool) error
	GetDataStore() (string, error)
}

type NerdctlNetworkSvc

type NerdctlNetworkSvc interface {
	FilterNetworks(filterf func(networkConfig *netutil.NetworkConfig) bool) ([]*netutil.NetworkConfig, error)
	AddNetworkList(ctx context.Context, netconflist *libcni.NetworkConfigList, conf *libcni.RuntimeConf) (cnitypes.Result, error)
	CreateNetwork(opts netutil.CreateOptions) (*netutil.NetworkConfig, error)
	RemoveNetwork(networkConfig *netutil.NetworkConfig) error
	InspectNetwork(ctx context.Context, networkConfig *netutil.NetworkConfig) (*dockercompat.Network, error)
	UsedNetworkInfo(ctx context.Context) (map[string][]string, error)
	NetconfPath() string
}

type NerdctlSystemSvc

type NerdctlSystemSvc interface {
	GetServerVersion(ctx context.Context) (*dockercompat.ServerVersion, error)
}

type NerdctlVolumeSvc

type NerdctlVolumeSvc interface {
	ListVolumes(size bool, filters []string) (map[string]native.Volume, error)
	RemoveVolume(ctx context.Context, name string, force bool, stdout io.Writer) error
	GetVolume(name string) (*native.Volume, error)
	CreateVolume(name string, labels []string) (*native.Volume, error)
}

type NerdctlWrapper

type NerdctlWrapper struct {
	CNI *libcni.CNIConfig
	// contains filtered or unexported fields
}

func NewNerdctlWrapper

func NewNerdctlWrapper(clientWrapper *ContainerdClientWrapper, options *types.GlobalCommandOptions) *NerdctlWrapper

func (*NerdctlWrapper) AddNetworkList

func (w *NerdctlWrapper) AddNetworkList(ctx context.Context, netconflist *libcni.NetworkConfigList, conf *libcni.RuntimeConf) (cnitypes.Result, error)

func (*NerdctlWrapper) Build

func (*NerdctlWrapper) CreateContainer

func (w *NerdctlWrapper) CreateContainer(ctx context.Context, args []string, netManager containerutil.NetworkOptionsManager, options types.ContainerCreateOptions) (containerd.Container, func(), error)

func (*NerdctlWrapper) CreateNetwork

func (w *NerdctlWrapper) CreateNetwork(opts netutil.CreateOptions) (*netutil.NetworkConfig, error)

func (*NerdctlWrapper) CreateVolume

func (w *NerdctlWrapper) CreateVolume(name string, labels []string) (*native.Volume, error)

func (*NerdctlWrapper) FilterNetworks

func (w *NerdctlWrapper) FilterNetworks(filterf func(networkConfig *netutil.NetworkConfig) bool) ([]*netutil.NetworkConfig, error)

func (*NerdctlWrapper) GetBuildkitHost

func (w *NerdctlWrapper) GetBuildkitHost() (string, error)

func (*NerdctlWrapper) GetDataStore

func (w *NerdctlWrapper) GetDataStore() (string, error)

func (*NerdctlWrapper) GetDockerResolver

GetDockerResolver returns a new Docker config resolver from the reference host and auth credentials.

func (*NerdctlWrapper) GetNerdctlExe

func (w *NerdctlWrapper) GetNerdctlExe() (string, error)

func (*NerdctlWrapper) GetServerVersion

func (w *NerdctlWrapper) GetServerVersion(ctx context.Context) (*dockercompat.ServerVersion, error)

func (*NerdctlWrapper) GetVolume

func (w *NerdctlWrapper) GetVolume(name string) (*native.Volume, error)

GetVolume wrapper function to call nerdctl function to get the details of a volume.

func (*NerdctlWrapper) InspectContainer

func (*NerdctlWrapper) InspectImage

func (w *NerdctlWrapper) InspectImage(ctx context.Context, image images.Image) (*dockercompat.Image, error)

func (*NerdctlWrapper) InspectNetNS

func (w *NerdctlWrapper) InspectNetNS(ctx context.Context, pid int) (*native.NetNS, error)

func (*NerdctlWrapper) InspectNetwork

func (w *NerdctlWrapper) InspectNetwork(ctx context.Context, networkConfig *netutil.NetworkConfig) (*dockercompat.Network, error)

func (*NerdctlWrapper) ListContainers

func (w *NerdctlWrapper) ListContainers(ctx context.Context, options types.ContainerListOptions) ([]container.ListItem, error)

func (*NerdctlWrapper) ListVolumes

func (w *NerdctlWrapper) ListVolumes(size bool, filters []string) (map[string]native.Volume, error)

func (*NerdctlWrapper) LoadImage

func (w *NerdctlWrapper) LoadImage(ctx context.Context, img string, stdout io.Writer, _ bool) error

func (*NerdctlWrapper) LoggingInitContainerLogViewer

func (*NerdctlWrapper) LoggingInitContainerLogViewer(containerLabels map[string]string, lvopts logging.LogViewOptions, stopChannel chan os.Signal, experimental bool) (contlv *logging.ContainerLogViewer, err error)

func (*NerdctlWrapper) LoggingPrintLogsTo

func (*NerdctlWrapper) LoggingPrintLogsTo(stdout, stderr io.Writer, clv *logging.ContainerLogViewer) error

func (*NerdctlWrapper) NetconfPath

func (w *NerdctlWrapper) NetconfPath() string

func (*NerdctlWrapper) NewNetworkingOptionsManager

func (w *NerdctlWrapper) NewNetworkingOptionsManager(options types.NetworkOptions) (containerutil.NetworkOptionsManager, error)

func (*NerdctlWrapper) PullImage

func (w *NerdctlWrapper) PullImage(ctx context.Context, stdout, stderr io.Writer, resolver remotes.Resolver, ref string, platforms []ocispec.Platform) (*imgutil.EnsuredImage, error)

PullImage pulls an image from nerdctl's imgutil library.

func (*NerdctlWrapper) PushImage

func (w *NerdctlWrapper) PushImage(ctx context.Context, resolver remotes.Resolver, tracker docker.StatusTracker, stdout io.Writer, pushRef, ref string, platMC platforms.MatchComparer) error

PushImage pushes an image using nerdctl's imgutil library.

func (*NerdctlWrapper) RemoveContainer

func (w *NerdctlWrapper) RemoveContainer(ctx context.Context, c containerd.Container, force bool, removeVolumes bool) error

func (*NerdctlWrapper) RemoveNetwork

func (w *NerdctlWrapper) RemoveNetwork(networkConfig *netutil.NetworkConfig) error

func (*NerdctlWrapper) RemoveVolume

func (w *NerdctlWrapper) RemoveVolume(ctx context.Context, name string, force bool, stdout io.Writer) error

RemoveVolume wrapper function to call nerdctl function to remove a volume.

func (*NerdctlWrapper) RenameContainer

func (w *NerdctlWrapper) RenameContainer(ctx context.Context, con containerd.Container, newName string, options types.ContainerRenameOptions) error

func (*NerdctlWrapper) SearchImage

func (w *NerdctlWrapper) SearchImage(ctx context.Context, name string) (int, int, []*images.Image, error)

func (*NerdctlWrapper) StartContainer

func (w *NerdctlWrapper) StartContainer(ctx context.Context, container containerd.Container) error

StartContainer wrapper function to call nerdctl function to start a container.

func (*NerdctlWrapper) StopContainer

func (*NerdctlWrapper) StopContainer(ctx context.Context, container containerd.Container, timeout *time.Duration) error

StopContainer wrapper function to call nerdctl function to stop a container.

func (*NerdctlWrapper) UsedNetworkInfo

func (w *NerdctlWrapper) UsedNetworkInfo(ctx context.Context) (map[string][]string, error)

Jump to

Keyboard shortcuts

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