Documentation ¶
Index ¶
- Constants
- func Build(builder libcnb.BuildFunc, options ...libcnb.Option)
- func BuildpackMain(detect libcnb.DetectFunc, build libcnb.BuildFunc, options ...libcnb.Option)
- func ContributableBuildFunc(contributeLayersFunc ContributeLayersFunc) libcnb.BuildFunc
- func Detect(detector libcnb.DetectFunc, options ...libcnb.Option)
- func ExtensionMain(detect libcnb.DetectFunc, generate libcnb.GenerateFunc, ...)
- func Generate(generator libcnb.GenerateFunc, options ...libcnb.Option)
- func IsBionicStack(stack string) bool
- func IsJammyStack(stack string) bool
- func IsNoValidDependencies(err error) bool
- func IsShellPresentOnStack(stack string) bool
- func IsStaticStack(stack string) bool
- func IsTinyStack(stack string) bool
- func ShallowMerge(a, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error)
- type BuildModuleConfiguration
- type BuildModuleDependency
- type BuildModuleDependencyLicense
- type BuildModuleMetadata
- type ConfigurationResolver
- type Contributable
- type ContributeLayersFunc
- type DependenciesFormatter
- type DependencyCache
- type DependencyLayerContributor
- type DependencyLayerFunc
- type DependencyResolver
- type HelperLayerContributor
- type HttpClientTimeouts
- type LayerContributor
- type LayerFunc
- type MergeFunc
- type NoValidDependenciesError
- type PlanEntryResolver
- type RequestModifierFunc
Constants ¶
const ( // BionicStackID is the ID for the Cloud Native Buildpacks bionic stack. BionicStackID = "io.buildpacks.stacks.bionic" // BionicTinyStackID is the ID for the Paketo Buildpacks bionic tiny stack. BionicTinyStackID = "io.paketo.stacks.tiny" // TinyStackID is the ID for the Paketo Buildpacks bionic tiny stack. // // Deprecated: use BionicTinyStackID instead TinyStackID = "io.paketo.stacks.tiny" // JammyStackID is the ID for the Cloud Native Buildpacks jammy stack. JammyStackID = "io.buildpacks.stacks.jammy" // JammyTinyStackID is the ID for the Cloud Native Buildpacks jammy tiny stack. JammyTinyStackID = "io.buildpacks.stacks.jammy.tiny" // JammyStaticStackID is the ID for the Cloud Native Buildpacks jammy static stack. JammyStaticStackID = "io.buildpacks.stacks.jammy.static" )
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(builder libcnb.BuildFunc, options ...libcnb.Option)
Build is called by the main function of a buildpack, for build.
func BuildpackMain ¶
func BuildpackMain(detect libcnb.DetectFunc, build libcnb.BuildFunc, options ...libcnb.Option)
Main is called by the main function of a buildpack, encapsulating both detection and build in the same binary.
func ContributableBuildFunc ¶
func ContributableBuildFunc(contributeLayersFunc ContributeLayersFunc) libcnb.BuildFunc
ContributableBuildFunc is a standard libcnb.BuildFunc implementation that delegates to a list of Contributables
func Detect ¶
func Detect(detector libcnb.DetectFunc, options ...libcnb.Option)
Detect is called by the main function of a buildpack, for detection.
func ExtensionMain ¶
func ExtensionMain(detect libcnb.DetectFunc, generate libcnb.GenerateFunc, options ...libcnb.Option)
Main is called by the main function of an extension, encapsulating both detection and generation in the same binary.
func Generate ¶
func Generate(generator libcnb.GenerateFunc, options ...libcnb.Option)
Generate is called by the main function of an extension, for generation.
func IsBionicStack ¶
IsBionicStack returns true if the stack is one of the bionic variants
func IsJammyStack ¶
IsJammyStack returns true if the stack is one of the jammy variants
func IsNoValidDependencies ¶
IsNoValidDependencies indicates whether an error is a NoValidDependenciesError.
func IsShellPresentOnStack ¶
IsShellPresentOnStack returns true if the stack is known to have a shell
func IsStaticStack ¶
IsStaticStack returns true if the stack is one of the static variants
func IsTinyStack ¶
IsTinyStack returns true if the stack is one of the tiny variants
func ShallowMerge ¶
func ShallowMerge(a, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error)
ShallowMerge merges two BuildpackPlanEntry's together. Declared versions are combined with a comma delimiter and metadata is combined with the values for b taking priority over the values of a when the keys are duplicated.
Types ¶
type BuildModuleConfiguration ¶
type BuildModuleConfiguration struct { // Build indicates whether the configuration is for build-time. Optional. Build bool `toml:"build"` // Default is the default value of the configuration parameter. Optional. Default string `toml:"default"` // Description is the description of the configuration parameter. Description string `toml:"description"` // Launch indicates whether the configuration is for launch-time. Optional. Launch bool `toml:"launch"` // Name is the environment variable name of the configuration parameter. Name string `toml:"name"` }
BuildpackConfiguration represents a build or launch configuration parameter.
type BuildModuleDependency ¶
type BuildModuleDependency struct { // ID is the dependency ID. ID string `toml:"id"` // Name is the dependency name. Name string `toml:"name"` // Version is the dependency version. Version string `toml:"version"` // URI is the dependency URI. URI string `toml:"uri"` // SHA256 is the hash of the dependency. SHA256 string `toml:"sha256"` // Stacks are the stacks the dependency is compatible with. Stacks []string `toml:"stacks"` // Licenses are the licenses the dependency is distributed under. Licenses []BuildModuleDependencyLicense `toml:"licenses"` // CPEs are the Common Platform Enumeration identifiers for the dependency CPEs []string `toml:"cpes"` // PURL is the package URL that identifies the dependency PURL string `toml:"purl"` // DeprecationDate is the time when the dependency is deprecated DeprecationDate time.Time `toml:"deprecation_date"` }
BuildModuleDependency describes a dependency known to the buildpack/extension
func (BuildModuleDependency) AsSyftArtifact ¶
func (b BuildModuleDependency) AsSyftArtifact(source string) (sbom.SyftArtifact, error)
AsSyftArtifact renders a bill of materials entry describing the dependency as Syft.
func (BuildModuleDependency) Equals ¶
func (b1 BuildModuleDependency) Equals(b2 BuildModuleDependency) bool
Equals compares the 2 structs if they are equal. This is very simiar to reflect.DeepEqual except that properties that will not work (e.g. DeprecationDate) are ignored.
func (BuildModuleDependency) IsDeprecated ¶
func (b BuildModuleDependency) IsDeprecated() bool
func (BuildModuleDependency) IsSoonDeprecated ¶
func (b BuildModuleDependency) IsSoonDeprecated() bool
type BuildModuleDependencyLicense ¶
type BuildModuleDependencyLicense struct { // Type is the type of the license. This is typically the SPDX short identifier. Type string `toml:"type"` // URI is the location where the license can be found. URI string `toml:"uri"` }
BuildModuleDependencyLicense represents a license that a BuildModuleDependency is distributed under. At least one of Name or URI MUST be specified.
type BuildModuleMetadata ¶
type BuildModuleMetadata struct { // Configurations are environment variables that can be used at build time to configure the buildpack and launch // time to configure the application. Configurations []BuildModuleConfiguration // Dependencies are the dependencies known to the buildpack. Dependencies []BuildModuleDependency // IncludeFiles describes the files to include in the package. IncludeFiles []string // PrePackage describes a command to invoke before packaging. PrePackage string }
BuildpackMetadata is an extension to libcnb.Buildpack / libcnb.Extension's metadata with opinions.
func NewBuildModuleMetadata ¶
func NewBuildModuleMetadata(metadata map[string]interface{}) (BuildModuleMetadata, error)
NewBuildpackMetadata creates a new instance of BuildpackMetadata from the contents of libcnb.Buildpack.Metadata
type ConfigurationResolver ¶
type ConfigurationResolver struct { // Configurations are the configurations to resolve against Configurations []BuildModuleConfiguration }
ConfigurationResolver provides functionality for resolving a configuration value.
func NewConfigurationResolver ¶
func NewConfigurationResolver(md BuildModuleMetadata) (ConfigurationResolver, error)
NewConfigurationResolver creates a new instance from buildmodule metadata.
func (*ConfigurationResolver) LogConfiguration ¶
func (c *ConfigurationResolver) LogConfiguration(logger log.Logger)
LogConfiguration will write the configuration options to the body level in the form 'Set $Name to configure $Description[. Default <i>$Default</i>.]'.
func (*ConfigurationResolver) Resolve ¶
func (c *ConfigurationResolver) Resolve(name string) (string, bool)
Resolve resolves the value for a configuration option, returning the default value and false if it was not set.
func (*ConfigurationResolver) ResolveBool ¶
func (c *ConfigurationResolver) ResolveBool(name string) bool
ResolveBool resolves a boolean value for a configuration option. Returns true for 1, t, T, TRUE, true, True. Returns false for all other values or unset.
type Contributable ¶
type Contributable interface { // Contribute accepts a new empty layer and transforms it Contribute(layer *libcnb.Layer) error // Name is the name of the layer. Name() string }
Contributable is an interface that is implemented when you want to contribute new layers
type ContributeLayersFunc ¶
type ContributeLayersFunc func(context libcnb.BuildContext, result *libcnb.BuildResult) ([]Contributable, error)
ContributeLayersFunc takes a context and result pointer returning a list of Contributables, the list of Contributables will be turned into layers automatically
type DependenciesFormatter ¶
type DependenciesFormatter []BuildModuleDependency
DependenciesFormatter is the formatter for a []BuildpackDependency.
func (DependenciesFormatter) String ¶
func (d DependenciesFormatter) String() string
type DependencyCache ¶
type DependencyCache struct { // CachePath is the location where the buildmodule has cached its dependencies. CachePath string // DownloadPath is the location of all downloads during this execution of the build. DownloadPath string // Logger is the logger used to write to the console. Logger log.Logger // UserAgent is the User-Agent string to use with requests. UserAgent string // Mappings optionally provides URIs mapping for BuildModuleDependencies Mappings map[string]string // httpClientTimeouts contains the timeout values used by HTTP client HttpClientTimeouts HttpClientTimeouts }
DependencyCache allows a user to get an artifact either from a buildmodule's cache, a previous download, or to download directly.
func NewDependencyCache ¶
func NewDependencyCache(buildModuleID string, buildModuleVersion string, buildModulePath string, platformBindings libcnb.Bindings, logger log.Logger) (DependencyCache, error)
NewDependencyCache creates a new instance setting the default cache path (<BUILDMODULE_PATH>/dependencies) and user agent (<BUILDMODULE_ID>/<BUILDMODULE_VERSION>).
func (*DependencyCache) Artifact ¶
func (d *DependencyCache) Artifact(dependency BuildModuleDependency, mods ...RequestModifierFunc) (*os.File, error)
Artifact returns the path to the artifact. Resolution of that path follows three tiers:
1. CachePath 2. DownloadPath 3. Download from URI
If the BuildpackDependency's SHA256 is not set, the download can never be verified to be up to date and will always download, skipping all the caches.
type DependencyLayerContributor ¶
type DependencyLayerContributor struct { // Dependency is the dependency being contributed. Dependency BuildModuleDependency // DependencyCache is the cache to use to get the dependency. DependencyCache DependencyCache // ExpectedTypes indicates the types that should be set on the layer. ExpectedTypes libcnb.LayerTypes // ExpectedMetadata contains metadata describing the expected layer ExpectedMetadata interface{} // Logger is the logger to use. Logger log.Logger // RequestModifierFuncs is an optional Request Modifier to use when downloading the dependency. RequestModifierFuncs []RequestModifierFunc }
DependencyLayerContributor is a helper for implementing a Contributable for a BuildpackDependency in order to get consistent logging and avoidance.
func NewDependencyLayerContributor ¶
func NewDependencyLayerContributor(dependency BuildModuleDependency, cache DependencyCache, types libcnb.LayerTypes, logger log.Logger) DependencyLayerContributor
NewDependencyLayerContributor returns a new DependencyLayerContributor for the given BuildpackDependency
func (*DependencyLayerContributor) Contribute ¶
func (d *DependencyLayerContributor) Contribute(layer *libcnb.Layer, f DependencyLayerFunc) error
Contribute is the function to call whe implementing your Contributable.
func (*DependencyLayerContributor) LayerName ¶
func (d *DependencyLayerContributor) LayerName() string
LayerName returns the conventional name of the layer for this contributor
func (*DependencyLayerContributor) Name ¶
func (d *DependencyLayerContributor) Name() string
Name returns the human readable name of the layer
type DependencyLayerFunc ¶
DependencyLayerFunc is a callback function that is invoked when a dependency needs to be contributed.
type DependencyResolver ¶
type DependencyResolver struct { // Dependencies are the dependencies to resolve against. Dependencies []BuildModuleDependency // StackID is the stack id of the build. StackID string // Logger is the logger used to write to the console. Logger log.Logger }
DependencyResolver provides functionality for resolving a dependency given a collection of constraints.
func NewDependencyResolver ¶
func NewDependencyResolver(md BuildModuleMetadata, stackId string) (DependencyResolver, error)
NewDependencyResolver creates a new instance from the build module metadata and stack id.
func (*DependencyResolver) Resolve ¶
func (d *DependencyResolver) Resolve(id string, version string) (BuildModuleDependency, error)
Resolve returns the latest version of a dependency within the collection of Dependencies. The candidate set is first filtered by the constraints, then the remaining candidates are sorted for the latest result by semver semantics. Version can contain wildcards and defaults to "*" if not specified.
type HelperLayerContributor ¶
type HelperLayerContributor struct { // Path is the path to the helper application. Path string // BuildpackInfo describes the buildpack that provides the helper BuildpackInfo libcnb.BuildpackInfo // Logger is the logger to use. Logger log.Logger // Names are the names of the helpers to create Names []string }
HelperLayerContributor is a helper for implementing a Contributable for a buildpack helper application in order to get consistent logging and avoidance.
func NewHelperLayerContributor ¶
func NewHelperLayerContributor(buildpack libcnb.Buildpack, logger log.Logger, names ...string) HelperLayerContributor
NewHelperLayerContributor returns a new HelperLayerContributor
func (HelperLayerContributor) AsSyftArtifact ¶
func (h HelperLayerContributor) AsSyftArtifact() (sbom.SyftArtifact, error)
func (HelperLayerContributor) Contribute ¶
func (h HelperLayerContributor) Contribute(layer *libcnb.Layer) error
Contribute is the function to call whe implementing your Contributable.
func (HelperLayerContributor) Name ¶
func (h HelperLayerContributor) Name() string
Name returns the conventional name of the layer for this contributor
type HttpClientTimeouts ¶
type LayerContributor ¶
type LayerContributor struct { // ExpectedMetadata is the metadata to compare against any existing layer metadata. ExpectedMetadata interface{} // Logger is the logger to use. Logger log.Logger // Name is the user readable name of the contribution. Name string // ExpectedTypes indicates the types that should be set on the layer. ExpectedTypes libcnb.LayerTypes }
LayerContributor is a helper for implementing Contributable in order to get consistent logging and avoidance.
func NewLayerContributor ¶
func NewLayerContributor(name string, expectedMetadata interface{}, expectedTypes libcnb.LayerTypes, logger log.Logger) LayerContributor
NewLayerContributor creates a new instance.
func (*LayerContributor) Contribute ¶
func (l *LayerContributor) Contribute(layer *libcnb.Layer, f LayerFunc) error
Contribute is the function to call when implementing Contributable.
type LayerFunc ¶
type LayerFunc func(*libcnb.Layer) error
LayerFunc is a callback function that is invoked when a layer needs to be contributed.
type MergeFunc ¶
type MergeFunc func(a, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error)
MergeFunc takes two BuildpackPlanEntry's and returns a merged entry.
type NoValidDependenciesError ¶
type NoValidDependenciesError struct { // Message is the error message Message string }
NoValidDependenciesError is returned when the resolver cannot find any valid dependencies given the constraints.
func (NoValidDependenciesError) Error ¶
func (n NoValidDependenciesError) Error() string
type PlanEntryResolver ¶
type PlanEntryResolver struct {
// Plan is the BuildpackPlan to resolve against.
Plan libcnb.BuildpackPlan
}
PlanEntryResolver provides functionality for resolving a Buildpack Plan Entry given a name.
func (*PlanEntryResolver) Resolve ¶
func (p *PlanEntryResolver) Resolve(name string) (libcnb.BuildpackPlanEntry, bool, error)
Resolve calls ResolveWithMerge function passing in the ShallowMerge function as the merge strategy.
func (*PlanEntryResolver) ResolveWithMerge ¶
func (p *PlanEntryResolver) ResolveWithMerge(name string, f MergeFunc) (libcnb.BuildpackPlanEntry, bool, error)
ResolveWithMerge returns a single BuildpackPlanEntry that is a merged version of all entries that have a given name. A merge function is used to describe how two entries are merged together.