Skip to content

Commit

Permalink
nydusify: rename image_version to fs-version to be consistent wit…
Browse files Browse the repository at this point in the history
…h nydus-image

Signed-off-by: Qi Wang <wangqi@linux.alibaba.com>
  • Loading branch information
yawqi committed Jun 8, 2022
1 parent 8f78162 commit 45769c3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions contrib/nydusify/cmd/nydusify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions contrib/nydusify/pkg/build/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions contrib/nydusify/pkg/build/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type WorkflowOption struct {
TargetDir string
NydusImagePath string
PrefetchPatterns string
ImageVersion string
FsVersion string
}

type Workflow struct {
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions contrib/nydusify/pkg/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions contrib/nydusify/pkg/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ type Opt struct {
NydusifyVersion string
Source string

ChunkDict ChunkDictOpt
ImageVersion string
ChunkDict ChunkDictOpt
FsVersion string
}

type Converter struct {
Expand Down Expand Up @@ -118,8 +118,8 @@ type Converter struct {

storageBackend backend.Backend

chunkDict ChunkDictOpt
ImageVersion string
chunkDict ChunkDictOpt
FsVersion string
}

func imageRepository(ref string) (string, error) {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down
30 changes: 15 additions & 15 deletions contrib/nydusify/tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions contrib/nydusify/tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 7 additions & 7 deletions contrib/nydusify/tests/nydusify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand All @@ -73,7 +73,7 @@ func NewNydusify(registry *Registry, source, target, cache string, chunkDictArgs
backendType: backendType,
backendConfig: backendConfig,
chunkDictArgs: chunkDictArgs,
imageVersion: imageVersion,
fsVersion: fsVersion,
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 45769c3

Please sign in to comment.