common

package
v0.0.0-...-678bb0e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package common defines structures and functions used by cipd/* packages.

Index

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

func DefaultHash() hash.Hash

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

func GetInstanceTagKey(t string) string

GetInstanceTagKey returns key portion of the instance tag or empty string.

func HashForInstanceID

func HashForInstanceID(instanceID string) (hash.Hash, error)

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

func InstanceIDFromHash(h hash.Hash) string

InstanceIDFromHash returns an instance ID string, given a hash state.

func TemplateArgs

func TemplateArgs() map[string]string

TemplateArgs returns the default template args which can be used with the ensure.PackageDef.Resolve() method.

func ValidateFileHash

func ValidateFileHash(s string) error

ValidateFileHash returns error if a string isn't a valid exe hash.

func ValidateInstanceID

func ValidateInstanceID(s string) error

ValidateInstanceID returns error if a string isn't a valid instance id.

func ValidateInstanceTag

func ValidateInstanceTag(t string) error

ValidateInstanceTag returns error if a string doesn't look like a valid tag.

func ValidateInstanceVersion

func ValidateInstanceVersion(v string) error

ValidateInstanceVersion return error if a string can't be used as version.

A version can be specified as:

  1. Instance ID (hash, e.g "1234deadbeef2234...").
  2. Package ref (e.g. "latest").
  3. Instance tag (e.g. "git_revision:abcdef...").

func ValidatePackageName

func ValidatePackageName(name string) error

ValidatePackageName returns error if a string isn't a valid package name.

func ValidatePackageRef

func ValidatePackageRef(r string) error

ValidatePackageRef returns error if a string doesn't look like a valid ref.

func ValidatePin

func ValidatePin(pin Pin) error

ValidatePin returns error if package name or instance id are invalid.

func ValidateSubdir

func ValidateSubdir(subdir string) error

ValidateSubdir returns an error if the string can't be used as an ensure-file subdir.

Types

type Pin

type Pin struct {
	PackageName string `json:"package"`
	InstanceID  string `json:"instance_id"`
}

Pin uniquely identifies an instance of some package.

func (Pin) String

func (pin Pin) String() string

String converts pin to a human readable string.

type PinMap

type PinMap map[string]string

PinMap is a map of package_name to instanceID.

func (PinMap) ToSlice

func (m PinMap) ToSlice() PinSlice

ToSlice converts the PinMap to a PinSlice.

type PinMapBySubdir

type PinMapBySubdir map[string]PinMap

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 PinSlice

type PinSlice []Pin

PinSlice is a simple list of Pins

func (PinSlice) ToMap

func (s PinSlice) ToMap() PinMap

ToMap converts the PinSlice to a PinMap.

func (PinSlice) Validate

func (s PinSlice) Validate() error

Validate ensures that this PinSlice contains no duplicate packages or invalid pins.

type PinSliceBySubdir

type PinSliceBySubdir map[string]PinSlice

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.

Jump to

Keyboard shortcuts

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