Help us shape the future of Go! Take the 2026 Go Developer Survey

platform

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 16 Imported by: 12

Documentation

Index

Constants

View Source
const (
	EnvAnalyzedPath        = "CNB_ANALYZED_PATH"
	EnvAppDir              = "CNB_APP_DIR"
	EnvBuildImage          = "CNB_BUILD_IMAGE"
	EnvBuildpacksDir       = "CNB_BUILDPACKS_DIR"
	EnvCacheDir            = "CNB_CACHE_DIR"
	EnvCacheImage          = "CNB_CACHE_IMAGE"
	EnvDeprecationMode     = "CNB_DEPRECATION_MODE"
	EnvExperimentalMode    = "CNB_EXPERIMENTAL_MODE"
	EnvExtensionsDir       = "CNB_EXTENSIONS_DIR"
	EnvGID                 = "CNB_GROUP_ID"
	EnvGeneratedDir        = "CNB_GENERATED_DIR"
	EnvGroupPath           = "CNB_GROUP_PATH"
	EnvKanikoCacheTTL      = "CNB_KANIKO_CACHE_TTL"
	EnvLaunchCacheDir      = "CNB_LAUNCH_CACHE_DIR"
	EnvLayersDir           = "CNB_LAYERS_DIR"
	EnvLogLevel            = "CNB_LOG_LEVEL"
	EnvNoColor             = "CNB_NO_COLOR" // defaults to false
	EnvOrderPath           = "CNB_ORDER_PATH"
	EnvPlanPath            = "CNB_PLAN_PATH"
	EnvPlatformAPI         = "CNB_PLATFORM_API"
	EnvPlatformDir         = "CNB_PLATFORM_DIR"
	EnvPreviousImage       = "CNB_PREVIOUS_IMAGE"
	EnvProcessType         = "CNB_PROCESS_TYPE"
	EnvProjectMetadataPath = "CNB_PROJECT_METADATA_PATH"
	EnvReportPath          = "CNB_REPORT_PATH"
	EnvRunImage            = "CNB_RUN_IMAGE"
	EnvSkipLayers          = "CNB_ANALYZE_SKIP_LAYERS" // defaults to false
	EnvSkipRestore         = "CNB_SKIP_RESTORE"        // defaults to false
	EnvStackPath           = "CNB_STACK_PATH"
	EnvUID                 = "CNB_USER_ID"
	EnvUseDaemon           = "CNB_USE_DAEMON" // defaults to false

	DefaultExperimentalMode = ModeError
	DefaultLogLevel         = "info"
	DefaultPlatformAPI      = "0.3"

	DefaultAnalyzedFile        = "analyzed.toml"
	DefaultGroupFile           = "group.toml"
	DefaultOrderFile           = "order.toml"
	DefaultPlanFile            = "plan.toml"
	DefaultProjectMetadataFile = "project-metadata.toml"
	DefaultReportFile          = "report.toml"

	ModeQuiet = "quiet"
	ModeWarn  = "warn"
	ModeError = "error"
)
View Source
const (
	BuildMetadataLabel   = "io.buildpacks.build.metadata"
	LayerMetadataLabel   = "io.buildpacks.lifecycle.metadata"
	ProjectMetadataLabel = "io.buildpacks.project.metadata"
	StackIDLabel         = "io.buildpacks.stack.id"
	MixinsLabel          = "io.buildpacks.stack.mixins"
)
View Source
const (
	CodeForFailed = 1
)
View Source
const (
	FeatureDockerfiles = "Dockerfiles"
)

Variables

View Source
var (
	DefaultAppDir         = filepath.Join(rootDir, "workspace")
	DefaultBuildpacksDir  = filepath.Join(rootDir, "cnb", "buildpacks")
	DefaultExtensionsDir  = filepath.Join(rootDir, "cnb", "extensions")
	DefaultKanikoCacheTTL = 14 * (24 * time.Hour)
	DefaultLauncherPath   = filepath.Join(rootDir, "cnb", "lifecycle", "launcher"+execExt)
	DefaultLayersDir      = filepath.Join(rootDir, "layers")
	DefaultOutputDir      = filepath.Join(rootDir, "layers")
	DefaultPlatformDir    = filepath.Join(rootDir, "platform")
	DefaultStackPath      = filepath.Join(rootDir, "cnb", "stack.toml")

	PlaceholderAnalyzedPath        = filepath.Join("<layers>", DefaultAnalyzedFile)
	PlaceholderGeneratedDir        = filepath.Join("<layers>", "generated")
	PlaceholderGroupPath           = filepath.Join("<layers>", DefaultGroupFile)
	PlaceholderOrderPath           = filepath.Join("<layers>", DefaultOrderFile)
	PlaceholderPlanPath            = filepath.Join("<layers>", DefaultPlanFile)
	PlaceholderProjectMetadataPath = filepath.Join("<layers>", DefaultProjectMetadataFile)
	PlaceholderReportPath          = filepath.Join("<layers>", DefaultReportFile)
)
View Source
var ExperimentalMode = envOrDefault(EnvExperimentalMode, DefaultExperimentalMode)

Functions

func DecodeBuildMetadataTOML added in v0.15.0

func DecodeBuildMetadataTOML(path string, platformAPI *api.Version, buildmd *BuildMetadata) error

DecodeBuildMetadataTOML reads a metadata.toml file

func GuardExperimental added in v0.15.0

func GuardExperimental(requested string, logger log.Logger) error

Types

type AnalyzeInputs added in v0.14.1

type AnalyzeInputs struct {
	AdditionalTags   str.Slice // satisfies the `Value` interface required by the `flag` package
	AnalyzedPath     string
	CacheImageRef    string
	LaunchCacheDir   string
	LayersDir        string
	LegacyCacheDir   string
	LegacyGroupPath  string
	OutputImageRef   string
	PreviousImageRef string
	RunImageRef      string
	StackPath        string
	UID              int
	GID              int
	SkipLayers       bool
	UseDaemon        bool
}

AnalyzeInputs holds the values of command-line flags and args. Fields are the cumulative total of inputs across all supported platform APIs.

func (AnalyzeInputs) RegistryImages added in v0.14.1

func (a AnalyzeInputs) RegistryImages() []string

RegistryImages returns the inputs that are images in a registry.

type AnalyzedMetadata

type AnalyzedMetadata struct {
	PreviousImage *ImageIdentifier `toml:"image"`
	Metadata      LayersMetadata   `toml:"metadata"`
	RunImage      *ImageIdentifier `toml:"run-image,omitempty"`
	BuildImage    *ImageIdentifier `toml:"build-image,omitempty"`
}

type BuildMetadata

type BuildMetadata struct {
	BOM                         []buildpack.BOMEntry     `toml:"bom,omitempty" json:"bom"`
	Buildpacks                  []buildpack.GroupElement `toml:"buildpacks" json:"buildpacks"`
	Extensions                  []buildpack.GroupElement `toml:"extensions,omitempty" json:"extensions,omitempty"`
	Labels                      []buildpack.Label        `toml:"labels" json:"-"`
	Launcher                    LauncherMetadata         `toml:"-" json:"launcher"`
	Processes                   []launch.Process         `toml:"processes" json:"processes"`
	Slices                      []layers.Slice           `toml:"slices" json:"-"`
	BuildpackDefaultProcessType string                   `toml:"buildpack-default-process-type,omitempty" json:"buildpack-default-process-type,omitempty"`
	PlatformAPI                 *api.Version             `toml:"-" json:"-"`
}

func (*BuildMetadata) MarshalJSON added in v0.14.0

func (md *BuildMetadata) MarshalJSON() ([]byte, error)

func (BuildMetadata) ToLaunchMD

func (md BuildMetadata) ToLaunchMD() launch.Metadata

type BuildPlan

type BuildPlan struct {
	Entries []BuildPlanEntry `toml:"entries"`
}

func (BuildPlan) Filter

func (p BuildPlan) Filter(metRequires []string) BuildPlan

FIXME: ensure at least one claimed entry of each name is provided by the BP

func (BuildPlan) Find

func (p BuildPlan) Find(kind, id string) buildpack.Plan

type BuildPlanEntry

type BuildPlanEntry struct {
	Providers []buildpack.GroupElement `toml:"providers"`
	Requires  []buildpack.Require      `toml:"requires"`
}

func (BuildPlanEntry) NoOpt

func (be BuildPlanEntry) NoOpt() BuildPlanEntry

type BuildReport

type BuildReport struct {
	BOM []buildpack.BOMEntry `toml:"bom"`
}

type CacheMetadata

type CacheMetadata struct {
	BOM        LayerMetadata              `json:"sbom"`
	Buildpacks []buildpack.LayersMetadata `json:"buildpacks"`
}

func (*CacheMetadata) MetadataForBuildpack

func (cm *CacheMetadata) MetadataForBuildpack(id string) buildpack.LayersMetadata

type DefaultExiter added in v0.13.2

type DefaultExiter struct{}

func (*DefaultExiter) CodeFor added in v0.13.2

func (e *DefaultExiter) CodeFor(errType LifecycleExitError) int

type DetectInputs added in v0.15.0

type DetectInputs struct {
	AnalyzedPath  string
	AppDir        string
	BuildpacksDir string
	ExtensionsDir string
	GeneratedDir  string
	GroupPath     string
	LayersDir     string
	OrderPath     string
	PlanPath      string
	PlatformDir   string
}

DetectInputs holds the values of command-line flags and args. Fields are the cumulative total of inputs across all supported platform APIs.

type DirStore added in v0.15.0

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

func NewDirStore added in v0.15.0

func NewDirStore(buildpacksDir string, extensionsDir string) (*DirStore, error)

func (*DirStore) Lookup added in v0.15.0

func (s *DirStore) Lookup(kind, id, version string) (buildpack.Descriptor, error)

func (*DirStore) LookupBp added in v0.15.0

func (s *DirStore) LookupBp(id, version string) (*buildpack.BpDescriptor, error)

func (*DirStore) LookupExt added in v0.15.0

func (s *DirStore) LookupExt(id, version string) (*buildpack.ExtDescriptor, error)

type Exiter added in v0.13.2

type Exiter interface {
	CodeFor(errType LifecycleExitError) int
}

func NewExiter added in v0.14.1

func NewExiter(platformAPI string) Exiter

type ExportReport

type ExportReport struct {
	Build BuildReport `toml:"build,omitempty"`
	Image ImageReport `toml:"image"`
}

type ExtendInputs added in v0.15.0

type ExtendInputs struct {
	AnalyzedPath   string
	AppDir         string
	BuildpacksDir  string
	GeneratedDir   string
	GroupPath      string
	ImageRef       string
	LayersDir      string
	PlanPath       string
	PlatformDir    string
	UID, GID       int
	KanikoCacheTTL time.Duration
}

ExtendInputs holds the values of command-line flags and args. Fields are the cumulative total of inputs across all supported platform APIs.

type GitMetadata

type GitMetadata struct {
	Repository string `json:"repository"`
	Commit     string `json:"commit"`
}

type ImageIdentifier

type ImageIdentifier struct {
	Reference string `toml:"reference"`
}

FIXME: fix key names to be accurate in the daemon case

type ImageReport

type ImageReport struct {
	Tags         []string `toml:"tags"`
	ImageID      string   `toml:"image-id,omitempty"`
	Digest       string   `toml:"digest,omitempty"`
	ManifestSize int64    `toml:"manifest-size,omitzero"`
}

type InputsResolver added in v0.14.1

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

InputsResolver resolves inputs for each of the lifecycle phases.

func NewInputsResolver added in v0.14.1

func NewInputsResolver(platformAPI *api.Version) *InputsResolver

NewInputsResolver accepts a platform API and returns a new InputsResolver.

func (*InputsResolver) ResolveAnalyze added in v0.14.1

func (r *InputsResolver) ResolveAnalyze(inputs AnalyzeInputs, logger log.Logger) (AnalyzeInputs, error)

ResolveAnalyze accepts an AnalyzeInputs and returns a new AnalyzeInputs with default values filled in, or an error if the provided inputs are not valid.

func (*InputsResolver) ResolveDetect added in v0.15.0

func (r *InputsResolver) ResolveDetect(inputs DetectInputs) (DetectInputs, error)

ResolveDetect accepts a DetectInputs and returns a new DetectInputs with default values filled in, or an error if the provided inputs are not valid.

func (*InputsResolver) ResolveExtend added in v0.15.0

func (r *InputsResolver) ResolveExtend(inputs ExtendInputs) (ExtendInputs, error)

ResolveExtend accepts a ExtendInputs and returns a new ExtendInputs with default values filled in, or an error if the provided inputs are not valid.

type LauncherMetadata

type LauncherMetadata struct {
	Version string         `json:"version"`
	Source  SourceMetadata `json:"source"`
}

type LayerMetadata

type LayerMetadata struct {
	SHA string `json:"sha" toml:"sha"`
}

type LayersMetadata

type LayersMetadata struct {
	App          []LayerMetadata            `json:"app" toml:"app"`
	BOM          *LayerMetadata             `json:"sbom,omitempty" toml:"sbom,omitempty"`
	Buildpacks   []buildpack.LayersMetadata `json:"buildpacks" toml:"buildpacks"`
	Config       LayerMetadata              `json:"config" toml:"config"`
	Launcher     LayerMetadata              `json:"launcher" toml:"launcher"`
	ProcessTypes LayerMetadata              `json:"process-types" toml:"process-types"`
	RunImage     RunImageMetadata           `json:"runImage" toml:"run-image"`
	Stack        StackMetadata              `json:"stack" toml:"stack"`
}

NOTE: This struct MUST be kept in sync with `LayersMetadataCompat`

func (*LayersMetadata) MetadataForBuildpack

func (m *LayersMetadata) MetadataForBuildpack(id string) buildpack.LayersMetadata

type LayersMetadataCompat

type LayersMetadataCompat struct {
	App          interface{}                `json:"app" toml:"app"`
	BOM          *LayerMetadata             `json:"sbom,omitempty" toml:"sbom,omitempty"`
	Buildpacks   []buildpack.LayersMetadata `json:"buildpacks" toml:"buildpacks"`
	Config       LayerMetadata              `json:"config" toml:"config"`
	Launcher     LayerMetadata              `json:"launcher" toml:"launcher"`
	ProcessTypes LayerMetadata              `json:"process-types" toml:"process-types"`
	RunImage     RunImageMetadata           `json:"runImage" toml:"run-image"`
	Stack        StackMetadata              `json:"stack" toml:"stack"`
}

NOTE: This struct MUST be kept in sync with `LayersMetadata`. It exists for situations where the `App` field type cannot be guaranteed, yet the original struct data must be maintained.

type LegacyExiter added in v0.13.2

type LegacyExiter struct{}

func (*LegacyExiter) CodeFor added in v0.13.2

func (e *LegacyExiter) CodeFor(errType LifecycleExitError) int

type LifecycleExitError added in v0.13.2

type LifecycleExitError int
const (
	FailedDetect             LifecycleExitError = iota // generic detect error
	FailedDetectWithErrors                             // no buildpacks detected
	DetectError                                        // no buildpacks detected and at least one errored
	AnalyzeError                                       // generic analyze error
	RestoreError                                       // generic restore error
	FailedBuildWithErrors                              // buildpack error during /bin/build
	BuildError                                         // generic build error
	ExportError                                        // generic export error
	RebaseError                                        // generic rebase error
	LaunchError                                        // generic launch error
	FailedGenerateWithErrors                           // extension error during /bin/generate
	GenerateError                                      // generic generate error
	ExtendError                                        // generic extend error
)

type Platform

type Platform struct {
	*InputsResolver
	Exiter
	// contains filtered or unexported fields
}

Platform handles logic pertaining to inputs and outputs from a platform (lifecycle invoker)'s perspective.

func NewPlatform

func NewPlatform(apiStr string) *Platform

NewPlatform accepts a platform API and returns a new Platform.

func (*Platform) API

func (p *Platform) API() *api.Version

API returns the platform API.

type ProjectMetadata

type ProjectMetadata struct {
	Source *ProjectSource `toml:"source" json:"source,omitempty"`
}

type ProjectSource

type ProjectSource struct {
	Type     string                 `toml:"type" json:"type,omitempty"`
	Version  map[string]interface{} `toml:"version" json:"version,omitempty"`
	Metadata map[string]interface{} `toml:"metadata" json:"metadata,omitempty"`
}

type RunImageMetadata

type RunImageMetadata struct {
	TopLayer  string `json:"topLayer" toml:"top-layer"`
	Reference string `json:"reference" toml:"reference"`
}

type SourceMetadata

type SourceMetadata struct {
	Git GitMetadata `json:"git"`
}

type StackMetadata

type StackMetadata struct {
	RunImage StackRunImageMetadata `json:"runImage" toml:"run-image"`
}

func (*StackMetadata) BestRunImageMirror

func (sm *StackMetadata) BestRunImageMirror(registry string) (string, error)

type StackRunImageMetadata

type StackRunImageMetadata struct {
	Image   string   `toml:"image" json:"image"`
	Mirrors []string `toml:"mirrors" json:"mirrors,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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