Documentation ¶
Overview ¶
Package common defines structures and functions used by cipd/* packages.
Index ¶
- func CurrentArchitecture() string
- func CurrentOS() string
- func DefaultHash() hash.Hash
- func GetInstanceTagKey(t string) string
- func HashForInstanceID(instanceID string) (hash.Hash, error)
- func InstanceIDFromHash(h hash.Hash) string
- func TemplateArgs() map[string]string
- func ValidateFileHash(s string) error
- func ValidateInstanceID(s string) error
- func ValidateInstanceTag(t string) error
- func ValidateInstanceVersion(v string) error
- func ValidatePackageName(name string) error
- func ValidatePackageRef(r string) error
- func ValidatePin(pin Pin) error
- func ValidateSubdir(subdir string) error
- type Pin
- type PinMap
- type PinMapBySubdir
- type PinSlice
- type PinSliceBySubdir
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentArchitecture ¶
func CurrentArchitecture() string
CurrentArchitecture returns the current cipd-style architecture that the current go binary conforms to. Possible values:
- "armv6l" (if GOARCH=arm)
- other GOARCH values
func CurrentOS ¶
func CurrentOS() string
CurrentOS returns the current cipd-style os that the current go binary conforms to. Possible values:
- "mac" (if GOOS=darwin)
- other GOOS values
func DefaultHash ¶
DefaultHash returns a zero hash.Hash instance to use for package verification by default.
Currently it is always SHA1.
TODO(vadimsh): Use this function where sha1.New() is used now.
func GetInstanceTagKey ¶
GetInstanceTagKey returns key portion of the instance tag or empty string.
func HashForInstanceID ¶
HashForInstanceID constructs correct zero hash.Hash instance that can be used to verify given instance ID.
Currently it is always SHA1.
TODO(vadimsh): Use this function where sha1.New() is used now.
func InstanceIDFromHash ¶
InstanceIDFromHash returns an instance ID string, given a hash state.
func TemplateArgs ¶
TemplateArgs returns the default template args which can be used with the ensure.PackageDef.Resolve() method.
func ValidateFileHash ¶
ValidateFileHash returns error if a string isn't a valid exe hash.
func ValidateInstanceID ¶
ValidateInstanceID returns error if a string isn't a valid instance id.
func ValidateInstanceTag ¶
ValidateInstanceTag returns error if a string doesn't look like a valid tag.
func ValidateInstanceVersion ¶
ValidateInstanceVersion return error if a string can't be used as version.
A version can be specified as:
- Instance ID (hash, e.g "1234deadbeef2234...").
- Package ref (e.g. "latest").
- Instance tag (e.g. "git_revision:abcdef...").
func ValidatePackageName ¶
ValidatePackageName returns error if a string isn't a valid package name.
func ValidatePackageRef ¶
ValidatePackageRef returns error if a string doesn't look like a valid ref.
func ValidatePin ¶
ValidatePin returns error if package name or instance id are invalid.
Types ¶
type Pin ¶
Pin uniquely identifies an instance of some package.
type PinMap ¶
PinMap is a map of package_name to instanceID.
type PinMapBySubdir ¶
PinMapBySubdir is a simple mapping of subdir -> package_name -> instanceID
func (PinMapBySubdir) ToSlice ¶
func (p PinMapBySubdir) ToSlice() PinSliceBySubdir
ToSlice converts this to a PinSliceBySubdir
type PinSliceBySubdir ¶
PinSliceBySubdir is a simple mapping of subdir to pin slice.
func (PinSliceBySubdir) ToMap ¶
func (p PinSliceBySubdir) ToMap() PinMapBySubdir
ToMap converts this to a PinMapBySubdir
func (PinSliceBySubdir) Validate ¶
func (p PinSliceBySubdir) Validate() error
Validate ensures that this doesn't contain any invalid subdirs, duplicate packages within the same subdir, or invalid pins.