mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 11:04:24 +02:00
Fix handling of volume directive
This commit is contained in:
+10
-1
@@ -138,6 +138,7 @@ func (s *stageBuilder) build(opts *config.KanikoOptions) error {
|
||||
if err := s.snapshotter.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
var volumes []string
|
||||
args := dockerfile.NewBuildArgs(opts.BuildArgs)
|
||||
for index, cmd := range s.stage.Commands {
|
||||
finalCmd := index == len(s.stage.Commands)-1
|
||||
@@ -167,6 +168,10 @@ func (s *stageBuilder) build(opts *config.KanikoOptions) error {
|
||||
return err
|
||||
}
|
||||
files := command.FilesToSnapshot()
|
||||
if cmd.Name() == constants.VolumeCmdName {
|
||||
volumes = append(volumes, files...)
|
||||
continue
|
||||
}
|
||||
var contents []byte
|
||||
|
||||
// If this is an intermediate stage, we only snapshot for the last command and we
|
||||
@@ -188,9 +193,14 @@ func (s *stageBuilder) build(opts *config.KanikoOptions) error {
|
||||
// the files that were changed, we'll snapshot those explicitly, otherwise we'll
|
||||
// check if anything in the filesystem changed.
|
||||
if files != nil {
|
||||
if len(files) > 0 {
|
||||
files = append(files, volumes...)
|
||||
volumes = []string{}
|
||||
}
|
||||
contents, err = s.snapshotter.TakeSnapshot(files)
|
||||
} else {
|
||||
contents, err = s.snapshotter.TakeSnapshotFS()
|
||||
volumes = []string{}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +208,6 @@ func (s *stageBuilder) build(opts *config.KanikoOptions) error {
|
||||
return fmt.Errorf("Error taking snapshot of files for command %s: %s", command, err)
|
||||
}
|
||||
|
||||
util.MoveVolumeWhitelistToWhitelist()
|
||||
if contents == nil {
|
||||
logrus.Info("No files were changed, appending empty layer to config. No layer added to image.")
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user