Documentation ¶
Overview ¶
Package phase handles logic internal to the CNB lifecycle, and roughly corresponds to the actions denoted by "the lifecycle MUST" and "the lifecycle SHALL" in the Platform Interface Specification.
Index ¶
- Constants
- Variables
- func PrependExtensions(orderBp buildpack.Order, orderExt buildpack.Order) buildpack.Order
- func SBOMExtensions() []string
- func TruncateSha(sha string) string
- type Analyzer
- type BuildEnv
- type Builder
- type BuildpackAPIVerifier
- type Cache
- type CacheHandler
- type ConfigHandler
- type ConnectedFactory
- type DefaultDetectResolver
- type DetectResolver
- type Detector
- type DirStore
- type DockerfileApplier
- type ExportOptions
- type Exporter
- type Extender
- type GenerateResult
- type Generator
- type HermeticFactory
- func (f *HermeticFactory) NewDetector(inputs platform.LifecycleInputs, logger log.LoggerHandlerWithLevel) (*Detector, error)
- func (f *HermeticFactory) NewExtender(inputs platform.LifecycleInputs, dockerfileApplier DockerfileApplier, ...) (*Extender, error)
- func (f *HermeticFactory) NewGenerator(inputs platform.LifecycleInputs, stdout, stderr io.Writer, logger log.Logger) (*Generator, error)
- type LauncherConfig
- type LayerDir
- type LayerFactory
- type MultiError
- type Platform
- type Rebaser
- type Restorer
Constants ¶
const ( CodeDetectPass = 0 CodeDetectFail = 100 )
const RebasableLabel = "io.buildpacks.rebasable"
Variables ¶
var ( ErrFailedDetection = errors.New("no buildpacks participating") ErrBuildpack = errors.New("buildpack(s) failed with err") )
Functions ¶
func PrependExtensions ¶
func SBOMExtensions ¶
func SBOMExtensions() []string
func TruncateSha ¶
Types ¶
type Analyzer ¶
type Analyzer struct { PreviousImage imgutil.Image RunImage imgutil.Image Logger log.Logger SBOMRestorer layer.SBOMRestorer PlatformAPI *api.Version }
Analyzer reads metadata from the previous image (if it exists) and the run image, and additionally restores the SBOM layer from the previous image for use later in the build.
type BuildEnv ¶
type BuildEnv interface { AddRootDir(baseDir string) error AddEnvDir(envDir string, defaultAction env.ActionType) error WithOverrides(platformDir string, baseConfigDir string) ([]string, error) List() []string }
BuildEnv encapsulates modifications that the lifecycle can make to buildpacks' build environment.
type Builder ¶
type BuildpackAPIVerifier ¶
type BuildpackAPIVerifier interface {
VerifyBuildpackAPI(kind, name, requestedVersion string, logger log.Logger) error
}
BuildpackAPIVerifier verifies a requested Buildpack API version.
type Cache ¶
type Cache interface { Exists() bool Name() string SetMetadata(metadata platform.CacheMetadata) error RetrieveMetadata() (platform.CacheMetadata, error) AddLayerFile(tarPath string, sha string) error ReuseLayer(sha string) error RetrieveLayer(sha string) (io.ReadCloser, error) Commit() error VerifyLayer(sha string) error }
type CacheHandler ¶
type CacheHandler interface {
InitCache(imageRef, dir string, deletionEnabled bool) (Cache, error)
}
CacheHandler wraps initialization of a cache image or cache volume.
type ConfigHandler ¶
type ConfigHandler interface { ReadAnalyzed(path string, logger log.Logger) (files.Analyzed, error) ReadGroup(path string) (buildpack.Group, error) ReadOrder(path string) (buildpack.Order, buildpack.Order, error) ReadRun(runPath string, logger log.Logger) (files.Run, error) ReadPlan(path string) (files.Plan, error) }
ConfigHandler reads configuration files for the lifecycle.
type ConnectedFactory ¶
type ConnectedFactory struct {
// contains filtered or unexported fields
}
ConnectedFactory is used to construct lifecycle phases that require access to an image repository (registry, layout directory, or docker daemon) and/or a cache.
func NewConnectedFactory ¶
func NewConnectedFactory( platformAPI *api.Version, apiVerifier BuildpackAPIVerifier, cacheHandler CacheHandler, configHandler ConfigHandler, imageHandler image.Handler, registryHandler image.RegistryHandler, ) *ConnectedFactory
NewConnectedFactory constructs a new ConnectedFactory.
func (*ConnectedFactory) NewAnalyzer ¶
func (f *ConnectedFactory) NewAnalyzer(inputs platform.LifecycleInputs, logger log.Logger) (*Analyzer, error)
NewAnalyzer configures a new Analyzer according to the provided Platform API version.
type DefaultDetectResolver ¶
func NewDefaultDetectResolver ¶
func NewDefaultDetectResolver(logger log.Logger) *DefaultDetectResolver
func (*DefaultDetectResolver) Resolve ¶
func (r *DefaultDetectResolver) Resolve(done []buildpack.GroupElement, detectRuns *sync.Map) ([]buildpack.GroupElement, []files.BuildPlanEntry, error)
Resolve aggregates the detect output for a group of buildpacks and tries to resolve a build plan for the group. If any required buildpack in the group failed detection or a build plan cannot be resolved, it returns an error.
type DetectResolver ¶
type DetectResolver interface {
Resolve(done []buildpack.GroupElement, detectRuns *sync.Map) ([]buildpack.GroupElement, []files.BuildPlanEntry, error)
}
DetectResolver given a group of buildpacks (and optional image extensions) processes the outputs of each `./bin/detect` to determine if the group is viable - that is, whether all non-optional buildpacks passed detection and a valid Build Plan can be resolved from each "requires" and "provides" expressed by each group element.
type Detector ¶
type Detector struct { AppDir string BuildConfigDir string DirStore DirStore Executor buildpack.DetectExecutor HasExtensions bool Logger log.LoggerHandlerWithLevel Order buildpack.Order PlatformDir string Resolver DetectResolver Runs *sync.Map AnalyzeMD files.Analyzed PlatformAPI *api.Version // contains filtered or unexported fields }
type DirStore ¶
type DirStore interface { Lookup(kind, id, version string) (buildpack.Descriptor, error) LookupBp(id, version string) (*buildpack.BpDescriptor, error) LookupExt(id, version string) (*buildpack.ExtDescriptor, error) }
DirStore is a repository of buildpacks and/or image extensions. Each element should be present on disk according to the format outlined in the Platform Interface Specification, namely: `/cnb/<buildpacks|extensions>/<id>/<version>/<root directory>`.
type DockerfileApplier ¶
type DockerfileApplier interface { ImageFor(reference string) (v1.Image, error) Apply(dockerfile extend.Dockerfile, toBaseImage v1.Image, withBuildOptions extend.Options, logger log.Logger) (v1.Image, error) Cleanup() error }
DockerfileApplier given a base image and a `build.Dockerfile` or `run.Dockerfile` will apply it to the base image and return a new image, or an error if encountered.
type ExportOptions ¶
type ExportOptions struct { // WorkingImage is the image to save. WorkingImage imgutil.Image // AdditionalNames are additional tags to save to, besides WorkingImage.Name(). AdditionalNames []string // ExtendedDir is the location of extension-provided layers. ExtendedDir string // AppDir is the source directory. AppDir string // LayersDir is the location of buildpack-provided layers. LayersDir string // OrigMetadata was read from the previous image during the `analyze` phase, and is used to determine if a previously-uploaded layer can be re-used. OrigMetadata files.LayersMetadata // LauncherConfig is the launcher config. LauncherConfig LauncherConfig // DefaultProcessType is the user-provided default process type. DefaultProcessType string // RunImageRef is the run image reference for the layer metadata label. RunImageRef string // RunImageForExport is run image metadata for the layer metadata label for Platform API >= 0.12. RunImageForExport files.RunImageForExport // Project is project metadata for the project metadata label. Project files.ProjectMetadata }
type Exporter ¶
type Exporter struct { Buildpacks []buildpack.GroupElement LayerFactory LayerFactory Logger log.Logger PlatformAPI *api.Version }
type Extender ¶
type Extender struct { AppDir string // explicitly ignored by the Dockerfile applier, also the Dockefile build context ExtendedDir string // output directory for extended image layers GeneratedDir string // input Dockerfiles are found here ImageRef string // the image to extend LayersDir string // explicitly ignored by the Dockerfile applier PlatformDir string // explicitly ignored by the Dockerfile applier CacheTTL time.Duration // a platform input DockerfileApplier DockerfileApplier // uses kaniko, BuildKit, or other to apply the provided Dockerfile to the provided image Extensions []buildpack.GroupElement // extensions are ordered from group.toml PlatformAPI *api.Version }
type Generator ¶
type Generator struct { AppDir string BuildConfigDir string GeneratedDir string // e.g., <layers>/generated PlatformAPI *api.Version PlatformDir string AnalyzedMD files.Analyzed DirStore DirStore Executor buildpack.GenerateExecutor Extensions []buildpack.GroupElement Logger log.Logger Out, Err io.Writer Plan files.Plan RunMetadata files.Run }
func (*Generator) Generate ¶
func (g *Generator) Generate() (GenerateResult, error)
type HermeticFactory ¶
type HermeticFactory struct {
// contains filtered or unexported fields
}
HermeticFactory is used to construct lifecycle phases that do NOT require access to an image repository.
func NewHermeticFactory ¶
func NewHermeticFactory( platformAPI *api.Version, apiVerifier BuildpackAPIVerifier, configHandler ConfigHandler, dirStore DirStore, ) *HermeticFactory
NewHermeticFactory is used to construct a new HermeticFactory.
func (*HermeticFactory) NewDetector ¶
func (f *HermeticFactory) NewDetector(inputs platform.LifecycleInputs, logger log.LoggerHandlerWithLevel) (*Detector, error)
NewDetector constructs a new Detector by initializing services and reading the provided analyzed and order files.
func (*HermeticFactory) NewExtender ¶
func (f *HermeticFactory) NewExtender(inputs platform.LifecycleInputs, dockerfileApplier DockerfileApplier, logger log.Logger) (*Extender, error)
NewExtender constructs a new Extender by initializing services and reading the provided analyzed and group files to determine the image to extend and the extensions to use.
func (*HermeticFactory) NewGenerator ¶
func (f *HermeticFactory) NewGenerator(inputs platform.LifecycleInputs, stdout, stderr io.Writer, logger log.Logger) (*Generator, error)
NewGenerator constructs a new Generator by initializing services and reading the provided analyzed, group, plan, and run files.
type LauncherConfig ¶
type LauncherConfig struct { Path string SBOMDir string Metadata files.LauncherMetadata }
type LayerFactory ¶
type LayerFactory interface { DirLayer(id string, dir string, createdBy string) (layers.Layer, error) LauncherLayer(path string) (layers.Layer, error) ProcessTypesLayer(metadata launch.Metadata) (layers.Layer, error) SliceLayers(dir string, slices []layers.Slice) ([]layers.Layer, error) TarLayer(withID string, fromTarPath string, createdBy string) (layer layers.Layer, err error) }
LayerFactory given a directory on the local filesystem will return a `layers.Layer` that can be used to construct an OCI image.
type MultiError ¶
type MultiError struct {
Errors []error
}
func (*MultiError) Error ¶
func (me *MultiError) Error() string
type Restorer ¶
type Restorer struct { LayersDir string Logger log.Logger Buildpacks []buildpack.GroupElement LayerMetadataRestorer layer.MetadataRestorer LayersMetadata files.LayersMetadata PlatformAPI *api.Version SBOMRestorer layer.SBOMRestorer }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package testmock is a generated GoMock package.
|
Package testmock is a generated GoMock package. |
auth
Package testmockauth is a generated GoMock package.
|
Package testmockauth is a generated GoMock package. |
cache
Package testmockcache is a generated GoMock package.
|
Package testmockcache is a generated GoMock package. |