Skip to content

Commit 2c7faf8

Browse files
author
Ma Shimiao
authored
Merge pull request #388 from q384566678/runtimetest-path
runtimetest: add path option
2 parents bbf9886 + ae84553 commit 2c7faf8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cmd/runtimetest/main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ type validation struct {
5252
description string
5353
}
5454

55-
func loadSpecConfig() (spec *rspec.Spec, err error) {
56-
cf, err := os.Open(specConfig)
55+
func loadSpecConfig(path string) (spec *rspec.Spec, err error) {
56+
configPath := filepath.Join(path, specConfig)
57+
cf, err := os.Open(configPath)
5758
if err != nil {
5859
if os.IsNotExist(err) {
5960
return nil, fmt.Errorf("%s not found", specConfig)
@@ -602,7 +603,8 @@ func validate(context *cli.Context) error {
602603
}
603604
logrus.SetLevel(logLevel)
604605

605-
spec, err := loadSpecConfig()
606+
inputPath := context.String("path")
607+
spec, err := loadSpecConfig(inputPath)
606608
if err != nil {
607609
return err
608610
}
@@ -705,13 +707,17 @@ func main() {
705707
app.Version = "0.0.1"
706708
app.Usage = "Compare the environment with an OCI configuration"
707709
app.Description = "runtimetest compares its current environment with an OCI runtime configuration read from config.json in its current working directory. The tests are fairly generic and cover most configurations used by the runtime validation suite, but there are corner cases where a container launched by a valid runtime would not satisfy runtimetest."
708-
app.UsageText = "runtimetest [options]"
709710
app.Flags = []cli.Flag{
710711
cli.StringFlag{
711712
Name: "log-level",
712713
Value: "error",
713714
Usage: "Log level (panic, fatal, error, warn, info, or debug)",
714715
},
716+
cli.StringFlag{
717+
Name: "path",
718+
Value: ".",
719+
Usage: "path to the configuration",
720+
},
715721
}
716722

717723
app.Action = validate

0 commit comments

Comments
 (0)