/
registry_options.go
38 lines (31 loc) · 1.09 KB
/
registry_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package image
import (
"github.com/google/go-containerregistry/pkg/authn"
"github.com/nextlinux/stereoscope/internal/log"
)
// RegistryOptions for the OCI registry provider.
// If no specific Credential is found in the RegistryCredentials, will check
// for Keychain, and barring that will use Default Keychain.
type RegistryOptions struct {
InsecureSkipTLSVerify bool
InsecureUseHTTP bool
Credentials []RegistryCredentials
Keychain authn.Keychain
Platform string
}
// Authenticator returns an object capable of authenticating against the given registry. If no credentials match the
// given registry, or there is partial information configured, then nil is returned.
func (r RegistryOptions) Authenticator(registry string) authn.Authenticator {
for idx, credentials := range r.Credentials {
if !credentials.canBeUsedWithRegistry(registry) {
continue
}
authenticator := credentials.authenticator()
if authenticator == nil {
continue
}
log.Debugf("using registry credentials from config index %d", idx)
return authenticator
}
return nil
}