Skip to content

Commit

Permalink
Resolve tags by the controller's platform (knative#3998)
Browse files Browse the repository at this point in the history
* Resolve tags by the controller's platform

* Link to CRI-O bug
  • Loading branch information
jonjohnsonjr authored and knative-prow-robot committed May 4, 2019
1 parent 9980c08 commit ce9bdcb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/reconciler/revision/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import (
"io/ioutil"
"net"
"net/http"
"runtime"
"time"

"github.com/google/go-containerregistry/pkg/authn/k8schain"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -106,9 +108,20 @@ func (r *digestResolver) Resolve(
return "", nil
}

desc, err := remote.Get(tag, remote.WithTransport(r.transport), remote.WithAuthFromKeychain(kc))
// TODO(#3997): Use remote.Get to resolve manifest lists to digests as well
// once CRI-O is fixed: https://github.com/cri-o/cri-o/issues/2157
platform := v1.Platform{
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
}
img, err := remote.Image(tag, remote.WithTransport(r.transport), remote.WithAuthFromKeychain(kc), remote.WithPlatform(platform))
if err != nil {
return "", err
}

dgst, err := img.Digest()
if err != nil {
return "", err
}
return fmt.Sprintf("%s@%s", tag.Repository.String(), desc.Digest), nil
return fmt.Sprintf("%s@%s", tag.Repository.String(), dgst), nil
}

0 comments on commit ce9bdcb

Please sign in to comment.