Fix issues with layer caching, noPush and tarPath (#549)
* Set TarPath to empty when pushing a layer * Fix issues with layer caching, noPush and tarPath. - Layer caching should work even when tarPath is specified, so this commit changes the value of tarPath to empty when caching layers. - When an image is built with just the tarPath and noPush is true, we should still create the tarBall (which wasn't happening before this commit). * Set no-push to false for cache layers * Remove extra log * go-imports fix
This commit is contained in:
parent
9f65174cb8
commit
82fe355f14
|
|
@ -49,10 +49,6 @@ func (w *withUserAgent) RoundTrip(r *http.Request) (*http.Response, error) {
|
|||
|
||||
// DoPush is responsible for pushing image to the destinations specified in opts
|
||||
func DoPush(image v1.Image, opts *config.KanikoOptions) error {
|
||||
if opts.NoPush {
|
||||
logrus.Info("Skipping push to container registry due to --no-push flag")
|
||||
return nil
|
||||
}
|
||||
t := timing.Start("Total Push Time")
|
||||
destRefs := []name.Tag{}
|
||||
for _, destination := range opts.Destinations {
|
||||
|
|
@ -71,6 +67,11 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error {
|
|||
return tarball.MultiWriteToFile(opts.TarPath, tagToImage)
|
||||
}
|
||||
|
||||
if opts.NoPush {
|
||||
logrus.Info("Skipping push to container registry due to --no-push flag")
|
||||
return nil
|
||||
}
|
||||
|
||||
// continue pushing unless an error occurs
|
||||
for _, destRef := range destRefs {
|
||||
registryName := destRef.Repository.Registry.Name()
|
||||
|
|
@ -135,6 +136,8 @@ func pushLayerToCache(opts *config.KanikoOptions, cacheKey string, tarPath strin
|
|||
return errors.Wrap(err, "appending layer onto empty image")
|
||||
}
|
||||
cacheOpts := *opts
|
||||
cacheOpts.TarPath = "" // tarPath doesn't make sense for Docker layers
|
||||
cacheOpts.NoPush = false // we want to push cached layers
|
||||
cacheOpts.Destinations = []string{cache}
|
||||
cacheOpts.InsecureRegistries = opts.InsecureRegistries
|
||||
cacheOpts.SkipTLSVerifyRegistries = opts.SkipTLSVerifyRegistries
|
||||
|
|
|
|||
Loading…
Reference in New Issue