containertools

package
v1.40.0 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: 5 Imported by: 14

Documentation

Index

Constants

View Source
const (
	DefaultBinarySourceImage = "quay.io/operator-framework/opm:latest"
	DefaultDbLocation        = "/database/index.db"
	DbLocationLabel          = "operators.operatorframework.io.index.database.v1"
	ConfigsLocationLabel     = "operators.operatorframework.io.index.configs.v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions

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

func DefaultBuildOptions

func DefaultBuildOptions() BuildOptions

func (*BuildOptions) AddTag

func (o *BuildOptions) AddTag(tag string)

func (*BuildOptions) SetContext

func (o *BuildOptions) SetContext(context string)

func (*BuildOptions) SetDockerfile

func (o *BuildOptions) SetDockerfile(dockerfile string)

func (*BuildOptions) SetFormatDocker

func (o *BuildOptions) SetFormatDocker()

func (*BuildOptions) SetFormatOCI

func (o *BuildOptions) SetFormatOCI()

type CommandFactory

type CommandFactory interface {
	BuildCommand(o BuildOptions) (*exec.Cmd, error)
}

type CommandRunner

type CommandRunner interface {
	GetToolName() string
	Pull(image string) error
	Build(dockerfile, tag string) error
	Inspect(image string) ([]byte, error)
}

CommandRunner defines methods to shell out to common container tools

type ContainerCommandRunner

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

ContainerCommandRunner is configured to select a container cli tool and execute commands with that tooling.

func NewCommandRunner

func NewCommandRunner(containerTool ContainerTool, logger *logrus.Entry, opts ...RunnerOption) *ContainerCommandRunner

NewCommandRunner takes the containerTool as an input string and returns a CommandRunner to run commands with that cli tool

func (*ContainerCommandRunner) Build

func (r *ContainerCommandRunner) Build(dockerfile, tag string) error

Build takes a dockerfile and a tag and builds a container image

func (*ContainerCommandRunner) GetToolName

func (r *ContainerCommandRunner) GetToolName() string

GetToolName returns the container tool this command runner is using

func (*ContainerCommandRunner) Inspect

func (r *ContainerCommandRunner) Inspect(image string) ([]byte, error)

Inspect runs the 'inspect' command to get image metadata of a local container image and returns a byte array of the command's output

func (*ContainerCommandRunner) Pull

func (r *ContainerCommandRunner) Pull(image string) error

Pull takes a container image path hosted on a container registry and runs the pull command to download it onto the local environment

func (*ContainerCommandRunner) Unpack

func (r *ContainerCommandRunner) Unpack(image, src, dst string) error

Unpack copies a directory from a local container image to a directory in the local filesystem.

type ContainerTool

type ContainerTool int
const (
	NoneTool ContainerTool = iota
	PodmanTool
	DockerTool
)

func NewCommandContainerTool

func NewCommandContainerTool(s string) (t ContainerTool)

NewCommandContainerTool returns a tool that can be used in `exec` statements.

func NewContainerTool

func NewContainerTool(s string, defaultTool ContainerTool) (t ContainerTool)

func (ContainerTool) CommandFactory

func (t ContainerTool) CommandFactory() CommandFactory

func (ContainerTool) String

func (t ContainerTool) String() (s string)

type DockerCommandFactory

type DockerCommandFactory struct{}

func (*DockerCommandFactory) BuildCommand

func (d *DockerCommandFactory) BuildCommand(o BuildOptions) (*exec.Cmd, error)

type DockerConfig

type DockerConfig struct {
	Labels map[string]string `json:"Labels"`
}

type DockerImageData

type DockerImageData struct {
	Config DockerConfig `json:"Config"`
}

type DockerfileGenerator

type DockerfileGenerator interface {
	GenerateIndexDockerfile(string, string) string
}

DockerfileGenerator defines functions to generate index dockerfiles

func NewDockerfileGenerator

func NewDockerfileGenerator(logger *logrus.Entry) DockerfileGenerator

NewDockerfileGenerator is a constructor that returns a DockerfileGenerator

type GetImageDataOption

type GetImageDataOption func(*GetImageDataOptions)

func WithWorkingDir

func WithWorkingDir(workingDir string) GetImageDataOption

type GetImageDataOptions

type GetImageDataOptions struct {
	WorkingDir string
}

type ImageLabelReader

type ImageLabelReader struct {
	Logger *logrus.Entry
	Cmd    CommandRunner
}

func (ImageLabelReader) GetLabelsFromImage

func (r ImageLabelReader) GetLabelsFromImage(image string) (map[string]string, error)

GetLabelsFromImage takes a container image path as input, pulls that image to the local environment and then inspects it for labels

type IndexDockerfileGenerator

type IndexDockerfileGenerator struct {
	Logger *logrus.Entry
}

IndexDockerfileGenerator struct implementation of DockerfileGenerator interface

func (*IndexDockerfileGenerator) GenerateIndexDockerfile

func (g *IndexDockerfileGenerator) GenerateIndexDockerfile(binarySourceImage, databasePath string) string

GenerateIndexDockerfile builds a string representation of a dockerfile to use when building an operator-registry index image

type LabelReader

type LabelReader interface {
	GetLabelsFromImage(string) (map[string]string, error)
}

func NewLabelReader

func NewLabelReader(containerTool ContainerTool, logger *logrus.Entry) LabelReader

type PodmanCommandFactory

type PodmanCommandFactory struct{}

func (*PodmanCommandFactory) BuildCommand

func (p *PodmanCommandFactory) BuildCommand(o BuildOptions) (*exec.Cmd, error)

type PodmanImageData

type PodmanImageData struct {
	Labels map[string]string `json:"Labels"`
}

type RunnerConfig

type RunnerConfig struct {
	SkipTLS bool
}

type RunnerOption

type RunnerOption func(config *RunnerConfig)

func SkipTLS

func SkipTLS(skip bool) RunnerOption

type StubCommandFactory

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

func (*StubCommandFactory) BuildCommand

func (s *StubCommandFactory) BuildCommand(o BuildOptions) (*exec.Cmd, error)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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