Skip to content

Commit 81d12ed

Browse files
author
Mrunal Patel
authored
Merge pull request #234 from Mashimiao/fix-make-config-path-const
fix: make config path as const
2 parents 667045d + 5d50eaf commit 81d12ed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

cmd/oci-runtime-tool/validate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/urfave/cli"
2020
)
2121

22+
const specConfig = "config.json"
23+
2224
type configCheck func(rspec.Spec, string, bool) []string
2325

2426
var bundleValidateFlags = []cli.Flag{
@@ -77,7 +79,7 @@ var bundleValidateCommand = cli.Command{
7779
return err
7880
}
7981

80-
configPath := filepath.Join(inputPath, "config.json")
82+
configPath := filepath.Join(inputPath, specConfig)
8183
content, err := ioutil.ReadFile(configPath)
8284
if err != nil {
8385
return err

cmd/runtimetest/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
// the kernel
2525
const PR_GET_NO_NEW_PRIVS = 39
2626

27+
const specConfig = "config.json"
28+
2729
var (
2830
defaultFS = map[string]string{
2931
"/proc": "proc",
@@ -47,11 +49,10 @@ var (
4749
type validation func(*rspec.Spec) error
4850

4951
func loadSpecConfig() (spec *rspec.Spec, err error) {
50-
cPath := "config.json"
51-
cf, err := os.Open(cPath)
52+
cf, err := os.Open(specConfig)
5253
if err != nil {
5354
if os.IsNotExist(err) {
54-
return nil, fmt.Errorf("config.json not found")
55+
return nil, fmt.Errorf("%s not found", specConfig)
5556
}
5657
}
5758
defer cf.Close()

0 commit comments

Comments
 (0)