godist

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

Go Distribution Cloud Native Buildpack

The Go Distribution 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 Distribution 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

    # Setting the launch flag to true will ensure that the Go
    # dependency is available on the $PATH for the running application. If you are
    # writing an application that needs to run Go at runtime, this flag should
    # be set to true.
    launch = 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.

Go Build Configuration

Specifying the Go Dist configuration through buildpack.yml configuration will be deprecated in Go Build Buildpack v1.0.0.

To migrate from using buildpack.yml please set the following environment variables at build time either directly (ex. pack build my-app --env BP_ENVIRONMENT_VARIABLE=some-value) or through a project.toml file

BP_GO_VERSION

The BP_GO_VERSION variable allows you to specify the version of Go that is installed.

BP_GO_VERSION=1.14.1

This will replace the following structure in buildpack.yml:

go:
  version: 1.14.1

Documentation

Index

Constants

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

Variables

View Source
var Priorities = []interface{}{
	"BP_GO_VERSION",
	"buildpack.yml",
	"go.mod",
}

Functions

func Build

func Build(entryResolver EntryResolver, dependencyManager DependencyManager, clock chronos.Clock, logs GoLogger) 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"`
	Version       string `toml:"version"`
}

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)
	Deliver(dependency postal.Dependency, cnbPath, layerPath, platformPath string) error
	GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry
}

type EntryResolver

type EntryResolver interface {
	Resolve(name string, entries []packit.BuildpackPlanEntry, priorites []interface{}) (packit.BuildpackPlanEntry, []packit.BuildpackPlanEntry)
	MergeLayerTypes(name string, entries []packit.BuildpackPlanEntry) (launch, build bool)
}

type GoLogger added in v0.4.0

type GoLogger struct {
	scribe.Emitter
}

func NewGoLogger added in v0.4.0

func NewGoLogger(emitter scribe.Emitter) GoLogger

func (GoLogger) WarnBuildpackYML added in v0.4.0

func (gl GoLogger) WarnBuildpackYML(buildpackVersion string)

type VersionParser

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

Directories

Path Synopsis
dependency
retrieval module

Jump to

Keyboard shortcuts

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