Skip to content

Commit

Permalink
Pull docker image only if pull-image flag is set
Browse files Browse the repository at this point in the history
This commit introduces EdenSetupArgs.Eve.PullImage bool flag
which is used to determine if we need to pull latest docker images.

This enables us to use docker load to get EVE image from cache

Signed-off-by: Pavel Abramov <[email protected]>
  • Loading branch information
uncleDecart committed Dec 4, 2023
1 parent 9611e40 commit 5b351ba
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions cmd/edenConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func newConfigAddCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
configAddCmd.Flags().StringVar(&cfg.Eve.Ssid, "ssid", "", "set ssid of wifi for rpi")
configAddCmd.Flags().StringVar(&cfg.Eve.Arch, "arch", "", "arch of EVE (amd64 or arm64)")
configAddCmd.Flags().StringVar(&cfg.Eve.ModelFile, "devmodel-file", "", "File to use for overwrite of model defaults")
configAddCmd.Flags().BoolVarP(&cfg.Eve.PullImage, "pull-image", "", true, "Download latest EVE")
configAddCmd.Flags().BoolVarP(&force, "force", "", false, "force overwrite config file")

return configAddCmd
Expand Down
1 change: 1 addition & 0 deletions cmd/edenSetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func newSetupCmd(configName, verbosity *string) *cobra.Command {
setupCmd.Flags().StringToStringVarP(&cfg.Eve.HostFwd, "eve-hostfwd", "", defaults.DefaultQemuHostFwd, "port forward map")
setupCmd.Flags().StringVarP(&cfg.Eve.QemuFileToSave, "qemu-config", "", cfg.Eve.QemuFileToSave, "file to save qemu config")
setupCmd.Flags().StringVarP(&cfg.Eve.HV, "eve-hv", "", defaults.DefaultEVEHV, "hv of rootfs to use")
setupCmd.Flags().BoolVarP(&cfg.Eve.PullImage, "pull-image", "", true, "Download latest EVE")

setupCmd.Flags().StringVarP(&cfg.Eden.Images.EServerImageDist, "image-dist", "", cfg.Eden.Images.EServerImageDist, "image dist for eserver")
setupCmd.Flags().StringVarP(&cfg.Eden.BinDir, "bin-dist", "", filepath.Join(currentPath, defaults.DefaultDist, defaults.DefaultBinDist), "directory for binaries")
Expand Down
1 change: 1 addition & 0 deletions pkg/openevec/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type EveConfig struct {
Password string `mapstructure:"password" cobraflag:"password"`
Serial string `mapstructure:"serial" cobraflag:"eve-serial"`
Accel bool `mapstructure:"accel" cobraflag:"eve-accel"`
PullImage bool `mapstructure:"latest" cobraflag:"pull-image"`

Pid string `mapstructure:"pid" cobraflag:"eve-pid" resolvepath:""`
Log string `mapstructure:"log" cobraflag:"eve-log" resolvepath:""`
Expand Down
1 change: 1 addition & 0 deletions pkg/openevec/eden.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func setupEve(netboot, installer bool, softSerial, ipxeOverride string, cfg Eden
Tag: cfg.Eve.Tag,
Format: imageFormat,
ImageSizeMB: cfg.Eve.ImageSizeMB,
Latest: cfg.Eve.PullImage,
}
if cfg.Eve.CustomInstaller.Path != "" {
// With installer image already prepared, install only UEFI.
Expand Down
23 changes: 15 additions & 8 deletions pkg/utils/downloaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type EVEDescription struct {
Tag string
Format string
ImageSizeMB int
PullImage bool
}

// Image extracts image tag from EVEDescription
Expand Down Expand Up @@ -75,8 +76,10 @@ func DownloadUEFI(eve EVEDescription, outputDir string) (err error) {
if err != nil {
return err
}
if err := PullImage(image); err != nil {
return fmt.Errorf("ImagePull (%s): %s", image, err)
if eve.PullImage {
if err := PullImage(image); err != nil {
return fmt.Errorf("ImagePull (%s): %s", image, err)
}
}
if err := SaveImageAndExtract(image, outputDir, "/bits/firmware"); err != nil {
return fmt.Errorf("SaveImageAndExtract: %w", err)
Expand All @@ -90,9 +93,11 @@ func DownloadEveLive(eve EVEDescription, outputFile string) (err error) {
if err != nil {
return err
}
log.Debugf("Try ImagePull with (%s)", image)
if err := PullImage(image); err != nil {
return fmt.Errorf("ImagePull (%s): %s", image, err)
if eve.PullImage {
log.Debugf("Try ImagePull with (%s)", image)
if err := PullImage(image); err != nil {
return fmt.Errorf("ImagePull (%s): %s", image, err)
}
}
if eve.ConfigPath != "" {
if _, err := os.Stat(eve.ConfigPath); os.IsNotExist(err) {
Expand Down Expand Up @@ -281,9 +286,11 @@ func DownloadEveNetBoot(eve EVEDescription, outputDir string) (err error) {
if err != nil {
return err
}
log.Debugf("Try ImagePull with (%s)", image)
if err := PullImage(image); err != nil {
return fmt.Errorf("ImagePull (%s): %s", image, err)
if eve.PullImage {
log.Debugf("Try ImagePull with (%s)", image)
if err := PullImage(image); err != nil {
return fmt.Errorf("ImagePull (%s): %s", image, err)
}
}
if eve.ConfigPath != "" {
if _, err := os.Stat(eve.ConfigPath); os.IsNotExist(err) {
Expand Down

0 comments on commit 5b351ba

Please sign in to comment.