Documentation ¶
Overview ¶
Package credentials provides OAuth2 TokenSource built based on the gitconfig configs.
Index ¶
- func MakeCookies(u *url.URL, token *oauth2.Token) []*http.Cookie
- func MakeToken(ctx context.Context, g GitBinary, u *url.URL) (*oauth2.Token, error)
- func TokenSourceFromConfig(ctx context.Context, c *CredentialConfig) (oauth2.TokenSource, error)
- type CredentialConfig
- type GitBinary
- func (g GitBinary) BoolConfig(ctx context.Context, key string) (bool, error)
- func (g GitBinary) CredentialConfigFromGitConfig(ctx context.Context, u *url.URL) (*CredentialConfig, error)
- func (g GitBinary) ListURLs(ctx context.Context) ([]*url.URL, error)
- func (g GitBinary) PathConfig(ctx context.Context, key string) (string, error)
- func (g GitBinary) StringConfig(ctx context.Context, key string) (string, error)
- func (g GitBinary) StringListConfig(ctx context.Context, key string) ([]string, error)
- func (g GitBinary) WithURL(u *url.URL) GitConfigAccessor
- type GitConfigAccessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeCookies ¶
MakeCookies create cookies for .gitcookies.
func TokenSourceFromConfig ¶
func TokenSourceFromConfig(ctx context.Context, c *CredentialConfig) (oauth2.TokenSource, error)
TokenSourceFromConfig returns a TokenSource configured based on gitconfig.
Types ¶
type CredentialConfig ¶
type CredentialConfig struct { // An account to be used. This can take one of the following values. If // empty, it defaults to `gcloud`. // // * `gcloud` // // Use the default account of `gcloud`. // // * `application-default` // // Use the applicaiton default credentials. // // * Google Account emails // // Get an access token by using `gcloud auth print-access-token // EMAIL`. The account specified here must be registered in gcloud // by using `gcloud auth login` // // * Service account emails // (`SERVICE_ACCOUNT@YOUR_PROJECT.iam.gserviceaccount.com`) // // Start from the application default credentials, use IAM Service // Account Credentials API to obtain the specified service account // credentials. The account used for the application default service // account must have `iam.serviceAccounts.getAccessToken` for the // account specified here. // // In a rare situation where you need a multi-hop delegation, you can // specify a list of delegated service account emails in // `ServiceAccountDelegateEmails`. Account string // OAuth2 scopes. If empty, it defaults to // `https://www.googleapis.com/auth/cloud-platform`. // // This config is usually not effective unless you use service account // emails for `Account`. Scopes []string // List of service account email addresses for multi-hop authentication. // See the description of `Account`. ServiceAccountDelegateEmails []string // Path to gcloud executable. GcloudPath string }
CredentialConfig is the configuration for credentials.
type GitBinary ¶
type GitBinary struct { // Path is a path to the Git binary. Path string // Configs are the additional Git configs specified via "-c". Configs []string }
GitBinary is a path to Git binary.
func FindGitBinary ¶
FindGitBinary finds a git binary from the PATH.
func (GitBinary) BoolConfig ¶
func (GitBinary) CredentialConfigFromGitConfig ¶
func (g GitBinary) CredentialConfigFromGitConfig(ctx context.Context, u *url.URL) (*CredentialConfig, error)
ConfigFromGitConfig creates a CredentialConfig from git-config.
func (GitBinary) PathConfig ¶
func (GitBinary) StringConfig ¶
func (GitBinary) StringListConfig ¶
type GitConfigAccessor ¶
type GitConfigAccessor interface { // BoolConfig returns a gitconfig config value as a boolean. BoolConfig(ctx context.Context, key string) (bool, error) // PathConfig returns a gitconfig config value as a string path. PathConfig(ctx context.Context, key string) (string, error) // StringConfig returns a gitconfig config value as a string. StringConfig(ctx context.Context, key string) (string, error) // StringListConfig returns a gitconfig config value as a string slice. // The value is split by comma. StringListConfig(ctx context.Context, key string) ([]string, error) }
GitConfigAccessor is an interface for reading git-config.
Click to show internal directories.
Click to hide internal directories.