forked from AbelHu/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
35 lines (27 loc) · 766 Bytes
/
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
package app
import (
"encoding/json"
bosherr "github.com/cloudfoundry/bosh-agent/errors"
boshinf "github.com/cloudfoundry/bosh-agent/infrastructure"
boshplatform "github.com/cloudfoundry/bosh-agent/platform"
boshsys "github.com/cloudfoundry/bosh-agent/system"
)
type Config struct {
Platform boshplatform.ProviderOptions
Infrastructure boshinf.ProviderOptions
}
func LoadConfigFromPath(fs boshsys.FileSystem, path string) (Config, error) {
var config Config
if path == "" {
return config, nil
}
bytes, err := fs.ReadFile(path)
if err != nil {
return config, bosherr.WrapError(err, "Reading file")
}
err = json.Unmarshal(bytes, &config)
if err != nil {
return config, bosherr.WrapError(err, "Loading file")
}
return config, nil
}