vagrant-bosh 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -6
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent-log +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent-run +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent.cert +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent.json +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent.key +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/bosh-agent +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/bosh-agent-rc +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/bosh-blobstore-dav +0 -0
- data/bosh-provisioner/assets/bosh-provisioner +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monit +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monit-log +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monit-run +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monitrc +0 -0
- data/dev/Vagrantfile +1 -1
- data/dev/example-bosh-manifest.yml +12 -12
- data/lib/vagrant-bosh/bootstrapper.rb +6 -2
- data/lib/vagrant-bosh/config.rb +1 -1
- data/lib/vagrant-bosh/provisioner.rb +1 -1
- data/lib/vagrant-bosh/version.rb +1 -1
- data/vagrant-bosh.gemspec +3 -1
- metadata +20 -139
- data/go/.gitignore +0 -11
- data/go/bin/build +0 -10
- data/go/bin/build-linux-amd64 +0 -9
- data/go/bin/env +0 -13
- data/go/bin/go +0 -5
- data/go/bin/golint +0 -19
- data/go/bin/test +0 -37
- data/go/src/boshprovisioner/agent/client/client_interface.go +0 -73
- data/go/src/boshprovisioner/agent/client/fakes/fake_client.go +0 -81
- data/go/src/boshprovisioner/agent/client/http_client.go +0 -299
- data/go/src/boshprovisioner/agent/client/http_client_envelope.go +0 -107
- data/go/src/boshprovisioner/deployment/deployment.go +0 -221
- data/go/src/boshprovisioner/deployment/instance.go +0 -54
- data/go/src/boshprovisioner/deployment/manifest/deployment.go +0 -84
- data/go/src/boshprovisioner/deployment/manifest/ips.go +0 -23
- data/go/src/boshprovisioner/deployment/manifest/manifest.go +0 -143
- data/go/src/boshprovisioner/deployment/manifest/manifest_suite_test.go +0 -13
- data/go/src/boshprovisioner/deployment/manifest/manifest_test.go +0 -86
- data/go/src/boshprovisioner/deployment/manifest/syntax_validator.go +0 -186
- data/go/src/boshprovisioner/deployment/manifest/watch_time.go +0 -43
- data/go/src/boshprovisioner/deployment/manifest_reader.go +0 -46
- data/go/src/boshprovisioner/deployment/reader_factory.go +0 -25
- data/go/src/boshprovisioner/deployment/semantic_validator.go +0 -111
- data/go/src/boshprovisioner/downloader/blobstore_downloader.go +0 -55
- data/go/src/boshprovisioner/downloader/default_mux_downloader.go +0 -22
- data/go/src/boshprovisioner/downloader/downloader_interface.go +0 -6
- data/go/src/boshprovisioner/downloader/http_downloader.go +0 -53
- data/go/src/boshprovisioner/downloader/local_fs_downloader.go +0 -48
- data/go/src/boshprovisioner/downloader/mux_downloader.go +0 -69
- data/go/src/boshprovisioner/eventlog/log.go +0 -72
- data/go/src/boshprovisioner/eventlog/stage.go +0 -39
- data/go/src/boshprovisioner/eventlog/task.go +0 -58
- data/go/src/boshprovisioner/index/file_index.go +0 -289
- data/go/src/boshprovisioner/index/file_index_test.go +0 -296
- data/go/src/boshprovisioner/index/index_interface.go +0 -18
- data/go/src/boshprovisioner/index/index_suite_test.go +0 -13
- data/go/src/boshprovisioner/instance/instance.go +0 -43
- data/go/src/boshprovisioner/instance/instance_provisioner.go +0 -48
- data/go/src/boshprovisioner/instance/templatescompiler/concrete_templates_compiler.go +0 -284
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/erb_renderer.go +0 -117
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/erbrenderer_suite_test.go +0 -13
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/render_properties.go +0 -77
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/render_properties_test.go +0 -193
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/template_evaluation_context.go +0 -85
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/template_evaluation_context_rb.go +0 -155
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/concrete_jobs_repository.go +0 -86
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/concrete_runtime_packages_repository.go +0 -113
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/concrete_template_to_job_repository.go +0 -86
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/jobs_repository_interface.go +0 -49
- data/go/src/boshprovisioner/instance/templatescompiler/rendered_archives_compiler.go +0 -81
- data/go/src/boshprovisioner/instance/templatescompiler/templates_compiler_interface.go +0 -20
- data/go/src/boshprovisioner/instance/templatescompiler/templatesrepo/ct_repository.go +0 -54
- data/go/src/boshprovisioner/instance/templatescompiler/templatesrepo/templates_repository_interface.go +0 -16
- data/go/src/boshprovisioner/instance/updater/applier/applier.go +0 -93
- data/go/src/boshprovisioner/instance/updater/applier/empty_state.go +0 -66
- data/go/src/boshprovisioner/instance/updater/applier/job_state.go +0 -178
- data/go/src/boshprovisioner/instance/updater/drainer.go +0 -72
- data/go/src/boshprovisioner/instance/updater/starter.go +0 -36
- data/go/src/boshprovisioner/instance/updater/stopper.go +0 -36
- data/go/src/boshprovisioner/instance/updater/updater.go +0 -97
- data/go/src/boshprovisioner/instance/updater/updater_factory.go +0 -80
- data/go/src/boshprovisioner/instance/updater/updater_suite_test.go +0 -13
- data/go/src/boshprovisioner/instance/updater/waiter.go +0 -77
- data/go/src/boshprovisioner/instance/updater/waiter_test.go +0 -147
- data/go/src/boshprovisioner/main/config.go +0 -95
- data/go/src/boshprovisioner/main/config_test.go +0 -67
- data/go/src/boshprovisioner/main/main.go +0 -185
- data/go/src/boshprovisioner/main/main_suite_test.go +0 -13
- data/go/src/boshprovisioner/main/repos_factory.go +0 -86
- data/go/src/boshprovisioner/packagescompiler/compiledpackagesrepo/compiled_packages_repository_interface.go +0 -17
- data/go/src/boshprovisioner/packagescompiler/compiledpackagesrepo/concrete_compiled_packages_repository.go +0 -61
- data/go/src/boshprovisioner/packagescompiler/concrete_packages_compiler.go +0 -179
- data/go/src/boshprovisioner/packagescompiler/concrete_packages_compiler_factory.go +0 -48
- data/go/src/boshprovisioner/packagescompiler/packages_compiler_interface.go +0 -20
- data/go/src/boshprovisioner/packagescompiler/packagesrepo/concrete_packages_repository.go +0 -65
- data/go/src/boshprovisioner/packagescompiler/packagesrepo/packages_repository_interface.go +0 -16
- data/go/src/boshprovisioner/provisioner/blobstore_config.go +0 -65
- data/go/src/boshprovisioner/provisioner/blobstore_provisioner.go +0 -38
- data/go/src/boshprovisioner/provisioner/deployment_provisioner_interface.go +0 -10
- data/go/src/boshprovisioner/provisioner/release_compiler.go +0 -95
- data/go/src/boshprovisioner/provisioner/single_configured_vm_provisioner.go +0 -124
- data/go/src/boshprovisioner/provisioner/single_non_configured_vm_provisioner.go +0 -40
- data/go/src/boshprovisioner/provisioner/single_vm_provisioner_factory.go +0 -68
- data/go/src/boshprovisioner/release/dir_reader.go +0 -146
- data/go/src/boshprovisioner/release/job/job.go +0 -86
- data/go/src/boshprovisioner/release/job/manifest/manifest.go +0 -79
- data/go/src/boshprovisioner/release/job/manifest/manifest_suite_test.go +0 -13
- data/go/src/boshprovisioner/release/job/manifest/manifest_test.go +0 -59
- data/go/src/boshprovisioner/release/job/manifest/syntax_validator.go +0 -43
- data/go/src/boshprovisioner/release/job/reader_factory.go +0 -34
- data/go/src/boshprovisioner/release/job/tar_reader.go +0 -133
- data/go/src/boshprovisioner/release/manifest/manifest.go +0 -120
- data/go/src/boshprovisioner/release/manifest/manifest_suite_test.go +0 -13
- data/go/src/boshprovisioner/release/manifest/manifest_test.go +0 -126
- data/go/src/boshprovisioner/release/manifest/syntax_validator.go +0 -134
- data/go/src/boshprovisioner/release/reader_factory.go +0 -45
- data/go/src/boshprovisioner/release/reader_interface.go +0 -6
- data/go/src/boshprovisioner/release/release.go +0 -144
- data/go/src/boshprovisioner/release/release_suite_test.go +0 -13
- data/go/src/boshprovisioner/release/release_test.go +0 -129
- data/go/src/boshprovisioner/release/tar_reader.go +0 -141
- data/go/src/boshprovisioner/tar/cmd_compressor.go +0 -68
- data/go/src/boshprovisioner/tar/cmd_extractor.go +0 -47
- data/go/src/boshprovisioner/tar/compressor_interface.go +0 -6
- data/go/src/boshprovisioner/tar/extractor_interface.go +0 -6
- data/go/src/boshprovisioner/util/possible_base64.go +0 -21
- data/go/src/boshprovisioner/util/string_keyed.go +0 -70
- data/go/src/boshprovisioner/vm/vagrant/agent_provisioner.go +0 -296
- data/go/src/boshprovisioner/vm/vagrant/asset_manager.go +0 -61
- data/go/src/boshprovisioner/vm/vagrant/configured_vm.go +0 -29
- data/go/src/boshprovisioner/vm/vagrant/deps_provisioner.go +0 -214
- data/go/src/boshprovisioner/vm/vagrant/monit_provisioner.go +0 -85
- data/go/src/boshprovisioner/vm/vagrant/non_configured_vm.go +0 -26
- data/go/src/boshprovisioner/vm/vagrant/runit_provisioner.go +0 -229
- data/go/src/boshprovisioner/vm/vagrant/simple_cmds.go +0 -54
- data/go/src/boshprovisioner/vm/vagrant/vcap_user_provisioner.go +0 -167
- data/go/src/boshprovisioner/vm/vagrant/vm_provisioner.go +0 -119
- data/go/src/boshprovisioner/vm/vagrant/vm_provisioner_factory.go +0 -101
- data/go/src/boshprovisioner/vm/vm_interface.go +0 -45
- data/lib/vagrant-bosh/assets/provisioner +0 -0
@@ -1,117 +0,0 @@
|
|
1
|
-
package erbrenderer
|
2
|
-
|
3
|
-
import (
|
4
|
-
"encoding/json"
|
5
|
-
"os"
|
6
|
-
"path/filepath"
|
7
|
-
|
8
|
-
bosherr "bosh/errors"
|
9
|
-
boshlog "bosh/logger"
|
10
|
-
boshsys "bosh/system"
|
11
|
-
)
|
12
|
-
|
13
|
-
const erbRendererLogTag = "ERBRenderer"
|
14
|
-
|
15
|
-
type ERBRenderer struct {
|
16
|
-
fs boshsys.FileSystem
|
17
|
-
runner boshsys.CmdRunner
|
18
|
-
context TemplateEvaluationContext
|
19
|
-
logger boshlog.Logger
|
20
|
-
|
21
|
-
rendererScript string
|
22
|
-
}
|
23
|
-
|
24
|
-
func NewERBRenderer(
|
25
|
-
fs boshsys.FileSystem,
|
26
|
-
runner boshsys.CmdRunner,
|
27
|
-
context TemplateEvaluationContext,
|
28
|
-
logger boshlog.Logger,
|
29
|
-
) ERBRenderer {
|
30
|
-
return ERBRenderer{
|
31
|
-
fs: fs,
|
32
|
-
runner: runner,
|
33
|
-
context: context,
|
34
|
-
logger: logger,
|
35
|
-
|
36
|
-
rendererScript: templateEvaluationContextRb,
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
func (r ERBRenderer) Render(srcPath, dstPath string) error {
|
41
|
-
r.logger.Debug(erbRendererLogTag, "Rendering template %s", dstPath)
|
42
|
-
|
43
|
-
dirPath := filepath.Dir(dstPath)
|
44
|
-
|
45
|
-
err := r.fs.MkdirAll(dirPath, os.FileMode(0755))
|
46
|
-
if err != nil {
|
47
|
-
return bosherr.WrapError(err, "Creating directory %s", dirPath)
|
48
|
-
}
|
49
|
-
|
50
|
-
rendererScriptPath, err := r.writeRendererScript()
|
51
|
-
if err != nil {
|
52
|
-
return err
|
53
|
-
}
|
54
|
-
|
55
|
-
contextPath, err := r.writeContext()
|
56
|
-
if err != nil {
|
57
|
-
return err
|
58
|
-
}
|
59
|
-
|
60
|
-
// Use ruby to compile job templates
|
61
|
-
command := boshsys.Command{
|
62
|
-
Name: r.determineRubyExePath(),
|
63
|
-
Args: []string{rendererScriptPath, contextPath, srcPath, dstPath},
|
64
|
-
}
|
65
|
-
|
66
|
-
_, _, _, err = r.runner.RunComplexCommand(command)
|
67
|
-
if err != nil {
|
68
|
-
return bosherr.WrapError(err, "Running ruby")
|
69
|
-
}
|
70
|
-
|
71
|
-
return nil
|
72
|
-
}
|
73
|
-
|
74
|
-
func (r ERBRenderer) writeRendererScript() (string, error) {
|
75
|
-
// todo use temp path; it's same everytime?
|
76
|
-
path := "/tmp/erb-render.rb"
|
77
|
-
|
78
|
-
err := r.fs.WriteFileString(path, r.rendererScript)
|
79
|
-
if err != nil {
|
80
|
-
return "", bosherr.WrapError(err, "Writing renderer script")
|
81
|
-
}
|
82
|
-
|
83
|
-
return path, nil
|
84
|
-
}
|
85
|
-
|
86
|
-
func (r ERBRenderer) writeContext() (string, error) {
|
87
|
-
contextBytes, err := json.Marshal(r.context)
|
88
|
-
if err != nil {
|
89
|
-
return "", bosherr.WrapError(err, "Marshalling context")
|
90
|
-
}
|
91
|
-
|
92
|
-
// todo use temp path?
|
93
|
-
path := "/tmp/erb-context.json"
|
94
|
-
|
95
|
-
err = r.fs.WriteFileString(path, string(contextBytes))
|
96
|
-
if err != nil {
|
97
|
-
return "", bosherr.WrapError(err, "Writing context")
|
98
|
-
}
|
99
|
-
|
100
|
-
return path, nil
|
101
|
-
}
|
102
|
-
|
103
|
-
func (r ERBRenderer) determineRubyExePath() string {
|
104
|
-
// Prefer ruby executable on the PATH
|
105
|
-
if r.runner.CommandExists("ruby") {
|
106
|
-
return "ruby"
|
107
|
-
}
|
108
|
-
|
109
|
-
// Fallback to chef-solo ruby usually found in vagrant boxes
|
110
|
-
vagrantRuby := "/opt/vagrant_ruby/bin/ruby"
|
111
|
-
|
112
|
-
if r.fs.FileExists(vagrantRuby) {
|
113
|
-
return vagrantRuby
|
114
|
-
}
|
115
|
-
|
116
|
-
return "ruby"
|
117
|
-
}
|
@@ -1,77 +0,0 @@
|
|
1
|
-
package erbrenderer
|
2
|
-
|
3
|
-
import (
|
4
|
-
"encoding/json"
|
5
|
-
"strings"
|
6
|
-
|
7
|
-
bosherr "bosh/errors"
|
8
|
-
|
9
|
-
bpdep "boshprovisioner/deployment"
|
10
|
-
bpreljob "boshprovisioner/release/job"
|
11
|
-
)
|
12
|
-
|
13
|
-
type RenderProperties struct {
|
14
|
-
relJob bpreljob.Job
|
15
|
-
instance bpdep.Instance
|
16
|
-
}
|
17
|
-
|
18
|
-
func NewRenderProperties(relJob bpreljob.Job, instance bpdep.Instance) RenderProperties {
|
19
|
-
return RenderProperties{relJob: relJob, instance: instance}
|
20
|
-
}
|
21
|
-
|
22
|
-
// AsMap returns job and instance properties merged together.
|
23
|
-
func (p RenderProperties) AsMap() (map[string]interface{}, error) {
|
24
|
-
result, err := p.deepCopyInstanceProperties()
|
25
|
-
if err != nil {
|
26
|
-
return result, err
|
27
|
-
}
|
28
|
-
|
29
|
-
for _, prop := range p.relJob.Properties {
|
30
|
-
p.copyProperty(prop.Name, prop.Default, result)
|
31
|
-
}
|
32
|
-
|
33
|
-
return result, nil
|
34
|
-
}
|
35
|
-
|
36
|
-
// copyProperty fills in property in dst with value if it's not already set.
|
37
|
-
func (p RenderProperties) copyProperty(path string, value interface{}, dst map[string]interface{}) {
|
38
|
-
pathParts := strings.Split(path, ".")
|
39
|
-
|
40
|
-
for i, part := range pathParts {
|
41
|
-
if dstNested, ok := dst[part]; ok { // Found section; check if modified
|
42
|
-
if dstNestedMap, ok := dstNested.(map[string]interface{}); ok {
|
43
|
-
dst = dstNestedMap
|
44
|
-
} else {
|
45
|
-
break // Not a section; cannot modify
|
46
|
-
}
|
47
|
-
} else if len(pathParts)-1 == i { // Last property path part
|
48
|
-
dst[part] = value
|
49
|
-
} else {
|
50
|
-
m := map[string]interface{}{}
|
51
|
-
dst[part] = m
|
52
|
-
dst = m
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
// deepCopyInstanceProperties makes a deep copy of instance properties.
|
58
|
-
// Always returns an initialized map even if instance properties are nil.
|
59
|
-
func (p RenderProperties) deepCopyInstanceProperties() (map[string]interface{}, error) {
|
60
|
-
result := map[string]interface{}{}
|
61
|
-
|
62
|
-
if p.instance.Properties == nil {
|
63
|
-
return result, nil
|
64
|
-
}
|
65
|
-
|
66
|
-
bytes, err := json.Marshal(p.instance.Properties)
|
67
|
-
if err != nil {
|
68
|
-
return result, bosherr.WrapError(err, "Marshalling instance properties")
|
69
|
-
}
|
70
|
-
|
71
|
-
err = json.Unmarshal(bytes, &result)
|
72
|
-
if err != nil {
|
73
|
-
return result, bosherr.WrapError(err, "Unmarshalling instance properties")
|
74
|
-
}
|
75
|
-
|
76
|
-
return result, nil
|
77
|
-
}
|
data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/render_properties_test.go
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
package erbrenderer_test
|
2
|
-
|
3
|
-
import (
|
4
|
-
. "github.com/onsi/ginkgo"
|
5
|
-
. "github.com/onsi/gomega"
|
6
|
-
|
7
|
-
bpdep "boshprovisioner/deployment"
|
8
|
-
. "boshprovisioner/instance/templatescompiler/erbrenderer"
|
9
|
-
bpreljob "boshprovisioner/release/job"
|
10
|
-
)
|
11
|
-
|
12
|
-
var _ = Describe("RenderProperties", func() {
|
13
|
-
var (
|
14
|
-
job bpreljob.Job
|
15
|
-
instance bpdep.Instance
|
16
|
-
props RenderProperties
|
17
|
-
)
|
18
|
-
|
19
|
-
JustBeforeEach(func() {
|
20
|
-
props = NewRenderProperties(job, instance)
|
21
|
-
})
|
22
|
-
|
23
|
-
Describe("AsMap", func() {
|
24
|
-
Context("when job specifies a default for a nested property", func() {
|
25
|
-
BeforeEach(func() {
|
26
|
-
job = bpreljob.Job{
|
27
|
-
Properties: []bpreljob.Property{
|
28
|
-
bpreljob.Property{
|
29
|
-
Name: "prop.nest-prop",
|
30
|
-
Default: "job-val",
|
31
|
-
},
|
32
|
-
},
|
33
|
-
}
|
34
|
-
})
|
35
|
-
|
36
|
-
Context("when instance specifies nested property", func() {
|
37
|
-
BeforeEach(func() {
|
38
|
-
instance = bpdep.Instance{
|
39
|
-
Properties: map[string]interface{}{
|
40
|
-
"prop": map[string]interface{}{
|
41
|
-
"nest-prop": "instance-val",
|
42
|
-
},
|
43
|
-
},
|
44
|
-
}
|
45
|
-
})
|
46
|
-
|
47
|
-
It("returns map with property value from job", func() {
|
48
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
49
|
-
"prop": map[string]interface{}{
|
50
|
-
"nest-prop": "instance-val",
|
51
|
-
},
|
52
|
-
}))
|
53
|
-
})
|
54
|
-
})
|
55
|
-
|
56
|
-
Context("when instance does not specify nested property", func() {
|
57
|
-
Context("when first nesting level is specified", func() {
|
58
|
-
BeforeEach(func() {
|
59
|
-
instance = bpdep.Instance{
|
60
|
-
Properties: map[string]interface{}{
|
61
|
-
"prop": map[string]interface{}{},
|
62
|
-
},
|
63
|
-
}
|
64
|
-
})
|
65
|
-
|
66
|
-
It("returns map with default property from job", func() {
|
67
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
68
|
-
"prop": map[string]interface{}{
|
69
|
-
"nest-prop": "job-val",
|
70
|
-
},
|
71
|
-
}))
|
72
|
-
})
|
73
|
-
})
|
74
|
-
|
75
|
-
Context("when first nesting level is not specified", func() {
|
76
|
-
BeforeEach(func() {
|
77
|
-
instance = bpdep.Instance{}
|
78
|
-
})
|
79
|
-
|
80
|
-
It("returns map with default property from job", func() {
|
81
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
82
|
-
"prop": map[string]interface{}{
|
83
|
-
"nest-prop": "job-val",
|
84
|
-
},
|
85
|
-
}))
|
86
|
-
})
|
87
|
-
})
|
88
|
-
})
|
89
|
-
})
|
90
|
-
|
91
|
-
Context("when job specifies an empty string default for a nested property", func() {
|
92
|
-
BeforeEach(func() {
|
93
|
-
job = bpreljob.Job{
|
94
|
-
Properties: []bpreljob.Property{
|
95
|
-
bpreljob.Property{
|
96
|
-
Name: "prop.nest-prop",
|
97
|
-
Default: "",
|
98
|
-
},
|
99
|
-
},
|
100
|
-
}
|
101
|
-
})
|
102
|
-
|
103
|
-
Context("when instance specifies nested property", func() {
|
104
|
-
BeforeEach(func() {
|
105
|
-
instance = bpdep.Instance{
|
106
|
-
Properties: map[string]interface{}{
|
107
|
-
"prop": map[string]interface{}{
|
108
|
-
"nest-prop": "instance-val",
|
109
|
-
},
|
110
|
-
},
|
111
|
-
}
|
112
|
-
})
|
113
|
-
|
114
|
-
It("returns map with property value from instance", func() {
|
115
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
116
|
-
"prop": map[string]interface{}{
|
117
|
-
"nest-prop": "instance-val",
|
118
|
-
},
|
119
|
-
}))
|
120
|
-
})
|
121
|
-
})
|
122
|
-
|
123
|
-
Context("when instance does not specify nested property", func() {
|
124
|
-
BeforeEach(func() {
|
125
|
-
instance = bpdep.Instance{
|
126
|
-
Properties: map[string]interface{}{
|
127
|
-
"prop": map[string]interface{}{},
|
128
|
-
},
|
129
|
-
}
|
130
|
-
})
|
131
|
-
|
132
|
-
It("returns map with default property from job", func() {
|
133
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
134
|
-
"prop": map[string]interface{}{
|
135
|
-
"nest-prop": "",
|
136
|
-
},
|
137
|
-
}))
|
138
|
-
})
|
139
|
-
})
|
140
|
-
})
|
141
|
-
|
142
|
-
Context("when job does not specify a default (nil) for a nested property", func() {
|
143
|
-
BeforeEach(func() {
|
144
|
-
job = bpreljob.Job{
|
145
|
-
Properties: []bpreljob.Property{
|
146
|
-
bpreljob.Property{
|
147
|
-
Name: "prop.nest-prop",
|
148
|
-
Default: nil,
|
149
|
-
},
|
150
|
-
},
|
151
|
-
}
|
152
|
-
})
|
153
|
-
|
154
|
-
Context("when instance specifies nested property", func() {
|
155
|
-
BeforeEach(func() {
|
156
|
-
instance = bpdep.Instance{
|
157
|
-
Properties: map[string]interface{}{
|
158
|
-
"prop": map[string]interface{}{
|
159
|
-
"nest-prop": "instance-val",
|
160
|
-
},
|
161
|
-
},
|
162
|
-
}
|
163
|
-
})
|
164
|
-
|
165
|
-
It("returns map with property value from instance", func() {
|
166
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
167
|
-
"prop": map[string]interface{}{
|
168
|
-
"nest-prop": "instance-val",
|
169
|
-
},
|
170
|
-
}))
|
171
|
-
})
|
172
|
-
})
|
173
|
-
|
174
|
-
Context("when instance does not specify nested property", func() {
|
175
|
-
BeforeEach(func() {
|
176
|
-
instance = bpdep.Instance{
|
177
|
-
Properties: map[string]interface{}{
|
178
|
-
"prop": map[string]interface{}{},
|
179
|
-
},
|
180
|
-
}
|
181
|
-
})
|
182
|
-
|
183
|
-
It("returns map with default property from job", func() {
|
184
|
-
Expect(props.AsMap()).To(Equal(map[string]interface{}{
|
185
|
-
"prop": map[string]interface{}{
|
186
|
-
"nest-prop": nil,
|
187
|
-
},
|
188
|
-
}))
|
189
|
-
})
|
190
|
-
})
|
191
|
-
}) //~
|
192
|
-
})
|
193
|
-
})
|
data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/template_evaluation_context.go
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
package erbrenderer
|
2
|
-
|
3
|
-
import (
|
4
|
-
"encoding/json"
|
5
|
-
|
6
|
-
bosherr "bosh/errors"
|
7
|
-
|
8
|
-
bpdep "boshprovisioner/deployment"
|
9
|
-
bpreljob "boshprovisioner/release/job"
|
10
|
-
)
|
11
|
-
|
12
|
-
type TemplateEvaluationContext struct {
|
13
|
-
relJob bpreljob.Job
|
14
|
-
instance bpdep.Instance
|
15
|
-
}
|
16
|
-
|
17
|
-
// rootContext is exposed as an open struct in ERB templates.
|
18
|
-
// It must stay same to provide backwards compatible API.
|
19
|
-
type rootContext struct {
|
20
|
-
Index int `json:"index"`
|
21
|
-
|
22
|
-
JobContext jobContext `json:"job"`
|
23
|
-
|
24
|
-
Deployment string `json:"deployment"`
|
25
|
-
|
26
|
-
// Usually is accessed with <%= spec.networks.default.ip %>
|
27
|
-
NetworkContexts map[string]networkContext `json:"networks"`
|
28
|
-
|
29
|
-
Properties map[string]interface{} `json:"properties"`
|
30
|
-
}
|
31
|
-
|
32
|
-
type jobContext struct {
|
33
|
-
Name string `json:"name"`
|
34
|
-
}
|
35
|
-
|
36
|
-
// networkContext is not fully backwards compatible.
|
37
|
-
type networkContext struct {
|
38
|
-
IP string `json:"ip"`
|
39
|
-
Netmask string `json:"netmask"`
|
40
|
-
Gateway string `json:"gateway"`
|
41
|
-
}
|
42
|
-
|
43
|
-
func NewTemplateEvaluationContext(
|
44
|
-
relJob bpreljob.Job,
|
45
|
-
instance bpdep.Instance,
|
46
|
-
) TemplateEvaluationContext {
|
47
|
-
return TemplateEvaluationContext{
|
48
|
-
relJob: relJob,
|
49
|
-
instance: instance,
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
func (c TemplateEvaluationContext) MarshalJSON() ([]byte, error) {
|
54
|
-
properties, err := NewRenderProperties(c.relJob, c.instance).AsMap()
|
55
|
-
if err != nil {
|
56
|
-
return nil, bosherr.WrapError(err, "Rendering properties")
|
57
|
-
}
|
58
|
-
|
59
|
-
context := rootContext{
|
60
|
-
Index: c.instance.Index,
|
61
|
-
JobContext: jobContext{Name: c.instance.JobName},
|
62
|
-
Deployment: c.instance.DeploymentName,
|
63
|
-
|
64
|
-
NetworkContexts: c.buildNetworkContexts(),
|
65
|
-
Properties: properties,
|
66
|
-
}
|
67
|
-
|
68
|
-
return json.Marshal(context)
|
69
|
-
}
|
70
|
-
|
71
|
-
func (c TemplateEvaluationContext) buildNetworkContexts() map[string]networkContext {
|
72
|
-
networkContexts := map[string]networkContext{}
|
73
|
-
|
74
|
-
for _, na := range c.instance.NetworkAssociations {
|
75
|
-
netConfig := c.instance.NetworkConfigurationForNetworkAssociation(na)
|
76
|
-
|
77
|
-
networkContexts[na.Network.Name] = networkContext{
|
78
|
-
IP: netConfig.IP,
|
79
|
-
Netmask: netConfig.Netmask,
|
80
|
-
Gateway: netConfig.Gateway,
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
return networkContexts
|
85
|
-
}
|