files

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 9

Documentation

Overview

Package files contains schema and helper methods for working with lifecycle configuration files.

Index

Constants

This section is empty.

Variables

View Source
var Handler = &TOMLHandler{}

Handler is the default handler used to read and write lifecycle configuration files.

Functions

This section is empty.

Types

type Analyzed

type Analyzed struct {
	// PreviousImage is the build image identifier, if the previous image exists.
	PreviousImage *ImageIdentifier `toml:"image,omitempty"`
	// BuildImage is the build image identifier.
	// It is recorded for use by the restorer in the case that image extensions are used
	// to extend the build image.
	BuildImage *ImageIdentifier `toml:"build-image,omitempty"`
	// LayersMetadata holds information about previously built layers.
	// It is used by the exporter to determine if any layers from the current build are unchanged,
	// to avoid re-uploading the same data to the export target,
	// and to provide information about previously-created layers to buildpacks.
	LayersMetadata LayersMetadata `toml:"metadata"`
	// RunImage holds information about the run image.
	// It is used to validate that buildpacks satisfy os/arch constraints,
	// and to provide information about the export target to buildpacks.
	RunImage *RunImage `toml:"run-image,omitempty"`
}

Analyzed is written by the analyzer as analyzed.toml and updated in subsequent phases to record information about: * the previous image (if it exists), * the run image, * the build image (if provided). The location of the file can be specified by providing `-analyzed <path>` to the lifecycle.

func (Analyzed) PreviousImageRef

func (a Analyzed) PreviousImageRef() string

func (Analyzed) RunImageImage

func (a Analyzed) RunImageImage() string

func (Analyzed) RunImageRef

func (a Analyzed) RunImageRef() string

func (Analyzed) RunImageTarget

func (a Analyzed) RunImageTarget() TargetMetadata

type BuildMetadata

type BuildMetadata struct {
	// BOM (deprecated) holds the unstructured bill-of-materials.
	BOM []buildpack.BOMEntry `toml:"bom,omitempty" json:"bom"`
	// Buildpacks are the buildpacks used in the build.
	Buildpacks []buildpack.GroupElement `toml:"buildpacks" json:"buildpacks"`
	// Extensions are the image extensions used in the build.
	Extensions []buildpack.GroupElement `toml:"extensions,omitempty" json:"extensions,omitempty"`
	// Labels are labels provided by buildpacks.
	Labels []buildpack.Label `toml:"labels" json:"-"`
	// Launcher is metadata to describe the launcher.
	Launcher LauncherMetadata `toml:"-" json:"launcher"`
	// Processes are processes provided by buildpacks.
	Processes []launch.Process `toml:"processes" json:"processes"`
	// Slices are application slices provided by buildpacks,
	// used by the exporter to "slice" the application directory into distinct layers.
	Slices []layers.Slice `toml:"slices" json:"-"`
	// BuildpackDefaultProcessType is the buildpack-provided default process type.
	// It will be the default process type for the image unless overridden by the end user.
	BuildpackDefaultProcessType string `toml:"buildpack-default-process-type,omitempty" json:"buildpack-default-process-type,omitempty"`
	// PlatformAPI is the Platform API version used for the build.
	PlatformAPI *api.Version `toml:"-" json:"-"`
}

BuildMetadata is written by the builder as <layers>/config/metadata.toml to record information about the build. It is also serialized by the exporter as the `io.buildpacks.build.metadata` label on the output image.

func (*BuildMetadata) MarshalJSON

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

func (BuildMetadata) ToLaunchMD

func (m BuildMetadata) ToLaunchMD() launch.Metadata

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 GitMetadata

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

type ImageIdentifier

type ImageIdentifier struct {
	Reference string `toml:"reference"` // FIXME: fix key name 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 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     RunImageForRebase          `json:"runImage" toml:"run-image"`
	Stack        *Stack                     `json:"stack,omitempty" toml:"stack,omitempty"`
}

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

func (*LayersMetadata) LayersMetadataFor

func (m *LayersMetadata) LayersMetadataFor(bpID 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     RunImageForRebase          `json:"runImage" toml:"run-image"`
	Stack        *Stack                     `json:"stack,omitempty" toml:"stack,omitempty"`
}

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 OSDistro

type OSDistro struct {
	Name    string `json:"name" toml:"name"`
	Version string `json:"version" toml:"version"`
}

OSDistro is the OS distribution that a base image provides.

type Plan

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

Plan is written by the detector as plan.toml to record the application dependencies requested by buildpacks, and the image extensions or buildpacks that provide them. A subset of the plan is presented to each image extension (during the `generate` phase) or buildpack (during the `build` phase) with the entries that the module is expected to provide. The location of the file can be specified by providing `-plan <path>` to the lifecycle.

func (Plan) Filter

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

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

func (Plan) Find

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

type ProjectMetadata

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

ProjectMetadata is written as `project_metadata.toml` by the exporter to record information about the application source code. It is also serialized by the exporter as the `io.buildpacks.project.metadata` label on the output image. The location of the file can be specified by providing `-project-metadata <path>` to the lifecycle.

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 RebaseReport added in v0.19.0

type RebaseReport struct {
	Image ImageReport `toml:"image"`
}

RebaseReport is written by the rebaser to record information about the rebased image.

type Report

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

Report is written by the exporter to record information about the build. It is not included in the output image, but can be saved off by the platform before the build container exits. The location of the file can be specified by providing `-report <path>` to the lifecycle.

type Run

type Run struct {
	Images []RunImageForExport `json:"-" toml:"images"`
}

Run is provided by the platform as run.toml to record information about the run images that may be used during export. Data from the selected run image is serialized by the exporter as the `runImage` key in the `io.buildpacks.lifecycle.metadata` label on the output image for use during rebase. The location of the file can be specified by providing `-run <path>` to the lifecycle.

func (*Run) Contains

func (r *Run) Contains(providedImage string) bool

Contains returns true if the provided image reference is found in the existing metadata, removing the digest portion of the reference when determining if two image names are equivalent.

type RunImage

type RunImage struct {
	Reference string `toml:"reference"`
	// Image specifies the repository name for the image that was provided - either by the platform, or by extensions.
	// When exporting to a daemon, the restorer uses this field to pull the run image if needed for the extender;
	// it can't use `Reference` because this may be a daemon image ID if analyzed.toml was last written by the analyzer.
	Image string `toml:"image,omitempty"`
	// Extend if true indicates that the run image should be extended by the extender.
	Extend         bool            `toml:"extend,omitempty"`
	TargetMetadata *TargetMetadata `json:"target,omitempty" toml:"target,omitempty"`
}

type RunImageForExport

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

func (*RunImageForExport) Contains

func (r *RunImageForExport) Contains(providedImage string) bool

Contains returns true if the provided image reference is found in the existing metadata, removing the digest portion of the reference when determining if two image names are equivalent.

type RunImageForRebase

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

func (*RunImageForRebase) Contains

func (r *RunImageForRebase) Contains(providedImage string) bool

Contains returns true if the provided image reference is found in the existing metadata, removing the digest portion of the reference when determining if two image names are equivalent.

func (*RunImageForRebase) ToStack

func (r *RunImageForRebase) ToStack() Stack

type SourceMetadata

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

type Stack

type Stack struct {
	RunImage RunImageForExport `json:"runImage" toml:"run-image"`
}

Stack (deprecated as of Platform API 0.12) is provided by the platform as stack.toml to record information about the run images that may be used during export. It is also serialized by the exporter as the `stack` key in the `io.buildpacks.lifecycle.metadata` label on the output image for use during rebase. The location of the file can be specified by providing `-stack <path>` to the lifecycle.

type TOMLHandler added in v0.19.0

type TOMLHandler struct{}

TOMLHandler reads and writes lifecycle configuration files in TOML format.

func NewHandler added in v0.19.0

func NewHandler() *TOMLHandler

NewHandler returns a new file handler.

func (*TOMLHandler) ReadAnalyzed added in v0.19.0

func (h *TOMLHandler) ReadAnalyzed(path string, logger log.Logger) (Analyzed, error)

ReadAnalyzed reads the provided analyzed.toml file. It logs a warning and returns empty analyzed metadata if the file does not exist.

func (*TOMLHandler) ReadBuildMetadata added in v0.19.0

func (h *TOMLHandler) ReadBuildMetadata(path string, platformAPI *api.Version) (*BuildMetadata, error)

ReadBuildMetadata reads the provided metadata.toml file, and sets the provided Platform API version on the returned struct so that the data can be re-encoded properly later.

func (*TOMLHandler) ReadGroup added in v0.19.0

func (h *TOMLHandler) ReadGroup(path string) (group buildpack.Group, err error)

ReadGroup reads the provided group.toml file.

func (*TOMLHandler) ReadOrder added in v0.19.0

func (h *TOMLHandler) ReadOrder(path string) (buildpack.Order, buildpack.Order, error)

ReadOrder reads the provided order.toml file.

func (*TOMLHandler) ReadPlan added in v0.19.0

func (h *TOMLHandler) ReadPlan(path string) (Plan, error)

ReadPlan reads the provided plan.toml file.

func (*TOMLHandler) ReadProjectMetadata added in v0.19.0

func (h *TOMLHandler) ReadProjectMetadata(path string, logger log.Logger) (ProjectMetadata, error)

ReadProjectMetadata reads the provided project_metadata.toml file. It logs a warning and returns empty project metadata if the file does not exist.

func (*TOMLHandler) ReadRun added in v0.19.0

func (h *TOMLHandler) ReadRun(path string, logger log.Logger) (Run, error)

ReadRun reads the provided run.toml file.

func (*TOMLHandler) ReadStack added in v0.19.0

func (h *TOMLHandler) ReadStack(path string, logger log.Logger) (Stack, error)

ReadStack reads the provided stack.toml file.

func (*TOMLHandler) WriteAnalyzed added in v0.19.0

func (h *TOMLHandler) WriteAnalyzed(path string, analyzedMD *Analyzed, logger log.Logger) error

WriteAnalyzed writes the provided analyzed metadata at the provided path.

func (*TOMLHandler) WriteBuildMetadata added in v0.19.0

func (h *TOMLHandler) WriteBuildMetadata(path string, buildMD *BuildMetadata) error

WriteBuildMetadata writes the provided build metadata at the provided path.

func (*TOMLHandler) WriteGroup added in v0.19.0

func (h *TOMLHandler) WriteGroup(path string, group *buildpack.Group) error

WriteGroup writes the provided group information at the provided path.

func (*TOMLHandler) WritePlan added in v0.19.0

func (h *TOMLHandler) WritePlan(path string, plan *Plan) error

WritePlan writes the provided plan information at the provided path.

func (*TOMLHandler) WriteRebaseReport added in v0.19.0

func (h *TOMLHandler) WriteRebaseReport(path string, report *RebaseReport) error

WriteRebaseReport writes the provided report information at the provided path.

func (*TOMLHandler) WriteReport added in v0.19.0

func (h *TOMLHandler) WriteReport(path string, report *Report) error

WriteReport writes the provided report information at the provided path.

type TargetMetadata

type TargetMetadata struct {
	ID          string `json:"id,omitempty" toml:"id,omitempty"`
	OS          string `json:"os" toml:"os"`
	Arch        string `json:"arch" toml:"arch"`
	ArchVariant string `json:"arch-variant,omitempty" toml:"arch-variant,omitempty"`

	Distro *OSDistro `json:"distro,omitempty" toml:"distro,omitempty"`
}

func (*TargetMetadata) String

func (t *TargetMetadata) String() string

Jump to

Keyboard shortcuts

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