Documentation
¶
Index ¶
- Variables
- func CheckAuth(ctx context.Context, image string, credentials docker.Credentials, ...) error
- func NewCredentialsProvider(configPath string, opts ...Opt) docker.CredentialsProvider
- func RegistryEquals(regA, regB string) bool
- type ChooseCredentialHelperCallback
- type CredentialsCallback
- type Opt
- func WithAdditionalCredentialLoaders(loaders ...CredentialsCallback) Opt
- func WithPromptForCredentialStore(cbk ChooseCredentialHelperCallback) Opt
- func WithPromptForCredentials(cbk CredentialsCallback) Opt
- func WithTransport(transport http.RoundTripper) Opt
- func WithVerifyCredentials(cbk VerifyCredentialsCallback) Opt
- type VerifyCredentialsCallback
Constants ¶
This section is empty.
Variables ¶
var ErrCredentialsNotFound = errors.New("credentials not found")
Functions ¶
func CheckAuth ¶
func CheckAuth(ctx context.Context, image string, credentials docker.Credentials, trans http.RoundTripper) error
CheckAuth verifies that credentials can be used for image push
func NewCredentialsProvider ¶
func NewCredentialsProvider(configPath string, opts ...Opt) docker.CredentialsProvider
NewCredentialsProvider returns new CredentialsProvider that tries to get credentials from docker/func config files.
In case getting credentials from the config files fails the caller provided callback (see WithPromptForCredentials) will be invoked to obtain credentials. The callback may be called multiple times in case the returned credentials are not correct (see WithVerifyCredentials).
When the callback succeeds the credentials will be saved by using helper defined in the func config. If the helper is not defined in the config file it may be picked by provided callback (see WithPromptForCredentialStore). The picked value will be saved in the func config.
To verify that credentials are correct custom callback can be used (see WithVerifyCredentials).
func RegistryEquals ¶
RegistryEquals checks whether registry matches in host and port with exception where empty port matches standard ports (80,443)
Types ¶
type CredentialsCallback ¶
type CredentialsCallback func(registry string) (docker.Credentials, error)
type Opt ¶
type Opt func(opts *credentialsProvider)
func WithAdditionalCredentialLoaders ¶
func WithAdditionalCredentialLoaders(loaders ...CredentialsCallback) Opt
WithAdditionalCredentialLoaders adds custom callbacks for credential retrieval. The callbacks shall return ErrCredentialsNotFound if the credentials are not found. The callbacks are supposed to be non-interactive as opposed to WithPromptForCredentials.
This might be useful when credentials are shared with some other service.
Example: OpenShift builtin registry shares credentials with the cluster (k8s) credentials.
func WithPromptForCredentialStore ¶
func WithPromptForCredentialStore(cbk ChooseCredentialHelperCallback) Opt
WithPromptForCredentialStore sets custom callback that is supposed to interactively ask user which credentials store/helper is used to store credentials obtained from user.
func WithPromptForCredentials ¶
func WithPromptForCredentials(cbk CredentialsCallback) Opt
WithPromptForCredentials sets custom callback that is supposed to interactively ask for credentials in case the credentials cannot be found in configuration files. The callback may be called multiple times in case incorrect credentials were returned before.
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Opt
func WithVerifyCredentials ¶
func WithVerifyCredentials(cbk VerifyCredentialsCallback) Opt
WithVerifyCredentials sets custom callback for credentials validation.
type VerifyCredentialsCallback ¶
type VerifyCredentialsCallback func(ctx context.Context, image string, credentials docker.Credentials) error
VerifyCredentialsCallback checks if credentials are authorized for image push. If credentials are incorrect this callback shall return ErrUnauthorized.