Documentation ¶
Index ¶
- Constants
- Variables
- func GetRepoHTTPClient(repoURL string, insecure bool, creds Creds, proxyURL 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 SameURL(leftRepo, rightRepo string) bool
- func TestRepo(repo string, creds Creds, insecure bool, enableLfs bool, proxy string) error
- type Client
- type ClientOpts
- type CommitOptions
- type Creds
- type CredsStore
- type EventHandlers
- type GenericHTTPSCreds
- type GitHubAppCreds
- type GoogleCloudCreds
- type HTTPSCreds
- type NoopCredsStore
- type NopCloser
- type NopCreds
- type PublicKeysWithOptions
- type Refs
- type RevisionMetadata
- type SSHCreds
Constants ¶
const (
// ASKPASS_NONCE_ENV is the environment variable that is used to pass the nonce to the askpass script
ASKPASS_NONCE_ENV = "ARGOCD_GIT_ASKPASS_NONCE"
)
Variables ¶
var DefaultSSHKeyExchangeAlgorithms = SupportedSSHKeyExchangeAlgorithms
List of default key exchange algorithms to use. We use those that are available by default, we can become more opinionated later on (when we support configuration of algorithms to use).
var ErrInvalidRepoURL = fmt.Errorf("repo URL is invalid")
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",
}
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 ¶
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
Types ¶
type Client ¶
type Client interface { Root() string Init() error Fetch(revision string) error ShallowFetch(revision string, depth int) error Submodule() error Checkout(revision string, submoduleEnabled bool) 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) Commit(pathSpec string, opts *CommitOptions) error Branch(sourceBranch string, targetBranch string) error Push(remote string, branch string, force bool) error Add(path string) error SymRefToBranch(symRef string) (string, error) Config(username string, email string) error }
Client is a generic git client interface
type ClientOpts ¶ added in v0.11.0
type ClientOpts func(c *nativeGitClient)
func WithCache ¶ added in v0.11.0
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 ¶ added in v0.11.0
func WithEventHandlers(handlers EventHandlers) ClientOpts
WithEventHandlers sets the git client event handlers
type CommitOptions ¶ added in v0.10.2
type CommitOptions struct { // CommitMessageText holds a short commit message (-m option) CommitMessageText string // CommitMessagePath holds the path to a file to be used for the commit message (-F option) CommitMessagePath string // SigningKey holds a GnuPG key ID or path to a Private SSH Key used to sign the commit with (-S option) SigningKey string // SigningMethod holds the signing method used to sign commits. (git -c gpg.format=ssh option) SigningMethod string // SignOff specifies whether to sign-off a commit (-s option) SignOff bool }
CommitOptions holds options for a git commit operation
type CredsStore ¶ added in v0.14.0
type EventHandlers ¶ added in v0.11.0
type GenericHTTPSCreds ¶ added in v0.11.0
type GenericHTTPSCreds interface { HasClientCert() bool GetClientCertData() string GetClientCertKey() string Environ() (io.Closer, []string, error) }
func NewGitHubAppCreds ¶ added in v0.11.0
func NewGitHubAppCreds(appID int64, appInstallId int64, privateKey string, baseURL string, repoURL string, clientCertData string, clientCertKey string, insecure bool, proxy string, store CredsStore) GenericHTTPSCreds
NewGitHubAppCreds provide github app credentials
func NewHTTPSCreds ¶
func NewHTTPSCreds(username string, password string, clientCertData string, clientCertKey string, insecure bool, proxy string, store CredsStore, forceBasicAuth bool) GenericHTTPSCreds
type GitHubAppCreds ¶ added in v0.11.0
type GitHubAppCreds struct {
// contains filtered or unexported fields
}
GitHubAppCreds to authenticate as GitHub application
func (GitHubAppCreds) Environ ¶ added in v0.11.0
func (g GitHubAppCreds) Environ() (io.Closer, []string, error)
func (GitHubAppCreds) GetClientCertData ¶ added in v0.11.0
func (g GitHubAppCreds) GetClientCertData() string
func (GitHubAppCreds) GetClientCertKey ¶ added in v0.11.0
func (g GitHubAppCreds) GetClientCertKey() string
func (GitHubAppCreds) HasClientCert ¶ added in v0.11.0
func (g GitHubAppCreds) HasClientCert() bool
type GoogleCloudCreds ¶ added in v0.14.0
type GoogleCloudCreds struct {
// contains filtered or unexported fields
}
GoogleCloudCreds to authenticate to Google Cloud Source repositories
func NewGoogleCloudCreds ¶ added in v0.14.0
func NewGoogleCloudCreds(jsonData string, store CredsStore) GoogleCloudCreds
type HTTPSCreds ¶
type HTTPSCreds struct {
// contains filtered or unexported fields
}
HTTPS creds implementation
func (HTTPSCreds) BasicAuthHeader ¶ added in v0.14.0
func (c HTTPSCreds) BasicAuthHeader() string
func (HTTPSCreds) Environ ¶
func (c HTTPSCreds) Environ() (io.Closer, []string, error)
Get additional required environment variables for executing git client to access specific repository via HTTPS.
func (HTTPSCreds) GetClientCertData ¶ added in v0.11.0
func (c HTTPSCreds) GetClientCertData() string
func (HTTPSCreds) GetClientCertKey ¶ added in v0.11.0
func (c HTTPSCreds) GetClientCertKey() string
func (HTTPSCreds) HasClientCert ¶ added in v0.11.0
func (g HTTPSCreds) HasClientCert() bool
type NoopCredsStore ¶ added in v0.14.0
type NoopCredsStore struct { }
func (NoopCredsStore) Add ¶ added in v0.14.0
func (d NoopCredsStore) Add(username string, password string) string
func (NoopCredsStore) Remove ¶ added in v0.14.0
func (d NoopCredsStore) Remove(id string)
type PublicKeysWithOptions ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (a *PublicKeysWithOptions) ClientConfig() (*ssh.ClientConfig, error)
ClientConfig returns a custom SSH client configuration
func (*PublicKeysWithOptions) Name ¶ added in v0.11.0
func (a *PublicKeysWithOptions) Name() string
Name returns the name of the auth method
func (*PublicKeysWithOptions) String ¶ added in v0.11.0
func (a *PublicKeysWithOptions) String() string
String returns the configured user and auth method name as string
type RevisionMetadata ¶
type SSHCreds ¶
type SSHCreds struct {
// contains filtered or unexported fields
}
SSH implementation