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



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

def address
  inspection['Address']
end

#create_indexObject

Key Type: Integer



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

def create_index
  inspection['CreateIndex']
end

#datacenterObject

Key Type: String



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

def datacenter
  inspection['Datacenter']
end

#has_address?(address) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_create_index?(create_index) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_datacenter?(datacenter) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_id?(id) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_modify_index?(modify_index) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_node_meta?(node_meta) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_address?(service_address) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_connect?(service_connect) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_enable_tag_override?(service_enable_tag_override) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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

#has_service_kind?(service_kind) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_meta?(service_meta) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_name?(service_name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_port?(service_port) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_proxy?(service_proxy) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_proxy_destination?(service_proxy_destination) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#has_service_tags?(service_tags) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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)


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

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

#idObject

Generated Code Start =##

TODO: Make these better Key Type: String



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

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



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

def modify_index
  inspection['ModifyIndex']
end

#nodeObject

Key Type: String



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

def node
  inspection['Node']
end

#node_metaObject

Key Type: Hash



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

def node_meta
  inspection['NodeMeta']
end

#service_addressObject

Key Type: String



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

def service_address
  inspection['ServiceAddress']
end

#service_connectObject

Key Type: Hash



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

def service_connect
  inspection['ServiceConnect']
end

#service_enable_tag_overrideObject

Key Type: FalseClass



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

def service_enable_tag_override
  inspection['ServiceEnableTagOverride']
end

#service_idObject

Key Type: String



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

def service_id
  inspection['ServiceID']
end

#service_kindObject

Key Type: String



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

def service_kind
  inspection['ServiceKind']
end

#service_metaObject

Key Type: Hash



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

def service_meta
  inspection['ServiceMeta']
end

#service_nameObject

Key Type: String



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

def service_name
  inspection['ServiceName']
end

#service_portObject

Key Type: Integer



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

def service_port
  inspection['ServicePort']
end

#service_proxyObject

Key Type: Hash



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

def service_proxy
  inspection['ServiceProxy']
end

#service_proxy_destinationObject

Key Type: String



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

def service_proxy_destination
  inspection['ServiceProxyDestination']
end

#service_tagsObject

Key Type: Array



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

def service_tags
  inspection['ServiceTags']
end

#service_weightsObject

Key Type: Hash



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

def service_weights
  inspection['ServiceWeights']
end

#tagged_addressesObject

Key Type: Hash



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

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