builder

package
v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package builder holds functionality for building CIPD packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildInstance

func BuildInstance(ctx context.Context, opts Options) (common.Pin, error)

BuildInstance builds a new package instance.

It builds an instance of a package named opts.PackageName by archiving input files (passed via opts.Input) and writing the final binary to opts.Output.

On success returns a pin of the built package which can later be used to register the package on CIPD backend.

Some output may be written even if BuildInstance eventually returns an error.

Types

type Options

type Options struct {
	// Input is a list of files to add to the package.
	Input []fs.File

	// Output is where to write the package file to.
	Output io.Writer

	// PackageName is name of the package being built, e.g. 'infra/tools/cipd'.
	PackageName string

	// VersionFile is slash separated path where to drop JSON with version info.
	VersionFile string

	// InstallMode defines how to install the package: "copy" or "symlink".
	InstallMode pkg.InstallMode

	// CompressionLevel defines deflate compression level in range [0-9].
	CompressionLevel int

	// HashAlgo specifies what hashing algorithm to use for computing instance ID.
	//
	// By default it is common.DefaultHashAlgo.
	HashAlgo api.HashAlgo

	// OverrideFormatVersion, if set, will override the default format version put
	// into the manifest file.
	//
	// This is useful for testing. Should not be normally used by other code.
	OverrideFormatVersion string
}

Options defines options for BuildInstance function.

type PackageChunkDef

type PackageChunkDef struct {
	// Dir is a directory to add to the package (recursively).
	Dir string

	// File is a single file to add to the package.
	File string

	// VersionFile defines where to drop JSON file with package version.
	VersionFile string `yaml:"version_file"`

	// Exclude is a list of regexp patterns to exclude when scanning a directory.
	Exclude []string
}

PackageChunkDef represents one entry in 'data' section of package definition.

It is either a single file, or a recursively scanned directory (with optional list of regexps for files to skip).

type PackageDef

type PackageDef struct {
	// Package defines a name of the package.
	Package string

	// Root defines where to search for files. It may either be an absolute path,
	// or it may be a path relative to the package file itself. If omitted, it
	// defaults to "." (i.e., the same directory as the package file)
	Root string

	// InstallMode defines how to deploy the package file: "copy" or "symlink".
	InstallMode pkg.InstallMode `yaml:"install_mode"`

	// PreserveModTime instructs CIPD to preserve the mtime of the files.
	PreserveModTime bool `yaml:"preserve_mtime"`

	// PreserveWritable instructs CIPD to preserve the user-writable permission
	// mode on the files.
	PreserveWritable bool `yaml:"preserve_writable"`

	// Data describes what is deployed with the package.
	Data []PackageChunkDef
}

PackageDef defines how exactly to build a package.

It specified what files to put into it, how to name them, how to name the package itself, etc. It is loaded from *.yaml file.

func LoadPackageDef

func LoadPackageDef(r io.Reader, vars map[string]string) (PackageDef, error)

LoadPackageDef loads package definition from a YAML source code.

It substitutes %{...} strings in the definition with corresponding values from 'vars' map.

func (*PackageDef) FindFiles

func (def *PackageDef) FindFiles(cwd string) ([]fs.File, error)

FindFiles scans files system and returns files to be added to the package.

It uses a path to package definition file directory ('cwd' argument) to find a root of the package.

func (*PackageDef) VersionFile

func (def *PackageDef) VersionFile() string

VersionFile defines where to drop JSON file with package version.

Jump to

Keyboard shortcuts

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