From 0ef3a6b5258ea0467edb0dd4e33ed5b056ce180e Mon Sep 17 00:00:00 2001 From: ejose19 <8742215+ejose19@users.noreply.github.com> Date: Fri, 2 Oct 2020 14:11:12 -0300 Subject: [PATCH] Fix permissions on cache when --no-push is set (#1445) --- pkg/executor/push.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/executor/push.go b/pkg/executor/push.go index b002d843a..a425ba30a 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -102,14 +102,17 @@ var ( // CheckPushPermissions checks that the configured credentials can be used to // push to every specified destination. func CheckPushPermissions(opts *config.KanikoOptions) error { + var targets = opts.Destinations + // When no push is set, whe want to check permissions for the cache repo + // instead of the destinations if opts.NoPush { - return nil + targets = []string{opts.CacheRepo} } checked := map[string]bool{} _, err := fs.Stat(DockerConfLocation()) dockerConfNotExists := os.IsNotExist(err) - for _, destination := range opts.Destinations { + for _, destination := range targets { destRef, err := name.NewTag(destination, name.WeakValidation) if err != nil { return errors.Wrap(err, "getting tag for destination")