Documentation
¶
Index ¶
Constants ¶
const ( FieldRepoURL = "repoURL" FieldRepoURLIsRegex = "repoURLIsRegex" FieldUsername = "username" FieldPassword = "password" )
Variables ¶
var DefaultProviderRegistry = MustNewProviderRegistry()
Functions ¶
func CalculateCacheTTL ¶ added in v1.9.4
CalculateCacheTTL calculates how long a credential may be cached for, given the credential's own expiry time and a safety margin. It returns nil when the credential expires within that margin, caching one that is spent, or nearly so, being how a caller comes to be handed a credential that has stopped working. A zero expiry time means the credential's lifetime is unknown, for which it returns a zero duration, deferring to whatever default TTL the cache was configured with.
func ProvidersEnabled ¶ added in v1.12.0
func ProvidersEnabled() bool
ProvidersEnabled indicates whether credential providers should add themselves to DefaultProviderRegistry. Every provider's init() consults this before doing anything else.
Kargo's components share a single binary, so a provider's init() runs no matter which component was invoked, and deciding whether a provider applies is not free: it reads configuration and, in one case, reaches for a cloud provider's metadata server. Only components that resolve credentials have any use for that, so the rest opt out by leaving this unset. An environment variable is the only mechanism available, as init() runs before a component has had any chance to say what it is.
Types ¶
type Credentials ¶
type Credentials struct {
// Username identifies a principal, which combined with the value of the
// Password field, can be used for access to some repository.
Username string
// Password, when combined with the principal identified by the Username
// field, can be used for access to some repository.
//
// #nosec G117 -- This struct is an internal representation of credentials
// that is not transmitted anywhere directly.
Password string
// SSHPrivateKey is a private key that can be used for access to some remote
// repository. This is primarily applicable for Git repositories.
//
// TODO(v1.13.0): Remove this field when SSH support is removed.
SSHPrivateKey string
}
Credentials generically represents any type of repository credential.
type Database ¶
type Database interface {
Get(
ctx context.Context,
namespace string,
credType Type,
repo string,
) (*Credentials, error)
}
Database is an interface for a Credentials store.
type FakeDB ¶
type FakeDB struct {
GetFn func(
ctx context.Context,
namespace string,
credType Type,
repo string,
) (*Credentials, error)
}
FakeDB is a mock implementation of the Database interface that is used to facilitate unit testing.
type Provider ¶
type Provider interface {
// Supports returns true if the Provider can potentially provide credentials
// for the credential request.
Supports(context.Context, Request) (bool, error)
// GetCredentials returns the credentials for the given CredentialRequest. If
// the Provider cannot provide credentials for the given CredentialRequest, it
// should return nil.
GetCredentials(context.Context, Request) (*Credentials, error)
}
Provider is an interface for providing credentials for a given type, repository URL and data values.
type ProviderPredicate ¶ added in v1.8.8
type ProviderRegistration ¶ added in v1.8.8
type ProviderRegistration = component.PredicateBasedRegistration[ Request, ProviderPredicate, Provider, struct{}, ]
type ProviderRegistry ¶ added in v1.8.8
type ProviderRegistry = component.PredicateBasedRegistry[ Request, ProviderPredicate, Provider, struct{}, ]
func MustNewProviderRegistry ¶ added in v1.8.8
func MustNewProviderRegistry( registrations ...ProviderRegistration, ) ProviderRegistry