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 GetRepoFetchOptions(ctx context.Context, repoCred *apiv1.RepoCredential, ...) (*git.FetchOptions, 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)
- func UpdateOptionsWithGitConfig[T git.CloneOptions | git.FetchOptions | git.PullOptions](gitConfig *config.Config, options *T) error
- type AuthorizationHeader
- 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 GetRepoFetchOptions ¶ added in v0.1.2
func GetRepoFetchOptions( ctx context.Context, repoCred *apiv1.RepoCredential, kubeClient k8sClient.Client, repoUrl string, ) (*git.FetchOptions, error)
GetRepoFetchOptions creates git.FetchOptions for fetching updates from 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, refName 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.
func ParseScp ¶
ParseScp parses rawurl into a URL object. The rawurl must be an SCP-like URL, otherwise ParseScp returns an error.
func ParseTransport ¶
ParseTransport parses rawurl into a URL object. Unless the URL's scheme is a known Git transport, ParseTransport returns an error.
func UpdateOptionsWithGitConfig ¶ added in v0.2.0
func UpdateOptionsWithGitConfig[T git.CloneOptions | git.FetchOptions | git.PullOptions]( gitConfig *config.Config, options *T, ) error
UpdateOptionsWithGitConfig updates the given git options object with information coming from the git config provided. The function only takes into account HTTP URLs (not SSH).
Types ¶
type AuthorizationHeader ¶ added in v0.2.0
func (AuthorizationHeader) Name ¶ added in v0.2.0
func (h AuthorizationHeader) Name() string
func (AuthorizationHeader) SetAuth ¶ added in v0.2.0
func (h AuthorizationHeader) SetAuth(r *http.Request)
func (AuthorizationHeader) String ¶ added in v0.2.0
func (h AuthorizationHeader) String() string
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.