build

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SupportedPlatformAPIVersions lists the Platform API versions pack supports listed from earliest to latest
	SupportedPlatformAPIVersions = builder.APISet{
		api.MustParse("0.3"),
		api.MustParse("0.4"),
		api.MustParse("0.5"),
		api.MustParse("0.6"),
		api.MustParse("0.7"),
		api.MustParse("0.8"),
		api.MustParse("0.9"),
		api.MustParse("0.10"),
		api.MustParse("0.11"),
		api.MustParse("0.12"),
		api.MustParse("0.13"),
	}
)

Functions

func FindLatestSupported added in v0.29.0

func FindLatestSupported(builderapis []*api.Version, lifecycleapis []string) (*api.Version, error)

FindLatestSupported finds the latest Platform API version supported by both the builder and the lifecycle.

Types

type Builder added in v0.10.0

type Builder interface {
	Name() string
	UID() int
	GID() int
	LifecycleDescriptor() builder.LifecycleDescriptor
	Stack() builder.StackMetadata
	RunImages() []builder.RunImageMetadata
	Image() imgutil.Image
	OrderExtensions() dist.Order
}

type Cache

type Cache interface {
	Name() string
	Clear(context.Context) error
	Type() cache.Type
}

type ContainerOperation added in v0.12.0

type ContainerOperation func(ctrClient DockerClient, ctx context.Context, containerID string, stdout, stderr io.Writer) error

func CopyDir added in v0.12.0

func CopyDir(src, dst string, uid, gid int, os string, includeRoot bool, fileFilter func(string) bool) ContainerOperation

CopyDir copies a local directory (src) to the destination on the container while filtering files and changing it's UID/GID. if includeRoot is set the UID/GID will be set on the dst directory.

func CopyOut added in v0.23.0

func CopyOut(handler func(closer io.ReadCloser) error, srcs ...string) ContainerOperation

CopyOut copies container directories to a handler function. The handler is responsible for closing the Reader.

func CopyOutMaybe added in v0.30.0

func CopyOutMaybe(handler func(closer io.ReadCloser) error, srcs ...string) ContainerOperation

CopyOutMaybe copies container directories to a handler function. The handler is responsible for closing the Reader. CopyOutMaybe differs from CopyOut in that it will silently continue to the next source file if the file reader cannot be instantiated because the source file does not exist in the container.

func CopyOutTo added in v0.24.0

func CopyOutTo(src, dest string) ContainerOperation

func CopyOutToMaybe added in v0.30.0

func CopyOutToMaybe(src, dest string) ContainerOperation

func EnsureVolumeAccess added in v0.14.0

func EnsureVolumeAccess(uid, gid int, os string, volumeNames ...string) ContainerOperation

EnsureVolumeAccess grants full access permissions to volumes for UID/GID-based user When UID/GID are 0 it grants explicit full access to BUILTIN\Administrators and any other UID/GID grants full access to BUILTIN\Users Changing permissions on volumes through stopped containers does not work on Docker for Windows so we start the container and make change using icacls See: https://github.com/moby/moby/issues/40771

func WriteProjectMetadata added in v0.21.0

func WriteProjectMetadata(dstPath string, metadata files.ProjectMetadata, os string) ContainerOperation

WriteProjectMetadata writes a `project-metadata.toml` based on the ProjectMetadata provided to the destination path.

func WriteRunToml added in v0.30.0

func WriteRunToml(dstPath string, runImages []builder.RunImageMetadata, os string) ContainerOperation

WriteRunToml writes a `run.toml` based on the RunConfig provided to the destination path.

func WriteStackToml added in v0.12.0

func WriteStackToml(dstPath string, stack builder.StackMetadata, os string) ContainerOperation

WriteStackToml writes a `stack.toml` based on the StackMetadata provided to the destination path.

type DefaultPhaseFactory added in v0.10.0

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

func (*DefaultPhaseFactory) New added in v0.10.0

type DockerClient added in v0.29.0

type DockerClient interface {
	ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error)
	VolumeRemove(ctx context.Context, volumeID string, force bool) error
	ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.WaitResponse, <-chan error)
	ContainerAttach(ctx context.Context, container string, options containertypes.AttachOptions) (types.HijackedResponse, error)
	ContainerStart(ctx context.Context, container string, options containertypes.StartOptions) error
	ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *specs.Platform, containerName string) (containertypes.CreateResponse, error)
	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, containertypes.PathStat, error)
	ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
	ContainerRemove(ctx context.Context, container string, options containertypes.RemoveOptions) error
	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options containertypes.CopyToContainerOptions) error
	NetworkCreate(ctx context.Context, name string, options networktypes.CreateOptions) (networktypes.CreateResponse, error)
	NetworkRemove(ctx context.Context, network string) error
}

type LifecycleExecution added in v0.13.0

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

func NewLifecycleExecution added in v0.13.0

func NewLifecycleExecution(logger logging.Logger, docker DockerClient, tmpDir string, opts LifecycleOptions) (*LifecycleExecution, error)

func (*LifecycleExecution) Analyze added in v0.13.0

func (l *LifecycleExecution) Analyze(ctx context.Context, buildCache, launchCache Cache, phaseFactory PhaseFactory) error

func (LifecycleExecution) AppDir added in v0.19.0

func (l LifecycleExecution) AppDir() string

func (*LifecycleExecution) AppPath added in v0.13.0

func (l *LifecycleExecution) AppPath() string

func (*LifecycleExecution) AppVolume added in v0.13.0

func (l *LifecycleExecution) AppVolume() string

func (*LifecycleExecution) Build added in v0.13.0

func (l *LifecycleExecution) Build(ctx context.Context, phaseFactory PhaseFactory) error

func (*LifecycleExecution) Builder added in v0.13.0

func (l *LifecycleExecution) Builder() Builder

func (*LifecycleExecution) Cleanup added in v0.13.0

func (l *LifecycleExecution) Cleanup() error

func (*LifecycleExecution) Create added in v0.13.0

func (l *LifecycleExecution) Create(ctx context.Context, buildCache, launchCache Cache, phaseFactory PhaseFactory) error

func (*LifecycleExecution) Detect added in v0.13.0

func (l *LifecycleExecution) Detect(ctx context.Context, phaseFactory PhaseFactory) error

func (*LifecycleExecution) Export added in v0.13.0

func (l *LifecycleExecution) Export(ctx context.Context, buildCache, launchCache, kanikoCache Cache, phaseFactory PhaseFactory) error

func (*LifecycleExecution) ExtendBuild added in v0.30.0

func (l *LifecycleExecution) ExtendBuild(ctx context.Context, kanikoCache Cache, phaseFactory PhaseFactory, experimental bool) error

func (*LifecycleExecution) ExtendRun added in v0.30.0

func (l *LifecycleExecution) ExtendRun(ctx context.Context, kanikoCache Cache, phaseFactory PhaseFactory, runImageName string, experimental bool) error

func (*LifecycleExecution) ImageName added in v0.22.0

func (l *LifecycleExecution) ImageName() name.Reference

func (*LifecycleExecution) LayersVolume added in v0.13.0

func (l *LifecycleExecution) LayersVolume() string

func (*LifecycleExecution) PlatformAPI added in v0.13.0

func (l *LifecycleExecution) PlatformAPI() *api.Version

func (*LifecycleExecution) PrevImageName added in v0.22.0

func (l *LifecycleExecution) PrevImageName() string

func (*LifecycleExecution) Restore added in v0.13.0

func (l *LifecycleExecution) Restore(ctx context.Context, buildCache Cache, kanikoCache Cache, phaseFactory PhaseFactory) error

func (*LifecycleExecution) Run added in v0.13.0

func (l *LifecycleExecution) Run(ctx context.Context, phaseFactoryCreator PhaseFactoryCreator) error

type LifecycleExecutor added in v0.13.0

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

func NewLifecycleExecutor added in v0.13.0

func NewLifecycleExecutor(logger logging.Logger, docker DockerClient) *LifecycleExecutor

func (*LifecycleExecutor) Execute added in v0.13.0

func (l *LifecycleExecutor) Execute(ctx context.Context, opts LifecycleOptions) error

type LifecycleOptions

type LifecycleOptions struct {
	AppPath                         string
	Image                           name.Reference
	Builder                         Builder
	BuilderImage                    string // differs from Builder.Name() and Builder.Image().Name() in that it includes the registry context
	LifecycleImage                  string
	LifecycleApis                   []string // optional - populated only if custom lifecycle image is downloaded, from that lifecycle image's labels.
	RunImage                        string
	FetchRunImageWithLifecycleLayer func(name string) (string, error)
	ProjectMetadata                 files.ProjectMetadata
	ClearCache                      bool
	Publish                         bool
	TrustBuilder                    bool
	UseCreator                      bool
	UseCreatorWithExtensions        bool
	Interactive                     bool
	Layout                          bool
	Termui                          Termui
	DockerHost                      string
	Cache                           cache.CacheOpts
	CacheImage                      string
	HTTPProxy                       string
	HTTPSProxy                      string
	NoProxy                         string
	Network                         string
	AdditionalTags                  []string
	Volumes                         []string
	DefaultProcessType              string
	FileFilter                      func(string) bool
	Workspace                       string
	GID                             int
	UID                             int
	PreviousImage                   string
	ReportDestinationDir            string
	SBOMDestinationDir              string
	CreationTime                    *time.Time
	Keychain                        authn.Keychain
}

type Phase

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

func (*Phase) Cleanup

func (p *Phase) Cleanup() error

func (*Phase) Run

func (p *Phase) Run(ctx context.Context) error

type PhaseConfigProvider added in v0.10.0

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

func NewPhaseConfigProvider added in v0.10.0

func NewPhaseConfigProvider(name string, lifecycleExec *LifecycleExecution, ops ...PhaseConfigProviderOperation) *PhaseConfigProvider

func (*PhaseConfigProvider) ContainerConfig added in v0.10.0

func (p *PhaseConfigProvider) ContainerConfig() *container.Config

func (*PhaseConfigProvider) ContainerOps added in v0.12.0

func (p *PhaseConfigProvider) ContainerOps() []ContainerOperation

func (*PhaseConfigProvider) ErrorWriter added in v0.11.0

func (p *PhaseConfigProvider) ErrorWriter() io.Writer

func (*PhaseConfigProvider) Handler added in v0.21.0

func (p *PhaseConfigProvider) Handler() pcontainer.Handler

func (*PhaseConfigProvider) HostConfig added in v0.10.0

func (p *PhaseConfigProvider) HostConfig() *container.HostConfig

func (*PhaseConfigProvider) InfoWriter added in v0.11.0

func (p *PhaseConfigProvider) InfoWriter() io.Writer

func (*PhaseConfigProvider) Name added in v0.10.0

func (p *PhaseConfigProvider) Name() string

func (*PhaseConfigProvider) PostContainerRunOps added in v0.23.0

func (p *PhaseConfigProvider) PostContainerRunOps() []ContainerOperation

type PhaseConfigProviderOperation added in v0.10.0

type PhaseConfigProviderOperation func(*PhaseConfigProvider)

func If added in v0.23.0

func NullOp added in v0.16.0

func WithArgs

func WithArgs(args ...string) PhaseConfigProviderOperation

func WithBinds

func WithBinds(binds ...string) PhaseConfigProviderOperation

func WithContainerOperations added in v0.12.0

func WithContainerOperations(operations ...ContainerOperation) PhaseConfigProviderOperation

func WithDaemonAccess

func WithDaemonAccess(dockerHost string) PhaseConfigProviderOperation

func WithEnv added in v0.11.0

func WithEnv(envs ...string) PhaseConfigProviderOperation

func WithFlags added in v0.12.0

func WithFlags(flags ...string) PhaseConfigProviderOperation

WithFlags differs from WithArgs as flags are always prepended

func WithImage added in v0.11.0

func WithImage(image string) PhaseConfigProviderOperation

func WithLifecycleProxy added in v0.10.0

func WithLifecycleProxy(lifecycleExec *LifecycleExecution) PhaseConfigProviderOperation

func WithLogPrefix added in v0.11.0

func WithLogPrefix(prefix string) PhaseConfigProviderOperation

WithLogPrefix sets a prefix for logs produced by this phase

func WithNetwork

func WithNetwork(networkMode string) PhaseConfigProviderOperation

func WithPostContainerRunOperations added in v0.23.0

func WithPostContainerRunOperations(operations ...ContainerOperation) PhaseConfigProviderOperation

func WithRegistryAccess

func WithRegistryAccess(authConfig string) PhaseConfigProviderOperation

type PhaseFactory added in v0.10.0

type PhaseFactory interface {
	New(provider *PhaseConfigProvider) RunnerCleaner
}

func NewDefaultPhaseFactory added in v0.10.0

func NewDefaultPhaseFactory(lifecycleExec *LifecycleExecution) PhaseFactory

type PhaseFactoryCreator added in v0.14.0

type PhaseFactoryCreator func(*LifecycleExecution) PhaseFactory

type RunnerCleaner added in v0.10.0

type RunnerCleaner interface {
	Run(ctx context.Context) error
	Cleanup() error
}

type Termui added in v0.21.0

type Termui interface {
	logging.Logger

	Run(funk func()) error
	Handler() container.Handler
	ReadLayers(reader io.ReadCloser) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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