Documentation ¶
Index ¶
- Constants
- Variables
- func CheckProjectsHostnames(projects Projects, allowList []string) error
- func CheckoutSnapshot(jirix *jiri.X, snapshot string, gc, runHooks, fetchPkgs bool, ...) error
- func CleanupProjects(jirix *jiri.X, localProjects Projects, cleanupBranches bool) (e error)
- func CreateSnapshot(jirix *jiri.X, file string, hooks Hooks, pkgs Packages, localManifest bool) error
- func FetchPackages(jirix *jiri.X, projects Projects, pkgs Packages, fetchTimeout uint) error
- func FilterOptionalProjectsPackages(jirix *jiri.X, attrs string, projects Projects, pkgs Packages) error
- func GenerateJiriLockFile(jirix *jiri.X, manifestFiles []string, resolveConfig ResolveConfig) error
- func GetHeadRevision(jirix *jiri.X, project Project) (string, error)
- func GetProjectStates(jirix *jiri.X, projects Projects, checkDirty bool) (map[ProjectKey]*ProjectState, error)
- func HostnameAllowed(reference, hostname string) bool
- func IsLocalProject(jirix *jiri.X, path string) (bool, error)
- func LoadManifest(jirix *jiri.X) (Projects, Hooks, Packages, error)
- func LoadManifestFile(jirix *jiri.X, file string, localProjects Projects, localManifest bool) (Projects, Hooks, Packages, error)
- func LoadSnapshotFile(jirix *jiri.X, snapshot string) (Projects, Hooks, Packages, error)
- func LoadUpdatedManifest(jirix *jiri.X, localProjects Projects, localManifest bool) (Projects, Hooks, Packages, error)
- func MarshalLockEntries(projectLocks ProjectLocks, pkgLocks PackageLocks) ([]byte, error)
- func MatchLocalWithRemote(localProjects, remoteProjects Projects)
- func NewSourceManifest(jirix *jiri.X, projects Projects) (*SourceManifest, MultiError)
- func RunHooks(jirix *jiri.X, hooks Hooks, runHookTimeout uint) error
- func UnmarshalLockEntries(jsonData []byte) (ProjectLocks, PackageLocks, error)
- func UpdateUniverse(jirix *jiri.X, ...) (e error)
- func WriteLocalConfig(jirix *jiri.X, project Project, lc LocalConfig) error
- func WritePackageFlags(jirix *jiri.X, pkgs, pkgsWA Packages) error
- func WriteProjectFlags(jirix *jiri.X, projs Projects) error
- func WriteUpdateHistoryLog(jirix *jiri.X) error
- func WriteUpdateHistorySnapshot(jirix *jiri.X, snapshotPath string, hooks Hooks, pkgs Packages, ...) error
- type BranchState
- type Hook
- type HookKey
- type Hooks
- type HooksByName
- type Import
- type LocalConfig
- type LocalImport
- type Manifest
- type MultiError
- type Package
- type PackageInstance
- type PackageKey
- type PackageKeys
- type PackageLock
- type PackageLockKey
- type PackageLocks
- type Packages
- type PathTrie
- type Project
- type ProjectKey
- type ProjectKeys
- type ProjectLock
- type ProjectLockKey
- type ProjectLocks
- type ProjectState
- type ProjectStatus
- type Projects
- type ProjectsByPath
- type ReferenceState
- type ResolveConfig
- type ScanMode
- type SourceManifest
- type SourceManifest_Directory
- type SourceManifest_GitCheckout
Constants ¶
const ( JiriProject = "release.go.jiri" JiriName = "jiri" JiriPackage = "github.com/btwiuse/jiri" ManifestVersion = "1.1" )
const ( FastScan = ScanMode(false) FullScan = ScanMode(true) )
const KeySeparator = "="
KeySeparator is a reserved string used in ProjectKeys and HookKeys. It cannot occur in Project or Hook names.
const (
SourceManifestVersion = int32(0)
)
Variables ¶
var ( DefaultHookTimeout = uint(5) // DefaultHookTimeout is the time in minutes to wait for a hook to timeout. DefaultPackageTimeout = uint(20) // DefaultPackageTimeout is the time in minutes to wait for cipd fetching packages. )
Functions ¶
func CheckProjectsHostnames ¶
CheckProjectsHostnames checks if the hostname of every project is allowed under allowList. If allowList is empty, the check is skipped.
func CheckoutSnapshot ¶
func CheckoutSnapshot(jirix *jiri.X, snapshot string, gc, runHooks, fetchPkgs bool, runHookTimeout, fetchTimeout uint) error
CheckoutSnapshot updates project state to the state specified in the given snapshot file. Note that the snapshot file must not contain remote imports.
func CleanupProjects ¶
CleanupProjects restores the given jiri projects back to their detached heads, resets to the specified revision if there is one, and gets rid of all the local changes. If "cleanupBranches" is true, it will also delete all the non-master branches.
func CreateSnapshot ¶
func CreateSnapshot(jirix *jiri.X, file string, hooks Hooks, pkgs Packages, localManifest bool) error
CreateSnapshot creates a manifest that encodes the current state of HEAD of all projects and writes this snapshot out to the given file. if hooks are not passed, jiri will read JiriManifestFile and get hooks from there, so always pass hooks incase updating from a snapshot
func FetchPackages ¶
FetchPackages fetches prebuilt packages described in given pkgs using cipd. Parameter fetchTimeout is in minutes.
func FilterOptionalProjectsPackages ¶
func FilterOptionalProjectsPackages(jirix *jiri.X, attrs string, projects Projects, pkgs Packages) error
FilterOptionalProjectsPackages removes projects and packages in place if the Optional field is true and attributes in attrs does not match the Attributes field. Currently "match" means the intersection of both attributes is not empty.
func GenerateJiriLockFile ¶
func GenerateJiriLockFile(jirix *jiri.X, manifestFiles []string, resolveConfig ResolveConfig) error
GenerateJiriLockFile generates jiri lockfile to lockFilePath using manifests in manifestFiles slice.
func GetProjectStates ¶
func GetProjectStates(jirix *jiri.X, projects Projects, checkDirty bool) (map[ProjectKey]*ProjectState, error)
func HostnameAllowed ¶
HostnameAllowed determines if hostname is allowed under reference. This function allows a single prefix '*' for wildcard matching E.g. "*.google.com" will match "fuchsia.google.com" but does not match "google.com".
func IsLocalProject ¶
IsLocalProject returns true if there is a project at the given path.
func LoadManifest ¶
LoadManifest loads the manifest, starting with the .jiri_manifest file, resolving remote and local imports. Returns the projects specified by the manifest.
WARNING: LoadManifest cannot be run multiple times in parallel! It invokes git operations which require a lock on the filesystem. If you see errors about ".git/index.lock exists", you are likely calling LoadManifest in parallel.
func LoadManifestFile ¶
func LoadManifestFile(jirix *jiri.X, file string, localProjects Projects, localManifest bool) (Projects, Hooks, Packages, error)
LoadManifestFile loads the manifest starting with the given file, resolving remote and local imports. Local projects are used to resolve remote imports; if nil, encountering any remote import will result in an error.
WARNING: LoadManifestFile cannot be run multiple times in parallel! It invokes git operations which require a lock on the filesystem. If you see errors about ".git/index.lock exists", you are likely calling LoadManifestFile in parallel.
func LoadSnapshotFile ¶
LoadSnapshotFile loads the specified snapshot manifest. If the snapshot manifest contains a remote import, an error will be returned.
func LoadUpdatedManifest ¶
func LoadUpdatedManifest(jirix *jiri.X, localProjects Projects, localManifest bool) (Projects, Hooks, Packages, error)
LoadUpdatedManifest loads an updated manifest starting with the .jiri_manifest file for localProjects. It will use local manifest files instead of manifest files in remote repositories if localManifest is set to true.
func MarshalLockEntries ¶
func MarshalLockEntries(projectLocks ProjectLocks, pkgLocks PackageLocks) ([]byte, error)
MarshalLockEntries marshals project locks and package locks into json format data.
func MatchLocalWithRemote ¶
func MatchLocalWithRemote(localProjects, remoteProjects Projects)
func NewSourceManifest ¶
func NewSourceManifest(jirix *jiri.X, projects Projects) (*SourceManifest, MultiError)
func UnmarshalLockEntries ¶
func UnmarshalLockEntries(jsonData []byte) (ProjectLocks, PackageLocks, error)
UnmarshalLockEntries unmarshals project locks and package locks from jsonData.
func UpdateUniverse ¶
func UpdateUniverse(jirix *jiri.X, gc, localManifest, rebaseTracked, rebaseUntracked, rebaseAll, runHooks, fetchPkgs bool, runHookTimeout, fetchTimeout uint) (e error)
UpdateUniverse updates all local projects and tools to match the remote counterparts identified in the manifest. Optionally, the 'gc' flag can be used to indicate that local projects that no longer exist remotely should be removed.
func WriteLocalConfig ¶
func WriteLocalConfig(jirix *jiri.X, project Project, lc LocalConfig) error
func WritePackageFlags ¶
WritePackageFlags write flag files into project directory using in "flag" attribute from pkgs.
func WriteProjectFlags ¶
WriteProjectFlags write flag files into project directory using in "flag" attribute from projs.
func WriteUpdateHistoryLog ¶
WriteUpdateHistoryLog creates a log file of the current update process.
Types ¶
type BranchState ¶
type BranchState struct { *ReferenceState Tracking *ReferenceState }
type Hook ¶
type Hook struct { Name string `xml:"name,attr"` Action string `xml:"action,attr"` ProjectName string `xml:"project,attr"` XMLName struct{} `xml:"hook"` ActionPath string `xml:"-"` }
Hook represents a hook to run
type HookKey ¶
type HookKey string
HookKey is a unique string for a project.
func MakeHookKey ¶
MakeHookKey returns the hook key, given the hook and project name.
type HooksByName ¶
type HooksByName []Hook
HooksByName implements the Sort interface. It sorts Hooks by the Name and ProjectName field.
func (HooksByName) Len ¶
func (hooks HooksByName) Len() int
func (HooksByName) Less ¶
func (hooks HooksByName) Less(i, j int) bool
func (HooksByName) Swap ¶
func (hooks HooksByName) Swap(i, j int)
type Import ¶
type Import struct { // Manifest file to use from the remote manifest project. Manifest string `xml:"manifest,attr,omitempty"` // Name is the name of the remote manifest project, used to determine the // project key. Name string `xml:"name,attr,omitempty"` // Remote is the remote manifest project to import. Remote string `xml:"remote,attr,omitempty"` // Revision is the revison to checkout, // this takes precedence over RemoteBranch Revision string `xml:"revision,attr,omitempty"` // RemoteBranch is the name of the remote branch to track. RemoteBranch string `xml:"remotebranch,attr,omitempty"` // Root path, prepended to all project paths specified in the manifest file. Root string `xml:"root,attr,omitempty"` XMLName struct{} `xml:"import"` }
Import represents a remote manifest import.
func (*Import) ProjectKey ¶
func (i *Import) ProjectKey() ProjectKey
ProjectKey returns the unique ProjectKey for the imported project.
func (*Import) RemoveDefaults ¶
func (i *Import) RemoveDefaults()
type LocalConfig ¶
type LocalConfig struct { Ignore bool `xml:"ignore"` NoUpdate bool `xml:"no-update"` NoRebase bool `xml:"no-rebase"` XMLName struct{} `xml:"config"` }
func LocalConfigFromFile ¶
func LocalConfigFromFile(jirix *jiri.X, filename string) (LocalConfig, error)
type LocalImport ¶
type LocalImport struct { // Manifest file to import from. File string `xml:"file,attr,omitempty"` XMLName struct{} `xml:"localimport"` }
LocalImport represents a local manifest import.
type Manifest ¶
type Manifest struct { Version string `xml:"version,attr,omitempty"` Attributes string `xml:"attributes,attr,omitempty"` Imports []Import `xml:"imports>import"` LocalImports []LocalImport `xml:"imports>localimport"` Projects []Project `xml:"projects>project"` ProjectOverrides []Project `xml:"overrides>project"` ImportOverrides []Import `xml:"overrides>import"` Hooks []Hook `xml:"hooks>hook"` Packages []Package `xml:"packages>package"` XMLName struct{} `xml:"manifest"` }
Manifest represents a setting used for updating the universe.
func ManifestFromBytes ¶
ManifestFromBytes returns a manifest parsed from data, with defaults filled in.
func ManifestFromFile ¶
ManifestFromFile returns a manifest parsed from the contents of filename, with defaults filled in.
Note that unlike ProjectFromFile, ManifestFromFile does not convert project paths to absolute paths because it's possible to load a manifest with a specific root directory different from jirix.Root. The usual way to load a manifest is through LoadManifest, which does absolutize the paths, and uses the correct root directory.
type MultiError ¶
type MultiError []error
func (MultiError) Error ¶
func (m MultiError) Error() string
type Package ¶
type Package struct { // Name represents the remote cipd path of the package. Name string `xml:"name,attr"` // Version represents the version tag of the cipd package. Version string `xml:"version,attr"` // Path stores the local path of fetched cipd package. Path string `xml:"path,attr,omitempty"` // Internal marks if this package require special permission // for access Internal bool `xml:"internal,attr,omitempty"` // Platforms defines the available platforms for this cipd package. Platforms string `xml:"platforms,attr,omitempty"` // Flag defines the content that should be written to a file when // this package is successfully fetched. Flag string `xml:"flag,attr,omitempty"` // Attributes store the the list attributes for this package. // When it starts with "+", a computed default attributes will // be appended. Attributes string `xml:"attributes,attr,omitempty"` // Instances store the known instance ids for this package. // It is mainly used by snapshot file. Instances []PackageInstance `xml:"instance"` XMLName struct{} `xml:"package"` // ComputedAttributes stores computed attributes object // which is easiler to perform matching and comparing. ComputedAttributes attributes `xml:"-"` // ManifestPath stores the absolute path of the manifest. ManifestPath string `xml:"-"` }
Package struct represents the <package> tag in manifest files.
func (*Package) FillDefaults ¶
FillDefaults function fills default platforms information into Package struct if it is not defined and path is using template.
func (*Package) GetPlatforms ¶
GetPlatforms returns the platforms information of this Package struct.
func (Package) Key ¶
func (p Package) Key() PackageKey
type PackageInstance ¶
type PackageKey ¶
type PackageKey string
type PackageKeys ¶
type PackageKeys []PackageKey
func (PackageKeys) Len ¶
func (pks PackageKeys) Len() int
func (PackageKeys) Less ¶
func (pks PackageKeys) Less(i, j int) bool
func (PackageKeys) Swap ¶
func (pks PackageKeys) Swap(i, j int)
type PackageLock ¶
type PackageLock struct { PackageName string `json:"package"` LocalPath string `json:"path,omitempty"` VersionTag string `json:"version"` InstanceID string `json:"instance_id"` }
PackageLock describes locked version information for a jiri managed package.
func (PackageLock) Key ¶
func (p PackageLock) Key() PackageLockKey
type PackageLockKey ¶
type PackageLockKey string
PackageLockKey defines the key used in PackageLocks type
type PackageLocks ¶
type PackageLocks map[PackageLockKey]PackageLock
PackageLocks type is map wrapper over PackageLock for faster look up
type Packages ¶
type Packages map[PackageKey]Package
type PathTrie ¶
type PathTrie struct {
// contains filtered or unexported fields
}
func NewPathTrie ¶
func NewPathTrie() *PathTrie
type Project ¶
type Project struct { // Name is the project name. Name string `xml:"name,attr,omitempty"` // Path is the path used to store the project locally. Project // manifest uses paths that are relative to the root directory. // When a manifest is parsed (e.g. in RemoteProjects), the program // logic converts the relative paths to an absolute paths, using // the current root as a prefix. Path string `xml:"path,attr,omitempty"` // Remote is the project remote. Remote string `xml:"remote,attr,omitempty"` // RemoteBranch is the name of the remote branch to track. RemoteBranch string `xml:"remotebranch,attr,omitempty"` // Revision is the revision the project should be advanced to during "jiri // update". If Revision is set, RemoteBranch will be ignored. If Revision // is not set, "HEAD" is used as the default. Revision string `xml:"revision,attr,omitempty"` // HistoryDepth is the depth flag passed to git clone and git fetch // commands. It is used to limit downloading large histories for large // projects. HistoryDepth int `xml:"historydepth,attr,omitempty"` // GerritHost is the gerrit host where project CLs will be sent. GerritHost string `xml:"gerrithost,attr,omitempty"` // GitHooks is a directory containing git hooks that will be installed for // this project. GitHooks string `xml:"githooks,attr,omitempty"` // Attributes is a list of attributes for a project seperated by comma. // The project will not be fetched by default when attributes are present. Attributes string `xml:"attributes,attr,omitempty"` // GitAttributes is a list comma-separated attributes for a project, // which will be helpful to group projects with similar purposes together. // It will be used for .gitattributes file generation. GitAttributes string `xml:"git_attributes,attr,omitempty"` // Flag defines the content that should be written to a file when // this project is successfully fetched. Flag string `xml:"flag,attr,omitempty"` XMLName struct{} `xml:"project"` // This is used to store computed key. This is useful when remote and // local projects are same but have different name or remote ComputedKey ProjectKey `xml:"-"` // This stores the local configuration file for the project LocalConfig LocalConfig `xml:"-"` // ComputedAttributes stores computed attributes object // which is easiler to perform matching and comparing. ComputedAttributes attributes `xml:"-"` // ManifestPath stores the absolute path of the manifest. ManifestPath string `xml:"-"` }
Project represents a jiri project.
func CurrentProject ¶
CurrentProject gets the current project from the current directory by reading the jiri project metadata located in a directory at the root of the current repository.
func ProjectAtPath ¶
ProjectAtPath returns a Project struct corresponding to the project at the path in the filesystem.
func ProjectFromFile ¶
ProjectFromFile returns a project parsed from the contents of filename, with defaults filled in and all paths absolute.
func (*Project) CacheDirPath ¶
CacheDirPath returns a generated path to a directory that can be used as a reference repo for the given project.
func (Project) Key ¶
func (p Project) Key() ProjectKey
Key returns the unique ProjectKey for the project.
type ProjectKey ¶
type ProjectKey string
ProjectKey is a unique string for a project.
func MakeProjectKey ¶
func MakeProjectKey(name, remote string) ProjectKey
MakeProjectKey returns the project key, given the project name and remote.
type ProjectKeys ¶
type ProjectKeys []ProjectKey
ProjectKeys is a slice of ProjectKeys implementing the Sort interface.
func (ProjectKeys) Len ¶
func (pks ProjectKeys) Len() int
func (ProjectKeys) Less ¶
func (pks ProjectKeys) Less(i, j int) bool
func (ProjectKeys) Swap ¶
func (pks ProjectKeys) Swap(i, j int)
type ProjectLock ¶
type ProjectLock struct { Remote string `json:"repository_url"` Name string `json:"name"` Revision string `json:"revision"` }
ProjectLock describes locked version information for a jiri managed project.
func (ProjectLock) Key ¶
func (p ProjectLock) Key() ProjectLockKey
type ProjectLockKey ¶
type ProjectLockKey string
ProjectLockKey defines the key used in ProjectLocks type
type ProjectLocks ¶
type ProjectLocks map[ProjectLockKey]ProjectLock
ProjectLocks type is a map wrapper over ProjectLock for faster look up.
type ProjectState ¶
type ProjectState struct { Branches []BranchState CurrentBranch BranchState HasUncommitted bool HasUntracked bool Project Project }
func GetProjectState ¶
type ProjectStatus ¶
type Projects ¶
type Projects map[ProjectKey]Project
Projects maps ProjectKeys to Projects.
func LocalProjects ¶
LocalProjects returns projects on the local filesystem. If all projects in the manifest exist locally and scanMode is set to FastScan, then only the projects in the manifest that exist locally will be returned. Otherwise, a full scan of the filesystem will take place, and all found projects will be returned.
type ProjectsByPath ¶
type ProjectsByPath []Project
ProjectsByPath implements the Sort interface. It sorts Projects by the Path field.
func (ProjectsByPath) Len ¶
func (projects ProjectsByPath) Len() int
func (ProjectsByPath) Less ¶
func (projects ProjectsByPath) Less(i, j int) bool
func (ProjectsByPath) Swap ¶
func (projects ProjectsByPath) Swap(i, j int)
type ReferenceState ¶
type ResolveConfig ¶
type ResolveConfig interface { AllowFloatingRefs() bool LockFilePath() string LocalManifest() bool EnablePackageLock() bool EnableProjectLock() bool HostnameAllowList() []string }
ResolveConfig interface provides the configuration for jiri resolve command.
type ScanMode ¶
type ScanMode bool
ScanMode determines whether LocalProjects should scan the local filesystem for projects (FullScan), or optimistically assume that the local projects will match those in the manifest (FastScan).
type SourceManifest ¶
type SourceManifest struct { // Version will increment on backwards-incompatible changes only. Backwards // compatible changes will not alter this version number. // // Currently, the only valid version number is 0. Version int32 `json:"version"` // Map of local file system directory path (with forward slashes) to // a Directory message containing one or more deployments. // // The local path is relative to some job-specific root. This should be used // for informational/display/organization purposes, and should not be used as // a global primary key. i.e. if you depend on chromium/src.git being in // a folder called “src”, I will find you and make really angry faces at you // until you change it...(╬ಠ益ಠ). Instead, implementations should consider // indexing by e.g. git repository URL or cipd package name as more better // primary keys. Directories map[string]*SourceManifest_Directory `json:"directories"` }
type SourceManifest_Directory ¶
type SourceManifest_Directory struct {
GitCheckout *SourceManifest_GitCheckout `json:"git_checkout,omitempty"`
}
type SourceManifest_GitCheckout ¶
type SourceManifest_GitCheckout struct { // The canonicalized URL of the original repo that is considered the “source // of truth” for the source code. Ex. // https://chromium.googlesource.com/chromium/tools/build.git // https://github.com/luci/recipes-py RepoUrl string `json:"repo_url,omitempty"` // If different from repo_url, this can be the URL of the repo that the source // was actually fetched from (i.e. a mirror). Ex. // https://chromium.googlesource.com/external/github.com/luci/recipes-py // // If this is empty, it's presumed to be equal to repo_url. FetchUrl string `json:"fetch_url,omitempty"` // The fully resolved revision (commit hash) of the source. Ex. // 3617b0eea7ec74b8e731a23fed2f4070cbc284c4 // // Note that this is the raw revision bytes, not their hex-encoded form. Revision string `json:"revision,omitempty"` // The ref that the task used to resolve/fetch the revision of the source // (if any). Ex. // refs/heads/master // refs/changes/04/511804/4 // // This should always be a ref on the hosted repo (not any local alias // like 'refs/remotes/...'). // // This should always be an absolute ref (i.e. starts with 'refs/'). An // example of a non-absolute ref would be 'master'. FetchRef string `json:"fetch_ref,omitempty"` }
This was created using proto file: https://github.com/luci/recipes-py/blob/master/recipe_engine/source_manifest.proto.