Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGitHubOrGitLabURL ¶
IsGitHubOrGitLabURL checks if the url is a github or gitlab url.
func IsGitHubShortURL ¶
IsGitHubShortURL returns true for github-friendly short urls such as srl-labs/containerlab.
func IsGitHubURL ¶
IsGitHubURL checks if the url is a github url.
func IsGitLabURL ¶
IsGitLabURL returns true if the given url is a gitlab url.
Types ¶
type Git ¶
type Git interface {
// Clone takes the given GitRepo reference and clones the repo
// with its internal implementation.
Clone() error
}
type GitHubRepo ¶
type GitHubRepo struct {
GitRepoStruct
}
GitHubRepo struct holds the parsed github url.
func NewGitHubRepoFromURL ¶
func NewGitHubRepoFromURL(url *neturl.URL) (*GitHubRepo, error)
NewGitHubRepoFromURL parses the given url and returns a GitHubRepo.
type GitLabRepo ¶
type GitLabRepo struct {
GitRepoStruct
}
GitLabRepo represents a gitlab repository.
func NewGitLabRepoFromURL ¶
func NewGitLabRepoFromURL(url *neturl.URL) (*GitLabRepo, error)
NewGitLabRepoFromURL parses the given url and returns a GitLabRepo.
type GitRepo ¶
type GitRepoStruct ¶
type GitRepoStruct struct {
// original URL parsed from the user input
URL *url.URL
// CloneURL is the URL that will be used for cloning the repo
CloneURL *url.URL
ProjectOwner string
RepositoryName string
// GitBranch is the referenced Git branch name.
GitBranch string
// Path is the path within the repository where the file is located.
Path []string
// FileName is the name of the file located at repo_root/path/filename.
FileName string
}
GitRepoStruct is a struct that contains all the fields required for a GitRepo instance.
func (*GitRepoStruct) GetBranch ¶
func (u *GitRepoStruct) GetBranch() string
GetBranch returns the referenced Git branch name. the empty string is returned otherwise.
func (*GitRepoStruct) GetCloneURL ¶
func (u *GitRepoStruct) GetCloneURL() *url.URL
GetCloneURL returns the CloneURL of the repository.
func (*GitRepoStruct) GetFilename ¶
func (u *GitRepoStruct) GetFilename() string
GetFilename returns the filename if a file was specifically referenced. the empty string is returned otherwise.
func (*GitRepoStruct) GetName ¶
func (u *GitRepoStruct) GetName() string
GetName returns the repository name.
func (*GitRepoStruct) GetPath ¶
func (u *GitRepoStruct) GetPath() []string
GetPath returns the path of the repository.