Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIpfsDir(dir string) (string, error)
- func DistVersions(ctx context.Context, fetcher Fetcher, dist string, sortDesc bool) ([]string, error)
- func ExeName(name string) string
- func FetchBinary(ctx context.Context, fetcher Fetcher, dist, ver, binName, out string) (string, error)
- func GetDistPathEnv(distPath string) string
- func IpfsDir(dir string) (string, error)
- func LatestDistVersion(ctx context.Context, fetcher Fetcher, dist string, stableOnly bool) (string, error)
- func NeedMigration(target int) (bool, error)
- func NewLimitReadCloser(rc io.ReadCloser, limit int64) io.ReadCloser
- func ReadMigrationConfig(repoRoot string, userConfigFile string) (*config.Migration, error)
- func RepoVersion(ipfsDir string) (int, error)
- func RunMigration(ctx context.Context, fetcher Fetcher, targetVer int, ipfsDir string, ...) error
- func WriteRepoVersion(ipfsDir string, version int) error
- type Fetcher
- type HttpFetcher
- type MultiFetcher
- type RetryFetcher
Constants ¶
const ( // Current distribution to fetch migrations from CurrentIpfsDist = "/ipfs/QmdaCHYBDHEhXCMoynH5UcohEay6m1XayZCcxWZzKAHNVN" // fs-repo-11-to-12 v1.0.2 // Latest distribution path. Default for fetchers. LatestIpfsDist = "/ipns/dist.ipfs.io" )
Variables ¶
var DownloadDirectory string
DownloadDirectory can be set as the location for FetchBinary to save the downloaded archive file in. If not set, then FetchBinary saves the archive in a temporary directory that is removed after the contents of the archive is extracted.
Functions ¶
func CheckIpfsDir ¶ added in v0.9.0
CheckIpfsDir gets the ipfs directory and checks that the directory exists.
func DistVersions ¶ added in v0.9.0
func DistVersions(ctx context.Context, fetcher Fetcher, dist string, sortDesc bool) ([]string, error)
DistVersions returns all versions of the specified distribution, that are available on the distriburion site. List is in ascending order, unless sortDesc is true.
func FetchBinary ¶ added in v0.9.0
func FetchBinary(ctx context.Context, fetcher Fetcher, dist, ver, binName, out string) (string, error)
FetchBinary downloads an archive from the distribution site and unpacks it.
The base name of the binary inside the archive may differ from the base archive name. If it does, then specify binName. For example, the following is needed because the archive "go-ipfs_v0.7.0_linux-amd64.tar.gz" contains a binary named "ipfs"
FetchBinary(ctx, fetcher, "go-ipfs", "v0.7.0", "ipfs", tmpDir)
If out is a directory, then the binary is written to that directory with the same name it has inside the archive. Otherwise, the binary file is written to the file named by out.
func GetDistPathEnv ¶ added in v0.9.0
GetDistPathEnv returns the IPFS path to the distribution site, using the value of environ variable specified by envIpfsDistPath. If the environ variable is not set, then returns the provided distPath, and if that is not set then returns the IPNS path.
To get the IPFS path of the latest distribution, if not overriddin by the environ variable: GetDistPathEnv(CurrentIpfsDist)
func IpfsDir ¶ added in v0.9.0
IpfsDir returns the path of the ipfs directory. If dir specified, then returns the expanded version dir. If dir is "", then return the directory set by IPFS_PATH, or if IPFS_PATH is not set, then return the default location in the home directory.
func LatestDistVersion ¶ added in v0.9.0
func LatestDistVersion(ctx context.Context, fetcher Fetcher, dist string, stableOnly bool) (string, error)
LatestDistVersion returns the latest version, of the specified distribution, that is available on the distribution site.
func NeedMigration ¶ added in v0.9.0
func NewLimitReadCloser ¶ added in v0.9.0
func NewLimitReadCloser(rc io.ReadCloser, limit int64) io.ReadCloser
NewLimitReadCloser returns a new io.ReadCloser with the reader wrappen in a io.LimitedReader limited to reading the amount specified.
func ReadMigrationConfig ¶ added in v0.10.0
ReadMigrationConfig reads the Migration section of the IPFS config, avoiding reading anything other than the Migration section. That way, we're free to make arbitrary changes to all _other_ sections in migrations.
func RepoVersion ¶ added in v0.9.0
RepoVersion returns the version of the repo in the ipfs directory. If the ipfs directory is not specified then the default location is used.
func RunMigration ¶ added in v0.4.3
func RunMigration(ctx context.Context, fetcher Fetcher, targetVer int, ipfsDir string, allowDowngrade bool) error
RunMigration finds, downloads, and runs the individual migrations needed to migrate the repo from its current version to the target version.
func WriteRepoVersion ¶ added in v0.9.0
WriteRepoVersion writes the specified repo version to the repo located in ipfsDir. If ipfsDir is not specified, then the default location is used.
Types ¶
type Fetcher ¶ added in v0.9.0
type HttpFetcher ¶ added in v0.9.0
type HttpFetcher struct {
// contains filtered or unexported fields
}
HttpFetcher fetches files over HTTP
func NewHttpFetcher ¶ added in v0.9.0
func NewHttpFetcher(distPath, gateway, userAgent string, fetchLimit int64) *HttpFetcher
NewHttpFetcher creates a new HttpFetcher
Specifying "" for distPath sets the default IPNS path. Specifying "" for gateway sets the default. Specifying 0 for fetchLimit sets the default, -1 means no limit.
func (*HttpFetcher) Close ¶ added in v0.9.0
func (f *HttpFetcher) Close() error
type MultiFetcher ¶ added in v0.9.0
type MultiFetcher struct {
// contains filtered or unexported fields
}
MultiFetcher holds multiple Fetchers and provides a Fetch that tries each until one succeeds.
func NewMultiFetcher ¶ added in v0.9.0
func NewMultiFetcher(f ...Fetcher) *MultiFetcher
NewMultiFetcher creates a MultiFetcher with the given Fetchers. The Fetchers are tried in order, then passed to this function.
func (*MultiFetcher) Close ¶ added in v0.9.0
func (f *MultiFetcher) Close() error
func (*MultiFetcher) Fetch ¶ added in v0.9.0
Fetch attempts to fetch the file at each of its fetchers until one succeeds.
func (*MultiFetcher) Fetchers ¶ added in v0.9.0
func (f *MultiFetcher) Fetchers() []Fetcher
func (*MultiFetcher) Len ¶ added in v0.9.0
func (f *MultiFetcher) Len() int