Documentation ¶
Index ¶
- Constants
- func Build(builder libcnb.Builder, options ...libcnb.Option)
- func Detect(detector libcnb.Detector, 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 Main(detector libcnb.Detector, builder libcnb.Builder, options ...libcnb.Option)
- func ShallowMerge(a, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error)
- type BuildpackConfiguration
- type BuildpackDependency
- func (b BuildpackDependency) AsBOMEntry() libcnb.BOMEntrydeprecated
- func (b BuildpackDependency) AsSyftArtifact() (sbom.SyftArtifact, error)
- func (b1 BuildpackDependency) Equals(b2 BuildpackDependency) bool
- func (b BuildpackDependency) IsDeprecated() bool
- func (b BuildpackDependency) IsSoonDeprecated() bool
- type BuildpackDependencyLicense
- type BuildpackMetadata
- type ConfigurationResolver
- type DependenciesFormatter
- type DependencyCache
- type DependencyLayerContributor
- func NewDependencyLayer(dependency BuildpackDependency, cache DependencyCache, types libcnb.LayerTypes) (DependencyLayerContributor, libcnb.BOMEntry)deprecated
- func NewDependencyLayerContributor(dependency BuildpackDependency, cache DependencyCache, types libcnb.LayerTypes) 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 IsBionicStack ¶ added in v1.65.0
IsBionicStack returns true if the stack is one of the bionic variants
func IsJammyStack ¶ added in v1.65.0
IsJammyStack returns true if the stack is one of the jammy variants
func IsNoValidDependencies ¶ added in v1.15.0
IsNoValidDependencies indicates whether an error is a NoValidDependenciesError.
func IsShellPresentOnStack ¶ added in v1.65.0
IsShellPresentOnStack returns true if the stack is known to have a shell
func IsStaticStack ¶ added in v1.65.0
IsStaticStack returns true if the stack is one of the static variants
func IsTinyStack ¶ added in v1.65.0
IsTinyStack returns true if the stack is one of the tiny variants
func Main ¶ added in v1.29.0
Main is called by the main function of a buildpack, encapsulating both detection and build in the same binary.
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 BuildpackConfiguration ¶ added in v1.31.0
type BuildpackConfiguration 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 BuildpackDependency ¶
type BuildpackDependency 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 []BuildpackDependencyLicense `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"` }
BuildpackDependency describes a dependency known to the buildpack.
func (BuildpackDependency) AsBOMEntry
deprecated
added in
v1.51.0
func (b BuildpackDependency) AsBOMEntry() libcnb.BOMEntry
AsBOMEntry renders a bill of materials entry describing the dependency.
Deprecated: as of Buildpacks RFC 95, use `BuildpackDependency.AsSyftArtifact` instead
func (BuildpackDependency) AsSyftArtifact ¶ added in v1.56.0
func (b BuildpackDependency) AsSyftArtifact() (sbom.SyftArtifact, error)
AsSyftArtifact renders a bill of materials entry describing the dependency as Syft.
func (BuildpackDependency) Equals ¶ added in v1.66.0
func (b1 BuildpackDependency) Equals(b2 BuildpackDependency) 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 (BuildpackDependency) IsDeprecated ¶ added in v1.64.0
func (b BuildpackDependency) IsDeprecated() bool
func (BuildpackDependency) IsSoonDeprecated ¶ added in v1.64.0
func (b BuildpackDependency) IsSoonDeprecated() bool
type BuildpackDependencyLicense ¶
type BuildpackDependencyLicense 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"` }
BuildpackDependencyLicense represents a license that a BuildpackDependency is distributed under. At least one of Name or URI MUST be specified.
type BuildpackMetadata ¶
type BuildpackMetadata struct { // Configurations are environment variables that can be used at build time to configure the buildpack and launch // time to configure the application. Configurations []BuildpackConfiguration // Dependencies are the dependencies known to the buildpack. Dependencies []BuildpackDependency // 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's metadata with opinions.
func NewBuildpackMetadata ¶
func NewBuildpackMetadata(metadata map[string]interface{}) (BuildpackMetadata, error)
NewBuildpackMetadata creates a new instance of BuildpackMetadata from the contents of libcnb.Buildpack.Metadata
type ConfigurationResolver ¶ added in v1.31.0
type ConfigurationResolver struct { // Configurations are the configurations to resolve against Configurations []BuildpackConfiguration }
ConfigurationResolver provides functionality for resolving a configuration value.
func NewConfigurationResolver ¶ added in v1.31.0
func NewConfigurationResolver(buildpack libcnb.Buildpack, logger *bard.Logger) (ConfigurationResolver, error)
NewConfigurationResolver creates a new instance from buildpack metadata. Logs configuration options to the body level int the form 'Set $Name to configure $Description[. Default <i>$Default</i>.]'.
func (*ConfigurationResolver) Resolve ¶ added in v1.31.0
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 ¶ added in v1.54.0
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 DependenciesFormatter ¶
type DependenciesFormatter []BuildpackDependency
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 buildpack 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 bard.Logger // UserAgent is the User-Agent string to use with requests. UserAgent string // Mappings optionally provides URIs mapping for BuildpackDependencies 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 buildpack's cache, a previous download, or to download directly.
func NewDependencyCache ¶
func NewDependencyCache(context libcnb.BuildContext) (DependencyCache, error)
NewDependencyCache creates a new instance setting the default cache path (<BUILDPACK_PATH>/dependencies) and user agent (<BUILDPACK_ID>/<BUILDPACK_VERSION>). Mappings will be read from any libcnb.Binding in the context with type "dependency-mappings"
func (*DependencyCache) Artifact ¶
func (d *DependencyCache) Artifact(dependency BuildpackDependency, 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 BuildpackDependency // 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 bard.Logger // RequestModifierFuncs is an optional Request Modifier to use when downloading the dependency. RequestModifierFuncs []RequestModifierFunc }
DependencyLayerContributor is a helper for implementing a libcnb.LayerContributor for a BuildpackDependency in order to get consistent logging and avoidance.
func NewDependencyLayer
deprecated
added in
v1.51.0
func NewDependencyLayer(dependency BuildpackDependency, cache DependencyCache, types libcnb.LayerTypes) (DependencyLayerContributor, libcnb.BOMEntry)
NewDependencyLayer returns a new DependencyLayerContributor for the given BuildpackDependency and a BOMEntry describing the layer contents.
Deprecated: this method uses `libcnb.BOMEntry` which has been deprecated upstream, a future version will drop support for `libcnb.BOMEntry` which will change this method signature. Use NewDependencyLayerContributor instead.
func NewDependencyLayerContributor ¶
func NewDependencyLayerContributor(dependency BuildpackDependency, cache DependencyCache, types libcnb.LayerTypes) DependencyLayerContributor
NewDependencyLayerContributor returns a new DependencyLayerContributor for the given BuildpackDependency
func (*DependencyLayerContributor) Contribute ¶
func (d *DependencyLayerContributor) Contribute(layer libcnb.Layer, f DependencyLayerFunc) (libcnb.Layer, error)
Contribute is the function to call whe implementing your libcnb.LayerContributor.
func (*DependencyLayerContributor) LayerName ¶ added in v1.40.0
func (d *DependencyLayerContributor) LayerName() string
LayerName returns the conventional name of the layer for this contributor
func (*DependencyLayerContributor) Name ¶ added in v1.51.0
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 []BuildpackDependency // StackID is the stack id of the build. StackID string // Logger is the logger used to write to the console. Logger *bard.Logger }
DependencyResolver provides functionality for resolving a dependency given a collection of constraints.
func NewDependencyResolver ¶
func NewDependencyResolver(context libcnb.BuildContext) (DependencyResolver, error)
NewDependencyResolver creates a new instance from the buildpack metadata and stack id.
func (*DependencyResolver) Resolve ¶
func (d *DependencyResolver) Resolve(id string, version string) (BuildpackDependency, 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 bard.Logger // Names are the names of the helpers to create Names []string }
HelperLayerContributor is a helper for implementing a libcnb.LayerContributor for a buildpack helper application in order to get consistent logging and avoidance.
func NewHelperLayer
deprecated
added in
v1.51.0
func NewHelperLayer(buildpack libcnb.Buildpack, names ...string) (HelperLayerContributor, libcnb.BOMEntry)
NewHelperLayer returns a new HelperLayerContributor and a BOMEntry describing the layer contents.
Deprecated: this method uses `libcnb.BOMEntry` which has been deprecated upstream, a future version will drop support for `libcnb.BOMEntry` which will change this method signature. Use NewHelperLayerContributor instead.
func NewHelperLayerContributor ¶
func NewHelperLayerContributor(buildpack libcnb.Buildpack, names ...string) HelperLayerContributor
NewHelperLayerContributor returns a new HelperLayerContributor
func (HelperLayerContributor) AsSyftArtifact ¶ added in v1.56.0
func (h HelperLayerContributor) AsSyftArtifact() (sbom.SyftArtifact, error)
func (HelperLayerContributor) Contribute ¶
Contribute is the function to call whe implementing your libcnb.LayerContributor.
func (HelperLayerContributor) Name ¶ added in v1.41.0
func (h HelperLayerContributor) Name() string
Name returns the conventional name of the layer for this contributor
type HttpClientTimeouts ¶ added in v1.66.0
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 bard.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 a libcnb.LayerContributor in order to get consistent logging and avoidance.
func NewLayerContributor ¶
func NewLayerContributor(name string, expectedMetadata interface{}, expectedTypes libcnb.LayerTypes) LayerContributor
NewLayerContributor creates a new instance.
func (*LayerContributor) Contribute ¶
Contribute is the function to call when implementing your libcnb.LayerContributor.
type LayerFunc ¶
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.