bosh-director-core 1.3215.4.0 → 1.3232.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 565b5125d4c1c6a2f3c86213f28979c7270412da
4
- data.tar.gz: 158a463e928c8b226edd5bb79cb7e53b11917891
3
+ metadata.gz: 1996df7fb224c82448f175a7b9d9b859d2081278
4
+ data.tar.gz: 795f351ee1b4758e994f044eb5de6adeb693fa07
5
5
  SHA512:
6
- metadata.gz: a5186af8d2981d2058224c7486e88c7f8daca3bf4b14fa591a3d754e034f93bffc1096c0c5700c0ce223dfd49e155eacdb7884db51510ad2faf57cd099120536
7
- data.tar.gz: 63ef899969cdbe4f7f52c03d5ccb07f4926b51f065fa2c51e07dc46c769ae2fbc3f5bf20dd2d3d144053c75e6def3876ba6e6edcbade164b55c1828b30d11060
6
+ metadata.gz: c958b8c45dd45848042c7a43f4f58a1f581a33fba9ad43a527e8f9eca88b0dccb610e352630f36dc6207d0ba97c16fb447c60d99734d16d5b06fcd9e221f9ee7
7
+ data.tar.gz: 41c34f916330350978f039691d7984258cbde2da5f9db066e7861c3ef6952c88ef35bea8b50a207a41dd09a4ed2e29a73d3f490aae6f19396aafe3bdc90247d1
@@ -11,6 +11,7 @@ module Bosh::Director::Core
11
11
  def compress(base_dir, sources, dest, options = {})
12
12
  sources = [*sources]
13
13
  sources.each do |source|
14
+ source = source.gsub(%r(^\./), '')
14
15
  if source.include?(File::SEPARATOR)
15
16
  raise "Sources must have a path depth of 1 and contain no '#{File::SEPARATOR}'"
16
17
  end
@@ -17,12 +17,14 @@ module Bosh::Director::Core::Templates
17
17
 
18
18
  source_erbs = []
19
19
 
20
+ template_name = manifest.fetch('name', {})
21
+
20
22
  manifest.fetch('templates', {}).each_pair do |src_name, dest_name|
21
23
  erb_file = File.read(File.join(template_dir, 'templates', src_name))
22
24
  source_erbs << SourceErb.new(src_name, dest_name, erb_file, job_template.name)
23
25
  end
24
26
 
25
- JobTemplateRenderer.new(job_template.name, monit_source_erb, source_erbs, @logger)
27
+ JobTemplateRenderer.new(job_template.name, template_name, monit_source_erb, source_erbs, @logger)
26
28
  ensure
27
29
  FileUtils.rm_rf(template_dir) if template_dir
28
30
  end
@@ -36,7 +38,7 @@ module Bosh::Director::Core::Templates
36
38
  output = `tar -C #{template_dir} -xzf #{temp_path} 2>&1`
37
39
  if $?.exitstatus != 0
38
40
  raise JobTemplateUnpackFailed,
39
- "Cannot unpack `#{job_template.name}' job template, " +
41
+ "Cannot unpack '#{job_template.name}' job template, " +
40
42
  "tar returned #{$?.exitstatus}, " +
41
43
  "tar output: #{output}"
42
44
  end
@@ -8,21 +8,27 @@ module Bosh::Director::Core::Templates
8
8
  class JobTemplateRenderer
9
9
  attr_reader :monit_erb, :source_erbs
10
10
 
11
- def initialize(name, monit_erb, source_erbs, logger)
11
+ def initialize(name, template_name, monit_erb, source_erbs, logger)
12
12
  @name = name
13
+ @template_name = template_name
13
14
  @monit_erb = monit_erb
14
15
  @source_erbs = source_erbs
15
16
  @logger = logger
16
17
  end
17
18
 
18
19
  def render(spec)
19
- template_context = Bosh::Template::EvaluationContext.new(adjust_template_properties(spec,@name))
20
+ if spec['properties_need_filtering']
21
+ spec = remove_unused_properties(spec)
22
+ end
20
23
 
24
+ template_context = Bosh::Template::EvaluationContext.new(Bosh::Common::DeepCopy.copy(spec))
21
25
  monit = monit_erb.render(template_context, @logger)
22
26
 
23
27
  errors = []
24
28
 
25
29
  rendered_files = source_erbs.map do |source_erb|
30
+ template_context = Bosh::Template::EvaluationContext.new(Bosh::Common::DeepCopy.copy(spec))
31
+
26
32
  begin
27
33
  file_contents = source_erb.render(template_context, @logger)
28
34
  rescue Exception => e
@@ -47,29 +53,22 @@ module Bosh::Director::Core::Templates
47
53
 
48
54
  private
49
55
 
50
- # This method will check if the current template has any properties that were
51
- # defined at the template level in the deployment manifest; if yes, it will make
52
- # a deep copy of the spec and change the spec.properties to <current-template>.template_scoped_properties.
53
- # This is due to the requirement that limits the available properties for a template
54
- # by the properties defined in the template scope in the deployment manifest, if they exist.
55
- # We make a deep copy of the spec to be safe, as we are modifying it.
56
- def adjust_template_properties(spec, current_template_name)
57
- result = spec
58
- if spec['job'].is_a?(Hash) && !spec['job']['templates'].nil?
59
- current_template = spec['job']['templates'].find {|template| template['name'] == current_template_name }
60
-
61
- if !current_template['template_scoped_properties'].nil?
62
- # Make a deep copy of the spec and replace the properties with
63
- # the specific template properties.
64
- altered_spec = Bosh::Common::DeepCopy.copy(spec)
65
- altered_spec['properties'] = Bosh::Common::DeepCopy.copy(
66
- current_template['template_scoped_properties']
67
- )
68
- result = altered_spec
56
+ def remove_unused_properties(spec)
57
+ if spec.nil?
58
+ return nil
59
+ end
60
+
61
+ modified_spec = Bosh::Common::DeepCopy.copy(spec)
62
+
63
+ if modified_spec.has_key?('properties')
64
+ if modified_spec['properties'][@template_name]
65
+ properties_template = modified_spec['properties'][@template_name]
66
+ modified_spec['properties'] = properties_template
69
67
  end
70
68
  end
71
- result
69
+
70
+ modified_spec
72
71
  end
73
72
 
74
73
  end
75
- end
74
+ end
@@ -1,7 +1,7 @@
1
1
  module Bosh
2
2
  module Director
3
3
  module Core
4
- VERSION = '1.3215.4.0'
4
+ VERSION = '1.3232.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3215.4.0
4
+ version: 1.3232.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-14 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3215.4.0
19
+ version: 1.3232.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3215.4.0
26
+ version: 1.3232.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh-template
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3215.4.0
33
+ version: 1.3232.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3215.4.0
40
+ version: 1.3232.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement