Documentation ¶
Index ¶
- Variables
- func CheckGitURL(gitURL string) bool
- func FindCredByUrl(url string, config controllerConfig.GlobalConfig) *apiv1.RepoCredential
- func GetAuthMethod(ctx context.Context, repoCred *apiv1.RepoCredential, ...) (transport.AuthMethod, bool, error)
- func GetRepoCloneOptions(ctx context.Context, repoCred *apiv1.RepoCredential, ...) (*git.CloneOptions, error)
- func GetRepoPullOptions(ctx context.Context, repoCred *apiv1.RepoCredential, ...) (*git.PullOptions, error)
- func GetURLScheme(rawUrl string) (string, error)
- func NormalizeGitUrl(gitUrl string) string
- func Parse(rawurl string) (u *url.URL, err error)
- func ParseLocal(rawurl string) (*url.URL, error)
- func ParseScp(rawurl string) (*url.URL, error)
- func ParseTransport(rawurl string) (*url.URL, error)
- type GitUrlParser
- type TransportSet
Constants ¶
This section is empty.
Variables ¶
var (
Transports = NewTransportSet(
"ssh",
"git",
"git+ssh",
"http",
"https",
"ftp",
"ftps",
"rsync",
"file",
)
)
Valid git transports url Source -https://pkg.go.dev/github.com/whilp/git-urls@v1.0.0
Functions ¶
func CheckGitURL ¶
func FindCredByUrl ¶
func FindCredByUrl(url string, config controllerConfig.GlobalConfig) *apiv1.RepoCredential
FindCredByUrl searches for GitCredential by the specified URL within the provided GlobalConfig. It returns the matching GitCredential if the specified URL starts with the URL of any RepoCredentials, otherwise returns nil.
func GetAuthMethod ¶
func GetAuthMethod(ctx context.Context, repoCred *apiv1.RepoCredential, kubeClient k8sClient.Client, repoUrl string) (transport.AuthMethod, bool, error)
GetAuthMethod returns an authMethod for both cloning and fetching from a repo with HTTP, SSH, or TLS credentials from Kubernetes secrets.
func GetRepoCloneOptions ¶
func GetRepoCloneOptions(ctx context.Context, repoCred *apiv1.RepoCredential, kubeClient k8sClient.Client, repoUrl string) (*git.CloneOptions, error)
GetRepoCloneOptions creates git.CloneOptions for cloning a repo with HTTP, SSH, or TLS credentials from Kubernetes secrets.
func GetRepoPullOptions ¶
func GetRepoPullOptions(ctx context.Context, repoCred *apiv1.RepoCredential, kubeClient k8sClient.Client, repoUrl string) (*git.PullOptions, error)
GetRepoPullOptions creates git.PullOptions for pull updates from a repo with HTTP, SSH, or TLS credentials from Kubernetes secrets.
func GetURLScheme ¶
func NormalizeGitUrl ¶
NormalizeGitUrl function removes the protocol part and any user info from the URLs
func Parse ¶
Parse parses rawurl into a URL structure. Parse first attempts to find a standard URL with a valid Git transport as its scheme. If that cannot be found, it then attempts to find a SCP-like URL. And if that cannot be found, it assumes rawurl is a local path. If none of these rules apply, Parse returns an error.
func ParseLocal ¶
ParseLocal parses rawurl into a URL object with a "file" scheme. This will effectively never return an error.
Types ¶
type GitUrlParser ¶
GitUrlParser converts a string into a URL.
type TransportSet ¶
type TransportSet map[string]struct{}
func NewTransportSet ¶
func NewTransportSet(items ...string) TransportSet
NewTransportSet returns a TransportSet with the items' keys mapped to empty struct values.
func (TransportSet) Valid ¶
func (t TransportSet) Valid(transport string) bool
Valid returns true if transport is a known Git URL scheme and false if not.