Documentation ¶
Index ¶
- func Bootstrap(binaryPath string) (string, error)
- func CheckFloatingRefs(jirix *jiri.X, pkgs map[PackageInstance]bool, ...) error
- func CheckLoggedIn(jirix *jiri.X) (bool, error)
- func CheckPackageACL(jirix *jiri.X, pkgs map[string]bool) error
- func Decl(cipdPath string, platforms []Platform) (string, error)
- func Ensure(jirix *jiri.X, file, projectRoot string, timeout uint) error
- func Expand(cipdPath string, platforms []Platform) ([]string, error)
- func MustExpand(cipdPath string) bool
- type Expander
- type PackageInstance
- type Platform
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bootstrap ¶
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 ¶
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 ¶
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 ¶
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 ¶
Ensure runs cipd binary's ensure functionality over file. Fetched packages will be saved to projectRoot directory. Parameter timeout is in minutes.
func Expand ¶
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 ¶
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 ¶
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 ¶
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 ¶
PackageInstance describes package instance id information generated by cipd ensure-file-resolve. It is a copy of PackageLock type in project package.
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 ¶
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 ¶
NewPlatform parses a platform string into Platform struct.