gocompiler

package module
v0.0.168 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

Go Compiler Cloud Native Buildpack

The Go Compiler CNB provides the Go binary distribution that can be used to execute Go tooling. The buildpack installs the Go binary distribution onto the $PATH which makes it available for subsequent buildpacks. These buildpacks can then use that distribution to run Go tooling including building Go application binaries. Examples of buildpacks that perform this binary building process include the Go Mod CNB and the Dep CNB.

Integration

The Go Compiler CNB provides Go as a dependency. Downstream buildpacks, like Go Mod or Dep, can require the go dependency by generating a Build Plan TOML file that looks like the following:

[[requires]]

  # The name of the  dependency is "go". This value is considered
  # part of the public API for the buildpack and will not change without a plan
  # for deprecation.
  name = "go"

  # The version of the Go dependency is not required. In the case it
  # is not specified, the buildpack will provide the default version, which can
  # be seen in the buildpack.toml file.
  # If you wish to request a specific version, the buildpack supports
  # specifying a semver constraint in the form of "1.*", "1.13.*", or even
  # "1.13.9".
  version = "1.13.9"

  # The Go buildpack supports some non-required metadata options.
  [requires.metadata]

    # Setting the build flag to true will ensure that the Go
    # depdendency is available on the $PATH for subsequent buildpacks during
    # their build phase. If you are writing a buildpack that needs to run Go
    # during its build process, this flag should be set to true.
    build = true

Usage

To package this buildpack for consumption:

$ ./scripts/package.sh

This builds the buildpack's Go source using GOOS=linux by default. You can supply another value as the first argument to package.sh.

buildpack.yml Configurations

go:
  # this allows you to specify a version constaint for the Go dependency
  # any valid semver constaints (e.g. 1.* and 1.14.*) are also acceptable
  version: 1.14.1

Documentation

Index

Constants

View Source
const (
	DependencySHAKey = "dependency-sha"
	GoDependency     = "go"
	GoLayerName      = "go"
)

Variables

This section is empty.

Functions

func Build

func Build(entries EntryResolver, dependencies DependencyManager, planRefinery PlanRefinery, clock chronos.Clock, logs LogEmitter) packit.BuildFunc

func Detect

func Detect(buildpackYAMLParser VersionParser) packit.DetectFunc

Types

type BuildPlanMetadata

type BuildPlanMetadata struct {
	VersionSource string `toml:"version-source"`
	Build         bool   `toml:"build"`
}

type BuildPlanRefinery

type BuildPlanRefinery struct{}

func NewBuildPlanRefinery

func NewBuildPlanRefinery() BuildPlanRefinery

func (BuildPlanRefinery) BillOfMaterials

func (r BuildPlanRefinery) BillOfMaterials(dependency postal.Dependency) packit.BuildpackPlanEntry

type BuildpackYAMLParser

type BuildpackYAMLParser struct{}

func NewBuildpackYAMLParser

func NewBuildpackYAMLParser() BuildpackYAMLParser

func (BuildpackYAMLParser) ParseVersion

func (p BuildpackYAMLParser) ParseVersion(path string) (string, error)

type DependencyManager

type DependencyManager interface {
	Resolve(path, id, version, stack string) (postal.Dependency, error)
	Install(dependency postal.Dependency, cnbPath, layerPath string) error
}

type EntryResolver

type EntryResolver interface {
	Resolve([]packit.BuildpackPlanEntry) packit.BuildpackPlanEntry
}

type LogEmitter

type LogEmitter struct {
	scribe.Logger
}

func NewLogEmitter

func NewLogEmitter(output io.Writer) LogEmitter

func (LogEmitter) Candidates

func (l LogEmitter) Candidates(entries []packit.BuildpackPlanEntry)

func (LogEmitter) SelectedDependency

func (l LogEmitter) SelectedDependency(entry packit.BuildpackPlanEntry, dependency postal.Dependency, now time.Time)

func (LogEmitter) Title

func (l LogEmitter) Title(info packit.BuildpackInfo)

type PlanEntryResolver

type PlanEntryResolver struct{}

func NewPlanEntryResolver

func NewPlanEntryResolver() PlanEntryResolver

func (PlanEntryResolver) Resolve

type PlanRefinery

type PlanRefinery interface {
	BillOfMaterials(postal.Dependency) packit.BuildpackPlanEntry
}

type VersionParser

type VersionParser interface {
	ParseVersion(path string) (version string, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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