Fixup pull authorization and labeling

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2022-09-01 14:28:11 -07:00
parent 478f1c934d
commit e88baa0873
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB
2 changed files with 7 additions and 4 deletions

View File

@ -62,7 +62,7 @@ func (is *Store) String() string {
return fmt.Sprintf("Local Image Store (%s)", is.imageName) return fmt.Sprintf("Local Image Store (%s)", is.imageName)
} }
func (is *Store) FilterHandler(h images.HandlerFunc, cs content.Store) images.HandlerFunc { func (is *Store) ImageFilter(h images.HandlerFunc, cs content.Store) images.HandlerFunc {
h = images.SetChildrenMappedLabels(cs, h, is.labelMap) h = images.SetChildrenMappedLabels(cs, h, is.labelMap)
if is.allMetadata { if is.allMetadata {
// Filter manifests by platforms but allow to handle manifest // Filter manifests by platforms but allow to handle manifest

View File

@ -45,10 +45,10 @@ func init() {
// Initialize with hosts, authorizer callback, and headers // Initialize with hosts, authorizer callback, and headers
func NewOCIRegistry(ref string, headers http.Header, creds CredentialHelper) *OCIRegistry { func NewOCIRegistry(ref string, headers http.Header, creds CredentialHelper) *OCIRegistry {
// Create an authorizer // Create an authorizer
var ropts []docker.RegistryOpt var aopts []docker.AuthorizerOpt
if creds != nil { if creds != nil {
// TODO: Support bearer // TODO: Support bearer
authorizer := docker.NewDockerAuthorizer(docker.WithAuthCreds(func(host string) (string, string, error) { aopts = append(aopts, docker.WithAuthCreds(func(host string) (string, string, error) {
c, err := creds.GetCredentials(context.Background(), ref, host) c, err := creds.GetCredentials(context.Background(), ref, host)
if err != nil { if err != nil {
return "", "", err return "", "", err
@ -56,7 +56,10 @@ func NewOCIRegistry(ref string, headers http.Header, creds CredentialHelper) *OC
return c.Username, c.Secret, nil return c.Username, c.Secret, nil
})) }))
ropts = append(ropts, docker.WithAuthorizer(authorizer)) }
ropts := []docker.RegistryOpt{
docker.WithAuthorizer(docker.NewDockerAuthorizer(aopts...)),
} }
// TODO: Apply local configuration, maybe dynamically create resolver when requested // TODO: Apply local configuration, maybe dynamically create resolver when requested