migrations

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2021 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Current dirstibution to fetch migrations from
	CurrentIpfsDist = "/ipfs/QmVxxcTSuryJYdQJGcS8SyhzN7NBNLTqVPAxpu6gp2ZcrR"
	// Latest distribution path.  Default for fetchers.
	LatestIpfsDist = "/ipns/dist.ipfs.io"
)

Variables

This section is empty.

Functions

func CheckIpfsDir added in v1.0.0

func CheckIpfsDir(dir string) (string, error)

CheckIpfsDir gets the ipfs directory and checks that the directory exists.

func DistVersions added in v1.0.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 ExeName added in v1.0.0

func ExeName(name string) string

func FetchBinary added in v1.0.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 v1.0.0

func GetDistPathEnv(distPath string) string

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 v1.0.0

func IpfsDir(dir string) (string, error)

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 v1.0.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 v1.0.0

func NeedMigration(target int) (bool, error)

func NewLimitReadCloser added in v1.0.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 RepoVersion added in v1.0.0

func RepoVersion(ipfsDir string) (int, error)

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 v1.0.0

func WriteRepoVersion(ipfsDir string, version int) error

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 v1.0.0

type Fetcher interface {
	// Fetch attempts to fetch the file at the given ipfs path.
	// Returns io.ReadCloser on success, which caller must close.
	Fetch(ctx context.Context, filePath string) (io.ReadCloser, error)
}

func NewMultiFetcher added in v1.0.0

func NewMultiFetcher(f ...Fetcher) Fetcher

NewMultiFetcher creates a MultiFetcher with the given Fetchers. The Fetchers are tried in order ther passed to this function.

type HttpFetcher added in v1.0.0

type HttpFetcher struct {
	// contains filtered or unexported fields
}

HttpFetcher fetches files over HTTP

func NewHttpFetcher added in v1.0.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) Fetch added in v1.0.0

func (f *HttpFetcher) Fetch(ctx context.Context, filePath string) (io.ReadCloser, error)

Fetch attempts to fetch the file at the given path, from the distribution site configured for this HttpFetcher. Returns io.ReadCloser on success, which caller must close.

type MultiFetcher added in v1.0.0

type MultiFetcher struct {
	// contains filtered or unexported fields
}

MultiFetcher holds multiple Fetchers and provides a Fetch that tries each until one succeeds.

func (*MultiFetcher) Fetch added in v1.0.0

func (f *MultiFetcher) Fetch(ctx context.Context, ipfsPath string) (rc io.ReadCloser, err error)

Fetch attempts to fetch the file at each of its fetchers until one succeeds. Returns io.ReadCloser on success, which caller must close.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL