From c3997c1b6dd91111d3acc47b8800e62043c882f9 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Wed, 8 Jun 2022 10:16:02 +0800 Subject: [PATCH] nydusify: rename `image_version` to `fs-version` to be consistent with nydus-image Signed-off-by: Qi Wang --- contrib/nydusify/cmd/nydusify.go | 4 +-- contrib/nydusify/pkg/build/builder.go | 4 +-- contrib/nydusify/pkg/build/workflow.go | 4 +-- contrib/nydusify/pkg/checker/checker.go | 4 +-- contrib/nydusify/pkg/converter/converter.go | 14 +++++----- contrib/nydusify/tests/e2e_test.go | 30 ++++++++++----------- contrib/nydusify/tests/image_test.go | 4 +-- contrib/nydusify/tests/nydusify.go | 14 +++++----- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/contrib/nydusify/cmd/nydusify.go b/contrib/nydusify/cmd/nydusify.go index 8e0c05b90bf..5da776abc2e 100644 --- a/contrib/nydusify/cmd/nydusify.go +++ b/contrib/nydusify/cmd/nydusify.go @@ -210,7 +210,7 @@ func main() { // chosen to make it compatible with the 127 max in graph driver of // docker so that we can pull cache image using docker. &cli.UintFlag{Name: "build-cache-max-records", Value: maxCacheMaxRecords, Usage: "Maximum cache records in cache image", EnvVars: []string{"BUILD_CACHE_MAX_RECORDS"}}, - &cli.StringFlag{Name: "image-version", Required: false, Usage: "Image format version", EnvVars: []string{"IMAGE_VERSION"}, Value: "5", DefaultText: "V5 format"}, + &cli.StringFlag{Name: "fs-version", Required: false, Usage: "Image format version", EnvVars: []string{"FS_VERSION"}, Value: "5", DefaultText: "V5 format"}, }, Action: func(c *cli.Context) error { setupLogLevel(c) @@ -312,7 +312,7 @@ func main() { NydusifyVersion: version, Source: c.String("source"), - ImageVersion: c.String("image-version"), + FsVersion: c.String("fs-version"), ChunkDict: converter.ChunkDictOpt{ Args: c.String("chunk-dict"), diff --git a/contrib/nydusify/pkg/build/builder.go b/contrib/nydusify/pkg/build/builder.go index d3409268410..dfff0c37a01 100644 --- a/contrib/nydusify/pkg/build/builder.go +++ b/contrib/nydusify/pkg/build/builder.go @@ -26,7 +26,7 @@ type BuilderOption struct { // A regular file or fifo into which commands nydus-image to dump contents. BlobPath string AlignedChunk bool - ImageVersion string + FsVersion string } type CompactOption struct { @@ -122,7 +122,7 @@ func (builder *Builder) Run(option BuilderOption) error { "--blob", option.BlobPath, "--fs-version", - option.ImageVersion, + option.FsVersion, ) if len(option.PrefetchPatterns) > 0 { diff --git a/contrib/nydusify/pkg/build/workflow.go b/contrib/nydusify/pkg/build/workflow.go index 06d2319e6b7..06c3fc13036 100644 --- a/contrib/nydusify/pkg/build/workflow.go +++ b/contrib/nydusify/pkg/build/workflow.go @@ -21,7 +21,7 @@ type WorkflowOption struct { TargetDir string NydusImagePath string PrefetchPatterns string - ImageVersion string + FsVersion string } type Workflow struct { @@ -119,7 +119,7 @@ func (workflow *Workflow) Build( BlobPath: blobPath, AlignedChunk: alignedChunk, ChunkDict: workflow.ChunkDict, - ImageVersion: workflow.ImageVersion, + FsVersion: workflow.FsVersion, }); err != nil { return "", errors.Wrapf(err, "build layer %s", layerDir) } diff --git a/contrib/nydusify/pkg/checker/checker.go b/contrib/nydusify/pkg/checker/checker.go index 81edf031e24..34d42ac2908 100644 --- a/contrib/nydusify/pkg/checker/checker.go +++ b/contrib/nydusify/pkg/checker/checker.go @@ -32,7 +32,7 @@ type Opt struct { BackendType string BackendConfig string ExpectedArch string - ImageVersion string + FsVersion string } // Checker validates Nydus image manifest, bootstrap and mounts filesystem @@ -108,7 +108,7 @@ func (checker *Checker) Check(ctx context.Context) error { mode := "cache" digestValidate := true - if checker.ImageVersion == "6" { + if checker.FsVersion == "6" { mode = "direct" digestValidate = false diff --git a/contrib/nydusify/pkg/converter/converter.go b/contrib/nydusify/pkg/converter/converter.go index fa05175cab8..5b77a46bf31 100644 --- a/contrib/nydusify/pkg/converter/converter.go +++ b/contrib/nydusify/pkg/converter/converter.go @@ -89,8 +89,8 @@ type Opt struct { NydusifyVersion string Source string - ChunkDict ChunkDictOpt - ImageVersion string + ChunkDict ChunkDictOpt + FsVersion string } type Converter struct { @@ -118,8 +118,8 @@ type Converter struct { storageBackend backend.Backend - chunkDict ChunkDictOpt - ImageVersion string + chunkDict ChunkDictOpt + FsVersion string } func imageRepository(ref string) (string, error) { @@ -158,8 +158,8 @@ func New(opt Opt) (*Converter, error) { storageBackend: backend, - chunkDict: opt.ChunkDict, - ImageVersion: opt.ImageVersion, + chunkDict: opt.ChunkDict, + FsVersion: opt.FsVersion, }, nil } @@ -214,7 +214,7 @@ func (cvt *Converter) convert(ctx context.Context) (retErr error) { NydusImagePath: cvt.NydusImagePath, PrefetchPatterns: cvt.PrefetchPatterns, TargetDir: cvt.WorkDir, - ImageVersion: cvt.ImageVersion, + FsVersion: cvt.FsVersion, }) if err != nil { return errors.Wrap(err, "Create build flow") diff --git a/contrib/nydusify/tests/e2e_test.go b/contrib/nydusify/tests/e2e_test.go index 880643052b4..d542dea4409 100644 --- a/contrib/nydusify/tests/e2e_test.go +++ b/contrib/nydusify/tests/e2e_test.go @@ -9,73 +9,73 @@ import ( "testing" ) -func testBasicConvert(t *testing.T, imageVersion string) { +func testBasicConvert(t *testing.T, fsVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) registry.Build(t, "image-basic") - nydusify := NewNydusify(registry, "image-basic", "image-basic-nydus", "", "", imageVersion) + nydusify := NewNydusify(registry, "image-basic", "image-basic-nydus", "", "", fsVersion) nydusify.Convert(t) nydusify.Check(t) } -func testConvertWithCache(t *testing.T, imageVersion string) { +func testConvertWithCache(t *testing.T, fsVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) registry.Build(t, "image-basic") - nydusify1 := NewNydusify(registry, "image-basic", "image-basic-nydus-1", "cache:v1", "", imageVersion) + nydusify1 := NewNydusify(registry, "image-basic", "image-basic-nydus-1", "cache:v1", "", fsVersion) nydusify1.Convert(t) nydusify1.Check(t) - nydusify2 := NewNydusify(registry, "image-basic", "image-basic-nydus-2", "cache:v1", "", imageVersion) + nydusify2 := NewNydusify(registry, "image-basic", "image-basic-nydus-2", "cache:v1", "", fsVersion) nydusify2.Convert(t) nydusify2.Check(t) registry.Build(t, "image-from-1") - nydusify3 := NewNydusify(registry, "image-from-1", "image-from-nydus-1", "cache:v1", "", imageVersion) + nydusify3 := NewNydusify(registry, "image-from-1", "image-from-nydus-1", "cache:v1", "", fsVersion) nydusify3.Convert(t) nydusify3.Check(t) registry.Build(t, "image-from-2") - nydusify4 := NewNydusify(registry, "image-from-2", "image-from-nydus-2", "cache:v1", "", imageVersion) + nydusify4 := NewNydusify(registry, "image-from-2", "image-from-nydus-2", "cache:v1", "", fsVersion) nydusify4.Convert(t) nydusify4.Check(t) } -func testConvertWithChunkDict(t *testing.T, imageVersion string) { +func testConvertWithChunkDict(t *testing.T, fsVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) registry.Build(t, "chunk-dict-1") // build chunk-dict-1 bootstrap - nydusify1 := NewNydusify(registry, "chunk-dict-1", "nydus:chunk-dict-1", "", "", imageVersion) + nydusify1 := NewNydusify(registry, "chunk-dict-1", "nydus:chunk-dict-1", "", "", fsVersion) nydusify1.Convert(t) nydusify1.Check(t) chunkDictOpt := fmt.Sprintf("bootstrap:registry:%s/%s", registry.Host(), "nydus:chunk-dict-1") // build without build-cache registry.Build(t, "image-basic") - nydusify2 := NewNydusify(registry, "image-basic", "nydus:image-basic", "", chunkDictOpt, imageVersion) + nydusify2 := NewNydusify(registry, "image-basic", "nydus:image-basic", "", chunkDictOpt, fsVersion) nydusify2.Convert(t) nydusify2.Check(t) // build with build-cache registry.Build(t, "image-from-1") - nydusify3 := NewNydusify(registry, "image-from-1", "nydus:image-from-1", "nydus:cache_v1", chunkDictOpt, imageVersion) + nydusify3 := NewNydusify(registry, "image-from-1", "nydus:image-from-1", "nydus:cache_v1", chunkDictOpt, fsVersion) nydusify3.Convert(t) nydusify3.Check(t) // change chunk dict registry.Build(t, "chunk-dict-2") - nydusify4 := NewNydusify(registry, "chunk-dict-2", "nydus:chunk-dict-2", "", "", imageVersion) + nydusify4 := NewNydusify(registry, "chunk-dict-2", "nydus:chunk-dict-2", "", "", fsVersion) nydusify4.Convert(t) nydusify4.Check(t) chunkDictOpt = fmt.Sprintf("bootstrap:registry:%s/%s", registry.Host(), "nydus:chunk-dict-2") registry.Build(t, "image-from-2") - nydusify5 := NewNydusify(registry, "image-from-2", "nydus:image-from-2", "nydus:cache_v1", chunkDictOpt, imageVersion) + nydusify5 := NewNydusify(registry, "image-from-2", "nydus:image-from-2", "nydus:cache_v1", chunkDictOpt, fsVersion) nydusify5.Convert(t) nydusify5.Check(t) } func TestSmoke(t *testing.T) { - imageVersions := [2]string{"5", "6"} - for _, v := range imageVersions { + fsVersions := [2]string{"5", "6"} + for _, v := range fsVersions { testBasicConvert(t, v) testConvertWithCache(t, v) testConvertWithChunkDict(t, v) diff --git a/contrib/nydusify/tests/image_test.go b/contrib/nydusify/tests/image_test.go index f50a6624abb..0b522912a81 100644 --- a/contrib/nydusify/tests/image_test.go +++ b/contrib/nydusify/tests/image_test.go @@ -34,11 +34,11 @@ func transfer(t *testing.T, ref string) { run(t, fmt.Sprintf("docker push %s/%s", host, ref), true) } -func convert(t *testing.T, ref string, imageVersion string) { +func convert(t *testing.T, ref string, fsVersion string) { registry := NewRegistry(t) defer registry.Destroy(t) transfer(t, ref) - nydusify := NewNydusify(registry, ref, fmt.Sprintf("%s-nydus", ref), "", "", imageVersion) + nydusify := NewNydusify(registry, ref, fmt.Sprintf("%s-nydus", ref), "", "", fsVersion) nydusify.Convert(t) nydusify.Check(t) } diff --git a/contrib/nydusify/tests/nydusify.go b/contrib/nydusify/tests/nydusify.go index 3424cbdfbeb..7bea2167d59 100644 --- a/contrib/nydusify/tests/nydusify.go +++ b/contrib/nydusify/tests/nydusify.go @@ -42,10 +42,10 @@ type Nydusify struct { backendType string backendConfig string chunkDictArgs string - imageVersion string + fsVersion string } -func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs string, imageVersion string) *Nydusify { +func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs string, fsVersion string) *Nydusify { host := registry.Host() backendType := "registry" @@ -61,8 +61,8 @@ func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs if os.Getenv("BACKEND_CONFIG") != "" { backendConfig = os.Getenv("BACKEND_CONFIG") } - if len(imageVersion) == 0 { - imageVersion = "5" + if len(fsVersion) == 0 { + fsVersion = "5" } return &Nydusify{ @@ -73,7 +73,7 @@ func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs backendType: backendType, backendConfig: backendConfig, chunkDictArgs: chunkDictArgs, - imageVersion: imageVersion, + fsVersion: fsVersion, } } @@ -133,7 +133,7 @@ func (nydusify *Nydusify) Convert(t *testing.T) { Insecure: false, Platform: "linux/amd64", }, - ImageVersion: nydusify.imageVersion, + fsVersion: nydusify.fsVersion, } cvt, err := converter.New(opt) @@ -157,7 +157,7 @@ func (nydusify *Nydusify) Check(t *testing.T) { BackendType: nydusify.backendType, BackendConfig: nydusify.backendConfig, ExpectedArch: "amd64", - ImageVersion: nydusify.imageVersion, + fsVersion: nydusify.fsVersion, }) assert.Nil(t, err)