Skip to content

Commit

Permalink
refactor(versions)!: data_img to data in versions (#49)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Cui <[email protected]>
  • Loading branch information
BlackHole1 authored Jul 1, 2024
1 parent 52a7115 commit a162252
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ At the same time, ovm will also create `tmp.img` and data.img in this directory.

#### `-versions` (Required)

Set versions of the kernel/initrd/rootfs/dataImg
Set versions of the kernel/initrd/rootfs/data

Format: `kernel=version,initrd=version,rootfs=version,dataImg=version`
Format: `kernel=version,initrd=version,rootfs=version,data=version`

When the version number differs from the previous one, the new file will be used to overwrite the previous file.

Expand Down
30 changes: 15 additions & 15 deletions pkg/cli/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
)

type versionsJSON struct {
Kernel string `json:"kernel"`
Initrd string `json:"initrd"`
Rootfs string `json:"rootfs"`
DataImg string `json:"data_img"`
Kernel string `json:"kernel"`
Initrd string `json:"initrd"`
Rootfs string `json:"rootfs"`
Data string `json:"data"`

path string
needUpdateJSON bool
Expand Down Expand Up @@ -77,8 +77,8 @@ func (v *versionsJSON) get(key string) string {
return v.Initrd
case "rootfs":
return v.Rootfs
case "data_img":
return v.DataImg
case "data":
return v.Data
default:
return ""
}
Expand All @@ -93,8 +93,8 @@ func (v *versionsJSON) set(key, val string) {
vK = &v.Initrd
case "rootfs":
vK = &v.Rootfs
case "data_img":
vK = &v.DataImg
case "data":
vK = &v.Data
}

if *vK != val {
Expand All @@ -116,7 +116,7 @@ type targetContext struct {
versionsJSON *versionsJSON
}

func newTarget(targetPath, kernelPath, initrdPath, rootfsPath, dataImgPath, versionsPath string) (*targetContext, error) {
func newTarget(targetPath, kernelPath, initrdPath, rootfsPath, dataPath, versionsPath string) (*targetContext, error) {
versionsJSON, err := newVersionsJSON(versionsPath)
if err != nil {
return nil, err
Expand All @@ -128,7 +128,7 @@ func newTarget(targetPath, kernelPath, initrdPath, rootfsPath, dataImgPath, vers
{"kernel", kernelPath},
{"initrd", initrdPath},
{"rootfs", rootfsPath},
{"data_img", dataImgPath},
{"data", dataPath},
},

versionsJSON: versionsJSON,
Expand Down Expand Up @@ -164,7 +164,7 @@ func (t *targetContext) copyOrCreate(src srcPath, g *errgroup.Group) {
distPath := path.Join(t.targetPath, filepath.Base(src.p))

g.Go(func() error {
if src.key == "data_img" {
if src.key == "data" {
if err := os.RemoveAll(distPath); err != nil {
return err
}
Expand All @@ -177,10 +177,10 @@ func (t *targetContext) copyOrCreate(src srcPath, g *errgroup.Group) {
}

var versionsParams = map[string]string{
"kernel": "",
"initrd": "",
"rootfs": "",
"data_img": "",
"kernel": "",
"initrd": "",
"rootfs": "",
"data": "",
}

func parseVersions() error {
Expand Down

0 comments on commit a162252

Please sign in to comment.