Documentation
¶
Index ¶
- func VersionToRevision(version string) string
- type Cache
- func (cache *Cache) DownloadRepo(modulePath string) (repo *CachedRepo, err error)
- func (cache *Cache) EnsureDirectoryStructurePresent() error
- func (cache *Cache) GetModuleBaseDir() string
- func (cache *Cache) GetModuleDir(version module.Version) (string, error)
- func (cache *Cache) GetReplaceBaseDir() string
- func (cache *Cache) GetReplaceDir(version module.Version) (string, error)
- func (cache *Cache) GetRepoBaseDir() string
- func (cache *Cache) GetRepoDir(path string) (string, error)
- func (cache *Cache) InstallMod(version module.Version) (*CachedModule, error)
- func (cache *Cache) IsDirectoryStructurePresent() (bool, error)
- func (cache *Cache) ListModules() ([]module.Version, error)
- func (cache *Cache) RemoveTmpFiles() error
- func (cache *Cache) ReplaceMod(version module.Version, path string) (*CachedModule, error)
- type CachedModule
- type CachedRepo
- func (cr *CachedRepo) Checkout(revision string) error
- func (cr *CachedRepo) CheckoutDefault() error
- func (cr *CachedRepo) Close() error
- func (cr *CachedRepo) CurrentVersion(modulePath string) (module.Version, error)
- func (cr *CachedRepo) FetchUpdates() error
- func (cr *CachedRepo) ListTags() ([]string, error)
- func (cr *CachedRepo) Update() error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VersionToRevision ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides access to the on-disk cache of modules, and the version control repositories that those modules come from. The cache uses locking to ensure that multiple processes may access the same cache simultaneously.
func New ¶
New creates a cache object to access the cache. The location of the cache is determined by the config. This function does not create, delete or modify any files or directories, it simply opens the cache object for use.
func (*Cache) DownloadRepo ¶
func (cache *Cache) DownloadRepo(modulePath string) (repo *CachedRepo, err error)
DownloadRepo will download the repo corresponding to the given module path, and place it in the repo cache. If that repo is already cached, it won't be downloaded again.
func (*Cache) EnsureDirectoryStructurePresent ¶
EnsureDirectoryStructurePresent will check if the base directories exist on the filesystem, and create them if they do not exist.
func (*Cache) GetModuleBaseDir ¶
GetModuleBaseDir returns the path of the directory that contains the module cache.
func (*Cache) GetModuleDir ¶
GetModuleDir returns the directory where the module (at the given version) should be stored. There is no guarantee that this version of the module is actually in the cache.
func (*Cache) GetReplaceBaseDir ¶
GetReplaceBaseDir returns the path of the directory that contains the module replacements cache.
func (*Cache) GetReplaceDir ¶
GetReplaceDir returns the directory where the module (at the given version) should be stored. There is no guarantee that this version of the module is actually in the cache.
func (*Cache) GetRepoBaseDir ¶
GetRepoBaseDir returns the path of the directory that contains the repository cache.
func (*Cache) GetRepoDir ¶
GetRepoDir returns the directory where the repository with the given root path should be stored. There is no guarantee that this repo is actually in the cache.
func (*Cache) InstallMod ¶
func (cache *Cache) InstallMod(version module.Version) (*CachedModule, error)
InstallMod will install the given version of a module into the module cache. If the module is already there, this returns the existing cache entry.
func (*Cache) IsDirectoryStructurePresent ¶
IsDirectoryStructurePresent will check if the base directories exist on the filesystem.
func (*Cache) ListModules ¶
ListModules will return a slice of every module version that is currently in the cache. If the cache is missing entirely, returns the empty slice.
func (*Cache) RemoveTmpFiles ¶
RemoveTmpFiles removes any temporary files that were used as part of this cache. This is not the same as clearing the cache, temporary files are used for a single cache instance only.
func (*Cache) ReplaceMod ¶
ReplaceMod creates a cached replacement directory that mirrors the structure used for remote modules but whose source is the given path.
type CachedModule ¶
CachedModule represents a module stored in a Cache. This structure contains a lock on the module cache directory. It is essential that you close it!
func (*CachedModule) Close ¶
func (mod *CachedModule) Close() error
func (*CachedModule) GetModFilePath ¶
func (mod *CachedModule) GetModFilePath() string
func (*CachedModule) ListDependencies ¶
func (mod *CachedModule) ListDependencies() ([]module.Version, error)
ListDependencies returns a slice of all this module's direct dependencies We assume that a module lacking a proto.mod file has no dependencies
type CachedRepo ¶
CachedRepo represents a VCS repo stored in a cache. This structure contains a lock on the repository cache directory. You must close it (use a defer)
func (*CachedRepo) Checkout ¶
func (cr *CachedRepo) Checkout(revision string) error
Checkout will change the contents of the repo to a specified revision. revision could be:
- a tag name
- a branch name
- a commit identifier (e.g. a git commit hash)
This operation is not atomic; if Checkout returns an error, the repo may be in an inconsistent state, so you should call it again before you use the contents of the repo directory for anything.
func (*CachedRepo) CheckoutDefault ¶
func (cr *CachedRepo) CheckoutDefault() error
CheckoutDefault will checkout whatever the remote considers to be the default branch for this repo. e.g. typically 'main' or 'master' for Git repos
func (*CachedRepo) Close ¶
func (cr *CachedRepo) Close() error
func (*CachedRepo) CurrentVersion ¶
func (cr *CachedRepo) CurrentVersion(modulePath string) (module.Version, error)
CurrentVersion calculates the version string used in module files, that corresponds to revision currently checked out in this repository
func (*CachedRepo) FetchUpdates ¶
func (cr *CachedRepo) FetchUpdates() error
FetchUpdates will download new commits from the default remote. This might change the current branch.
func (*CachedRepo) ListTags ¶
func (cr *CachedRepo) ListTags() ([]string, error)
func (*CachedRepo) Update ¶
func (cr *CachedRepo) Update() error
Update will download new commits from the current branch. The tip of the repo should be on a branch for this to work.