From a8cf965b2a0f2de839bf7a2e11bc98637e62ade7 Mon Sep 17 00:00:00 2001 From: niusmallnan Date: Fri, 16 Aug 2019 13:46:12 +0800 Subject: [PATCH] Rename stage to save for install cli args --- cmd/control/install.go | 24 ++++++++++++------------ cmd/control/install/service.go | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/control/install.go b/cmd/control/install.go index 036205ea..8931961c 100644 --- a/cmd/control/install.go +++ b/cmd/control/install.go @@ -86,8 +86,8 @@ var installCommand = cli.Command{ Usage: "reboot using kexec", }, cli.BoolFlag{ - Name: "stage, s", - Usage: "stage services", + Name: "save, s", + Usage: "save services and images for next booting", }, cli.BoolFlag{ Name: "debug", @@ -179,13 +179,13 @@ func installAction(c *cli.Context) error { cloudConfig = uc } - stageImages := []string{} - if c.Bool("stage") && cloudConfig != "" && installType != "upgrade" { - stageImages = install.GetCacheImageList(cloudConfig, cfg) - log.Debugf("Will cache these images: %s", stageImages) + savedImages := []string{} + if c.Bool("save") && cloudConfig != "" && installType != "upgrade" { + savedImages = install.GetCacheImageList(cloudConfig, cfg) + log.Debugf("Will cache these images: %s", savedImages) } - if err := runInstall(image, installType, cloudConfig, device, partition, statedir, kappend, force, kexec, isoinstallerloaded, debug, stageImages); err != nil { + if err := runInstall(image, installType, cloudConfig, device, partition, statedir, kappend, force, kexec, isoinstallerloaded, debug, savedImages); err != nil { log.WithFields(log.Fields{"err": err}).Fatal("Failed to run install") return err } @@ -198,7 +198,7 @@ func installAction(c *cli.Context) error { return nil } -func runInstall(image, installType, cloudConfig, device, partition, statedir, kappend string, force, kexec, isoinstallerloaded, debug bool, stageImages []string) error { +func runInstall(image, installType, cloudConfig, device, partition, statedir, kappend string, force, kexec, isoinstallerloaded, debug bool, savedImages []string) error { fmt.Printf("Installing from %s\n", image) if !force { @@ -283,8 +283,8 @@ func runInstall(image, installType, cloudConfig, device, partition, statedir, ka if statedir != "" { installerCmd = append(installerCmd, "--statedir", statedir) } - if len(stageImages) > 0 { - installerCmd = append(installerCmd, "--stage") + if len(savedImages) > 0 { + installerCmd = append(installerCmd, "--save") } // TODO: mount at /mnt for shared mount? @@ -348,8 +348,8 @@ func runInstall(image, installType, cloudConfig, device, partition, statedir, ka return err } - if len(stageImages) > 0 { - return install.RunCacheScript(partition, stageImages) + if len(savedImages) > 0 { + return install.RunCacheScript(partition, savedImages) } return nil diff --git a/cmd/control/install/service.go b/cmd/control/install/service.go index 6a9c246b..e7e25af2 100644 --- a/cmd/control/install/service.go +++ b/cmd/control/install/service.go @@ -18,21 +18,21 @@ type ImageConfig struct { } func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string { - stageImages := make([]string, 0) + savedImages := make([]string, 0) bytes, err := readConfigFile(cloudconfig) if err != nil { log.WithFields(log.Fields{"err": err}).Fatal("Failed to read cloud-config") - return stageImages + return savedImages } r := make(map[interface{}]interface{}) if err := yaml.Unmarshal(bytes, &r); err != nil { log.WithFields(log.Fields{"err": err}).Fatal("Failed to unmarshal cloud-config") - return stageImages + return savedImages } newcfg := &config.CloudConfig{} if err := util.Convert(r, newcfg); err != nil { log.WithFields(log.Fields{"err": err}).Fatal("Failed to convert cloud-config") - return stageImages + return savedImages } // services_include @@ -40,7 +40,7 @@ func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string if value { serviceImage := getServiceImage(key, "", oldcfg, newcfg) if serviceImage != "" { - stageImages = append(stageImages, serviceImage) + savedImages = append(savedImages, serviceImage) } } } @@ -50,7 +50,7 @@ func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string if newConsole != "" && newConsole != "default" { consoleImage := getServiceImage(newConsole, "console", oldcfg, newcfg) if consoleImage != "" { - stageImages = append(stageImages, consoleImage) + savedImages = append(savedImages, consoleImage) } } @@ -59,12 +59,12 @@ func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string if newEngine != "" && newEngine != oldcfg.Rancher.Docker.Engine { engineImage := getServiceImage(newEngine, "docker", oldcfg, newcfg) if engineImage != "" { - stageImages = append(stageImages, engineImage) + savedImages = append(savedImages, engineImage) } } - return stageImages + return savedImages } func getServiceImage(service, svctype string, oldcfg, newcfg *config.CloudConfig) string {