Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 473a2b2

Browse files
authored
Save flag functional for cloud, ID, and tar (#17)
* Save flag functional for cloud, ID, and tar * Adding glog statement with image save location
1 parent 38f78ae commit 473a2b2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cmd/root.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var file bool
2525
var history bool
2626
var pip bool
2727

28+
var save bool
29+
2830
var diffFlagMap = map[string]*bool{
2931
"apt": &apt,
3032
"node": &node,
@@ -120,10 +122,15 @@ var RootCmd = &cobra.Command{
120122
}
121123
fmt.Println()
122124
glog.Info("Removing image file system directories from system")
123-
errMsg := remove(image1.FSPath, true)
124-
errMsg += remove(image2.FSPath, true)
125-
if errMsg != "" {
126-
glog.Error(errMsg)
125+
if !save {
126+
errMsg := remove(image1.FSPath, true)
127+
errMsg += remove(image2.FSPath, true)
128+
if errMsg != "" {
129+
glog.Error(errMsg)
130+
}
131+
} else {
132+
dir, _ := os.Getwd()
133+
glog.Infof("Images were saved at %s as %s and %s", dir, image1.FSPath, image2.FSPath)
127134
}
128135
} else {
129136
glog.Error(err.Error())
@@ -222,4 +229,5 @@ func init() {
222229
RootCmd.Flags().BoolVarP(&apt, "apt", "a", false, "Set this flag to use the apt differ.")
223230
RootCmd.Flags().BoolVarP(&file, "file", "f", false, "Set this flag to use the file differ.")
224231
RootCmd.Flags().BoolVarP(&history, "history", "d", false, "Set this flag to use the dockerfile history differ.")
232+
RootCmd.Flags().BoolVarP(&save, "save", "s", false, "Set this flag to save rather than remove the final image filesystems on exit.")
225233
}

0 commit comments

Comments
 (0)