Skip to content

Commit f47425d

Browse files
authored
Merge pull request #137 from q384566678/value-test
cmd: Modify the assignment of parameters
2 parents c091118 + 606d521 commit f47425d

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

cmd/oci-image-tool/create.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@ func createHandle(context *cli.Context) error {
3939
return fmt.Errorf("both src and dest must be provided")
4040
}
4141

42-
var v bundleCmd
43-
if context.IsSet("type") {
44-
v.typ = context.String("type")
45-
}
46-
if context.IsSet("ref") {
47-
v.ref = context.String("ref")
48-
}
49-
if context.IsSet("rootfs") {
50-
v.root = context.String("rootfs")
51-
} else {
52-
v.root = "rootfs"
42+
v := bundleCmd{
43+
typ: context.String("type"),
44+
ref: context.String("ref"),
45+
root: context.String("rootfs"),
5346
}
5447

5548
if v.typ == "" {

cmd/oci-image-tool/unpack.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ func unpackHandle(context *cli.Context) error {
3838
return fmt.Errorf("both src and dest must be provided")
3939
}
4040

41-
var v unpackCmd
42-
if context.IsSet("type") {
43-
v.typ = context.String("type")
44-
}
45-
if context.IsSet("ref") {
46-
v.ref = context.String("ref")
41+
v := unpackCmd{
42+
typ: context.String("type"),
43+
ref: context.String("ref"),
4744
}
4845

4946
if v.typ == "" {

cmd/oci-image-tool/validate.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,9 @@ func validateHandler(context *cli.Context) error {
4848
return fmt.Errorf("no files specified")
4949
}
5050

51-
if context.IsSet("type") {
52-
v.typ = context.String("type")
53-
}
54-
55-
if context.IsSet("ref") {
56-
v.refs = context.StringSlice("ref")
51+
v = validateCmd{
52+
typ: context.String("type"),
53+
refs: context.StringSlice("ref"),
5754
}
5855

5956
var errs []string

0 commit comments

Comments
 (0)