Documentation
¶
Index ¶
- Variables
- func GetRepoHTTPClient(repoURL string, insecure bool, creds Creds, proxyURL string, noProxy string) *http.Client
- func IsCommitSHA(sha string) bool
- func IsHTTPSURL(url string) bool
- func IsHTTPURL(url string) bool
- func IsSSHURL(url string) (bool, string)
- func IsTruncatedCommitSHA(sha string) bool
- func NormalizeGitURL(repo string) string
- func NormalizeGitURLAllowInvalid(repo string) string
- func SameURL(leftRepo, rightRepo string) bool
- func TestRepo(repo string, creds Creds, insecure bool, enableLfs bool, proxy string, ...) error
- type AzureWorkloadIdentityCreds
- type Client
- type ClientOpts
- type CommitMetadata
- type Creds
- type CredsStore
- type EventHandlers
- type GenericHTTPSCreds
- type GitHubAppCreds
- type GoogleCloudCreds
- type HTTPSCreds
- func (creds HTTPSCreds) BasicAuthHeader() string
- func (creds HTTPSCreds) BearerAuthHeader() string
- func (creds HTTPSCreds) Environ() (io.Closer, []string, error)
- func (creds HTTPSCreds) GetClientCertData() string
- func (creds HTTPSCreds) GetClientCertKey() string
- func (creds HTTPSCreds) GetUserInfo(_ context.Context) (string, string, error)
- func (creds HTTPSCreds) HasClientCert() bool
- type NoopCredsStore
- type NopCloser
- type NopCreds
- type PublicKeysWithOptions
- type Refs
- type RevisionMetadata
- type RevisionReference
- type SSHCreds
Constants ¶
This section is empty.
Variables ¶
var BuiltinGitConfigEnv []string
BuiltinGitConfigEnv contains builtin git configuration in the format acceptable by Git.
var ErrInvalidRepoURL = errors.New("repo URL is invalid")
var SupportedFIPSCompliantSSHKeyExchangeAlgorithms = []string{
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha256",
}
SupportedFIPSCompliantSSHKeyExchangeAlgorithms is a list of all currently supported algorithms for SSH key exchange that are FIPS compliant
var SupportedSSHKeyExchangeAlgorithms = []string{
"curve25519-sha256",
"curve25519-sha256@libssh.org",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha256",
"diffie-hellman-group14-sha1",
}
SupportedSSHKeyExchangeAlgorithms is a list of all currently supported algorithms for SSH key exchange Unfortunately, crypto/ssh does not offer public constants or list for this.
Functions ¶
func GetRepoHTTPClient ¶
func GetRepoHTTPClient(repoURL string, insecure bool, creds Creds, proxyURL string, noProxy string) *http.Client
Returns a HTTP client object suitable for go-git to use using the following pattern:
- If insecure is true, always returns a client with certificate verification turned off.
- If one or more custom certificates are stored for the repository, returns a client with those certificates in the list of root CAs used to verify the server's certificate.
- Otherwise (and on non-fatal errors), a default HTTP client is returned.
func IsCommitSHA ¶
IsCommitSHA returns whether or not a string is a 40 character SHA-1
func IsHTTPSURL ¶
IsHTTPSURL returns true if supplied URL is HTTPS URL
func IsTruncatedCommitSHA ¶
IsTruncatedCommitSHA returns whether or not a string is a truncated SHA-1
func NormalizeGitURL ¶
NormalizeGitURL normalizes a git URL for purposes of comparison, as well as preventing redundant local clones (by normalizing various forms of a URL to a consistent location). Prefer using SameURL() over this function when possible. This algorithm may change over time and should not be considered stable from release to release
func NormalizeGitURLAllowInvalid ¶
NormalizeGitURLAllowInvalid is similar to NormalizeGitURL, except returning an original url if the url is invalid. Needed to allow a deletion of repos with invalid urls. See https://github.com/argoproj/argo-cd/issues/20921.
Types ¶
type AzureWorkloadIdentityCreds ¶
type AzureWorkloadIdentityCreds struct {
// contains filtered or unexported fields
}
func NewAzureWorkloadIdentityCreds ¶
func NewAzureWorkloadIdentityCreds(store CredsStore, tokenProvider workloadidentity.TokenProvider) AzureWorkloadIdentityCreds
func (AzureWorkloadIdentityCreds) Environ ¶
func (creds AzureWorkloadIdentityCreds) Environ() (io.Closer, []string, error)
func (AzureWorkloadIdentityCreds) GetAzureDevOpsAccessToken ¶
func (creds AzureWorkloadIdentityCreds) GetAzureDevOpsAccessToken() (string, error)
func (AzureWorkloadIdentityCreds) GetUserInfo ¶
GetUserInfo returns the username and email address for the credentials, if they're available.
type Client ¶
type Client interface {
Root() string
Init() error
Fetch(revision string) error
Submodule() error
Checkout(revision string, submoduleEnabled bool) (string, error)
LsRefs() (*Refs, error)
LsRemote(revision string) (string, error)
LsFiles(path string, enableNewGitFileGlobbing bool) ([]string, error)
LsLargeFiles() ([]string, error)
CommitSHA() (string, error)
RevisionMetadata(revision string) (*RevisionMetadata, error)
VerifyCommitSignature(string) (string, error)
IsAnnotatedTag(string) bool
ChangedFiles(revision string, targetRevision string) ([]string, error)
IsRevisionPresent(revision string) bool
// SetAuthor sets the author name and email in the git configuration.
SetAuthor(name, email string) (string, error)
// CheckoutOrOrphan checks out the branch. If the branch does not exist, it creates an orphan branch.
CheckoutOrOrphan(branch string, submoduleEnabled bool) (string, error)
// CheckoutOrNew checks out the given branch. If the branch does not exist, it creates an empty branch based on
// the base branch.
CheckoutOrNew(branch, base string, submoduleEnabled bool) (string, error)
// RemoveContents removes all files from the given paths in the git repository.
RemoveContents(paths []string) (string, error)
// CommitAndPush commits and pushes changes to the target branch.
CommitAndPush(branch, message string) (string, error)
}
Client is a generic git client interface
type ClientOpts ¶
type ClientOpts func(c *nativeGitClient)
func WithBuiltinGitConfig ¶ added in v3.2.1
func WithBuiltinGitConfig(enable bool) ClientOpts
func WithCache ¶
func WithCache(cache gitRefCache, loadRefFromCache bool) ClientOpts
WithCache sets git revisions cacher as well as specifies if client should tries to use cached resolved revision
func WithEventHandlers ¶
func WithEventHandlers(handlers EventHandlers) ClientOpts
WithEventHandlers sets the git client event handlers
type CommitMetadata ¶ added in v3.1.0
type CommitMetadata struct {
// Author is the author of the commit.
// Comes from the Argocd-reference-commit-author trailer.
Author mail.Address
// Date is the date of the commit, formatted as by `git show -s --format=%aI`.
// May be an empty string if the date is unknown.
// Comes from the Argocd-reference-commit-date trailer.
Date string
// Subject is the commit message subject, i.e. `git show -s --format=%s`.
// Comes from the Argocd-reference-commit-subject trailer.
Subject string
// Body is the commit message body, excluding the subject, i.e. `git show -s --format=%b`.
// Comes from the Argocd-reference-commit-body trailer.
Body string
// SHA is the commit hash.
// Comes from the Argocd-reference-commit-sha trailer.
SHA string
// RepoURL is the URL of the repository where the commit is located.
// Comes from the Argocd-reference-commit-repourl trailer.
// This value is not validated beyond confirming that it's a URL, and it should not be used to construct UI links
// unless it is properly validated and/or sanitized first.
RepoURL string
}
CommitMetadata contains metadata about a commit that is related in some way to another commit.
type CredsStore ¶
type EventHandlers ¶
type GenericHTTPSCreds ¶
type GenericHTTPSCreds interface {
HasClientCert() bool
GetClientCertData() string
GetClientCertKey() string
Creds
}
func NewGitHubAppCreds ¶
func NewGitHubAppCreds(appID int64, appInstallId int64, privateKey string, baseURL string, clientCertData string, clientCertKey string, insecure bool, proxy string, noProxy string, store CredsStore) GenericHTTPSCreds
NewGitHubAppCreds provide github app credentials
func NewHTTPSCreds ¶
func NewHTTPSCreds(username string, password string, bearerToken string, clientCertData string, clientCertKey string, insecure bool, store CredsStore, forceBasicAuth bool) GenericHTTPSCreds
type GitHubAppCreds ¶
type GitHubAppCreds struct {
// contains filtered or unexported fields
}
GitHubAppCreds to authenticate as GitHub application
func (GitHubAppCreds) GetClientCertData ¶
func (g GitHubAppCreds) GetClientCertData() string
func (GitHubAppCreds) GetClientCertKey ¶
func (g GitHubAppCreds) GetClientCertKey() string
func (GitHubAppCreds) GetUserInfo ¶
GetUserInfo returns the username and email address for the credentials, if they're available.
func (GitHubAppCreds) HasClientCert ¶
func (g GitHubAppCreds) HasClientCert() bool
type GoogleCloudCreds ¶
type GoogleCloudCreds struct {
// contains filtered or unexported fields
}
GoogleCloudCreds to authenticate to Google Cloud Source repositories
func NewGoogleCloudCreds ¶
func NewGoogleCloudCreds(jsonData string, store CredsStore) GoogleCloudCreds
func (GoogleCloudCreds) GetUserInfo ¶
GetUserInfo returns the username and email address for the credentials, if they're available. TODO: implement getting email instead of just username.
type HTTPSCreds ¶
type HTTPSCreds struct {
// contains filtered or unexported fields
}
HTTPS creds implementation
func (HTTPSCreds) BasicAuthHeader ¶
func (creds HTTPSCreds) BasicAuthHeader() string
func (HTTPSCreds) BearerAuthHeader ¶
func (creds HTTPSCreds) BearerAuthHeader() string
func (HTTPSCreds) Environ ¶
func (creds HTTPSCreds) Environ() (io.Closer, []string, error)
Get additional required environment variables for executing git client to access specific repository via HTTPS.
func (HTTPSCreds) GetClientCertData ¶
func (creds HTTPSCreds) GetClientCertData() string
func (HTTPSCreds) GetClientCertKey ¶
func (creds HTTPSCreds) GetClientCertKey() string
func (HTTPSCreds) GetUserInfo ¶
GetUserInfo returns the username and email address for the credentials, if they're available.
func (HTTPSCreds) HasClientCert ¶
func (creds HTTPSCreds) HasClientCert() bool
type NoopCredsStore ¶
type NoopCredsStore struct{}
func (NoopCredsStore) Environ ¶
func (d NoopCredsStore) Environ(_ string) []string
func (NoopCredsStore) Remove ¶
func (d NoopCredsStore) Remove(_ string)
type PublicKeysWithOptions ¶
type PublicKeysWithOptions struct {
KexAlgorithms []string
gitssh.PublicKeys
}
PublicKeysWithOptions is an auth method for go-git's SSH client that inherits from PublicKeys, but provides the possibility to override some client options.
func (*PublicKeysWithOptions) ClientConfig ¶
func (a *PublicKeysWithOptions) ClientConfig() (*ssh.ClientConfig, error)
ClientConfig returns a custom SSH client configuration
func (*PublicKeysWithOptions) Name ¶
func (a *PublicKeysWithOptions) Name() string
Name returns the name of the auth method
func (*PublicKeysWithOptions) String ¶
func (a *PublicKeysWithOptions) String() string
String returns the configured user and auth method name as string
type RevisionMetadata ¶
type RevisionMetadata struct {
// Author is the author of the commit. Corresponds to the output of `git log -n 1 --pretty='format:%an <%ae>'`.
Author string
// Date is the date of the commit. Corresponds to the output of `git log -n 1 --pretty='format:%ad'`.
Date time.Time
Tags []string
// Message is the commit message.
Message string
// References contains metadata about information that is related in some way to this commit. This data comes from
// git commit trailers starting with "Argocd-reference-". We currently only support a single reference to a commit,
// but we return an array to allow for future expansion.
References []RevisionReference
}
type RevisionReference ¶ added in v3.1.0
type RevisionReference struct {
// Commit contains metadata about the commit that is related in some way to another commit.
Commit *CommitMetadata
}
RevisionReference contains a reference to a some information that is related in some way to another commit. For now, it supports only references to a commit. In the future, it may support other types of references.
func GetReferences ¶ added in v3.1.0
func GetReferences(logCtx *log.Entry, commitMessageBody string) ([]RevisionReference, string)
GetReferences extracts related commit metadata from the commit message trailers. If referenced commit metadata is present, we return a slice containing a single metadata object. If no related commit metadata is found, we return a nil slice.
If a trailer fails validation, we log an error and skip that trailer. We truncate the trailer values to 100 characters to avoid excessively long log messages.
We also return the commit message body with all valid Argocd-reference-commit-* trailers removed.
type SSHCreds ¶
type SSHCreds struct {
// contains filtered or unexported fields
}
SSH implementation