Skip to content

Commit d4a4f02

Browse files
committed
overwrite the 'platform' value when 'host-specific' was set
Signed-off-by: liangchenye <liangchenye@huawei.com>
1 parent 2f4cbd9 commit d4a4f02

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

man/oci-runtime-tool.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ oci-runtime-tool is a collection of tools for working with the [OCI runtime spec
3333
Log level (panic, fatal, error, warn, info, or debug) (default: "error").
3434

3535
**--platform**
36-
Platform the tool targets.
36+
Platform the tool targets. It will be overwritten by the host platform if '--host-specific' was set.
3737

3838
**-v**, **--version**
3939
Print version information.

validate/validate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"path/filepath"
1111
"reflect"
12+
"runtime"
1213
"strings"
1314
"unicode"
1415
"unicode/utf8"
@@ -52,6 +53,9 @@ type Validator struct {
5253

5354
// NewValidator creates a Validator
5455
func NewValidator(spec *rspec.Spec, bundlePath string, hostSpecific bool, platform string) Validator {
56+
if hostSpecific && platform != runtime.GOOS {
57+
platform = runtime.GOOS
58+
}
5559
return Validator{
5660
spec: spec,
5761
bundlePath: bundlePath,
@@ -62,6 +66,9 @@ func NewValidator(spec *rspec.Spec, bundlePath string, hostSpecific bool, platfo
6266

6367
// NewValidatorFromPath creates a Validator with specified bundle path
6468
func NewValidatorFromPath(bundlePath string, hostSpecific bool, platform string) (Validator, error) {
69+
if hostSpecific && platform != runtime.GOOS {
70+
platform = runtime.GOOS
71+
}
6572
if bundlePath == "" {
6673
return Validator{}, fmt.Errorf("Bundle path shouldn't be empty")
6774
}

0 commit comments

Comments
 (0)