Documentation
¶
Index ¶
- Constants
- Variables
- func CloneMirror(repo *V1Repository, components []string, ...) error
- func FnameWithVersion(fname string, version uint) string
- func MergeMirror(keys map[string]*v1manifest.KeyInfo, base Mirror, additions ...Mirror) error
- func PlatformString(os, arch string) string
- func UpdateManifestForPublish(m *v1manifest.Component, name, ver, entry, os, arch, desc string, ...) *v1manifest.Component
- type CloneOptions
- type ComponentSpec
- type DisableProgress
- type DownloadProgress
- type Mirror
- type MirrorOptions
- type MockMirror
- func (l *MockMirror) Close() error
- func (l *MockMirror) Download(resource, targetDir string) error
- func (l *MockMirror) Fetch(resource string, maxSize int64) (io.ReadCloser, error)
- func (l *MockMirror) Grant(id, name string, key *v1manifest.KeyInfo) error
- func (l *MockMirror) Open() error
- func (l *MockMirror) Publish(manifest *v1manifest.Manifest, info model.ComponentInfo) error
- func (l *MockMirror) Rotate(m *v1manifest.Manifest) error
- func (l *MockMirror) Source() string
- type Options
- type ProgressBar
- type Repository
- type V1Repository
- func (r *V1Repository) BinaryPath(installPath string, componentID string, ver string) (string, error)
- func (r *V1Repository) ComponentVersion(id, ver 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) FetchComponentManifest(id string, withYanked bool) (com *v1manifest.Component, err error)
- func (r *V1Repository) FetchIndexManifest() (index *v1manifest.Index, err error)
- func (r *V1Repository) FetchRootManifest() (root *v1manifest.Root, err error)
- func (r *V1Repository) LatestNightlyVersion(id string) (utils.Version, *v1manifest.VersionItem, error)
- func (r *V1Repository) LatestStableVersion(id string, withYanked bool) (utils.Version, *v1manifest.VersionItem, error)
- func (r *V1Repository) Local() v1manifest.LocalManifests
- func (r *V1Repository) Mirror() Mirror
- func (r *V1Repository) PlatformString() string
- func (r *V1Repository) PurgeTimestamp()
- func (r *V1Repository) ResolveComponentVersion(id, constraint string) (utils.Version, error)
- func (r *V1Repository) UpdateComponentManifests() error
- func (r *V1Repository) UpdateComponents(specs []ComponentSpec) error
- func (r *V1Repository) WithOptions(opts Options) *V1Repository
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" )
const ( // OptionYanked is the key that represents a component is yanked or not OptionYanked = "yanked" // OptionStandalone is the key that represents a component is standalone or not OptionStandalone = "standalone" // OptionHidden is the key that represents a component is hidden or not OptionHidden = "hidden" )
Variables ¶
var ( ErrNotFound = stderrors.New("not found") // resource does not exists ErrManifestTooOld = stderrors.New("component manifest is too old, update it before publish") )
predefined errors
var ErrUnknownComponent = errors.New("unknown component")
ErrUnknownComponent represents the specific component cannot be found in index.json
var ErrUnknownVersion = errors.New("unknown version")
ErrUnknownVersion represents the specific component version cannot be found in component.json
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 MergeMirror ¶ added in v1.3.0
MergeMirror merges two or more mirrors
func PlatformString ¶
PlatformString returns a string identifying the current system.
func UpdateManifestForPublish ¶ added in v1.3.0
func UpdateManifestForPublish(m *v1manifest.Component, name, ver, entry, os, arch, desc string, filehash v1manifest.FileHash) *v1manifest.Component
UpdateManifestForPublish set corresponding field for component manifest
Types ¶
type CloneOptions ¶
type CloneOptions struct { Archs []string OSs []string Versions []string Full bool Components map[string]*[]string Prefix bool Jobs uint }
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 }
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 { model.Backend // 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 Upstream string KeyDir string }
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) Grant ¶ added in v1.3.0
func (l *MockMirror) Grant(id, name string, key *v1manifest.KeyInfo) error
Grant implements the model.Backend interface
func (*MockMirror) Publish ¶ added in v1.3.0
func (l *MockMirror) Publish(manifest *v1manifest.Manifest, info model.ComponentInfo) error
Publish implements the Mirror interface
func (*MockMirror) Rotate ¶ added in v1.3.0
func (l *MockMirror) Rotate(m *v1manifest.Manifest) error
Rotate implements the model.Backend interface
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
}
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.
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, ver 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, ver 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 ¶ added in v1.3.0
func (r *V1Repository) DownloadTiUP(targetDir string) error
DownloadTiUP downloads the tiup tarball and expands it into targetDir
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) FetchRootManifest ¶ added in v1.5.0
func (r *V1Repository) FetchRootManifest() (root *v1manifest.Root, err error)
FetchRootManifest fetch the root manifest.
func (*V1Repository) LatestNightlyVersion ¶ added in v1.3.3
func (r *V1Repository) LatestNightlyVersion(id string) (utils.Version, *v1manifest.VersionItem, error)
LatestNightlyVersion returns the latest nightly version of specific component
func (*V1Repository) LatestStableVersion ¶ added in v1.0.8
func (r *V1Repository) LatestStableVersion(id string, withYanked bool) (utils.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) PurgeTimestamp ¶ added in v1.4.0
func (r *V1Repository) PurgeTimestamp()
PurgeTimestamp remove timestamp cache from repository
func (*V1Repository) ResolveComponentVersion ¶ added in v1.5.0
func (r *V1Repository) ResolveComponentVersion(id, constraint string) (utils.Version, error)
ResolveComponentVersion resolves the latest version of a component that satisfies the constraint
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.
func (*V1Repository) WithOptions ¶ added in v1.3.6
func (r *V1Repository) WithOptions(opts Options) *V1Repository
WithOptions clone a new V1Repository with given options