Documentation
¶
Index ¶
- type Archive
- type MockVersions
- func (m *MockVersions) DownloadRelease(tag, url string) (path string, err error)
- func (m *MockVersions) GetInstalledVersion(constraint string) (tag string, path string, err error)
- func (m *MockVersions) GetLatestReleaseURL(constraint string) (tag string, url string, err error)
- func (m *MockVersions) InRange(version string, constraint string) (bool, error)
- func (m *MockVersions) ListInstalledVersions(constraint string) (map[string]string, error)
- func (m *MockVersions) ListReleases(constraint string) (map[string]string, error)
- func (m *MockVersions) SortMapKeys(ma map[string]string, descending bool) []string
- type Options
- type Versions
- type VersionsImpl
- func (v *VersionsImpl) DownloadRelease(tag, url string) (filePath string, err error)
- func (v *VersionsImpl) GetInstalledVersion(constraint string) (string, string, error)
- func (v *VersionsImpl) GetLatestReleaseURL(constraint string) (string, string, error)
- func (v *VersionsImpl) InRange(version string, constraint string) (bool, error)
- func (v *VersionsImpl) ListInstalledVersions(constraint string) (map[string]string, error)
- func (v *VersionsImpl) ListReleases(constraint string) (map[string]string, error)
- func (v *VersionsImpl) SortMapKeys(m map[string]string, decending bool) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockVersions ¶
func (*MockVersions) DownloadRelease ¶
func (m *MockVersions) DownloadRelease(tag, url string) (path string, err error)
func (*MockVersions) GetInstalledVersion ¶
func (m *MockVersions) GetInstalledVersion(constraint string) (tag string, path string, err error)
func (*MockVersions) GetLatestReleaseURL ¶
func (m *MockVersions) GetLatestReleaseURL(constraint string) (tag string, url string, err error)
func (*MockVersions) InRange ¶
func (m *MockVersions) InRange(version string, constraint string) (bool, error)
func (*MockVersions) ListInstalledVersions ¶
func (m *MockVersions) ListInstalledVersions(constraint string) (map[string]string, error)
func (*MockVersions) ListReleases ¶
func (m *MockVersions) ListReleases(constraint string) (map[string]string, error)
func (*MockVersions) SortMapKeys ¶
func (m *MockVersions) SortMapKeys(ma map[string]string, descending bool) []string
type Options ¶
type Options struct {
Organization string
Repo string
GOOS string // set to os default if blank
GOARCH string // set to os value if blank
AssetNameFunc func(ver, goos, goarch string) string
ExeNameFunc func(ver, goos, goarch string) string
ReleasesPath string // location to store donwloaded releases
}
Options defines the options for Versions
type Versions ¶
type Versions interface {
// ListAvailable lists the currently available releases
// returns a map of version tags with the asset URL
// Optionally specify a semantic version contstraint to filter results
// e.g. "~1.2.3", version is greater or equal to 1.2.3 and less than 1.3.0
ListReleases(constraint string) (map[string]string, error)
// GetLatestRelease returns the asset for the latest release given the constraint
GetLatestReleaseURL(constraint string) (tag string, url string, err error)
// Download and uncompress the release at the given url
DownloadRelease(tag, url string) (path string, err error)
// ListInstalledVersions lists versions which have been installed
ListInstalledVersions(constraint string) (map[string]string, error)
// GetInstalledVersion returns the version for the latests release given the constraint
GetInstalledVersion(constraint string) (tag string, path string, err error)
// SortMapKeys sorts the keys in the map and returns a sorted slice
// keys must adhere to Semver
SortMapKeys(map[string]string, bool) []string
// InRange returns true when the version can be satisfied by the constraint
// Returns an error if either the constraint or the version are not valid semantic versions
InRange(version string, constraint string) (bool, error)
}
Versions defines the methods for a Go Version Manager implementation
type VersionsImpl ¶
type VersionsImpl struct {
// contains filtered or unexported fields
}
VersionsImpl is the concrete implementation for the Versions interface
func (*VersionsImpl) DownloadRelease ¶
func (v *VersionsImpl) DownloadRelease(tag, url string) (filePath string, err error)
DownloadRelease and uncompress the given release
func (*VersionsImpl) GetInstalledVersion ¶
func (v *VersionsImpl) GetInstalledVersion(constraint string) (string, string, error)
func (*VersionsImpl) GetLatestReleaseURL ¶
func (v *VersionsImpl) GetLatestReleaseURL(constraint string) (string, string, error)
GetLatestRelease returns the asset which has the latest semantic version matching the constraint
func (*VersionsImpl) InRange ¶
func (v *VersionsImpl) InRange(version string, constraint string) (bool, error)
func (*VersionsImpl) ListInstalledVersions ¶
func (v *VersionsImpl) ListInstalledVersions(constraint string) (map[string]string, error)
ListInstalledVersions lists the versions of the software which are installed int the archive folder
func (*VersionsImpl) ListReleases ¶
func (v *VersionsImpl) ListReleases(constraint string) (map[string]string, error)
ListReleases returns a map of assets for releases which match the given semantic version and which contain assets matching the value returned from AssetNameFunc If no version is specified all versions with matching assets are returned Release tags which are not valid semantic versions are ignored
func (*VersionsImpl) SortMapKeys ¶
func (v *VersionsImpl) SortMapKeys(m map[string]string, decending bool) []string