Documentation
¶
Overview ¶
Package token contains functions for getting an authenticated token from a user's machine for a given VCS provider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fetch ¶
func Fetch(_ context.Context, vcsp vcs.Provider, allowUnauthenticated bool, optss ...*Options) (*shared.Token, error)
Fetch returns a valid token from one of the configured credential providers. If no token is found, ErrNoToken is returned.
allowUnauthenticated is DEPRECATED and will be removed in a future release. Use the Options struct instead, setting AllowUnauthenticated to true/false.
optss is a variadic argument only to avoid a breaking change. Only one option struct is allowed, an error will be returned if more than one is provided.
Types ¶
type ErrNoToken ¶
type ErrNoToken []error
ErrNoToken is returned when no token is found in the configured credential providers.
func (ErrNoToken) Error ¶
func (errs ErrNoToken) Error() string
Error returns the error message for ErrNoToken.
func (ErrNoToken) Unwrap ¶
func (errs ErrNoToken) Unwrap() []error
Unwrap returns the errors that caused the ErrNoToken error.
type Options ¶ added in v0.4.0
type Options struct {
// AllowUnauthenticated allows for an empty token to be returned if
// no token is found.
AllowUnauthenticated bool
// UseGlobalCache allows for the use of a global cache for tokens. If
// set to true, the token will be cached globally (all instances of
// this library). Otherwise, the token will always be fetched.
//
// Defaults to true.
//
// Note: When using [shared.Token], the value will never change.
// Caching refers only to function calls provided by this package
// (e.g., [Fetch]).
UseGlobalCache *bool
}
Options contains options for the Fetch function.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
github
Package github implements shared.Provider for Github.
|
Package github implements shared.Provider for Github. |
|
gitlab
Package gitlab contains Gitlab specific [token.Provider]s.
|
Package gitlab contains Gitlab specific [token.Provider]s. |
|
shared
Package shared contains shared provider implementations.
|
Package shared contains shared provider implementations. |