Documentation
¶
Overview ¶
Package vcslocator offers functions and tools to parse SPDX VCS locator strings and access data referenced by them.
Index ¶
- Constants
- func CloneRepository[T ~string](locator T, funcs ...fnOpt) (fs.FS, error)
- func CopyFile[T ~string](locator T, w io.Writer, funcs ...fnOpt) error
- func CopyFileGroup[T ~string](locators []T, writers []io.Writer, funcs ...fnOpt) error
- func Download[T ~string](locator T, localDir string, funcs ...fnOpt) error
- func GetAuthMethod[T ~string](locator T, funcs ...fnOpt) (transport.AuthMethod, error)
- func GetGroup[T ~string](locators []T) ([][]byte, error)
- func WithClonePath(path string) fnOpt
- func WithHttpAuth(user, password string) fnOpt
- func WithRefAsBranch(sino bool) fnOpt
- func WithSystemCredentials(yesno bool) fnOpt
- type Components
- type ErrorList
- type Locator
Constants ¶
const ( // Supported transport strings TransportSSH = "ssh" TransportHTTPS = "https" TransportFile = "file" ToolGit = "git" )
Variables ¶
This section is empty.
Functions ¶
func CloneRepository ¶
CloneRepository clones the repository defined by the locator to a path.
func CopyFile ¶
CopyFile downloads a file specified by the VCS locator and copies it to an io.Writer.
func CopyFileGroup ¶ added in v0.2.0
CopyFileGroup copies a group of locators to the specified writers
func GetAuthMethod ¶ added in v0.4.0
func GetAuthMethod[T ~string](locator T, funcs ...fnOpt) (transport.AuthMethod, error)
getAuthMethod returns an appropriate auth method based on the transport type and available credentials.
It mimics git's behavior by automatically detecting and using SSH keys, SSH agent, or configuring http credentials from the options.
func GetGroup ¶ added in v0.2.0
GetGroup gets the data of several vcs locators in an efficient manner
func WithClonePath ¶
func WithClonePath(path string) fnOpt
WithClonePath specifies the directory to clone the repository. When
func WithHttpAuth ¶ added in v0.4.0
func WithHttpAuth(user, password string) fnOpt
WithHttpAuth configures basic authentication for http operations
func WithRefAsBranch ¶
func WithRefAsBranch(sino bool) fnOpt
WithRefAsBranch instructs the parser to treat the ref as branch name instead of a tag name.
func WithSystemCredentials ¶ added in v0.4.0
func WithSystemCredentials(yesno bool) fnOpt
WithSystemCredentials controls if cloning uses the system credentials
Types ¶
type Components ¶
type Components struct {
Tool string
Transport string
Hostname string
RepoPath string
RefString string
Commit string
Tag string
Branch string
SubPath string
}
Components captures the parsed pieces of a VCS locator.
func (*Components) RepoURL ¶
func (c *Components) RepoURL() string
RepoURL forms the repository URL to clone based on the defined components