wip
This commit is contained in:
		
							parent
							
								
									75864d5c85
								
							
						
					
					
						commit
						db7687dbce
					
				|  | @ -318,7 +318,6 @@ func (s *stageBuilder) build() error { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	initSnapshotTaken := false | 	initSnapshotTaken := false | ||||||
| 	layer := 0 |  | ||||||
| 
 | 
 | ||||||
| 	cacheGroup := errgroup.Group{} | 	cacheGroup := errgroup.Group{} | ||||||
| 	for index, command := range s.cmds { | 	for index, command := range s.cmds { | ||||||
|  | @ -349,10 +348,9 @@ func (s *stageBuilder) build() error { | ||||||
| 				return false | 				return false | ||||||
| 			} | 			} | ||||||
| 		}() | 		}() | ||||||
| 		if !initSnapshotTaken && !isCacheCommand && !command.MetadataOnly() { | 		if !initSnapshotTaken && !command.ProvidesFilesToSnapshot() { | ||||||
| 			if !command.ProvidesFilesToSnapshot() { | 				// Take initial snapshot if command does not expect to return
 | ||||||
| 				// Take initial snapshot if command is not metadata only
 | 				// a list of files.
 | ||||||
| 				// and does not return a list of files changed
 |  | ||||||
| 				t := timing.Start("Initial FS snapshot") | 				t := timing.Start("Initial FS snapshot") | ||||||
| 				if err := s.snapshotter.Init(); err != nil { | 				if err := s.snapshotter.Init(); err != nil { | ||||||
| 					return err | 					return err | ||||||
|  | @ -360,7 +358,6 @@ func (s *stageBuilder) build() error { | ||||||
| 				timing.DefaultRun.Stop(t) | 				timing.DefaultRun.Stop(t) | ||||||
| 				initSnapshotTaken = true | 				initSnapshotTaken = true | ||||||
| 		} | 		} | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		if err := command.ExecuteCommand(&s.cf.Config, s.args); err != nil { | 		if err := command.ExecuteCommand(&s.cf.Config, s.args); err != nil { | ||||||
| 			return errors.Wrap(err, "failed to execute command") | 			return errors.Wrap(err, "failed to execute command") | ||||||
|  | @ -371,8 +368,6 @@ func (s *stageBuilder) build() error { | ||||||
| 		if !s.shouldTakeSnapshot(index, files, command.ProvidesFilesToSnapshot()) { | 		if !s.shouldTakeSnapshot(index, files, command.ProvidesFilesToSnapshot()) { | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		layer++ |  | ||||||
|     logrus.Infof(fmt.Sprintf("%d", layer)) |  | ||||||
| 		if isCacheCommand { | 		if isCacheCommand { | ||||||
| 			v := command.(commands.Cached) | 			v := command.(commands.Cached) | ||||||
| 			layer := v.Layer() | 			layer := v.Layer() | ||||||
|  | @ -415,6 +410,7 @@ func (s *stageBuilder) build() error { | ||||||
| func (s *stageBuilder) takeSnapshot(files []string) (string, error) { | func (s *stageBuilder) takeSnapshot(files []string) (string, error) { | ||||||
| 	var snapshot string | 	var snapshot string | ||||||
| 	var err error | 	var err error | ||||||
|  | 
 | ||||||
| 	t := timing.Start("Snapshotting FS") | 	t := timing.Start("Snapshotting FS") | ||||||
| 	if files == nil || s.opts.SingleSnapshot { | 	if files == nil || s.opts.SingleSnapshot { | ||||||
| 		snapshot, err = s.snapshotter.TakeSnapshotFS() | 		snapshot, err = s.snapshotter.TakeSnapshotFS() | ||||||
|  | @ -427,13 +423,20 @@ func (s *stageBuilder) takeSnapshot(files []string) (string, error) { | ||||||
| 	return snapshot, err | 	return snapshot, err | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (s *stageBuilder) shouldTakeSnapshot(index int, files []string, provideFiles bool) bool { | func (s *stageBuilder) singleSnapshot(index int) bool { | ||||||
|   isLastCommand := index == len(s.stage.Commands)-1 |   isLastCommand := index == len(s.stage.Commands)-1 | ||||||
| 
 | 
 | ||||||
|   // We only snapshot the very end with single snapshot mode on.
 |   // We only snapshot the very end with single snapshot mode on.
 | ||||||
|   if s.opts.SingleSnapshot { |   if s.opts.SingleSnapshot { | ||||||
|     return isLastCommand |     return isLastCommand | ||||||
|   } |   } | ||||||
|  |   return false | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (s *stageBuilder) shouldTakeSnapshot(index int, files []string, provideFiles bool) bool { | ||||||
|  | 	if s.singleSnapshot(index){ | ||||||
|  | 		return true | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	// Always take snapshots if we're using the cache.
 | 	// Always take snapshots if we're using the cache.
 | ||||||
| 	if s.opts.Cache { | 	if s.opts.Cache { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue