Skip to content

Commit

Permalink
Move k8schain usage to image_util.go
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Jul 21, 2018
1 parent effbe1e commit a29c950
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/util/image_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ limitations under the License.
package util

import (
"github.com/GoogleContainerTools/kaniko/pkg/constants"
"path/filepath"
"strconv"

"github.com/docker/docker/builder/dockerfile/instructions"
"github.com/google/go-containerregistry/pkg/authn"
"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/empty"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/sirupsen/logrus"
"net/http"
"path/filepath"
"strconv"

"github.com/GoogleContainerTools/kaniko/pkg/constants"
)

var (
Expand Down Expand Up @@ -74,9 +76,11 @@ func remoteImage(image string) (v1.Image, error) {
if err != nil {
return nil, err
}
auth, err := authn.DefaultKeychain.Resolve(ref.Context().Registry)
k8sc, err := k8schain.NewNoClient()
if err != nil {
return nil, err
}
return remote.Image(ref, remote.WithAuth(auth), remote.WithTransport(http.DefaultTransport))
kc := authn.NewMultiKeychain(authn.DefaultKeychain, k8sc)
return remote.Image(ref, remote.WithAuthFromKeychain(kc))

}

0 comments on commit a29c950

Please sign in to comment.