Documentation
¶
Index ¶
- Variables
- func ArchiveURLFor(owner, repo, ref string, kind RefKind) string
- func CopyDir(src, dest string) error
- func DownloadFile(srcURL string) (string, error)
- func DownloadFileContext(ctx context.Context, srcURL string) (string, error)
- func ExtractTarGz(tarPath, destDir string, stripComponents int) error
- func ExtractZip(zipPath, destDir string, stripComponents int) error
- type GitHubRef
- type HTTPStatusError
- type RefKind
- type SourceKind
Constants ¶
This section is empty.
Variables ¶
var GitHubBaseURL = "https://github.com"
GitHubBaseURL is the host archive URLs are built on. Tests point it at an httptest server; production code never changes it.
Functions ¶
func ArchiveURLFor ¶ added in v1.5.0
ArchiveURLFor returns the zip archive URL for a ref of a GitHub repository. Each path segment of the ref is escaped on its own, so a branch such as "release/1.5" keeps its slash.
func DownloadFile ¶
DownloadFile fetches srcURL into a temporary file and returns its path. The caller removes the file.
func DownloadFileContext ¶ added in v1.5.0
DownloadFileContext is DownloadFile with cancellation. A non-200 response is returned as an *HTTPStatusError so callers can tell "not found" from a network failure.
func ExtractTarGz ¶
func ExtractZip ¶
Types ¶
type HTTPStatusError ¶ added in v1.5.0
HTTPStatusError reports a download that reached the server but was answered with a status other than 200.
func (*HTTPStatusError) Error ¶ added in v1.5.0
func (e *HTTPStatusError) Error() string
type RefKind ¶ added in v1.5.0
type RefKind int
RefKind says how a Git ref should be requested from GitHub's archive endpoint. RefAny lets GitHub resolve a branch, tag, or commit by name.
type SourceKind ¶
type SourceKind int
const ( SourceGitHub SourceKind = iota SourceZipURL SourceTarGzURL SourceLocalDir SourceLocalZipFile SourceUnknown )
func InferSourceKind ¶
func InferSourceKind(src string) SourceKind