Documentation
¶
Overview ¶
Package getit provides a simple API for fetching archives.
Index ¶
- Variables
- func Fetch(ctx context.Context, source, dest string) error
- func FetchIntoPipe(ctx context.Context, u *url.URL, cmd string, args ...string) error
- func FilePath(source string) (string, bool)
- func GitHub(source string) (string, bool)
- func GitHubOrgRepo(source string) (string, bool)
- func Resolve(source string) (Resolver, Source, error)
- type Fetcher
- type File
- type Git
- type Mapper
- type Resolver
- type Source
- type TAR
- type ZIP
Constants ¶
This section is empty.
Variables ¶
var Default = New( []Resolver{ NewFile(), NewGit(), NewTAR(), NewZIP(), }, []Mapper{ GitHub, GitHubOrgRepo, FilePath, }, )
Default Fetcher with built-in resolvers and mappers.
Functions ¶
func Fetch ¶ added in v0.1.0
Fetch fetches an archive from a source and unpacks it to a destination.
func FetchIntoPipe ¶
FetchIntoPipe retrieves the given URL using Go's HTTP library then pipes it into the input of the given command.
func FilePath ¶ added in v0.1.0
FilePath is a Mapper that maps filesystem paths to file:// URLs.
It handles absolute paths, relative paths (./..., ../...), home-relative paths (~/...), and bare directory names. The path must exist and be a directory.
func GitHub ¶
GitHub is a Mapper that supports shorthand GitHub URLs with no scheme or org/repo.
Query parameters and anchors are preserved.
func GitHubOrgRepo ¶
GitHubOrgRepo is a Mapper that supports shorthand GitHub URLs with org/repo.
Query parameters and anchors are preserved.
Types ¶
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher retrieves archives from a pluggable source.
All sources support an optional subdirectory, specified via appending a //<subdir> to the URL path:
git+ssh://host/path/to/repo.git//path/to/subdir https://host/path/to/archive.tgz//path/to/subdir
type File ¶ added in v0.1.0
type File struct{}
File is a Resolver that copies local directories.
The URL format supported is:
file:///absolute/path/to/dir file://relative/path/to/dir
type Git ¶
type Git struct{}
The Git Resolver uses Git repositories as archive sources, cloning directly.
The URL format supported is:
git://host/path/to/repo git+ssh://host/path/to/repo git+https://host/path/to/repo
All forms support the following query parameters that control cloning behaviour:
ref=<ref> depth=<depth>
type Mapper ¶
Mapper maps one form of a source to another.
eg.
github.com/user/repo -> https://github.com/user/repo.git user/repo -> https://github.com/user/repo.git
func SingleGitHubOrg ¶
SingleGitHubOrg is a Mapper that supports shorthand GitHub URLs as just repo.
Query parameters and anchors are preserved.