git

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 CheckGitURL(gitURL string) bool

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 GetURLScheme(rawUrl string) (string, error)

func NormalizeGitUrl

func NormalizeGitUrl(gitUrl string) string

NormalizeGitUrl function removes the protocol part and any user info from the URLs

func Parse

func Parse(rawurl string) (u *url.URL, err error)

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

func ParseLocal(rawurl string) (*url.URL, error)

ParseLocal parses rawurl into a URL object with a "file" scheme. This will effectively never return an error.

func ParseScp

func ParseScp(rawurl string) (*url.URL, error)

ParseScp parses rawurl into a URL object. The rawurl must be an SCP-like URL, otherwise ParseScp returns an error.

func ParseTransport

func ParseTransport(rawurl string) (*url.URL, error)

ParseTransport parses rawurl into a URL object. Unless the URL's scheme is a known Git transport, ParseTransport returns an error.

Types

type GitUrlParser

type GitUrlParser func(string) (*url.URL, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL