@@ -15,7 +15,6 @@ package main
15
15
16
16
import (
17
17
"encoding/json"
18
- "fmt"
19
18
"io/ioutil"
20
19
"os"
21
20
@@ -38,24 +37,28 @@ const (
38
37
39
38
// Config represents runtime configuration parameters
40
39
type Config struct {
41
- FirecrackerBinaryPath string `json:"firecracker_binary_path"`
42
- KernelImagePath string `json:"kernel_image_path"`
43
- KernelArgs string `json:"kernel_args"`
44
- RootDrive string `json:"root_drive"`
45
- CPUCount int `json:"cpu_count"`
46
- CPUTemplate string `json:"cpu_template"`
47
- LogLevel string `json:"log_level"`
48
- HtEnabled bool `json:"ht_enabled"`
49
- Debug bool `json:"debug"`
50
-
51
- JailerConfig JailerConfig `json:"jailer"`
40
+ FirecrackerBinaryPath string `json:"firecracker_binary_path"`
41
+ KernelImagePath string `json:"kernel_image_path"`
42
+ KernelArgs string `json:"kernel_args"`
43
+ RootDrive string `json:"root_drive"`
44
+ CPUCount int `json:"cpu_count"`
45
+ CPUTemplate string `json:"cpu_template"`
46
+ LogLevel string `json:"log_level"`
47
+ HtEnabled bool `json:"ht_enabled"`
48
+ Debug bool `json:"debug"`
49
+ JailerConfig JailerConfig `json:"jailer"`
52
50
}
53
51
54
52
// JailerConfig houses a set of configurable values for jailing
55
53
type JailerConfig struct {
56
54
DisableJailing bool `json:"disable_jailing"`
57
- UID * int `json:"uid"`
58
- GID * int `json:"gid"`
55
+ // MinID represents the minimum value for the UID and GID when finding those
56
+ // values.
57
+ MinID uint32 `json:"min_id"`
58
+ // MaxID represents the maximum value for the UID and GID when finding those
59
+ // values
60
+ MaxID uint32 `json:"max_id"`
61
+ RuncBinaryPath string `json:"runc_binary_path"`
59
62
}
60
63
61
64
// LoadConfig loads configuration from JSON file at 'path'
@@ -79,34 +82,15 @@ func LoadConfig(path string) (*Config, error) {
79
82
RootDrive : defaultRootfsPath ,
80
83
CPUCount : defaultCPUCount ,
81
84
CPUTemplate : string (defaultCPUTemplate ),
85
+ JailerConfig : JailerConfig {
86
+ MinID : defaultMinIDCount ,
87
+ MaxID : defaultMaxIDCount ,
88
+ },
82
89
}
90
+
83
91
if err := json .Unmarshal (data , cfg ); err != nil {
84
92
return nil , errors .Wrapf (err , "failed to unmarshal config from %q" , path )
85
93
}
86
94
87
95
return cfg , nil
88
96
}
89
-
90
- var (
91
- // ErrNoUIDProvided returns when no UID was specified in the configuration
92
- // file
93
- ErrNoUIDProvided = fmt .Errorf ("no uid provided in configuration" )
94
- // ErrNoGIDProvided returns when no GID was specified in the configuration
95
- // filme
96
- ErrNoGIDProvided = fmt .Errorf ("no gid provided in configuration" )
97
- )
98
-
99
- // Validate ensures that the configuration file has valid values
100
- func (c * Config ) Validate () error {
101
- if ! c .JailerConfig .DisableJailing {
102
- if c .JailerConfig .UID == nil {
103
- return ErrNoUIDProvided
104
- }
105
-
106
- if c .JailerConfig .GID == nil {
107
- return ErrNoGIDProvided
108
- }
109
- }
110
-
111
- return nil
112
- }
0 commit comments