forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.go
54 lines (41 loc) · 978 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package director
import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshsys "github.com/cloudfoundry/bosh-utils/system"
"gopkg.in/yaml.v2"
)
/*
---
name: some-deployment
...
*/
type Manifest struct {
Name string
Releases []ManifestRelease
}
type ManifestRelease struct {
Name string
Version string
URL string
SHA1 string
}
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 manifest '%s'", path)
}
err = yaml.Unmarshal(bytes, &manifest)
if err != nil {
return manifest, bosherr.WrapError(err, "Unmarshalling manifest")
}
return manifest, nil
}
func NewManifestFromBytes(bytes []byte) (Manifest, error) {
var manifest Manifest
err := yaml.Unmarshal(bytes, &manifest)
if err != nil {
return manifest, bosherr.WrapError(err, "Unmarshalling manifest")
}
return manifest, nil
}