llbutils

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: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APT is the const used to install apt packages with InstallSystemPackages.
	APT = "apt"
	APK = "apk"
)

Variables

View Source
var (
	// UnsupportedPackageManager is thrown when the package manager used by the
	// base image distro isn't supported by zbuild.
	UnsupportedPackageManager = xerrors.New("unspported package manager")
)

Functions

func CacheMountOpt

func CacheMountOpt(pathToCache, cacheIDNamespace string, owner string) llb.RunOption

CacheMountOpt is used to consistently mount cache folders used when executing commands (eg. to cache downloads of apt, apk or language-specific package managers).

func Copy

func Copy(src llb.State, srcPath string, dest llb.State, destPath string, owner string, ignoreCache bool) llb.State

func CopyAll

func CopyAll(src, dest llb.State, paths map[string]string, owner string, ignoreCache bool) llb.State

func CopyExternalFiles

func CopyExternalFiles(state llb.State, externalFiles []ExternalFile) llb.State

CopyExternalFiles downloads the given list of ExternalFiles, each in their own DAG tree root (thus they're going to be executed in parallel), decompress and unpack them if required and finally copy them to the given state.

func FromContext

func FromContext(
	context *builddef.Context,
	opts ...llb.LocalOption,
) llb.State

func ImageSource

func ImageSource(imageRef string, withMeta bool) llb.State

func InstallPackagesWithAPK

func InstallPackagesWithAPK(
	state llb.State,
	packageSpecs []string,
	opts SystemPackagesCaching,
) (llb.State, error)

func InstallPackagesWithAPT

func InstallPackagesWithAPT(
	state llb.State,
	packageSpecs []string,
	opts SystemPackagesCaching,
) (llb.State, error)

func InstallSystemPackages

func InstallSystemPackages(
	state llb.State,
	pkgMgr string,
	locks map[string]string,
	opts SystemPackagesCaching,
) (llb.State, error)

InstallSystemPackages installs the given packages with the given package manager. Packages map have to be a set of package names associated to their respective version.

func JSONToDefinition

func JSONToDefinition(raw []byte) (*llb.Definition, error)

func Mkdir

func Mkdir(state llb.State, owner string, dirs ...string) llb.State

func ReadFile

func ReadFile(ctx context.Context, ref client.Reference, filepath string) ([]byte, bool, error)

ReadFile reads the content of the file at given filepath. It returns the file content, a bool indicating if the file was present and an error (excluding ErrNotExists).

func SetupAPTCache

func SetupAPTCache(state llb.State) llb.State

SetupAPTCache adds a Run operation to the given llb.State and returns the new state. That Run operation remove the docker-clean APT config file and replace it with a new config file that explicitly tells APT to keep downloaded files. This function has to be called before running InstallSystemPackages with cache mounts enabled.

func SetupSystemPackagesCache

func SetupSystemPackagesCache(state llb.State, pkgMgr string) llb.State

func Shell

func Shell(cmds ...string) llb.RunOption

func SolveState

func SolveState(
	ctx context.Context,
	c client.Client,
	src llb.State,
) (*client.Result, client.Reference, error)

SolveState takes any state and solve it. It returns the solve result, a unique ref and an error if any happens.

func StateToJSON

func StateToJSON(state llb.State) ([]byte, error)

Types

type ExternalFile

type ExternalFile struct {
	URL         string
	Compressed  bool
	Pattern     string
	Destination string
	Checksum    string
	Mode        os.FileMode
	Owner       string
}

ExternalFile represents a file that should be loaded through HTTP at build-time.

type SystemPackagesCaching

type SystemPackagesCaching struct {
	IgnoreLayerCache bool
	WithCacheMounts  bool
	CacheIDNamespace string
}

SystemPackagesCaching holds all the options relating to layer caching and package caching.

func NewCachingStrategyFromBuildOpts

func NewCachingStrategyFromBuildOpts(
	buildOpts builddef.BuildOpts,
) SystemPackagesCaching

Jump to

Keyboard shortcuts

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