libbuildpack

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

README

libbuildpack

libbuildpack is a Go language binding of the Cloud Native Buildpack V3 API. It is a non-opinionated implementation adding language constructs and convenience methods for working with the API.

License

This library is released under version 2.0 of the Apache License.

Documentation

Overview

Package libbuildpack contains types and functions for implementing a Buildpack V3 compliant buildpack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultStack

func DefaultStack(logger Logger) (string, error)

DefaultStack creates a new instance of Stack, extracting the name from the PACK_STACK_ID environment variable.

Types

type Application

type Application struct {
	// Root is the path to the root directory of the application.
	Root string

	// Logger is used to write debug and info to the console.
	Logger Logger
}

Application represents the application being processed by buildpacks.

func DefaultApplication

func DefaultApplication(logger Logger) (Application, error)

DefaultApplication creates a new instance of Application, extracting the Root path from the working directory.

func NewApplication

func NewApplication(root string, logger Logger) Application

NewApplication creates a new instance of Application, configuring the Root path.

func (Application) String

func (a Application) String() string

String makes Application satisfy the Stringer interface.

type Build

type Build struct {
	// Application is the application being processed by the buildpack.
	Application Application

	// Buildpack represents the metadata associated with a buildpack.
	Buildpack Buildpack

	// BuildPlan represents dependencies contributed by previous builds.
	BuildPlan BuildPlan

	// Cache represents the cache layers contributed by a buildpack.
	Cache Cache

	// Launch represents the launch layers contributed by a buildpack.
	Launch Launch

	// Logger is used to write debug and info to the console.
	Logger Logger

	// Platform represents components contributed by the platform to the buildpack.
	Platform Platform

	// Stack is the stack currently available to the application.
	Stack string
}

Build represents all of the components available to a buildpack at build time.

func DefaultBuild

func DefaultBuild() (Build, error)

DefaultBuild creates a new instance of Build using default values.

func (Build) Failure

func (b Build) Failure(code int)

Failure signals an unsuccessful build by exiting with a specified positive status code. This should be the final function called in building.

func (Build) String

func (b Build) String() string

String makes Build satisfy the Stringer interface.

func (Build) Success

func (b Build) Success()

Success signals a successful build by exiting with a zero status code. This should be the final function called in building.

type BuildImages

type BuildImages string

BuildImages is the build image source for a particular stack id.

type BuildPlan

type BuildPlan map[string]BuildPlanDependency

BuildPlan represents the dependencies contributed by a build.

func DefaultBuildPlan

func DefaultBuildPlan(logger Logger) (BuildPlan, error)

DefaultBuildPlan creates a new instance of BuildPlan, extracting the contents from stdin.

func NewBuildPlan

func NewBuildPlan(in io.Reader, logger Logger) (BuildPlan, error)

NewBuildPlan creates a new instance of BuildPlan from a specified io.Reader. Returns an error if the contents of the Reader are not valid TOML.

func (BuildPlan) String

func (p BuildPlan) String() string

String makes BuildPlan satisfy the Stringer interface.

type BuildPlanDependency

type BuildPlanDependency struct {
	// Provider is the optional ID of the buildpack that will provide the dependency.
	Provider string `toml:"provider"`

	// Version is the optional dependency version.
	Version string `toml:"version"`

	// Metadata is additional metadata attached to the dependency.
	Metadata BuildPlanDependencyMetadata `toml:"metadata"`
}

BuildPlanDependency represents a dependency in a build.

func (BuildPlanDependency) String

func (d BuildPlanDependency) String() string

String makes BuildPlanDependency satisfy the Stringer interface.

type BuildPlanDependencyMetadata

type BuildPlanDependencyMetadata map[string]interface{}

BuildPlanDependencyMetadata is additional metadata attached to a dependency.

type Buildpack

type Buildpack struct {
	// Info is information about the buildpack.
	Info BuildpackInfo `toml:"buildpack"`

	// Stacks is the collection of stacks that the buildpack supports.
	Stacks []BuildpackStack `toml:"stacks"`

	// Metadata is the additional metadata included in the buildpack.
	Metadata BuildpackMetadata `toml:"metadata"`

	// Logger is used to write debug and info to the console.
	Logger Logger

	// Root is the path to the root directory for the buildpack.
	Root string
}

Buildpack represents the metadata associated with a buildpack.

func DefaultBuildpack

func DefaultBuildpack(logger Logger) (Buildpack, error)

DefaultBuildpack creates a new instance of Buildpack extracting the contents of the buildpack.toml file in the root of the buildpack.

func NewBuildpack

func NewBuildpack(in io.Reader, logger Logger, root string) (Buildpack, error)

NewBuildpack creates a new instance of Buildpack from a specified io.Reader. Returns an error if the contents of the reader are not valid TOML.

func (Buildpack) String

func (b Buildpack) String() string

String makes Buildpack satisfy the Stringer interface.

type BuildpackInfo

type BuildpackInfo struct {
	// ID is the globally unique identifier of the buildpack.
	ID string `toml:"id"`

	// Name is the human readable name of the buildpack.
	Name string `toml:"name"`

	// Version is the semver-compliant version of the buildpack.
	Version string `toml:"version"`
}

BuildpackInfo is information about the buildpack.

func (BuildpackInfo) String

func (b BuildpackInfo) String() string

String makes BuildpackInfo satisfy the Stringer interface.

type BuildpackMetadata

type BuildpackMetadata map[string]interface{}

BuildpackMetadata is additional metadata included in the buildpack

type BuildpackStack

type BuildpackStack struct {
	// ID is the globally unique identifier of the stack.
	ID string `toml:"id"`

	// BuildImages are the suggested sources for stacks if the platform is unaware of the stack id.
	BuildImages []BuildImages `toml:"build-images"`

	// RunImages are the suggested sources for stacks if the platform is unaware of the stack id.
	RunImages []RunImages `toml:"run-images"`
}

BuildpackStack represents metadata about the stacks associated with the buildpack.

func (BuildpackStack) String

func (b BuildpackStack) String() string

String makes BuildpackStack satisfy the Stringer interface.

type Cache

type Cache struct {
	// Root is the path to the root directory for the caches.
	Root string

	// Logger is used to write debug and info to the console.
	Logger Logger
}

Cache represents cache layers for an application.

func DefaultCache

func DefaultCache(logger Logger) (Cache, error)

DefaultCache creates a new instance of Cache, extracting the Root path from os.Args[2].

func (Cache) Layer

func (c Cache) Layer(name string) CacheLayer

Layer creates a CacheLayer with a specified name.

func (Cache) String

func (c Cache) String() string

String makes Cache satisfy the Stringer interface.

type CacheLayer

type CacheLayer struct {
	// Root is the path to the root directory for the cache layer.
	Root string

	// Logger is used to write debug and info to the console.
	Logger Logger
}

CacheLayer represents a cache layer for an application.

func (CacheLayer) AppendEnv

func (c CacheLayer) AppendEnv(name string, format string, args ...interface{}) error

AppendEnv appends the value of this environment variable to any previous declarations of the value without any delimitation. If delimitation is important during concatenation, callers are required to add it.

func (CacheLayer) AppendPathEnv

func (c CacheLayer) AppendPathEnv(name string, format string, args ...interface{}) error

AppendPathEnv appends the value of this environment variable to any previous declarations of the value using the OS path delimiter.

func (CacheLayer) OverrideEnv

func (c CacheLayer) OverrideEnv(name string, format string, args ...interface{}) error

Override overrides any existing value for an environment variable with this value.

func (CacheLayer) String

func (c CacheLayer) String() string

String makes CacheLayer satisfy the Stringer interface.

type Detect

type Detect struct {
	// Application is the application being processed by the buildpack.
	Application Application

	// Buildpack represents the metadata associated with a buildpack.
	Buildpack Buildpack

	// BuildPlan represents dependencies contributed by previous builds.
	BuildPlan BuildPlan

	// Logger is used to write debug and info to the console.
	Logger Logger

	// Stack is the stack currently available to the application.
	Stack string
}

Detect represents all of the components available to a buildpack at detect time.

func DefaultDetect

func DefaultDetect() (Detect, error)

DefaultDetect creates a new instance of Detect using default values.

func (Detect) Error

func (d Detect) Error(code int)

Error signals an error during detection by exiting with a specified non-zero, non-100 status code. This should the final function called in detection.

func (Detect) Fail

func (d Detect) Fail()

Fail signals an unsuccessful detection by exiting with a 100 status code. This should be the final function called in detection.

func (Detect) Pass

func (d Detect) Pass(buildPlan BuildPlan)

Pass signals a successful detection by exiting with a 0 status code. This should be the final function called in detection.

func (Detect) String

func (d Detect) String() string

String makes Detect satisfy the Stringer interface.

type EnvironmentVariable

type EnvironmentVariable struct {
	// Name is the name of the environment variable
	Name string
	// contains filtered or unexported fields
}

EnvironmentVariable represents an environment variable provided by the platform.

func (EnvironmentVariable) Set

func (e EnvironmentVariable) Set() error

Set sets the environment variable content in the current process environment.

func (EnvironmentVariable) String

func (e EnvironmentVariable) String() string

String makes EnvironmentVariable satisfy the Stringer interface.

type EnvironmentVariables

type EnvironmentVariables []EnvironmentVariable

EnvironmentVariables is a collection of EnvironmentVariable instances.

func (EnvironmentVariables) SetAll

func (e EnvironmentVariables) SetAll() error

SetAll sets all of the environment variable content in the current process environment.

type Launch

type Launch struct {
	// Root is the path to the root directory for the layers.
	Root string

	// Logger is used to write debug and info to the console.
	Logger Logger
}

Launch represents launch layers for an application.

func DefaultLaunch

func DefaultLaunch(logger Logger) (Launch, error)

DefaultLaunch creates a new instance of Launch, extracting the Root path from os.Args[3].

func (Launch) Layer

func (l Launch) Layer(name string) LaunchLayer

Layer creates a LaunchLayer with a specified name.

func (Launch) String

func (l Launch) String() string

String makes Launch satisfy the Stringer interface.

func (Launch) WriteMetadata

func (l Launch) WriteMetadata(metadata LaunchMetadata) error

WriteMetadata writes Launch metadata to the filesystem.

type LaunchLayer

type LaunchLayer struct {
	// Root is the path to the root directory for the launch layer.
	Root string

	// Logger is used to write debug and info to the console.
	Logger Logger
	// contains filtered or unexported fields
}

LaunchLayer represents a launch layer for an application.

func (LaunchLayer) ReadMetadata

func (l LaunchLayer) ReadMetadata(v interface{}) error

ReadMetadata reads arbitrary launch layer metadata from the filesystem.

func (LaunchLayer) String

func (l LaunchLayer) String() string

String makes LaunchLayer satisfy the Stringer interface.

func (LaunchLayer) WriteMetadata

func (l LaunchLayer) WriteMetadata(metadata interface{}) error

WriteMetadata writes arbitrary launch layer metadata to the filesystem.

func (LaunchLayer) WriteProfile

func (l LaunchLayer) WriteProfile(file string, format string, args ...interface{}) error

WriteProfile writes a file to profile.d with this value.

type LaunchMetadata

type LaunchMetadata struct {
	// Processes is a collection of processes.
	Processes Processes `toml:"processes"`
}

LaunchMetadata represents metadata about the Launch.

func (LaunchMetadata) String

func (l LaunchMetadata) String() string

String makes LaunchMetadata satisfy the Stringer interface.

type Logger

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

Logger is a type that contains references to the console output for debug and info logging levels.

func NewLogger

func NewLogger(debug io.Writer, info io.Writer) Logger

NewLogger creates a new instance of Logger, configuring the debug and info writers to use. If writer is nil, that logging level is disabled.

func (Logger) Debug

func (l Logger) Debug(format string, args ...interface{})

Debug prints output to the configured debug writer, interpolating the format and any arguments and adding a newline at the end. If debug logging is not enabled, nothing is printed.

func (Logger) Info

func (l Logger) Info(format string, args ...interface{})

Info prints output to the configured info writer, interpolating the format and any arguments and adding a newline at the end. If info logging is not enabled, nothing is printed.

func (Logger) IsDebugEnabled

func (l Logger) IsDebugEnabled() bool

IsDebugEnabled returns true if debug logging is enabled, false otherwise.

func (Logger) IsInfoEnabled

func (l Logger) IsInfoEnabled() bool

IsInfoEnabled returns true if info logging is enabled, false otherwise.

func (Logger) String

func (l Logger) String() string

String makes Logger satisfy the Stringer interface.

type Platform

type Platform struct {
	// Root is the path to the root directory for the platform contributions.
	Root string

	// Envs is the collection of environment variables contributed by the platform.
	Envs EnvironmentVariables

	// Logger is used to write debug and info to the console.
	Logger Logger
}

Platform represents the platform contributions for an application.

func DefaultPlatform

func DefaultPlatform(logger Logger) (Platform, error)

DefaultPlatform creates a new instance of Platform, extracting the Root path from os.Args[1].

func NewPlatform

func NewPlatform(root string, logger Logger) (Platform, error)

NewPlatform creates a new instance of Platform, configuring the Root path.

func (Platform) String

func (p Platform) String() string

String makes Platform satisfy the Stringer interface.

type Process

type Process struct {
	// Type is the type of the process.
	Type string `toml:"type"`

	// Command is the command of the process.
	Command string `toml:"command"`
}

Process represents metadata about a type of command that can be run.

func (Process) String

func (p Process) String() string

String makes Process satisfy the Stringer interface.

type Processes

type Processes []Process

Processes is a collection of Process instances.

type RunImages

type RunImages string

RunImages is the run image source for a particular stack id.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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