statesolver

package
v0.0.0-...-25f2897 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FileNotFound = xerrors.New("file not found")
)

Functions

func LockContext

func LockContext(ctx context.Context, solver StateSolver, c *builddef.Context) (*builddef.Context, error)

func ResolveImageOS

func ResolveImageOS(
	ctx context.Context,
	solver StateSolver,
	imageRef string,
) (builddef.OSRelease, error)

ResolveImageOS reads /etc/os-release from a given image and parse it.

Types

type BuildkitSolver

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

func NewBuildkitSolver

func NewBuildkitSolver(c client.Client) BuildkitSolver

func (BuildkitSolver) ExecImage

func (s BuildkitSolver) ExecImage(
	ctx context.Context,
	imageRef string,
	cmd []string,
) (*bytes.Buffer, error)

func (BuildkitSolver) FileExists

func (s BuildkitSolver) FileExists(
	ctx context.Context,
	filepath string,
	source *builddef.Context,
) (bool, error)

func (BuildkitSolver) FromContext

func (s BuildkitSolver) FromContext(
	source *builddef.Context,
	opts ...llb.LocalOption,
) ReadFileOpt

func (BuildkitSolver) FromImage

func (s BuildkitSolver) FromImage(image string) ReadFileOpt

func (BuildkitSolver) ReadFile

func (s BuildkitSolver) ReadFile(ctx context.Context, filepath string, opt ReadFileOpt) ([]byte, error)

func (BuildkitSolver) ResolveImageRef

func (s BuildkitSolver) ResolveImageRef(ctx context.Context, imageRef string) (string, error)

type LocalSolver

type LocalSolver struct {
	Client *client.Client
	Labels map[string]string
	// RootDir is the path to the root of the build context.
	RootDir       string
	ImageResolver remotes.Resolver
}

LocalSolver is the solver used by zbuild CLI tool. As such, it uses Docker to read files from images and resolve image references.

func (LocalSolver) ExecImage

func (s LocalSolver) ExecImage(
	ctx context.Context,
	imageRef string,
	cmd []string,
) (*bytes.Buffer, error)

func (LocalSolver) FileExists

func (s LocalSolver) FileExists(
	ctx context.Context,
	filepath string,
	source *builddef.Context,
) (bool, error)

func (LocalSolver) FromContext

func (s LocalSolver) FromContext(
	source *builddef.Context,
	_ ...llb.LocalOption,
) ReadFileOpt

func (LocalSolver) FromImage

func (s LocalSolver) FromImage(image string) ReadFileOpt

func (LocalSolver) ReadFile

func (s LocalSolver) ReadFile(
	ctx context.Context,
	filepath string,
	opt ReadFileOpt,
) ([]byte, error)

func (LocalSolver) ResolveImageRef

func (s LocalSolver) ResolveImageRef(ctx context.Context, imageRef string) (string, error)

type ReadFileOpt

type ReadFileOpt func(ctx context.Context, filepath string) ([]byte, error)

type StateSolver

type StateSolver interface {
	// ResolveImageRef takes a denormalized image reference (e.g. nginx:latest)
	// and resolve it into a fully-qualified image reference with a digest. The
	// returned image reference can be used in lockfiles.
	// It returns an error if it can't resolve the image ref or if this method
	// is not supported.
	ResolveImageRef(ctx context.Context, imageRef string) (string, error)

	// ExecImage is a method that execute a given command in the given image
	// ref. It returns a byte buffer containing the command stdout. An error is
	// returned if the executed command doesn't return an exit code = 0.
	ExecImage(ctx context.Context, imageRef string, cmd []string) (*bytes.Buffer, error)
	// FileExists check if the given filepath exists in the given context.
	FileExists(ctx context.Context, filepath string, source *builddef.Context) (bool, error)
	// ReadFile is the method to use to read a given file from either an image
	// or a local source (see From methods). It returns the file content as a
	// byte slice if it's found. If the path couldn't be found, it returns
	// a FileNotFound error.
	ReadFile(ctx context.Context, filepath string, opt ReadFileOpt) ([]byte, error)

	FromContext(source *builddef.Context, opts ...llb.LocalOption) ReadFileOpt
	// Fromimage returns a ReadFileOpt that can be used with the ReadFile
	// method of the same solver to read a given path from an image.
	FromImage(image string) ReadFileOpt
}

Jump to

Keyboard shortcuts

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