Added integration test, minor changes to files

This commit is contained in:
Priya Wadhwa
2018-03-08 11:49:56 -08:00
parent 04cca43ce4
commit 75e7e47b76
12 changed files with 99 additions and 50 deletions
+16 -29
View File
@@ -91,7 +91,7 @@ func execute() error {
}
// Execute commands here
if err := image.SetEnvVariables(); err != nil {
if err := image.SetEnvVariables(sourceImage); err != nil {
return err
}
@@ -109,36 +109,23 @@ func execute() error {
// If this is nil, snapshot the entire filesystem
// Else take a snapshot of the specific files
snapshotFiles := dockerCommand.FilesToSnapshot()
var contents []byte
if snapshotFiles == nil {
logrus.Info("Taking snapshot of full filesystem...")
contents, filesAdded, err := snapshotter.TakeSnapshot()
if err != nil {
return err
}
if !filesAdded {
logrus.Info("No files were changed, appending empty layer to config.")
image.AppendConfigHistory(dockerCommand.Author(), true)
continue
}
// Append the layer to the image
if err := image.AppendLayer(contents, dockerCommand.Author()); err != nil {
return err
}
contents, err = snapshotter.TakeSnapshot()
} else {
logrus.Infof("Taking snapshot of files %v...", snapshotFiles)
contents, err := snapshotter.TakeSnapshotOfFiles(snapshotFiles)
if err != nil {
return err
}
if contents == nil {
logrus.Info("No files were changed, appending empty layer to config.")
image.AppendConfigHistory(dockerCommand.Author(), true)
continue
}
// Append the layer to the image
if err := image.AppendLayer(contents, dockerCommand.Author()); err != nil {
return err
}
contents, err = snapshotter.TakeSnapshotOfFiles(snapshotFiles)
}
if err != nil {
return err
}
if contents == nil {
logrus.Info("No files were changed, appending empty layer to config.")
sourceImage.AppendConfigHistory(dockerCommand.Author(), true)
continue
}
// Append the layer to the image
if err := sourceImage.AppendLayer(contents, dockerCommand.Author()); err != nil {
return err
}
}
}