Documentation ¶
Index ¶
- Constants
- func Build(builder libcnb.Builder, options ...libcnb.Option)
- func Detect(detector libcnb.Detector, options ...libcnb.Option)
- func IsNoValidDependencies(err error) bool
- func Main(detector libcnb.Detector, builder libcnb.Builder, options ...libcnb.Option)
- func ShallowMerge(a, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error)
- type BindingResolver
- type BuildpackConfiguration
- type BuildpackDependency
- type BuildpackDependencyLicense
- type BuildpackMetadata
- type ConfigurationResolver
- type DependenciesFormatter
- type DependencyCache
- type DependencyLayerContributor
- type DependencyLayerFunc
- type DependencyResolver
- type HelperLayerContributor
- type HelperLayerFunc
- 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" // TinyStackID is the ID for the Paketo Buildpacks tiny stack. TinyStackID = "io.paketo.stacks.tiny" )
Variables ¶
This section is empty.
Functions ¶
func IsNoValidDependencies ¶ added in v1.15.0
IsNoValidDependencies indicates whether an error is a NoValidDependenciesError.
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 BindingResolver ¶
type BindingResolver struct { // Bindings are the bindings to resolve against. Bindings libcnb.Bindings }
BindingResolver provides functionality for resolving a binding given a collection of constraints.
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 stacks the dependency is distributed under. Licenses []BuildpackDependencyLicense `toml:"licenses"` }
BuildpackDependency describes a dependency known to the buildpack.
func (BuildpackDependency) AsBuildpackPlanEntry ¶ added in v1.21.0
func (b BuildpackDependency) AsBuildpackPlanEntry() libcnb.BuildpackPlanEntry
AsBuildpackPlanEntry renders the dependency as a BuildpackPlanEntry.
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>.]'.
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 }
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(buildpack libcnb.Buildpack) DependencyCache
NewDependencyCache creates a new instance setting the default cache path (<BUILDPACK_PATH>/dependencies) and user agent (<BUILDPACK_ID>/<BUILDPACK_VERSION>).
func (*DependencyCache) Artifact ¶
func (d *DependencyCache) Artifact(dependency BuildpackDependency) (*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.
func (*DependencyCache) ArtifactWithRequestModification ¶ added in v1.25.0
func (d *DependencyCache) ArtifactWithRequestModification(dependency BuildpackDependency, f RequestModifierFunc) (*os.File, error)
ArtifactWithRequestModification 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 // LayerContributor is the contained LayerContributor used for the actual contribution. LayerContributor LayerContributor // Logger is the logger to use. Logger bard.Logger // RequestModifierFunc is an optional Request Modifier to use when downloading the dependency. RequestModifierFunc RequestModifierFunc }
DependencyLayerContributor is a helper for implementing a libcnb.LayerContributor for a BuildpackDependency in order to get consistent logging and avoidance.
func NewDependencyLayerContributor ¶
func NewDependencyLayerContributor(dependency BuildpackDependency, cache DependencyCache, plan *libcnb.BuildpackPlan) DependencyLayerContributor
NewDependencyLayerContributor creates a new instance and adds the dependency to the Buildpack Plan.
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.
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 }
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 // LayerContributor is the contained LayerContributor used for the actual contribution. LayerContributor LayerContributor // Logger is the logger to use. Logger bard.Logger }
HelperLayerContributor is a helper for implementing a libcnb.LayerContributor for a buildpack helper application in order to get consistent logging and avoidance.
func NewHelperLayerContributor ¶
func NewHelperLayerContributor(path string, name string, info libcnb.BuildpackInfo, plan *libcnb.BuildpackPlan) HelperLayerContributor
NewHelperLayerContributor creates a new instance and adds the helper to the Buildpack Plan.
func (*HelperLayerContributor) Contribute ¶
func (h *HelperLayerContributor) Contribute(layer libcnb.Layer, f HelperLayerFunc) (libcnb.Layer, error)
Contribute is the function to call whe implementing your libcnb.LayerContributor.
type HelperLayerFunc ¶
DependencyLayerFunc is a callback function that is invoked when a helper needs to be contributed.
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 }
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{}) 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.