cipd

package
v0.0.0-...-53353bc Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(binaryPath string) (string, error)

Bootstrap returns the path of a valid cipd binary. It will fetch cipd from remote if a valid cipd binary is not found. It will update cipd if there is a new version.

func CheckFloatingRefs

func CheckFloatingRefs(jirix *jiri.X, pkgs map[PackageInstance]bool, plats map[PackageInstance][]Platform) error

CheckFloatingRefs determines if pkgs contains a floating ref which shouldn't be used normally.

func CheckLoggedIn

func CheckLoggedIn(jirix *jiri.X) (bool, error)

CheckLoggedIn checks cipd's user login information. It will return true if login information is found or return false if login information is not found.

func CheckPackageACL

func CheckPackageACL(jirix *jiri.X, pkgs map[string]bool) error

CheckPackageACL checks cipd's access to packages in map "pkgs". The package names in "pkgs" should have trailing '/' removed before calling this function.

func Decl

func Decl(cipdPath string, platforms []Platform) (string, error)

Decl method expands a cipdPath that contains ${platform}, ${os}, ${arch} with information in platforms. Unlike the Expand method which returns a list of expanded cipd paths, the Decl method only returns a single path containing all platforms. For example, if platforms contain "linux-amd64" and "linux-arm64", ${platform} will be replaced to ${platform=linux-amd64,linux-arm64}. This is a workaround for a limitation in 'cipd ensure-file-resolve' which requires the header of '.ensure' file to contain all available platforms. But in some cases, a package may miss a particular platform, which will cause a crash on this cipd command. By explicitly list all supporting platforms in the cipdPath, we can avoid crashing cipd.

func Ensure

func Ensure(jirix *jiri.X, file, projectRoot string, timeout uint) error

Ensure runs cipd binary's ensure functionality over file. Fetched packages will be saved to projectRoot directory. Parameter timeout is in minutes.

func Expand

func Expand(cipdPath string, platforms []Platform) ([]string, error)

Expand method expands a cipdPath that contains templates such as ${platform} into concrete full paths. It might return an empty slice if platforms do not match the requirements in cipdPath.

func MustExpand

func MustExpand(cipdPath string) bool

MustExpand checks if template usages such as "${platform}" exist in cipdPath. If they exist, this function will return true. Otherwise it returns false.

Types

type Expander

type Expander map[string]string

Expander is a mapping of simple string substitutions which is used to expand cipd package name templates. For example:

ex, err := template.Expander{
  "platform": "mac-amd64"
}.Expand("foo/${platform}")

`ex` would be "foo/mac-amd64".

func (Expander) Expand

func (t Expander) Expand(template string) (pkg string, err error)

Expand applies package template expansion rules to the package template,

If err == ErrSkipTemplate, that means that this template does not apply to this os/arch combination and should be skipped.

The expansion rules are as follows:

  • "some text" will pass through unchanged
  • "${variable}" will directly substitute the given variable
  • "${variable=val1,val2}" will substitute the given variable, if its value matches one of the values in the list of values. If the current value does not match, this returns ErrSkipTemplate.

Attempting to expand an unknown variable is an error. After expansion, any lingering '$' in the template is an error.

type PackageInstance

type PackageInstance struct {
	PackageName string
	VersionTag  string
	InstanceID  string
}

PackageInstance describes package instance id information generated by cipd ensure-file-resolve. It is a copy of PackageLock type in project package.

func Resolve

func Resolve(jirix *jiri.X, file string) ([]PackageInstance, error)

Resolve runs cipd binary's ensure-file-resolve functionality over file. It returns a slice containing resolved packages and cipd instance ids.

type Platform

type Platform struct {
	// OS defines the operating system of this platform. It can be any OS
	// supported by golang.
	OS string
	// Arch defines the CPU architecture of this platform. It can be any
	// architecture supported by golang.
	Arch string
}

Platform contains the parameters for a "${platform}" template. The string value can be obtained by calling String().

var (
	// CipdPlatform represents the current runtime platform in cipd platform notation.
	CipdPlatform Platform

	// ErrSkipTemplate may be returned from Expander.Expand to indicate that
	// a given expansion doesn't apply to the current template parameters. For
	// example, expanding `"foo/${os=linux,mac}"` with a template parameter of "os"
	// == "win", would return ErrSkipTemplate.
	ErrSkipTemplate = errors.New("package template does not apply to the current system")
)

func DefaultPlatforms

func DefaultPlatforms() []Platform

DefaultPlatforms returns a slice of Platform objects that are currently validated by jiri.

func FuchsiaPlatform

func FuchsiaPlatform(plat Platform) Platform

FuchsiaPlatform returns a Platform struct which can be used in determing the correct path for prebuilt packages. It replace the os and arch names from cipd format to a format used by Fuchsia developers.

func NewPlatform

func NewPlatform(s string) (Platform, error)

NewPlatform parses a platform string into Platform struct.

func (Platform) Expander

func (p Platform) Expander() Expander

Expander returns an Expander populated with p's fields.

func (Platform) String

func (p Platform) String() string

String generates a string represents the Platform in "OS"-"Arch" form.

Jump to

Keyboard shortcuts

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