diff --git a/cmd/oci-runtime-tool/main.go b/cmd/oci-runtime-tool/main.go index a164ad034..600d540da 100644 --- a/cmd/oci-runtime-tool/main.go +++ b/cmd/oci-runtime-tool/main.go @@ -22,11 +22,6 @@ func main() { Value: "error", Usage: "Log level (panic, fatal, error, warn, info, or debug)", }, - cli.StringFlag{ - Name: "platform", - Value: "linux", - Usage: "Platform the tool targets", - }, } app.Commands = []cli.Command{ diff --git a/cmd/oci-runtime-tool/validate.go b/cmd/oci-runtime-tool/validate.go index bdf4d5eb2..9e08f4525 100644 --- a/cmd/oci-runtime-tool/validate.go +++ b/cmd/oci-runtime-tool/validate.go @@ -10,6 +10,7 @@ import ( var bundleValidateFlags = []cli.Flag{ cli.StringFlag{Name: "path", Value: ".", Usage: "path to a bundle"}, + cli.StringFlag{Name: "platform", Value: "linux", Usage: "platform of the target bundle (linux, windows, solaris)"}, } var bundleValidateCommand = cli.Command{ @@ -18,9 +19,9 @@ var bundleValidateCommand = cli.Command{ Flags: bundleValidateFlags, Before: before, Action: func(context *cli.Context) error { - inputPath := context.String("path") hostSpecific := context.GlobalBool("host-specific") - platform := context.GlobalString("platform") + inputPath := context.String("path") + platform := context.String("platform") v, err := validate.NewValidatorFromPath(inputPath, hostSpecific, platform) if err != nil { return err diff --git a/man/oci-runtime-tool-validate.1.md b/man/oci-runtime-tool-validate.1.md index d9b02175e..fba012026 100644 --- a/man/oci-runtime-tool-validate.1.md +++ b/man/oci-runtime-tool-validate.1.md @@ -18,6 +18,10 @@ Validate an OCI bundle **--path**=PATH Path to bundle. The default is current working directory. +**--platform**=PLATFORM + Platform of the target bundle. (linux, windows, solaris) (default: "linux") + It will be overwritten by the host platform if the global option '--host-specific' was set. + # SEE ALSO **oci-runtime-tool**(1) diff --git a/man/oci-runtime-tool.1.md b/man/oci-runtime-tool.1.md index 47795300c..27b2e1708 100644 --- a/man/oci-runtime-tool.1.md +++ b/man/oci-runtime-tool.1.md @@ -32,9 +32,6 @@ oci-runtime-tool is a collection of tools for working with the [OCI runtime spec **--log-level**=LEVEL Log level (panic, fatal, error, warn, info, or debug) (default: "error"). -**--platform** - Platform the tool targets. - **-v**, **--version** Print version information. diff --git a/validate/validate.go b/validate/validate.go index 94d4f9519..de6e4603d 100644 --- a/validate/validate.go +++ b/validate/validate.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "reflect" + "runtime" "strings" "unicode" "unicode/utf8" @@ -52,6 +53,9 @@ type Validator struct { // NewValidator creates a Validator func NewValidator(spec *rspec.Spec, bundlePath string, hostSpecific bool, platform string) Validator { + if hostSpecific && platform != runtime.GOOS { + platform = runtime.GOOS + } return Validator{ spec: spec, bundlePath: bundlePath, @@ -62,6 +66,9 @@ func NewValidator(spec *rspec.Spec, bundlePath string, hostSpecific bool, platfo // NewValidatorFromPath creates a Validator with specified bundle path func NewValidatorFromPath(bundlePath string, hostSpecific bool, platform string) (Validator, error) { + if hostSpecific && platform != runtime.GOOS { + platform = runtime.GOOS + } if bundlePath == "" { return Validator{}, fmt.Errorf("Bundle path shouldn't be empty") }