@@ -15,7 +15,6 @@ package main
1515
1616import (
1717 "encoding/json"
18- "fmt"
1918 "io/ioutil"
2019 "os"
2120
@@ -38,24 +37,28 @@ const (
3837
3938// Config represents runtime configuration parameters
4039type 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"`
5250}
5351
5452// JailerConfig houses a set of configurable values for jailing
5553type JailerConfig struct {
5654 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"`
5962}
6063
6164// LoadConfig loads configuration from JSON file at 'path'
@@ -79,34 +82,15 @@ func LoadConfig(path string) (*Config, error) {
7982 RootDrive : defaultRootfsPath ,
8083 CPUCount : defaultCPUCount ,
8184 CPUTemplate : string (defaultCPUTemplate ),
85+ JailerConfig : JailerConfig {
86+ MinID : defaultMinIDCount ,
87+ MaxID : defaultMaxIDCount ,
88+ },
8289 }
90+
8391 if err := json .Unmarshal (data , cfg ); err != nil {
8492 return nil , errors .Wrapf (err , "failed to unmarshal config from %q" , path )
8593 }
8694
8795 return cfg , nil
8896}
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