libjavabuildpack

package module
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

README

libjavabuildpack

libjavabuildpack is a Go library with useful functionality for building Java Buildpack-related buildpacks.

License

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

Documentation

Overview

Package libjavabuildpack contains types and functions for implementing a Java Buildpack-related buildpack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDirectory added in v1.11.0

func CopyDirectory(srcDir, destDir string) error

CopyDirectory copies srcDir to destDir

func CopyFile

func CopyFile(source, destFile string) error

CopyFile copies source file to destFile, creating all intermediate directories in destFile

func ExtractTarGz

func ExtractTarGz(tarFile, destDir string, stripComponents int) error

ExtractTarGz extracts tarfile to destDir

func ExtractZip

func ExtractZip(zipfile, destDir string, stripComponents int) error

ExtractZip extracts zipfile to destDir

func FileExists

func FileExists(file string) (bool, error)

FileExists returns true if a file exists, otherwise false.

func FromTomlFile

func FromTomlFile(file string, v interface{}) error

FromTomlFile decodes a TOML file into a struct.

func WriteToFile

func WriteToFile(source io.Reader, destFile string, mode os.FileMode) error

WriteToFile writes the contents of an io.Reader to a file.

Types

type Build

type Build struct {
	libbuildpack.Build

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

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

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

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

Build is an extension to libbuildpack.Build that allows additional functionality to be added.

func DefaultBuild

func DefaultBuild() (Build, error)

DefaultBuild creates a new instance of Build using default values.

func (Build) String

func (b Build) String() string

String makes Build satisfy the Stringer interface.

type Buildpack

type Buildpack struct {
	libbuildpack.Buildpack

	// CacheRoot is the path to the root directory for the buildpack's dependency cache.
	CacheRoot string
}

Buildpack is an extension to libbuildpack.Buildpack that adds additional opinionated behaviors.

func NewBuildpack added in v1.1.0

func NewBuildpack(buildpack libbuildpack.Buildpack) Buildpack

NewBuildpack creates a new instance of Buildpack from a specified libbuildpack.Buildpack.

func (Buildpack) Dependencies

func (b Buildpack) Dependencies() (Dependencies, error)

Dependencies returns the collection of dependencies extracted from the generic buildpack metadata.

func (Buildpack) IncludeFiles

func (b Buildpack) IncludeFiles() ([]string, error)

IncludeFiles returns the include_files buildpack metadata.

func (Buildpack) PrePackage

func (b Buildpack) PrePackage() (string, bool)

PrePackage returns the pre_package buildpack metadata.

type Cache

type Cache struct {
	libbuildpack.Cache

	// BuildpackCacheRoot is the path to the root directory for the buildpack's dependency cache.
	BuildpackCacheRoot string

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

Cache is an extension to libbuildpack.Cache that allows additional functionality to be added.

func (Cache) DependencyLayer

func (c Cache) DependencyLayer(dependency Dependency) DependencyCacheLayer

DependencyLayer returns a DependencyCacheLayer unique to a dependency.

func (Cache) DownloadLayer

func (c Cache) DownloadLayer(dependency Dependency) DownloadCacheLayer

DownloadLayer returns a DownloadCacheLayer unique to a dependency.

func (Cache) String

func (c Cache) String() string

String makes Cache satisfy the Stringer interface.

type CacheContributor

type CacheContributor func(artifact string, layer DependencyCacheLayer) error

CacheContributor defines a callback function that is called when a dependency needs to be contributed.

type Dependencies

type Dependencies []Dependency

Dependencies is a collection of Dependency instances.

func (Dependencies) Best

func (d Dependencies) Best(id string, versionConstraint string, stack string) (Dependency, error)

Best returns the best (latest version) dependency within a collection of Dependencies. The candidate set is first filtered by id, version, and stack, then the remaining candidates are sorted for the best result. If the versionConstraint is not specified (""), then the latest wildcard ("*") is used.

func (Dependencies) Len

func (d Dependencies) Len() int

Len makes Dependencies satisfy the sort.Interface interface.

func (Dependencies) Less

func (d Dependencies) Less(i int, j int) bool

Less makes Dependencies satisfy the sort.Interface interface.

func (Dependencies) Swap

func (d Dependencies) Swap(i int, j int)

Swap makes Dependencies satisfy the sort.Interface interface.

type Dependency

type Dependency struct {
	// ID is the dependency ID.
	ID string `toml:"id"`

	// Name is the dependency ID.
	Name string `toml:"name"`

	// Version is the dependency version.
	Version Version `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 Stacks `toml:"stacks"`

	// Licenses are the stacks the dependency is distributed under.
	Licenses Licenses `toml:"licenses"`
}

Dependency represents a buildpack dependency.

func (Dependency) String

func (d Dependency) String() string

String makes Dependency satisfy the Stringer interface.

type DependencyCacheLayer

type DependencyCacheLayer struct {
	libbuildpack.CacheLayer

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

DependencyCacheLayer is an extension to CacheLayer that is unique to a dependency contribution.

func (DependencyCacheLayer) AppendEnv added in v1.9.0

func (d DependencyCacheLayer) 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 (DependencyCacheLayer) AppendPathEnv added in v1.9.0

func (d DependencyCacheLayer) 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 (DependencyCacheLayer) Contribute

func (d DependencyCacheLayer) Contribute(contributor CacheContributor) error

Contribute contributes an artifact to a cache layer. If the artifact has already been contributed, the cache will be validated and used directly.

func (DependencyCacheLayer) OverrideEnv added in v1.9.0

func (d DependencyCacheLayer) OverrideEnv(name string, format string, args ...interface{}) error

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

func (DependencyCacheLayer) String

func (d DependencyCacheLayer) String() string

String makes DependencyCacheLayer satisfy the Stringer interface.

type DependencyLaunchLayer

type DependencyLaunchLayer struct {
	libbuildpack.LaunchLayer

	// Dependency is the dependency provided by this layer
	Dependency Dependency

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

DependencyLaunchLayer is an extension to LaunchLayer that is unique to a dependency.

func (DependencyLaunchLayer) ArtifactName

func (d DependencyLaunchLayer) ArtifactName() string

ArtifactName returns the name portion of the download path for the dependency.

func (DependencyLaunchLayer) Contribute

func (d DependencyLaunchLayer) Contribute(contributor LaunchContributor) error

Contribute facilitates custom contribution of an artifact to a launch layer. If the artifact has already been contributed, the contribution is validated and the contributor is not called.

func (DependencyLaunchLayer) String

func (d DependencyLaunchLayer) String() string

String makes DependencyLaunchLayer satisfy the Stringer interface.

func (DependencyLaunchLayer) WriteProfile added in v1.9.0

func (d DependencyLaunchLayer) WriteProfile(file string, format string, args ...interface{}) error

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

type Detect

type Detect struct {
	libbuildpack.Detect

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

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

Detect is an extension to libbuildpack.Detect that allows additional functionality to be added.

func DefaultDetect

func DefaultDetect() (Detect, error)

DefaultDetect creates a new instance of Detect using default values.

func (Detect) String

func (d Detect) String() string

String makes Detect satisfy the Stringer interface.

type DownloadCacheLayer

type DownloadCacheLayer struct {
	libbuildpack.CacheLayer

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

DownloadCacheLayer is an extension to CacheLayer that is unique to a dependency download.

func (DownloadCacheLayer) Artifact

func (d DownloadCacheLayer) Artifact() (string, error)

Artifact returns the path to an artifact cached in the layer. If the artifact has already been downloaded, the cache will be validated and used directly.

func (DownloadCacheLayer) Metadata

func (d DownloadCacheLayer) Metadata(root string) string

Metadata returns the path to the metadata file for an artifact cached in the later.

func (DownloadCacheLayer) String

func (d DownloadCacheLayer) String() string

String makes DownloadCacheLayer satisfy the Stringer interface.

type Launch

type Launch struct {
	libbuildpack.Launch

	// Cache is the Cache to use to acquire dependencies.
	Cache Cache

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

Launch is an extension to libbuildpack.Launch that allows additional functionality to be added.

func (Launch) DependencyLayer

func (l Launch) DependencyLayer(dependency Dependency) DependencyLaunchLayer

DependencyLayer returns a DependencyLaunchLayer unique to a dependency.

func (Launch) String

func (l Launch) String() string

String makes Launch satisfy the Stringer interface.

func (Launch) WriteMetadata added in v1.3.0

func (l Launch) WriteMetadata(metadata libbuildpack.LaunchMetadata) error

WriteMetadata writes Launch metadata to the filesystem.

type LaunchContributor

type LaunchContributor func(artifact string, layer DependencyLaunchLayer) error

LaunchContributor defines a callback function that is called when a dependency needs to be contributed.

type License added in v1.4.0

type License 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"`
}

License represents a license that a Dependency is distributed under. At least one of Name or URI MUST be specified.

type Licenses added in v1.4.0

type Licenses []License

Licenses is a collection of licenses

type Logger

type Logger struct {
	libbuildpack.Logger
}

Logger is an extension to libbuildpack.Logger to add additional functionality.

func (Logger) FirstLine

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

FirstLine prints the log messages with the first line eye catcher.

func (Logger) PrettyVersion

func (l Logger) PrettyVersion(v interface{}) string

PrettyVersion formats a standard pretty version of a dependency.

func (Logger) String

func (l Logger) String() string

String makes Logger satisfy the Stringer interface.

func (Logger) SubsequentLine

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

SubsequentLine prints log message with the subsequent line indent.

type Packager

type Packager struct {
	Buildpack Buildpack
	Cache     Cache
	Logger    Logger
}

Packager is a root element for packaging up a buildpack

func DefaultPackager

func DefaultPackager() (Packager, error)

DefaultPackager creates a new Packager, using the executable to find the root of the buildpack.

func (Packager) Create

func (p Packager) Create() error

Create creates a new buildpack package.

type Stacks

type Stacks []string

Stacks is a collection of stack ids

type Version

type Version struct {
	*semver.Version
}

func (Version) MarshalText

func (v Version) MarshalText() ([]byte, error)

MarshalText makes Version satisfy the encoding.TextMarshaler interface.

func (*Version) UnmarshalText

func (v *Version) UnmarshalText(text []byte) error

UnmarshalText makes Version satisfy the encoding.TextUnmarshaler interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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