Class: Serverspec::Type::ConsulService

Inherits:
ConsulBase show all
Defined in:
lib/serverspec_extra_types/types/consul_service.rb

Instance Method Summary collapse

Methods inherited from ConsulBase

#[], #initialize

Methods inherited from ApiBase

#[], #initialize

Constructor Details

This class inherits a constructor from Serverspec::Type::ConsulBase

Instance Method Details

#addressObject

Key Type: String



43
44
45
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 43

def address
  inspection['Address']
end

#create_indexObject

Key Type: Integer



189
190
191
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 189

def create_index
  inspection['CreateIndex']
end

#datacenterObject

Key Type: String



52
53
54
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 52

def datacenter
  inspection['Datacenter']
end

#has_address?(address) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 47

def has_address?(address)
  self.address == address
end

#has_create_index?(create_index) ⇒ Boolean

Returns:

  • (Boolean)


193
194
195
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 193

def has_create_index?(create_index)
  self.create_index == create_index
end

#has_datacenter?(datacenter) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 56

def has_datacenter?(datacenter)
  self.datacenter == datacenter
end

#has_id?(id) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 29

def has_id?(id)
  self.id == id
end

#has_modify_index?(modify_index) ⇒ Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 202

def has_modify_index?(modify_index)
  self.modify_index == modify_index
end

#has_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 38

def has_node?(node)
  self.node == node
end

#has_node_meta?(node_meta) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 75

def has_node_meta?(node_meta)
  self.node_meta == node_meta
end

#has_service_address?(service_address) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 120

def has_service_address?(service_address)
  self.service_address == service_address
end

#has_service_connect?(service_connect) ⇒ Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 184

def has_service_connect?(service_connect)
  self.service_connect == service_connect
end

#has_service_enable_tag_override?(service_enable_tag_override) ⇒ Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 157

def has_service_enable_tag_override?(service_enable_tag_override)
  self.service_enable_tag_override == service_enable_tag_override
end

#has_service_id?(service_id) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 93

def has_service_id?(service_id)
  self.service_id == service_id
end

#has_service_kind?(service_kind) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 84

def has_service_kind?(service_kind)
  self.service_kind == service_kind
end

#has_service_meta?(service_meta) ⇒ Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 139

def has_service_meta?(service_meta)
  self.service_meta == service_meta
end

#has_service_name?(service_name) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 102

def has_service_name?(service_name)
  self.service_name == service_name
end

#has_service_port?(service_port) ⇒ Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 148

def has_service_port?(service_port)
  self.service_port == service_port
end

#has_service_proxy?(service_proxy) ⇒ Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 175

def has_service_proxy?(service_proxy)
  self.service_proxy == service_proxy
end

#has_service_proxy_destination?(service_proxy_destination) ⇒ Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 166

def has_service_proxy_destination?(service_proxy_destination)
  self.service_proxy_destination == service_proxy_destination
end

#has_service_tags?(service_tags) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 111

def has_service_tags?(service_tags)
  self.service_tags == service_tags
end

#has_service_weights?(service_weights) ⇒ Boolean

TODO: do method for indiviual service weight are well as passing/warning

Returns:

  • (Boolean)


130
131
132
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 130

def has_service_weights?(service_weights)
  self.service_weights == service_weights
end

#has_tagged_addresses?(tagged_addresses) ⇒ Boolean

TODO: do method for indiviual tagged addresses

Returns:

  • (Boolean)


66
67
68
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 66

def has_tagged_addresses?(tagged_addresses)
  self.tagged_addresses == tagged_addresses
end

#idObject

Generated Code Start =##

TODO: Make these better Key Type: String



25
26
27
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 25

def id
  inspection['ID']
end

#inspectionObject



18
19
20
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 18

def inspection
  @inspection ||= ::MultiJson.load(get_inspection.stdout)[0]
end

#modify_indexObject

Key Type: Integer



198
199
200
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 198

def modify_index
  inspection['ModifyIndex']
end

#nodeObject

Key Type: String



34
35
36
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 34

def node
  inspection['Node']
end

#node_metaObject

Key Type: Hash



71
72
73
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 71

def node_meta
  inspection['NodeMeta']
end

#service_addressObject

Key Type: String



116
117
118
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 116

def service_address
  inspection['ServiceAddress']
end

#service_connectObject

Key Type: Hash



180
181
182
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 180

def service_connect
  inspection['ServiceConnect']
end

#service_enable_tag_overrideObject

Key Type: FalseClass



153
154
155
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 153

def service_enable_tag_override
  inspection['ServiceEnableTagOverride']
end

#service_idObject

Key Type: String



89
90
91
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 89

def service_id
  inspection['ServiceID']
end

#service_kindObject

Key Type: String



80
81
82
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 80

def service_kind
  inspection['ServiceKind']
end

#service_metaObject

Key Type: Hash



135
136
137
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 135

def service_meta
  inspection['ServiceMeta']
end

#service_nameObject

Key Type: String



98
99
100
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 98

def service_name
  inspection['ServiceName']
end

#service_portObject

Key Type: Integer



144
145
146
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 144

def service_port
  inspection['ServicePort']
end

#service_proxyObject

Key Type: Hash



171
172
173
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 171

def service_proxy
  inspection['ServiceProxy']
end

#service_proxy_destinationObject

Key Type: String



162
163
164
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 162

def service_proxy_destination
  inspection['ServiceProxyDestination']
end

#service_tagsObject

Key Type: Array



107
108
109
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 107

def service_tags
  inspection['ServiceTags']
end

#service_weightsObject

Key Type: Hash



125
126
127
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 125

def service_weights
  inspection['ServiceWeights']
end

#tagged_addressesObject

Key Type: Hash



61
62
63
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 61

def tagged_addresses
  inspection['TaggedAddresses']
end

#to_sObject



12
13
14
15
16
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 12

def to_s
  msg = "Consul Service #{@name}"
  msg << %( with acl token: "#{@token}") if @token
  msg
end

#urlObject



8
9
10
# File 'lib/serverspec_extra_types/types/consul_service.rb', line 8

def url
  "#{@url_base}/v1/catalog/service/#{@name}"
end