fetch

package
v0.0.0-...-dbe7a22 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestBzlmodDir = ""

TestBzlmodDir can be set in order to override the normal bzlmod cache dir for testing. Usage:

func TestSomething(t *testing.T) {
  fetch.TestBzlmodDir = t.TempDir()
  defer func() { fetch.TestBzlmodDir = "" }()
  ...
}

Functions

func BzlmodDir

func BzlmodDir() (string, error)

func HTTPCacheFilePath

func HTTPCacheFilePath(url string) (string, error)

func SharedRepoDir

func SharedRepoDir(hash string) (string, error)

SharedRepoDir returns the path to the directory under which the shared repo identified by the given hash is placed.

Types

type Archive

type Archive struct {
	URLs        []string
	Integrity   string
	StripPrefix string
	Patches     []Patch

	// Fprint should be a hash computed from information that is enough to distinguish this archive fetch from
	// others. It will be used as the name of the shared repo directory.
	// The field is not called Fingerprint to avoid conflict with the method name.
	Fprint string
}

Archive represents an archive to be fetched from one of multiple equivalent URLs.

func (*Archive) AppendPatches

func (a *Archive) AppendPatches(patches []Patch) error

func (*Archive) Fetch

func (a *Archive) Fetch(vendorDir string) (string, error)

func (*Archive) Fingerprint

func (a *Archive) Fingerprint() string

type Fetcher

type Fetcher interface {
	// Fetch performs the fetch and returns the absolute path to the local directory where the fetched contents can be
	// accessed.
	// If vendorDir is non-empty, we're operating in vendoring mode; Fetch should make the contents available under
	// vendorDir if appropriate. Otherwise, Fetch is free to place the contents wherever.
	Fetch(vendorDir string) (string, error)

	// Fingerprint returns a fingerprint of the fetched contents. When the fingerprint changes, it's a signal that the
	// repo should be re-fetched. Note that the fingerprint need not necessarily be calculated from the actual bytes of
	// fetched contents.
	Fingerprint() string

	// AppendPatches appends an extra set of patches to the Fetcher. This can return an error if, for example, this
	// Fetcher doesn't support patches.
	AppendPatches(patches []Patch) error
}

Fetcher contains all the information needed to "fetch" a repo. "Fetch" here is simply defined as making the contents of a repo available in a local directory through some means.

type Git

type Git struct {
	Repo    string
	Commit  string
	Patches []Patch
}

Git represents a Git repository.

func (*Git) AppendPatches

func (g *Git) AppendPatches(patches []Patch) error

func (*Git) Fetch

func (g *Git) Fetch(vendorDir string) (string, error)

func (*Git) Fingerprint

func (g *Git) Fingerprint() string

type LocalPath

type LocalPath struct {
	Path string
}

LocalPath represents a locally available unpacked directory.

func (*LocalPath) AppendPatches

func (lp *LocalPath) AppendPatches(patches []Patch) error

func (*LocalPath) Fetch

func (lp *LocalPath) Fetch(vendorDir string) (string, error)

func (*LocalPath) Fingerprint

func (lp *LocalPath) Fingerprint() string

type Patch

type Patch struct {
	PatchFile  string
	PatchStrip int
}

type Wrapper

type Wrapper struct {
	Archive   *Archive   `json:",omitempty"`
	Git       *Git       `json:",omitempty"`
	LocalPath *LocalPath `json:",omitempty"`
}

Wrapper wraps all known implementations of the Fetcher interface and acts as a multiplexer (only 1 member should be non-nil). It's useful in JSON marshalling/unmarshalling.

func Wrap

func Wrap(f Fetcher) Wrapper

func (Wrapper) AppendPatches

func (w Wrapper) AppendPatches(patches []Patch) error

func (Wrapper) Fetch

func (w Wrapper) Fetch(vendorDir string) (string, error)

func (Wrapper) Fingerprint

func (w Wrapper) Fingerprint() string

func (Wrapper) Unwrap

func (w Wrapper) Unwrap() Fetcher

Jump to

Keyboard shortcuts

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