migrations

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 43 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// Current distribution to fetch migrations from.
	CurrentIpfsDist = "/ipfs/QmRzRGJEjYDfbHHaALnHBuhzzrkXGdwcPMrgd5fgM7hqbe" // fs-repo-15-to-16 v1.0.1
	// Latest distribution path.  Default for fetchers.
	LatestIpfsDist = "/ipns/dist.ipfs.tech"
)

Variables

View Source
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.14.0

func CheckIpfsDir(dir string) (string, error)

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

func DistVersions added in v0.14.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 v0.14.0

func ExeName(name string) string

func FetchBinary added in v0.14.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.14.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 v0.14.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 v0.14.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.14.0

func NeedMigration(target int) (bool, error)

func NewLimitReadCloser added in v0.14.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.14.0

func ReadMigrationConfig(repoRoot string, userConfigFile string) (*config.Migration, error)

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.14.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 v0.14.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 v0.14.0

type Fetcher interface {
	// Fetch attempts to fetch the file at the given ipfs path.
	Fetch(ctx context.Context, filePath string) ([]byte, error)
	// Close performs any cleanup after the fetcher is not longer needed.
	Close() error
}

func GetMigrationFetcher added in v0.14.0

func GetMigrationFetcher(downloadSources []string, distPath string, newIpfsFetcher func(string) Fetcher) (Fetcher, error)

GetMigrationFetcher creates one or more fetchers according to downloadSources,.

type HttpFetcher added in v0.14.0

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

HttpFetcher fetches files over HTTP using verifiable CAR archives.

func NewHttpFetcher added in v0.14.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.14.0

func (f *HttpFetcher) Close() error

func (*HttpFetcher) Fetch added in v0.14.0

func (f *HttpFetcher) Fetch(ctx context.Context, filePath string) ([]byte, error)

Fetch attempts to fetch the file at the given path, from the distribution site configured for this HttpFetcher.

type MultiFetcher added in v0.14.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.14.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.14.0

func (f *MultiFetcher) Close() error

func (*MultiFetcher) Fetch added in v0.14.0

func (f *MultiFetcher) Fetch(ctx context.Context, ipfsPath string) ([]byte, error)

Fetch attempts to fetch the file at each of its fetchers until one succeeds.

func (*MultiFetcher) Fetchers added in v0.14.0

func (f *MultiFetcher) Fetchers() []Fetcher

func (*MultiFetcher) Len added in v0.14.0

func (f *MultiFetcher) Len() int

type RetryFetcher added in v0.14.0

type RetryFetcher struct {
	Fetcher
	MaxTries int
}

func (*RetryFetcher) Close added in v0.14.0

func (r *RetryFetcher) Close() error

func (*RetryFetcher) Fetch added in v0.14.0

func (r *RetryFetcher) Fetch(ctx context.Context, filePath string) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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