serverspec-extra-types 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -2
- data/lib/serverspec_extra_types/helpers/properties.rb +4 -4
- data/lib/serverspec_extra_types/matchers.rb +1 -1
- data/lib/serverspec_extra_types/matchers/be_a_manager_node.rb +1 -1
- data/lib/serverspec_extra_types/matchers/be_a_worker_node.rb +1 -1
- data/lib/serverspec_extra_types/matchers/be_active.rb +1 -3
- data/lib/serverspec_extra_types/matchers/configure_queue.rb +1 -1
- data/lib/serverspec_extra_types/matchers/have_count.rb +2 -2
- data/lib/serverspec_extra_types/matchers/have_engine_version.rb +1 -1
- data/lib/serverspec_extra_types/matchers/have_environment_variable.rb +1 -2
- data/lib/serverspec_extra_types/matchers/have_ha_sync_mode.rb +1 -1
- data/lib/serverspec_extra_types/matchers/have_label.rb +20 -13
- data/lib/serverspec_extra_types/matchers/have_mount.rb +8 -4
- data/lib/serverspec_extra_types/matchers/have_network.rb +1 -1
- data/lib/serverspec_extra_types/matchers/have_placement_constraint.rb +1 -1
- data/lib/serverspec_extra_types/matchers/have_user.rb +1 -1
- data/lib/serverspec_extra_types/matchers/map_port.rb +3 -5
- data/lib/serverspec_extra_types/matchers/mirror_all.rb +2 -4
- data/lib/serverspec_extra_types/matchers/publish_all_ports.rb +1 -1
- data/lib/serverspec_extra_types/types/consul_node.rb +1 -7
- data/lib/serverspec_extra_types/types/consul_node_list.rb +2 -6
- data/lib/serverspec_extra_types/types/consul_service.rb +0 -4
- data/lib/serverspec_extra_types/types/consul_service_list.rb +1 -5
- data/lib/serverspec_extra_types/types/docker_container.rb +6 -6
- data/lib/serverspec_extra_types/types/docker_network.rb +22 -0
- data/lib/serverspec_extra_types/types/docker_node.rb +2 -2
- data/lib/serverspec_extra_types/types/docker_service.rb +55 -5
- data/lib/serverspec_extra_types/types/rabbitmq_base.rb +1 -2
- data/lib/serverspec_extra_types/types/rabbitmq_node_list.rb +1 -6
- data/lib/serverspec_extra_types/types/rabbitmq_user_permission.rb +3 -5
- data/lib/serverspec_extra_types/types/rabbitmq_vhost_list.rb +2 -7
- data/lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb +0 -1
- data/lib/serverspec_extra_types/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fa7e592e8372304d35d02542def418d190d43fb780566c21c99769cc72bcef1
|
4
|
+
data.tar.gz: d114bf6691afdc377f9b510f34c49d0fc2aac0200e5cc3315bc89a55afa53051
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3314cbfb00b930aedbc74624e76010df186de9db54793b988b6c94cc6d0e89f173dc7b17ec01aa4a309de608f4a4ae543739268730db4e163ca14e14b3016cc6
|
7
|
+
data.tar.gz: b5c7335d7f3701a1b63397cb7680db498e698fbb115ffa144b19e42496df9335e4edb142b61772296dedc7f49636d3d73fb207d39a764c70d31c40108fc69fb4
|
data/.rubocop.yml
CHANGED
@@ -2,5 +2,18 @@ AllCops:
|
|
2
2
|
Exclude:
|
3
3
|
- 'serverspec-extra-types.gemspec'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
tyle/Documentation:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Metrics/LineLength:
|
9
|
+
Max: 140
|
10
|
+
|
11
|
+
|
12
|
+
Metrics/MethodLength:
|
13
|
+
Max: 15
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Exclude:
|
17
|
+
- 'Rakefile'
|
18
|
+
- '**/*.rake'
|
19
|
+
- 'spec/**/*.rb'
|
@@ -4,8 +4,8 @@ rabbitmq_user = ENV['RABBITMQ_USER'] || 'guest'
|
|
4
4
|
rabbitmq_password = ENV['RABBITMQ_PASSWORD'] || 'guest'
|
5
5
|
rabbitmq_url = ENV['RABBITMQ_URL'] || 'http://localhost:15672'
|
6
6
|
props = {
|
7
|
-
rabbitmq_user: rabbitmq_user,
|
8
|
-
rabbitmq_password: rabbitmq_password,
|
9
|
-
rabbitmq_url: rabbitmq_url
|
7
|
+
rabbitmq_user: property[:rabbitmq_user] || rabbitmq_user,
|
8
|
+
rabbitmq_password: property[:rabbitmq_password] || rabbitmq_password,
|
9
|
+
rabbitmq_url: property[:rabbitmq_url] || rabbitmq_url
|
10
10
|
}
|
11
|
-
set_property props
|
11
|
+
set_property property.merge(props)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
#--- Docker Matchers
|
3
2
|
require 'serverspec_extra_types/matchers/be_active'
|
4
3
|
require 'serverspec_extra_types/matchers/be_a_manager_node'
|
@@ -9,6 +8,7 @@ require 'serverspec_extra_types/matchers/have_placement_constraint'
|
|
9
8
|
require 'serverspec_extra_types/matchers/have_hostname'
|
10
9
|
require 'serverspec_extra_types/matchers/have_host'
|
11
10
|
require 'serverspec_extra_types/matchers/have_image'
|
11
|
+
require 'serverspec_extra_types/matchers/have_label'
|
12
12
|
require 'serverspec_extra_types/matchers/have_image_sha'
|
13
13
|
require 'serverspec_extra_types/matchers/have_restart_limit'
|
14
14
|
require 'serverspec_extra_types/matchers/have_restart_policy'
|
@@ -12,4 +12,4 @@ end
|
|
12
12
|
|
13
13
|
RSpec::Matchers.alias_matcher :be_manager, :be_a_manager_node
|
14
14
|
RSpec::Matchers.alias_matcher :be_a_manager, :be_a_manager_node
|
15
|
-
RSpec::Matchers.alias_matcher :be_manager_node, :be_a_manager_node
|
15
|
+
RSpec::Matchers.alias_matcher :be_manager_node, :be_a_manager_node
|
@@ -11,4 +11,4 @@ RSpec::Matchers.define :be_a_worker_node do
|
|
11
11
|
end
|
12
12
|
RSpec::Matchers.alias_matcher :be_worker, :be_a_worker_node
|
13
13
|
RSpec::Matchers.alias_matcher :be_a_worker, :be_a_worker_node
|
14
|
-
RSpec::Matchers.alias_matcher :be_worker_node, :be_a_worker_node
|
14
|
+
RSpec::Matchers.alias_matcher :be_worker_node, :be_a_worker_node
|
@@ -1,6 +1,6 @@
|
|
1
1
|
RSpec::Matchers.define :have_count do |count|
|
2
2
|
match do |actual|
|
3
|
-
actual.length ==
|
3
|
+
actual.length == count
|
4
4
|
end
|
5
5
|
description do
|
6
6
|
"have #{count}"
|
@@ -8,4 +8,4 @@ RSpec::Matchers.define :have_count do |count|
|
|
8
8
|
failure_message do |actual|
|
9
9
|
"expected count to be #{count} was #{actual.length}"
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec::Matchers.define :have_environment_variable do |regex|
|
2
|
-
chain :with_value do |
|
2
|
+
chain :with_value do |value|
|
3
3
|
@value = value
|
4
4
|
end
|
5
5
|
match do |actual|
|
@@ -17,5 +17,4 @@ RSpec::Matchers.define :have_environment_variable do |regex|
|
|
17
17
|
"expected #{regex} to have value #{@value}, it was #{actual.environment_variable(regex)}"
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
@@ -1,20 +1,27 @@
|
|
1
1
|
RSpec::Matchers.define :have_label do |label|
|
2
|
-
|
3
|
-
|
4
|
-
end
|
5
|
-
failure_message do |actual|
|
6
|
-
"expected #{actual.labels} to have key #{label}"
|
2
|
+
chain :with_value do |_value|
|
3
|
+
@value = _value
|
7
4
|
end
|
8
|
-
end
|
9
5
|
|
10
|
-
RSpec::Matchers.define :have_label_with_value do |label, value|
|
11
6
|
match do |actual|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
if !@value
|
8
|
+
actual.labels.key? label
|
9
|
+
else
|
10
|
+
actual.has_label?(label, @value)
|
11
|
+
end
|
16
12
|
end
|
17
13
|
description do
|
18
|
-
|
14
|
+
if !@value
|
15
|
+
"have label #{label}"
|
16
|
+
else
|
17
|
+
"have label #{label} with value #{@value}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
failure_message do |actual|
|
21
|
+
if !@value
|
22
|
+
"expected #{actual.labels} to have key #{label}"
|
23
|
+
else
|
24
|
+
"expected #{actual.label(label)[0]} to have value #{@value}, it had #{actual.label(label)[1]} "
|
25
|
+
end
|
19
26
|
end
|
20
|
-
end
|
27
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
|
-
RSpec::Matchers.define :have_mount do |source, target
|
1
|
+
RSpec::Matchers.define :have_mount do |source, target|
|
2
|
+
chain :type, :type
|
2
3
|
match do |actual|
|
3
|
-
|
4
|
+
@type ||= source.include?('/') ? 'bind' : 'volume'
|
5
|
+
actual.has_mount?(source, target, @type)
|
4
6
|
end
|
5
7
|
description do
|
6
|
-
|
8
|
+
@type ||= source.include?('/') ? 'bind' : 'volume'
|
9
|
+
"#{@type == 'bind' ? 'bind' : 'mount volume'} #{source} on host to #{target} in container"
|
7
10
|
end
|
8
11
|
failure_message do |actual|
|
9
|
-
|
12
|
+
@type ||= source.include?('/') ? 'bind' : 'volume'
|
13
|
+
"expected #{actual.mounts} to contain {'Target' => #{target}, 'Source' => #{source}, 'Type' => #{@type}}"
|
10
14
|
end
|
11
15
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
RSpec::Matchers.define :map_port do |host, container|
|
2
|
-
|
3
2
|
match do |actual|
|
4
|
-
@protocol
|
3
|
+
@protocol ||= 'tcp'
|
5
4
|
if @mode
|
6
5
|
actual.map_port? host, container, @protocol, @mode
|
7
6
|
else
|
@@ -15,11 +14,10 @@ RSpec::Matchers.define :map_port do |host, container|
|
|
15
14
|
msg
|
16
15
|
end
|
17
16
|
failure_message do |actual|
|
18
|
-
@protocol
|
17
|
+
@protocol ||= 'tcp'
|
19
18
|
"expected #{actual.port_map} to contain {\"#{container}/#{@protocol}\"=>[{\"HostPort\"=>\"#{host}\"}] }"
|
20
19
|
end
|
21
20
|
|
22
21
|
chain :using_protocol, :protocol
|
23
22
|
chain :with_mode, :mode
|
24
|
-
|
25
|
-
end
|
23
|
+
end
|
@@ -1,20 +1,14 @@
|
|
1
1
|
require 'serverspec_extra_types/types/consul_base'
|
2
2
|
|
3
|
-
|
4
3
|
# TODO: List and singular
|
5
4
|
module Serverspec::Type
|
6
5
|
class ConsulNode < ConsulBase
|
7
|
-
|
8
6
|
def url
|
9
7
|
"#{@url_base}/v1/catalog/node/#{@name}"
|
10
8
|
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
10
|
def inspection
|
15
|
-
@inspection ||= ::MultiJson.load(get_inspection.stdout) #Need a find
|
11
|
+
@inspection ||= ::MultiJson.load(get_inspection.stdout) # Need a find
|
16
12
|
end
|
17
|
-
|
18
|
-
|
19
13
|
end
|
20
14
|
end
|
@@ -1,20 +1,18 @@
|
|
1
1
|
require 'serverspec_extra_types/types/consul_base'
|
2
2
|
|
3
|
-
|
4
3
|
# TODO: List and singular
|
5
4
|
module Serverspec::Type
|
6
5
|
class ConsulNodeList < ConsulBase
|
7
|
-
|
8
6
|
def url
|
9
7
|
"#{@url_base}/v1/catalog/nodes"
|
10
8
|
end
|
11
9
|
|
12
10
|
def to_s
|
13
|
-
msg =
|
11
|
+
msg = 'Consul Node List'
|
14
12
|
msg << %( with acl token: "#{@token}") if @token
|
15
13
|
msg
|
16
14
|
end
|
17
|
-
|
15
|
+
|
18
16
|
def has_node?(node)
|
19
17
|
nodes.include? node
|
20
18
|
end
|
@@ -26,7 +24,5 @@ module Serverspec::Type
|
|
26
24
|
def inspection
|
27
25
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)
|
28
26
|
end
|
29
|
-
|
30
|
-
|
31
27
|
end
|
32
28
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'serverspec_extra_types/types/consul_base'
|
2
2
|
|
3
|
-
|
4
3
|
# TODO: List and singular
|
5
4
|
module Serverspec::Type
|
6
5
|
class ConsulService < ConsulBase
|
7
|
-
|
8
6
|
def url
|
9
7
|
"#{@url_base}/v1/catalog/service/#{@name}"
|
10
8
|
end
|
@@ -18,7 +16,5 @@ module Serverspec::Type
|
|
18
16
|
def inspection
|
19
17
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)
|
20
18
|
end
|
21
|
-
|
22
|
-
|
23
19
|
end
|
24
20
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require 'serverspec_extra_types/types/consul_base'
|
2
2
|
|
3
|
-
|
4
3
|
# TODO: List and singular
|
5
4
|
module Serverspec::Type
|
6
5
|
class ConsulServiceList < ConsulBase
|
7
|
-
|
8
6
|
def url
|
9
7
|
"#{@url_base}/v1/catalog/services"
|
10
8
|
end
|
11
9
|
|
12
10
|
def to_s
|
13
|
-
msg =
|
11
|
+
msg = 'Consul Service List'
|
14
12
|
msg << %( with acl token: "#{@token}") if @token
|
15
13
|
msg
|
16
14
|
end
|
@@ -26,7 +24,5 @@ module Serverspec::Type
|
|
26
24
|
def inspection
|
27
25
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)
|
28
26
|
end
|
29
|
-
|
30
|
-
|
31
27
|
end
|
32
28
|
end
|
@@ -12,7 +12,7 @@ module Serverspec::Type
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def has_image_sha?(image)
|
15
|
-
|
15
|
+
image_sha == image
|
16
16
|
end
|
17
17
|
|
18
18
|
def image
|
@@ -29,7 +29,6 @@ module Serverspec::Type
|
|
29
29
|
else
|
30
30
|
environment_variable(regex)
|
31
31
|
end
|
32
|
-
|
33
32
|
end
|
34
33
|
|
35
34
|
def environment_variable(regex)
|
@@ -57,7 +56,7 @@ module Serverspec::Type
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def has_domainname?(domain)
|
60
|
-
|
59
|
+
domain_name == domain
|
61
60
|
end
|
62
61
|
|
63
62
|
def domain_name
|
@@ -79,11 +78,13 @@ module Serverspec::Type
|
|
79
78
|
def restart_policy
|
80
79
|
inspection['HostConfig']['RestartPolicy']['Name']
|
81
80
|
end
|
81
|
+
|
82
82
|
def has_host?(host)
|
83
83
|
hosts.include? host
|
84
84
|
end
|
85
|
+
|
85
86
|
def hosts
|
86
|
-
inspection['HostConfig']['ExtraHosts'].map {|itm| itm.split(':')[1] + ' ' + itm.split(':')[0]}
|
87
|
+
inspection['HostConfig']['ExtraHosts'].map { |itm| itm.split(':')[1] + ' ' + itm.split(':')[0] }
|
87
88
|
end
|
88
89
|
|
89
90
|
def privileged?
|
@@ -95,7 +96,6 @@ module Serverspec::Type
|
|
95
96
|
inspection['HostConfig']['PublishAllPorts']
|
96
97
|
end
|
97
98
|
|
98
|
-
|
99
99
|
def map_port?(host, container, protocol = 'tcp')
|
100
100
|
inspection['NetworkSettings']['Ports']["#{container}/#{protocol}"][0]['HostPort'] == host
|
101
101
|
end
|
@@ -117,7 +117,7 @@ module Serverspec::Type
|
|
117
117
|
private
|
118
118
|
|
119
119
|
def get_inspection
|
120
|
-
@containers ||=
|
120
|
+
@containers ||= @name.include?('=') ? @runner.run_command("docker ps -qa -f #{@name}").stdout : @name
|
121
121
|
@get_inspection ||= @runner.run_command("docker inspect #{@containers}")
|
122
122
|
end
|
123
123
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'serverspec'
|
2
|
+
|
3
|
+
module Serverspec::Type
|
4
|
+
# This class monkey patches serverspec's docker container type with some more method to be used in matchers
|
5
|
+
class DockerNetwork < DockerBase
|
6
|
+
|
7
|
+
def name
|
8
|
+
inspection['Name']
|
9
|
+
end
|
10
|
+
|
11
|
+
def id
|
12
|
+
inspection['Id']
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
|
18
|
+
def get_inspection
|
19
|
+
@get_inspection ||= @runner.run_command("docker network inspect #{@name}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Serverspec::Type
|
2
2
|
class DockerNode < DockerBase
|
3
|
-
|
4
3
|
def active?
|
5
4
|
availability == 'active'
|
6
5
|
end
|
@@ -32,10 +31,11 @@ module Serverspec::Type
|
|
32
31
|
def engine_version
|
33
32
|
inspection['Description']['Engine']['EngineVersion']
|
34
33
|
end
|
34
|
+
|
35
35
|
private
|
36
36
|
|
37
37
|
def get_inspection
|
38
|
-
@get_inspection ||= @runner.run_command("docker
|
38
|
+
@get_inspection ||= @runner.run_command("docker node inspect #{@name}")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'serverspec'
|
2
2
|
require 'serverspec/type/base'
|
3
3
|
require 'serverspec/type/docker_base'
|
4
|
+
require 'serverspec_extra_types/types/docker_network'
|
4
5
|
|
5
6
|
module Serverspec::Type
|
6
7
|
class DockerService < DockerBase
|
@@ -58,6 +59,26 @@ module Serverspec::Type
|
|
58
59
|
inspection['Spec']['TaskTemplate']['ContainerSpec']['Mounts']
|
59
60
|
end
|
60
61
|
|
62
|
+
def has_config?(name, target = nil)
|
63
|
+
if target
|
64
|
+
configs.find { |config| config['ConfigName'] == name && config['File']['Name'] == target }
|
65
|
+
else
|
66
|
+
configs.find { |config| config['ConfigName'] == name }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def configs
|
71
|
+
inspection['Spec']['TaskTemplate']['ContainerSpec']['Configs']
|
72
|
+
end
|
73
|
+
|
74
|
+
def has_secret?(name)
|
75
|
+
secrets.find { |secret| secret['SecretName'] == name }
|
76
|
+
end
|
77
|
+
|
78
|
+
def secrets
|
79
|
+
inspection['Spec']['TaskTemplate']['ContainerSpec']['Secrets']
|
80
|
+
end
|
81
|
+
|
61
82
|
def has_host?(host)
|
62
83
|
hosts.include? host
|
63
84
|
end
|
@@ -78,9 +99,6 @@ module Serverspec::Type
|
|
78
99
|
inspection['Spec']['Mode']['Replicated']
|
79
100
|
end
|
80
101
|
|
81
|
-
def replicas
|
82
|
-
['Spec']['Mode']['Replicated']['Replicas']
|
83
|
-
end
|
84
102
|
def global?
|
85
103
|
inspection['Spec']['Mode']['Global']
|
86
104
|
end
|
@@ -94,14 +112,15 @@ module Serverspec::Type
|
|
94
112
|
end
|
95
113
|
|
96
114
|
def has_network?(name)
|
97
|
-
|
115
|
+
target_network = DockerNetwork.new(name)
|
116
|
+
networks.find { |network| network['Target'].include? target_network.id }
|
98
117
|
end
|
99
118
|
|
100
119
|
def port_map
|
101
120
|
inspection['Spec']['EndpointSpec']['Ports']
|
102
121
|
end
|
103
122
|
|
104
|
-
def map_port?(published, target, protocol = 'tcp',mode = 'ingress')
|
123
|
+
def map_port?(published, target, protocol = 'tcp', mode = 'ingress')
|
105
124
|
port_map.find do |port|
|
106
125
|
port['PublishedPort'] == published.to_i &&
|
107
126
|
port['TargetPort'] == target.to_i && port['PublishMode'] == mode &&
|
@@ -109,6 +128,37 @@ module Serverspec::Type
|
|
109
128
|
end
|
110
129
|
end
|
111
130
|
|
131
|
+
def has_environment_variable?(regex, value = nil)
|
132
|
+
if value
|
133
|
+
environment_variable(regex) == value
|
134
|
+
else
|
135
|
+
environment_variable(regex)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def environment_variable(regex)
|
140
|
+
environment_variables.find { |str| str =~ /^#{regex}=/ }.split('=')[1]
|
141
|
+
end
|
142
|
+
|
143
|
+
def environment_variables
|
144
|
+
inspection['Spec']['TaskTemplate']['ContainerSpec']['Env']
|
145
|
+
end
|
146
|
+
|
147
|
+
def has_label?(label, value = nil)
|
148
|
+
if value
|
149
|
+
label(label)[1] == value
|
150
|
+
else
|
151
|
+
label(label)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def label(label)
|
156
|
+
labels.find { |key, _val| key == label }
|
157
|
+
end
|
158
|
+
|
159
|
+
def labels
|
160
|
+
inspection['Spec']['Labels']
|
161
|
+
end
|
112
162
|
|
113
163
|
private
|
114
164
|
|
@@ -13,7 +13,6 @@ module Serverspec::Type
|
|
13
13
|
@url_base = property[:variables][:rabbitmq_url] || 'http://localhost:15672'
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
16
|
def inspection
|
18
17
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)[0]
|
19
18
|
end
|
@@ -21,7 +20,7 @@ module Serverspec::Type
|
|
21
20
|
def length
|
22
21
|
if inspection.is_a? String
|
23
22
|
inspection.length
|
24
|
-
elsif inspection.
|
23
|
+
elsif inspection.is_a? Array
|
25
24
|
inspection.length
|
26
25
|
else
|
27
26
|
1
|
@@ -1,18 +1,13 @@
|
|
1
1
|
require 'serverspec_extra_types/types/rabbitmq_base'
|
2
2
|
|
3
3
|
module Serverspec::Type
|
4
|
-
class RabbitmqNodeList
|
5
|
-
|
4
|
+
class RabbitmqNodeList < RabbitmqBase
|
6
5
|
def url
|
7
6
|
"#{@url_base}/api/vhosts"
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
9
|
def inspection
|
13
10
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)
|
14
11
|
end
|
15
|
-
|
16
|
-
|
17
12
|
end
|
18
13
|
end
|
@@ -2,7 +2,6 @@ require 'serverspec_extra_types/types/rabbitmq_base'
|
|
2
2
|
|
3
3
|
module Serverspec::Type
|
4
4
|
class RabbitmqUserPermission < RabbitmqBase
|
5
|
-
|
6
5
|
def url
|
7
6
|
"#{@url_base}/api/users/#{name}/permissions"
|
8
7
|
end
|
@@ -20,20 +19,19 @@ module Serverspec::Type
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def read_permissions(vhost)
|
23
|
-
inspection.find { |item| item['vhost'] == vhost}['read']
|
22
|
+
inspection.find { |item| item['vhost'] == vhost }['read']
|
24
23
|
end
|
25
24
|
|
26
25
|
def write_permissions(vhost)
|
27
|
-
inspection.find { |item| item['vhost'] == vhost}['write']
|
26
|
+
inspection.find { |item| item['vhost'] == vhost }['write']
|
28
27
|
end
|
29
28
|
|
30
29
|
def configure_permissions(vhost)
|
31
|
-
inspection.find { |item| item['vhost'] == vhost}['configure']
|
30
|
+
inspection.find { |item| item['vhost'] == vhost }['configure']
|
32
31
|
end
|
33
32
|
|
34
33
|
def inspection
|
35
34
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
39
37
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'serverspec_extra_types/types/rabbitmq_base'
|
2
2
|
|
3
3
|
module Serverspec::Type
|
4
|
-
class RabbitmqVhostList
|
5
|
-
|
6
|
-
|
4
|
+
class RabbitmqVhostList < RabbitmqBase
|
7
5
|
def has_vhost?(vhost)
|
8
|
-
|
6
|
+
inspection.find { |str| str['name'] == vhost }
|
9
7
|
end
|
10
8
|
|
11
9
|
def url
|
@@ -15,8 +13,5 @@ module Serverspec::Type
|
|
15
13
|
def inspection
|
16
14
|
@inspection ||= ::MultiJson.load(get_inspection.stdout)
|
17
15
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
16
|
end
|
22
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec-extra-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Wardrobe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/serverspec_extra_types/types/consul_service.rb
|
196
196
|
- lib/serverspec_extra_types/types/consul_service_list.rb
|
197
197
|
- lib/serverspec_extra_types/types/docker_container.rb
|
198
|
+
- lib/serverspec_extra_types/types/docker_network.rb
|
198
199
|
- lib/serverspec_extra_types/types/docker_node.rb
|
199
200
|
- lib/serverspec_extra_types/types/docker_service.rb
|
200
201
|
- lib/serverspec_extra_types/types/rabbitmq_base.rb
|
@@ -225,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
226
|
version: '0'
|
226
227
|
requirements: []
|
227
228
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.7.
|
229
|
+
rubygems_version: 2.7.6
|
229
230
|
signing_key:
|
230
231
|
specification_version: 4
|
231
232
|
summary: Additional Types and Matchers for Serverspec
|