bosh-template 2.2.0 → 2.2.1

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: 225cc24dcfea221f0c7c6dcd7c06857b21f07ae8
4
- data.tar.gz: a66bf44b3825ce1e406a7fc3dc22cf5fe3fdfdd2
3
+ metadata.gz: 5283a92f4022095fe04822e315c9c6f8fa78b2a2
4
+ data.tar.gz: 11aef776a890ddbf4581fef919324cf99c7c663d
5
5
  SHA512:
6
- metadata.gz: 93cfadffd893c78c122399b806f4ae8bdd3da693d40c342dc51a4bb18546b1bd91b8dc151f10544abc315a977685fe453036bf2661687056dc7ed3fbdf60bc86
7
- data.tar.gz: 4dba063576b3a70450260d33b5cafc6cf80524731949ea78aa77b658954427109d48684ac56e9121254bd28b877ba7560a414ca4e04cbd1a7c29e2ab6040f2a5
6
+ metadata.gz: 646a0e5647c7860a0ea184e845d20e21ca3d868a4e040bc80ca72ec717e31e8370d0f38c5ee380ebeff7874e884b73157b5318360f388bb5d48a670600e999b6
7
+ data.tar.gz: 2d9202fec9416f221b3d464e7ff94722787d306f68944e2cb40f24b976d0e2e19e2d8549647c371f653f31290c57dd3c5eaa9f8911aa134f88570eddf2a3fb74
@@ -51,6 +51,13 @@ module Bosh
51
51
  @links = spec['links'] || {}
52
52
  end
53
53
 
54
+ def ==(other)
55
+ public_members = %w[spec raw_properties name index properties]
56
+ public_members.all? do |member|
57
+ other.respond_to?(member) && send(member) == other.send(member)
58
+ end
59
+ end
60
+
54
61
  # @return [Binding] Template binding
55
62
  def get_binding
56
63
  binding.taint
@@ -154,15 +161,24 @@ module Bosh
154
161
  encoder_to_inject = @dns_encoder
155
162
  end
156
163
 
157
- return EvaluationLink.new(
164
+ group_name = link_spec['instance_group']
165
+ group_type = 'instance-group'
166
+
167
+ if link_spec.fetch('use_link_dns_names', false)
168
+ group_name = link_spec['group_name']
169
+ group_type = 'link'
170
+ end
171
+
172
+ EvaluationLink.new(
158
173
  link_instances,
159
174
  link_spec['properties'],
160
- link_spec['instance_group'],
175
+ group_name,
176
+ group_type,
161
177
  link_spec['default_network'],
162
178
  link_spec['deployment_name'],
163
179
  link_spec['domain'],
164
180
  encoder_to_inject,
165
- link_spec.fetch('use_short_dns_addresses', false)
181
+ link_spec.fetch('use_short_dns_addresses', false),
166
182
  )
167
183
  end
168
184
 
@@ -8,10 +8,21 @@ module Bosh
8
8
  attr_reader :instances
9
9
  attr_reader :properties
10
10
 
11
- def initialize(instances, properties, instance_group, default_network, deployment_name, root_domain, dns_encoder, use_short_dns)
11
+ def initialize(
12
+ instances,
13
+ properties,
14
+ group_name,
15
+ group_type,
16
+ default_network,
17
+ deployment_name,
18
+ root_domain,
19
+ dns_encoder,
20
+ use_short_dns
21
+ )
12
22
  @instances = instances
13
23
  @properties = properties
14
- @instance_group = instance_group
24
+ @group_name = group_name
25
+ @group_type = group_type
15
26
  @default_network = default_network
16
27
  @deployment_name = deployment_name
17
28
  @root_domain = root_domain
@@ -28,30 +39,33 @@ module Bosh
28
39
  end
29
40
 
30
41
  return args[1] if args.length == 2
31
- raise UnknownProperty.new(names)
42
+
43
+ raise UnknownProperty, names
32
44
  end
33
45
 
34
46
  def if_p(*names)
35
47
  values = names.map do |name|
36
48
  value = lookup_property(@properties, name)
37
49
  return Bosh::Template::EvaluationContext::ActiveElseBlock.new(self) if value.nil?
50
+
38
51
  value
39
52
  end
40
53
 
41
- yield *values
54
+ yield(*values)
55
+
42
56
  Bosh::Template::EvaluationContext::InactiveElseBlock.new
43
57
  end
44
58
 
45
59
  def address(criteria = {})
46
- raise NotImplementedError.new('link.address requires bosh director') if @dns_encoder.nil?
60
+ raise NotImplementedError, 'link.address requires bosh director' if @dns_encoder.nil?
47
61
 
48
62
  full_criteria = criteria.merge(
49
- instance_group: @instance_group,
63
+ group_name: @group_name,
64
+ group_type: @group_type,
50
65
  default_network: @default_network,
51
66
  deployment_name: @deployment_name,
52
67
  root_domain: @root_domain,
53
68
  )
54
-
55
69
  @dns_encoder.encode_query(full_criteria, @use_short_dns)
56
70
  end
57
71
  end
@@ -32,19 +32,21 @@ module Bosh
32
32
  end
33
33
 
34
34
  return args[1] if args.length == 2
35
- raise UnknownProperty.new(names)
35
+
36
+ raise UnknownProperty, names
36
37
  end
37
38
 
38
39
  def if_p(*names)
39
40
  values = names.map do |name|
40
41
  value = lookup_property(@properties, name)
41
- return ActiveElseBlock.new(self) if value.nil?
42
+ return Bosh::Template::EvaluationContext::ActiveElseBlock.new(self) if value.nil?
43
+
42
44
  value
43
45
  end
44
46
 
45
- yield *values
46
- InactiveElseBlock.new
47
+ yield(*values)
48
+ Bosh::Template::EvaluationContext::InactiveElseBlock.new
47
49
  end
48
50
  end
49
51
  end
50
- end
52
+ end
@@ -1,11 +1,12 @@
1
1
  module Bosh::Template::Test
2
2
  class Link
3
- attr_reader :instances, :name, :properties
3
+ attr_reader :instances, :name, :properties, :address
4
4
 
5
- def initialize(name:, instances: [], properties: {})
5
+ def initialize(name:, instances: [], properties: {}, address: nil)
6
6
  @instances = instances
7
7
  @name = name
8
8
  @properties = properties
9
+ @address = address
9
10
  end
10
11
 
11
12
  def to_h
@@ -13,6 +14,7 @@ module Bosh::Template::Test
13
14
  'instances' => instances.map(&:to_h),
14
15
  'name' => name,
15
16
  'properties' => properties,
17
+ 'address' => address,
16
18
  }
17
19
  end
18
20
  end
@@ -19,7 +19,7 @@ module Bosh::Template
19
19
 
20
20
  binding = Bosh::Template::EvaluationContext.new(sanitized_hash_with_spec, nil).get_binding
21
21
  raise "No such file at #{@template_path}" unless File.exist?(@template_path)
22
- ERB.new(File.read(@template_path), safe_level = nil, trim_mode = '-').result(binding)
22
+ ERB.new(File.read(@template_path), nil, '-').result(binding)
23
23
  end
24
24
 
25
25
  private
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Template
3
- VERSION = '2.2.0'
3
+ VERSION = '2.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-15 00:00:00.000000000 Z
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semi_semantic
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 2.6.14.1
75
+ rubygems_version: 2.6.14.3
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Renders bosh templates