Merge pull request #212 from thaJeztah/19.03_backport_gcr_fix

[19.03 backport] builder-next: fix gcr workaround token cache
This commit is contained in:
Andrew Hsu 2019-05-13 19:11:55 -07:00 committed by GitHub
commit 9fdccf6a47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
@ -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 {