buildpack

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package buildpack encapsulate downloading and running of Heroku buildpacks as described by the Buildpack API

See: https://devcenter.heroku.com/articles/buildpack-api

Index

Constants

View Source
const (
	// AppDir is the path relative to the build directory where the source to
	// be built is stored.
	AppDir = "app"

	// EnvironmentDir is the path relative to the build directory where the
	// environment/config variables are stored.
	EnvironmentDir = "environment"

	// BuildpacksDir is the path relative to the build directory where
	// buildpacks are stored and downloaded to.
	BuildpacksDir = "buildpacks"
)

Variables

This section is empty.

Functions

func Untargz added in v0.0.9

func Untargz(r io.Reader, dir string, unnest bool) error

Untargz extracts a GZipped Tarball into dir.

If unnest is true, during extraction the root directory of every filepath being extracted is skipped.

TODO: should this accept a context so we can cancel?

Types

type Build

type Build struct {
	BuildDir      string
	CacheDir      string
	Stack         string
	SourceVersion string
	Stdout        io.Writer
	Stderr        io.Writer
}

Build contains the information required to run a series of buildpacks.

type Buildpack

type Buildpack struct {
	URL       string `json:"url"`
	Directory string `json:"directory"`
}

Buildpack describes a buildpack that has been downloaded to the local filesystem.

func (*Buildpack) Compile

func (b *Buildpack) Compile(ctx context.Context, exports []*Buildpack, build *Build) error

Compile applies the buildpack to the current application.

It calls Export() on all previous buildpacks, to ensure any required setup is propagated between buildpacks.

See: https://devcenter.heroku.com/articles/buildpack-api#bin-compile

func (*Buildpack) Detect

func (b *Buildpack) Detect(ctx context.Context, build *Build) (string, bool, error)

Detect determines whether the buildpack can be applied to the current application.

It is expected that slug compilation fail if any configured buildpack cannot be applied to the current application.

See: https://devcenter.heroku.com/articles/buildpack-api#bin-detect

func (*Buildpack) Export

func (b *Buildpack) Export(_ context.Context, build *Build) (string, bool, error)

Export returns the path to the export file for the given buildpack, to be sourced by subsequent buildpacks, if it exists.

See: https://devcenter.heroku.com/articles/buildpack-api#composing-multiple-buildpacks

type Source

type Source interface {
	Download(ctx context.Context, baseDir string) (*Buildpack, error)
	Dir() string
}

Source described the interface for a buildpack source.

func ParseSource

func ParseSource(url string) (Source, error)

ParseSource parses and returns an appropriate Source for the given buildpack URL.

It currently supports official buildpack URLS of form `urn:buildpack:foo/bar` and GitHub repository URLs.

All other URLs are defaulted to being a generic URL to some GZipped Tar archive.

It does not support arbitrary .git URLs.

type TargzSource added in v0.0.8

type TargzSource struct {
	RawURL string
	URL    string
	// contains filtered or unexported fields
}

TargzSource implements Source for GZipped Tar buildpack archives.

It has custom support for GitHub hosted repositories and their nested tarball format.

func (*TargzSource) Dir added in v0.0.8

func (s *TargzSource) Dir() string

Dir returns the directory name for the buildpack being downloaded.

func (*TargzSource) Download added in v0.0.8

func (s *TargzSource) Download(ctx context.Context, baseDir string) (*Buildpack, error)

Download downloads a GZipped Tar buildpack from the configured URL into Dir() relative to baseDir.

Jump to

Keyboard shortcuts

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