forked from cloudfoundry-attic/bosh-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment_manifest_parser.go
43 lines (36 loc) · 1.45 KB
/
deployment_manifest_parser.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
package cmd
import (
bideplmanifest "github.com/cloudfoundry/bosh-init/deployment/manifest"
birel "github.com/cloudfoundry/bosh-init/release"
birelsetmanifest "github.com/cloudfoundry/bosh-init/release/set/manifest"
biui "github.com/cloudfoundry/bosh-init/ui"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type DeploymentManifestParser struct {
DeploymentParser bideplmanifest.Parser
DeploymentValidator bideplmanifest.Validator
ReleaseManager birel.Manager
}
func (y DeploymentManifestParser) GetDeploymentManifest(deploymentManifestPath string, releaseSetManifest birelsetmanifest.Manifest, stage biui.Stage) (bideplmanifest.Manifest, error) {
var deploymentManifest bideplmanifest.Manifest
err := stage.Perform("Validating deployment manifest", func() error {
var err error
deploymentManifest, err = y.DeploymentParser.Parse(deploymentManifestPath)
if err != nil {
return bosherr.WrapErrorf(err, "Parsing deployment manifest '%s'", deploymentManifestPath)
}
err = y.DeploymentValidator.Validate(deploymentManifest, releaseSetManifest)
if err != nil {
return bosherr.WrapError(err, "Validating deployment manifest")
}
err = y.DeploymentValidator.ValidateReleaseJobs(deploymentManifest, y.ReleaseManager)
if err != nil {
return bosherr.WrapError(err, "Validating deployment jobs refer to jobs in release")
}
return nil
})
if err != nil {
return bideplmanifest.Manifest{}, err
}
return deploymentManifest, nil
}