-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfig.go
56 lines (49 loc) · 1.25 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package openstack
import (
"fmt"
"io"
"strings"
"github.com/BurntSushi/toml"
"github.com/virtual-kubelet/node-cli/provider"
)
type providerConfig struct {
Region string
OperatingSystem string
CPU string
Memory string
Pods string
}
func (p *ZunProvider) loadConfig(r io.Reader) error {
var config providerConfig
if _, err := toml.DecodeReader(r, &config); err != nil {
return err
}
p.region = config.Region
// Default to 20 mcpu
p.cpu = "20"
if config.CPU != "" {
p.cpu = config.CPU
}
// Default to 100Gi
p.memory = "100Gi"
if config.Memory != "" {
p.memory = config.Memory
}
// Default to 20 pods
p.pods = "20"
if config.Pods != "" {
p.pods = config.Pods
}
// Default to Linux if the operating system was not defined in the config.
if config.OperatingSystem == "" {
config.OperatingSystem = provider.OperatingSystemLinux
} else {
// Validate operating system from config.
ok, _ := provider.ValidOperatingSystems[config.OperatingSystem]
if !ok {
return fmt.Errorf("%q is not a valid operating system, try one of the following instead: %s", config.OperatingSystem, strings.Join(provider.ValidOperatingSystems.Names(), " | "))
}
}
p.operatingSystem = config.OperatingSystem
return nil
}