containertools

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: Apache-2.0 Imports: 10 Imported by: 13

Documentation

Index

Constants

View Source
const (
	DefaultDbLocation = "/database/index.db"
	DbLocationLabel   = "operators.operatorframework.io.index.database.v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

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

CommandRunner defines methods to shell out to common container tools

func NewCommandRunner

func NewCommandRunner(containerTool ContainerTool, logger *logrus.Entry) CommandRunner

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

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 (*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) Save added in v1.5.4

func (r *ContainerCommandRunner) Save(image, tarFile string) error

Save takes a local container image and runs the save commmand to convert the image into a specified tarball and push it to the local directory

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) String

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

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 ImageLayerReader added in v1.5.4

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

func (ImageLayerReader) GetImageData added in v1.5.4

func (b ImageLayerReader) GetImageData(image, outputDir string, opts ...GetImageDataOption) error

type ImageReader added in v1.5.4

type ImageReader interface {
	GetImageData(string, string, ...GetImageDataOption) error
}

func NewImageReader added in v1.5.4

func NewImageReader(containerTool ContainerTool, logger *logrus.Entry) ImageReader

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 PodmanImageData

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

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