Fix runtime check during restore
cfg.RuntimePath was set to default runtime, so the empty string
check fails. Instead we could check if the flag was changed.
@@ -143,16 +143,15 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
cmd.Flag("import").Value.String(),
)
}
- if cfg.RuntimePath == "" {
- // If the user did not select a runtime, this takes the one from
- // the checkpoint archives and tells Podman to use it for the restore.
- runtimeFlag := cmd.Root().Flags().Lookup("runtime")
+
+ runtimeFlag := cmd.Root().Flag("runtime")
if runtimeFlag == nil {
- return errors.Errorf(
- "setting runtime to '%s' for restore",
- *runtime,
- )
+ return errors.New("failed to load --runtime flag")
}
+
+ if !runtimeFlag.Changed {
+ // If the user did not select a runtime, this takes the one from
+ // the checkpoint archives and tells Podman to use it for the restore.
if err := runtimeFlag.Value.Set(*runtime); err != nil {
return err
}
