Support for private registries in the cache warmer

Closes #503

Signed-off-by: Stijn De Haes <stijndehaes@gmail.com>
This commit is contained in:
Stijn De Haes
2020-01-15 15:35:42 +01:00
parent b5c3d95d8e
commit 3fa8f686db
2 changed files with 17 additions and 1 deletions
+4 -1
View File
@@ -20,10 +20,12 @@ import (
"bytes"
"io"
"io/ioutil"
"net/http"
"os"
"path"
"github.com/GoogleContainerTools/kaniko/pkg/config"
"github.com/GoogleContainerTools/kaniko/pkg/creds"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
@@ -115,7 +117,8 @@ func (w *Warmer) Warm(image string, opts *config.WarmerOptions) (v1.Hash, error)
return v1.Hash{}, errors.Wrapf(err, "Failed to verify image name: %s", image)
}
img, err := w.Remote(cacheRef)
rOpts := []remote.Option{remote.WithTransport(http.DefaultTransport.(*http.Transport)), remote.WithAuthFromKeychain(creds.GetKeychain())}
img, err := w.Remote(cacheRef, rOpts...)
if err != nil || img == nil {
return v1.Hash{}, errors.Wrapf(err, "Failed to retrieve image: %s", image)
}