forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.go
35 lines (28 loc) · 943 Bytes
/
manifest.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 manifest
import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-utils/system"
"gopkg.in/yaml.v2"
)
type Manifest struct {
Name string `yaml:"name"`
Templates map[string]string `yaml:"templates"`
Packages []string `yaml:"packages"`
Properties map[string]PropertyDefinition `yaml:"properties"`
}
type PropertyDefinition struct {
Description string `yaml:"description"`
Default interface{} `yaml:"default"`
}
func NewManifestFromPath(path string, fs boshsys.FileSystem) (Manifest, error) {
var manifest Manifest
bytes, err := fs.ReadFile(path)
if err != nil {
return manifest, bosherr.WrapErrorf(err, "Reading job spec '%s'", path)
}
err = yaml.Unmarshal(bytes, &manifest)
if err != nil {
return manifest, bosherr.WrapErrorf(err, "Unmarshalling job spec '%s'", path)
}
return manifest, nil
}