feat: add flag to disable pushing cache (#2038)
This commit is contained in:
		
							parent
							
								
									ce1fb51579
								
							
						
					
					
						commit
						872758b8b0
					
				|  | @ -199,6 +199,7 @@ func addKanikoOptionsFlags() { | |||
| 	RootCmd.PersistentFlags().BoolVarP(&opts.Reproducible, "reproducible", "", false, "Strip timestamps out of the image to make it reproducible") | ||||
| 	RootCmd.PersistentFlags().StringVarP(&opts.Target, "target", "", "", "Set the target build stage to build") | ||||
| 	RootCmd.PersistentFlags().BoolVarP(&opts.NoPush, "no-push", "", false, "Do not push the image to the registry") | ||||
| 	RootCmd.PersistentFlags().BoolVarP(&opts.NoPushCache, "no-push-cache", "", false, "Do not push the cache layers to the registry") | ||||
| 	RootCmd.PersistentFlags().StringVarP(&opts.CacheRepo, "cache-repo", "", "", "Specify a repository to use as a cache, otherwise one will be inferred from the destination provided") | ||||
| 	RootCmd.PersistentFlags().StringVarP(&opts.CacheDir, "cache-dir", "", "/cache", "Specify a local directory to use as a cache.") | ||||
| 	RootCmd.PersistentFlags().StringVarP(&opts.DigestFile, "digest-file", "", "", "Specify a file to save the digest of the built image to.") | ||||
|  |  | |||
|  | @ -420,7 +420,7 @@ func (s *stageBuilder) build() error { | |||
| 				logrus.Debugf("build: cache key for command %v %v", command.String(), ck) | ||||
| 
 | ||||
| 				// Push layer to cache (in parallel) now along with new config file
 | ||||
| 				if command.ShouldCacheOutput() { | ||||
| 				if command.ShouldCacheOutput() && ! s.opts.NoPushCache { | ||||
| 					cacheGroup.Go(func() error { | ||||
| 						return s.pushLayerToCache(s.opts, ck, tarPath, command.String()) | ||||
| 					}) | ||||
|  |  | |||
|  | @ -78,9 +78,13 @@ var ( | |||
| // push to every specified destination.
 | ||||
| func CheckPushPermissions(opts *config.KanikoOptions) error { | ||||
| 	targets := opts.Destinations | ||||
| 	// When no push is set, whe want to check permissions for the cache repo
 | ||||
| 	// When no push and no push cache are set, we don't need to check permissions
 | ||||
| 	if opts.NoPush && opt.noPushCache { | ||||
| 		targets = []string{} | ||||
| 	} | ||||
| 	// When no push is set, we want to check permissions for the cache repo
 | ||||
| 	// instead of the destinations
 | ||||
| 	if opts.NoPush { | ||||
| 	else if opts.NoPush && ! opt.noPushCache { | ||||
| 		targets = []string{opts.CacheRepo} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue