bug-fix (#252)
This commit is contained in:
committed by
Robbie Zhang
parent
89921a08c1
commit
32f996ab60
@@ -3,7 +3,7 @@ package mock
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
@@ -60,11 +60,16 @@ func NewMockProvider(providerConfig, nodeName, operatingSystem string, internalI
|
|||||||
|
|
||||||
// loadConfig loads the given json configuration files.
|
// loadConfig loads the given json configuration files.
|
||||||
func loadConfig(providerConfig string) (config MockConfig, err error) {
|
func loadConfig(providerConfig string) (config MockConfig, err error) {
|
||||||
data, err := ioutil.ReadFile(providerConfig)
|
if providerConfig != "" {
|
||||||
if err != nil {
|
data, err := ioutil.ReadFile(providerConfig)
|
||||||
return config, err
|
if err != nil {
|
||||||
|
return config, err
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(data, &config)
|
||||||
|
if err != nil {
|
||||||
|
return config, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(data, &config)
|
|
||||||
if config.CPU == "" {
|
if config.CPU == "" {
|
||||||
config.CPU = defaultCPUCapacity
|
config.CPU = defaultCPUCapacity
|
||||||
}
|
}
|
||||||
@@ -72,7 +77,7 @@ func loadConfig(providerConfig string) (config MockConfig, err error) {
|
|||||||
config.Memory = defaultMemoryCapacity
|
config.Memory = defaultMemoryCapacity
|
||||||
}
|
}
|
||||||
if config.Pods == "" {
|
if config.Pods == "" {
|
||||||
config.Memory = defaultPodCapacity
|
config.Pods = defaultPodCapacity
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = resource.ParseQuantity(config.CPU); err != nil {
|
if _, err = resource.ParseQuantity(config.CPU); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user