Documentation
¶
Index ¶
- Constants
- Variables
- func CloneMirror(repo *V1Repository, components []string, ...) error
- func FnameWithVersion(fname string, version uint) string
- func PlatformString(os, arch string) string
- type CloneOptions
- type ComponentSpec
- type DisableProgress
- type DownloadProgress
- type Mirror
- type MirrorOptions
- type MockMirror
- type Options
- type ProgressBar
- type Repository
- func (r *Repository) Close() error
- func (r *Repository) ComponentVersions(component string) (*v0manifest.VersionManifest, error)
- func (r *Repository) DownloadComponent(compsDir, component string, version v0manifest.Version) error
- func (r *Repository) DownloadTiup(targetDir string) error
- func (r *Repository) LatestStableVersion(component string) (v0manifest.Version, error)
- func (r *Repository) Manifest() (*v0manifest.ComponentManifest, error)
- func (r *Repository) Mirror() Mirror
- type V1Repository
- func (r *V1Repository) BinaryPath(installPath string, componentID string, version string) (string, error)
- func (r *V1Repository) ComponentVersion(id, version string, includeYanked bool) (*v1manifest.VersionItem, error)
- func (r *V1Repository) DownloadComponent(item *v1manifest.VersionItem, target string) error
- func (r *V1Repository) DownloadTiup(targetDir string) error
- func (r *V1Repository) FetchComponent(item *v1manifest.VersionItem) (io.Reader, error)
- func (r *V1Repository) FetchComponentManifest(id string, withYanked bool) (com *v1manifest.Component, err error)
- func (r *V1Repository) FetchIndexManifest() (index *v1manifest.Index, err error)
- func (r *V1Repository) LatestStableVersion(id string, withYanked bool) (v0manifest.Version, *v1manifest.VersionItem, error)
- func (r *V1Repository) Local() v1manifest.LocalManifests
- func (r *V1Repository) Mirror() Mirror
- func (r *V1Repository) PlatformString() string
- func (r *V1Repository) UpdateComponentManifests() error
- func (r *V1Repository) UpdateComponents(specs []ComponentSpec) error
Constants ¶
const ( // ManifestFileName is the filename of the manifest. ManifestFileName = "tiup-manifest.index" // DefaultMirror is the location of the mirror to use if none is specified by the user via `EnvMirrors`. DefaultMirror = "https://tiup-mirrors.pingcap.com/" // EnvMirrors is the name of an env var the user can set to specify a mirror. EnvMirrors = "TIUP_MIRRORS" // TiupBinaryName is the name of the tiup binary, both in the repository and locally. TiupBinaryName = "tiup" )
Variables ¶
var ErrNotFound = stderrors.New("not found")
ErrNotFound represents the resource not exists.
Functions ¶
func CloneMirror ¶
func CloneMirror(repo *V1Repository, components []string, tidbClusterVersionMapper func(string) string, targetDir string, selectedVersions []string, options CloneOptions) error
CloneMirror clones a local mirror from the remote repository
func FnameWithVersion ¶
FnameWithVersion returns a filename, which contains the specific version number
func PlatformString ¶
PlatformString returns a string identifying the current system.
Types ¶
type CloneOptions ¶
type CloneOptions struct { Archs []string OSs []string Versions []string Full bool Components map[string]*[]string Prefix bool }
CloneOptions represents the options of clone a remote mirror
type ComponentSpec ¶
type ComponentSpec struct { // TargetDir it the target directory of the component, // Will use the default directory of Profile if it's empty. TargetDir string // ID is the id of the component ID string // Version describes the versions which are desirable; "" = use the most recent, compatible version. Version string // Force is true means overwrite any existing installation. Force bool // Nightly means to install a latest nightly version. Nightly bool }
ComponentSpec describes a component a user would like to have or use.
type DisableProgress ¶
type DisableProgress struct{}
DisableProgress implement the DownloadProgress interface and disable download progress
func (DisableProgress) Finish ¶
func (d DisableProgress) Finish()
Finish implement the DownloadProgress interface
func (DisableProgress) SetCurrent ¶
func (d DisableProgress) SetCurrent(size int64)
SetCurrent implement the DownloadProgress interface
func (DisableProgress) Start ¶
func (d DisableProgress) Start(url string, size int64)
Start implement the DownloadProgress interface
type DownloadProgress ¶
DownloadProgress represents the download progress notifier
type Mirror ¶
type Mirror interface { // Source returns the address of the mirror Source() string // Open initialize the mirror. Open() error // Download fetches a resource to disk. // The implementation must return ErrNotFound if the resource not exists. Download(resource, targetDir string) error // Fetch fetches a resource into memory. The caller must close the returned reader. Id the size of the resource // is greater than maxSize, Fetch returns an error. Use maxSize == 0 for no limit. // The implementation must return ErrNotFound if the resource not exists. Fetch(resource string, maxSize int64) (io.ReadCloser, error) // Close closes the mirror and release local stashed files. Close() error }
Mirror represents a repository mirror, which can be remote HTTP server or a local file system directory
func NewMirror ¶
func NewMirror(mirror string, options MirrorOptions) Mirror
NewMirror returns a mirror instance Base on the schema of mirror
type MirrorOptions ¶
type MirrorOptions struct {
Progress DownloadProgress
}
MirrorOptions is used to customize the mirror download options
type MockMirror ¶
type MockMirror struct { // Resources is a map from resource name to resource content. Resources map[string]string }
MockMirror is a mirror for testing
func (*MockMirror) Download ¶
func (l *MockMirror) Download(resource, targetDir string) error
Download implements Mirror.
func (*MockMirror) Fetch ¶
func (l *MockMirror) Fetch(resource string, maxSize int64) (io.ReadCloser, error)
Fetch implements Mirror.
func (*MockMirror) Source ¶
func (l *MockMirror) Source() string
Source implements the Mirror interface
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar implement the DownloadProgress interface with download progress
func (*ProgressBar) Finish ¶
func (p *ProgressBar) Finish()
Finish implement the DownloadProgress interface
func (*ProgressBar) SetCurrent ¶
func (p *ProgressBar) SetCurrent(size int64)
SetCurrent implement the DownloadProgress interface
func (*ProgressBar) Start ¶
func (p *ProgressBar) Start(url string, size int64)
Start implement the DownloadProgress interface
type Repository ¶
type Repository struct { Options // contains filtered or unexported fields }
Repository represents a components repository. All logic concerning manifests and the locations of tarballs is contained in the Repository object. Any IO is delegated to mirrorSource, which in turn will delegate fetching files to a Mirror.
func NewRepository ¶
func NewRepository(mirror Mirror, opts Options) (*Repository, error)
NewRepository returns a repository instance based on mirror. mirror should be in an open state.
func (*Repository) Close ¶
func (r *Repository) Close() error
Close shuts down the repository, including any open mirrors.
func (*Repository) ComponentVersions ¶
func (r *Repository) ComponentVersions(component string) (*v0manifest.VersionManifest, error)
ComponentVersions returns the version manifest of specific component
func (*Repository) DownloadComponent ¶
func (r *Repository) DownloadComponent(compsDir, component string, version v0manifest.Version) error
DownloadComponent downloads a component with specific version from repository support `<component>[:version]` format
func (*Repository) DownloadTiup ¶
func (r *Repository) DownloadTiup(targetDir string) error
DownloadTiup downloads the tiup tarball and expands it into targetDir
func (*Repository) LatestStableVersion ¶
func (r *Repository) LatestStableVersion(component string) (v0manifest.Version, error)
LatestStableVersion returns the latest stable version of specific component
func (*Repository) Manifest ¶
func (r *Repository) Manifest() (*v0manifest.ComponentManifest, error)
Manifest returns the v0 component manifest fetched from repository
func (*Repository) Mirror ¶
func (r *Repository) Mirror() Mirror
Mirror returns the mirror of the repository
type V1Repository ¶
type V1Repository struct { Options // contains filtered or unexported fields }
V1Repository represents a remote repository viewed with the v1 manifest design.
func NewV1Repo ¶
func NewV1Repo(mirror Mirror, opts Options, local v1manifest.LocalManifests) *V1Repository
NewV1Repo creates a new v1 repository from the given mirror local must exists a trusted root.
func (*V1Repository) BinaryPath ¶
func (r *V1Repository) BinaryPath(installPath string, componentID string, version string) (string, error)
BinaryPath return the binary path of the component. Support you have install the component, need to get entry from local manifest. Load the manifest locally only to get then Entry, do not force do something need access mirror.
func (*V1Repository) ComponentVersion ¶
func (r *V1Repository) ComponentVersion(id, version string, includeYanked bool) (*v1manifest.VersionItem, error)
ComponentVersion returns version item of a component
func (*V1Repository) DownloadComponent ¶ added in v1.2.0
func (r *V1Repository) DownloadComponent(item *v1manifest.VersionItem, target string) error
DownloadComponent downloads the component specified by item into local file, the component will be removed if hash is not correct
func (*V1Repository) DownloadTiup ¶
func (r *V1Repository) DownloadTiup(targetDir string) error
DownloadTiup downloads the tiup tarball and expands it into targetDir
func (*V1Repository) FetchComponent ¶
func (r *V1Repository) FetchComponent(item *v1manifest.VersionItem) (io.Reader, error)
FetchComponent downloads the component specified by item.
func (*V1Repository) FetchComponentManifest ¶
func (r *V1Repository) FetchComponentManifest(id string, withYanked bool) (com *v1manifest.Component, err error)
FetchComponentManifest fetch the component manifest.
func (*V1Repository) FetchIndexManifest ¶
func (r *V1Repository) FetchIndexManifest() (index *v1manifest.Index, err error)
FetchIndexManifest fetch the index manifest.
func (*V1Repository) LatestStableVersion ¶ added in v1.0.8
func (r *V1Repository) LatestStableVersion(id string, withYanked bool) (v0manifest.Version, *v1manifest.VersionItem, error)
LatestStableVersion returns the latest stable version of specific component
func (*V1Repository) Local ¶ added in v1.0.2
func (r *V1Repository) Local() v1manifest.LocalManifests
Local returns the local cached manifests
func (*V1Repository) PlatformString ¶
func (r *V1Repository) PlatformString() string
PlatformString returns a string identifying the current system.
func (*V1Repository) UpdateComponentManifests ¶ added in v1.0.2
func (r *V1Repository) UpdateComponentManifests() error
UpdateComponentManifests updates all components's manifest to the latest version
func (*V1Repository) UpdateComponents ¶
func (r *V1Repository) UpdateComponents(specs []ComponentSpec) error
UpdateComponents updates the components described by specs.