Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[19.03 backport] builder-next: fix gcr workaround token cache #212

Merged
merged 1 commit into from
May 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions builder/builder-next/adapters/containerimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ func (r *resolverCache) Add(ctx context.Context, ref string, resolver remotes.Re
r.mu.Lock()
defer r.mu.Unlock()

ref = r.domain(ref) + "-" + session.FromContext(ctx)
ref = r.repo(ref) + "-" + session.FromContext(ctx)

cr, ok := r.m[ref]
cr.timeout = time.Now().Add(time.Minute)
Expand All @@ -855,19 +855,19 @@ func (r *resolverCache) Add(ctx context.Context, ref string, resolver remotes.Re
return &cr
}

func (r *resolverCache) domain(refStr string) string {
func (r *resolverCache) repo(refStr string) string {
ref, err := distreference.ParseNormalizedNamed(refStr)
if err != nil {
return refStr
}
return distreference.Domain(ref)
return ref.Name()
}

func (r *resolverCache) Get(ctx context.Context, ref string) remotes.Resolver {
r.mu.Lock()
defer r.mu.Unlock()

ref = r.domain(ref) + "-" + session.FromContext(ctx)
ref = r.repo(ref) + "-" + session.FromContext(ctx)

cr, ok := r.m[ref]
if !ok {
Expand Down