buildpack

package
v0.27.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataLabel = "io.buildpacks.buildpackage.metadata"

TODO: Move to dist

Variables

This section is empty.

Functions

func BuildpacksFromOCILayoutBlob

func BuildpacksFromOCILayoutBlob(blob Blob) (mainBP Buildpack, dependencies []Buildpack, err error)

BuildpackFromOCILayoutBlob constructs buildpacks from a blob in OCI layout format.

func ConfigFromOCILayoutBlob

func ConfigFromOCILayoutBlob(blob Blob) (config v1.ImageConfig, err error)

func ExtractBuildpacks

func ExtractBuildpacks(pkg Package) (mainBP Buildpack, depBPs []Buildpack, err error)

func HasDockerLocator

func HasDockerLocator(locator string) bool

func IsOCILayoutBlob

func IsOCILayoutBlob(blob blob2.Blob) (bool, error)

IsOCILayoutBlob checks whether a blob is in OCI layout format.

func NewDownloader

func NewDownloader(logger Logger, imageFetcher ImageFetcher, downloader Downloader, registryResolver RegistryResolver) *buildpackDownloader

func ParseIDLocator

func ParseIDLocator(locator string) (id string, version string)

ParseIDLocator parses a buildpack locator in the following formats into its ID and version.

  • <id>[@<version>]
  • urn:cnb:builder:<id>[@<version>]
  • urn:cnb:registry:<id>[@<version>]
  • from=builder:<id>[@<version>] (deprecated)

If version is omitted, the version returned will be empty. Any "from=builder:" or "urn:cnb" prefix will be ignored.

func ParsePackageLocator

func ParsePackageLocator(locator string) (imageName string)

ParsePackageLocator parses a locator (in format `[docker://][<host>/]<path>[:<tag>⏐@<digest>]`) to image name (`[<host>/]<path>[:<tag>⏐@<digest>]`)

func ParseRegistryID

func ParseRegistryID(registryID string) (namespace string, name string, version string, err error)

ParseRegistryID parses a registry id (ie. `<namespace>/<name>@<version>`) into namespace, name and version components.

Supported formats:

  • <ns>/<name>[@<version>]
  • urn:cnb:registry:<ns>/<name>[@<version>]

func ToLayerTar

func ToLayerTar(dest string, bp Buildpack) (string, error)

Types

type Blob

type Blob interface {
	// Open returns a io.ReadCloser for the contents of the Blob in tar format.
	Open() (io.ReadCloser, error)
}

type Buildpack

type Buildpack interface {
	// Open returns a reader to a tar with contents structured as per the distribution spec
	// (currently '/cnbs/buildpacks/{ID}/{version}/*', all entries with a zeroed-out
	// timestamp and root UID/GID).
	Open() (io.ReadCloser, error)
	Descriptor() dist.BuildpackDescriptor
}

func FromBlob

func FromBlob(bpd dist.BuildpackDescriptor, blob Blob) Buildpack

FromBlob constructs a buildpack from a blob. It is assumed that the buildpack contents are structured as per the distribution spec (currently '/cnbs/buildpacks/{ID}/{version}/*').

func FromRootBlob

func FromRootBlob(blob Blob, layerWriterFactory archive.TarWriterFactory) (Buildpack, error)

FromRootBlob constructs a buildpack from a blob. It is assumed that the buildpack contents reside at the root of the blob. The constructed buildpack contents will be structured as per the distribution spec (currently a tar with contents under '/cnbs/buildpacks/{ID}/{version}/*').

type DownloadOptions

type DownloadOptions struct {
	// Buildpack registry name. Defines where all registry buildpacks will be pulled from.
	RegistryName string

	// The base directory to use to resolve relative assets
	RelativeBaseDir string

	// The OS of the builder image
	ImageOS string

	// Deprecated: the older alternative to buildpack URI
	ImageName string

	Daemon bool

	PullPolicy image.PullPolicy
}

type Downloader

type Downloader interface {
	Download(ctx context.Context, pathOrURI string) (blob.Blob, error)
}

type ImageFactory

type ImageFactory interface {
	NewImage(repoName string, local bool, imageOS string) (imgutil.Image, error)
}

type ImageFetcher

type ImageFetcher interface {
	Fetch(ctx context.Context, name string, options image.FetchOptions) (imgutil.Image, error)
}

type LocatorType

type LocatorType int
const (
	InvalidLocator LocatorType = iota
	FromBuilderLocator
	URILocator
	IDLocator
	PackageLocator
	RegistryLocator
)

func GetLocatorType

func GetLocatorType(locator string, relativeBaseDir string, buildpacksFromBuilder []dist.BuildpackInfo) (LocatorType, error)

GetLocatorType determines which type of locator is designated by the given input. If a type cannot be determined, `INVALID_LOCATOR` will be returned. If an error is encountered, it will be returned.

func (LocatorType) String

func (l LocatorType) String() string

type Logger

type Logger interface {
	Debug(msg string)
	Debugf(fmt string, v ...interface{})
	Info(msg string)
	Infof(fmt string, v ...interface{})
	Warn(msg string)
	Warnf(fmt string, v ...interface{})
	Error(msg string)
	Errorf(fmt string, v ...interface{})
}

type Metadata

type Metadata struct {
	dist.BuildpackInfo
	Stacks []dist.Stack `toml:"stacks" json:"stacks"`
}

type Package

type Package interface {
	Label(name string) (value string, err error)
	GetLayer(diffID string) (io.ReadCloser, error)
}

type PackageBuilder

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

func NewBuilder

func NewBuilder(imageFactory ImageFactory) *PackageBuilder

TODO: Rename to PackageBuilder

func (*PackageBuilder) AddDependency

func (b *PackageBuilder) AddDependency(buildpack Buildpack)

func (*PackageBuilder) SaveAsFile

func (b *PackageBuilder) SaveAsFile(path, imageOS string) error

func (*PackageBuilder) SaveAsImage

func (b *PackageBuilder) SaveAsImage(repoName string, publish bool, imageOS string) (imgutil.Image, error)

func (*PackageBuilder) SetBuildpack

func (b *PackageBuilder) SetBuildpack(buildpack Buildpack)

type RegistryResolver

type RegistryResolver interface {
	Resolve(registryName, bpURI string) (string, error)
}

type WorkableImage

type WorkableImage interface {
	SetLabel(string, string) error
	AddLayerWithDiffID(path, diffID string) error
}

Jump to

Keyboard shortcuts

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