brightbox-cli 4.8.0 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +6 -2
  3. data/CHANGELOG.md +60 -0
  4. data/Gemfile.lock +17 -10
  5. data/brightbox-cli.gemspec +3 -7
  6. data/lib/brightbox-cli/accounts.rb +5 -1
  7. data/lib/brightbox-cli/api.rb +34 -1
  8. data/lib/brightbox-cli/cloud_ips.rb +6 -6
  9. data/lib/brightbox-cli/collaboration.rb +3 -7
  10. data/lib/brightbox-cli/commands/cloudips/unmap.rb +1 -1
  11. data/lib/brightbox-cli/commands/firewall/policies_apply.rb +1 -1
  12. data/lib/brightbox-cli/commands/firewall/policies_create.rb +1 -1
  13. data/lib/brightbox-cli/commands/firewall/policies_destroy.rb +1 -1
  14. data/lib/brightbox-cli/commands/firewall/policies_list.rb +1 -1
  15. data/lib/brightbox-cli/commands/firewall/policies_remove.rb +1 -1
  16. data/lib/brightbox-cli/commands/firewall/policies_show.rb +1 -1
  17. data/lib/brightbox-cli/commands/firewall/policies_update.rb +1 -1
  18. data/lib/brightbox-cli/commands/lbs/create.rb +28 -16
  19. data/lib/brightbox-cli/commands/lbs/show.rb +5 -0
  20. data/lib/brightbox-cli/commands/lbs/update.rb +9 -2
  21. data/lib/brightbox-cli/config.rb +12 -5
  22. data/lib/brightbox-cli/database_server.rb +20 -20
  23. data/lib/brightbox-cli/database_snapshot.rb +5 -5
  24. data/lib/brightbox-cli/database_type.rb +4 -8
  25. data/lib/brightbox-cli/detailed_server.rb +26 -28
  26. data/lib/brightbox-cli/detailed_server_group.rb +2 -2
  27. data/lib/brightbox-cli/firewall_policy.rb +5 -9
  28. data/lib/brightbox-cli/firewall_rule.rb +14 -15
  29. data/lib/brightbox-cli/images.rb +21 -20
  30. data/lib/brightbox-cli/indifferent_access_hash.rb +50 -0
  31. data/lib/brightbox-cli/load_balancers.rb +38 -4
  32. data/lib/brightbox-cli/server_groups.rb +4 -8
  33. data/lib/brightbox-cli/servers.rb +22 -16
  34. data/lib/brightbox-cli/types.rb +4 -8
  35. data/lib/brightbox-cli/user_collaboration.rb +1 -1
  36. data/lib/brightbox-cli/users.rb +3 -5
  37. data/lib/brightbox-cli/version.rb +1 -1
  38. data/lib/brightbox-cli/volume.rb +9 -13
  39. data/lib/brightbox-cli/zones.rb +0 -4
  40. data/lib/brightbox_cli.rb +1 -0
  41. data/spec/commands/cloudips/update_spec.rb +7 -5
  42. data/spec/commands/configmaps/create_spec.rb +6 -6
  43. data/spec/commands/configmaps/destroy_spec.rb +1 -1
  44. data/spec/commands/configmaps/list_spec.rb +1 -1
  45. data/spec/commands/configmaps/show_spec.rb +3 -3
  46. data/spec/commands/configmaps/update_spec.rb +9 -9
  47. data/spec/commands/lbs/create_spec.rb +158 -6
  48. data/spec/commands/lbs/show_spec.rb +99 -3
  49. data/spec/commands/lbs/update_spec.rb +50 -6
  50. data/spec/commands/servers/update_spec.rb +7 -7
  51. data/spec/commands/sql/instances/create_spec.rb +8 -8
  52. data/spec/commands/sql/instances/reset_spec.rb +3 -3
  53. data/spec/commands/sql/instances/resize_spec.rb +4 -4
  54. data/spec/commands/sql/instances/show_spec.rb +2 -1
  55. data/spec/commands/sql/instances/update_spec.rb +3 -3
  56. data/spec/commands/sql/snapshots/list_spec.rb +1 -1
  57. data/spec/commands/sql/snapshots/show_spec.rb +50 -7
  58. data/spec/commands/volumes/attach_spec.rb +4 -4
  59. data/spec/commands/volumes/copy_spec.rb +2 -2
  60. data/spec/commands/volumes/destroy_spec.rb +1 -1
  61. data/spec/commands/volumes/detach_spec.rb +1 -1
  62. data/spec/commands/volumes/list_spec.rb +1 -1
  63. data/spec/commands/volumes/resize_spec.rb +3 -3
  64. data/spec/commands/volumes/show_spec.rb +1 -1
  65. data/spec/commands/volumes/update_spec.rb +4 -4
  66. data/spec/spec_helper.rb +16 -0
  67. data/spec/support/shared/api_resource_examples.rb +25 -0
  68. data/spec/unit/brightbox/account/attributes_spec.rb +13 -0
  69. data/spec/unit/brightbox/api/attributes_spec.rb +65 -0
  70. data/spec/unit/brightbox/api/fog_attributes_spec.rb +65 -0
  71. data/spec/unit/brightbox/bb_config/config_directory_spec.rb +23 -3
  72. data/spec/unit/brightbox/cloud_ip/attributes_spec.rb +19 -0
  73. data/spec/unit/brightbox/collaborating_account/attributes_spec.rb +13 -0
  74. data/spec/unit/brightbox/database_server/attributes_spec.rb +13 -0
  75. data/spec/unit/brightbox/database_snapshot/attributes_spec.rb +13 -0
  76. data/spec/unit/brightbox/database_type/attributes_spec.rb +20 -0
  77. data/spec/unit/brightbox/detailed_server/attributes_spec.rb +29 -0
  78. data/spec/unit/brightbox/detailed_server_group/attributes_spec.rb +13 -0
  79. data/spec/unit/brightbox/firewall_policy/attributes_spec.rb +21 -0
  80. data/spec/unit/brightbox/firewall_rule/attributes_spec.rb +18 -0
  81. data/spec/unit/brightbox/image/attributes_spec.rb +13 -0
  82. data/spec/unit/brightbox/image/status_spec.rb +67 -0
  83. data/spec/unit/brightbox/load_balancer/acme_cert_spec.rb +75 -0
  84. data/spec/unit/brightbox/load_balancer/attributes_spec.rb +13 -0
  85. data/spec/unit/brightbox/load_balancer/formatted_acme_domains_spec.rb +78 -0
  86. data/spec/unit/brightbox/server/attributes_spec.rb +29 -0
  87. data/spec/unit/brightbox/server/hostname_spec.rb +27 -0
  88. data/spec/unit/brightbox/server_group/attributes_spec.rb +13 -0
  89. data/spec/unit/brightbox/type/attributes_spec.rb +20 -0
  90. data/spec/unit/brightbox/user/attributes_spec.rb +13 -0
  91. data/spec/unit/brightbox/user_collaboration/attributes_spec.rb +13 -0
  92. metadata +68 -23
  93. data/spec/cassettes/brightbox_sql_snapshots/show/when_resource_exists/does_not_output_to_stderr.yml +0 -93
@@ -1,40 +1,38 @@
1
1
  module Brightbox
2
2
  class DetailedServer < Server
3
3
  def to_row
4
- row_attributes = attributes
4
+ attributes.tap do |attrs|
5
+ attrs[:compatibility_mode] = attrs["compatibility_mode"]
5
6
 
6
- row_attributes[:compatibility_mode] = row_attributes["compatibility_mode"]
7
-
8
- if server_type
9
- row_attributes[:type] = server_type["id"]
10
- row_attributes[:type_handle] = server_type["handle"]
11
- row_attributes[:type_name] = server_type["name"]
12
- row_attributes[:ram] = server_type["ram"]
13
- row_attributes[:cores] = server_type["cores"]
14
- row_attributes[:disk] = server_type["disk_size"].to_i
15
- end
16
-
17
- if image
18
- row_attributes[:image_name] = image.name
19
- row_attributes[:arch] = image.arch
20
- row_attributes[:image_username] = image.username
21
- end
7
+ if server_type
8
+ attrs[:type] = server_type["id"]
9
+ attrs[:type_handle] = server_type["handle"]
10
+ attrs[:type_name] = server_type["name"]
11
+ attrs[:ram] = server_type["ram"]
12
+ attrs[:cores] = server_type["cores"]
13
+ attrs[:disk] = server_type["disk_size"].to_i
14
+ end
22
15
 
23
- row_attributes[:private_ips] = interfaces.map { |i| i["ipv4_address"] }.join(", ")
24
- row_attributes[:ipv6_address] = interfaces.map { |i| i["ipv6_address"] }.join(", ")
16
+ if image
17
+ attrs[:image_name] = image.name
18
+ attrs[:arch] = image.arch
19
+ attrs[:image_username] = image.username
20
+ end
25
21
 
26
- row_attributes[:cloud_ip_ids] = cloud_ips.map { |i| i["id"] }.join(", ")
27
- row_attributes[:cloud_ipv4s] = cloud_ips.map { |i| i["public_ipv4"] }.join(", ")
28
- row_attributes[:cloud_ipv6s] = cloud_ips.map { |i| i["public_ipv6"] }.join(", ")
29
- row_attributes[:snapshots] = snapshots.map { |i| i["id"] }.join(", ")
22
+ attrs[:private_ips] = interfaces.map { |i| i["ipv4_address"] }.join(", ")
23
+ attrs[:ipv6_address] = interfaces.map { |i| i["ipv6_address"] }.join(", ")
30
24
 
31
- if server_groups
32
- row_attributes[:server_groups] = server_groups.map { |sg| sg["id"] }.join(", ")
33
- end
25
+ attrs[:cloud_ip_ids] = cloud_ips.map { |i| i["id"] }.join(", ")
26
+ attrs[:cloud_ipv4s] = cloud_ips.map { |i| i["public_ipv4"] }.join(", ")
27
+ attrs[:cloud_ipv6s] = cloud_ips.map { |i| i["public_ipv6"] }.join(", ")
28
+ attrs[:snapshots] = snapshots.map { |i| i["id"] }.join(", ")
34
29
 
35
- row_attributes[:volumes] = volume_ids if volumes
30
+ if server_groups
31
+ attrs[:server_groups] = server_groups.map { |sg| sg["id"] }.join(", ")
32
+ end
36
33
 
37
- row_attributes
34
+ attrs[:volumes] = volume_ids if volumes
35
+ end.to_h
38
36
  end
39
37
 
40
38
  def volume_ids
@@ -1,9 +1,9 @@
1
1
  module Brightbox
2
2
  class DetailedServerGroup < ServerGroup
3
3
  def to_row
4
- row_attributes = super
4
+ row_attributes = attributes
5
5
  row_attributes[:firewall_policy] = firewall_policy && firewall_policy.id
6
- row_attributes
6
+ row_attributes.to_h
7
7
  end
8
8
 
9
9
  def self.default_field_order
@@ -15,15 +15,11 @@ module Brightbox
15
15
  end
16
16
 
17
17
  def attributes
18
- t = fog_model.attributes
19
- t[:name] = name
20
- t[:description] = description
21
- t[:server_group] = server_group_id
22
- t
23
- end
24
-
25
- def to_row
26
- attributes
18
+ fog_attributes.tap do |attrs|
19
+ attrs[:name] = name
20
+ attrs[:description] = description
21
+ attrs[:server_group] = server_group_id
22
+ end
27
23
  end
28
24
 
29
25
  def self.default_field_order
@@ -19,24 +19,23 @@ module Brightbox
19
19
  end
20
20
 
21
21
  def attributes
22
- t = @attributes || fog_model.attributes
23
- t[:sport] = t[:source_port]
24
- t[:dport] = t[:destination_port]
25
- t[:firewall_policy] = t[:firewall_policy_id]
26
- t[:icmp_type] = t[:icmp_type_name]
27
- t
28
- end
29
-
30
- def to_row
31
- attrs = attributes.dup
32
- %i[protocol source sport destination dport icmp_type].each do |key|
33
- attrs[key] = attributes[key] || "-"
22
+ (@attributes || fog_attributes).tap do |attrs|
23
+ attrs[:sport] = attrs[:source_port]
24
+ attrs[:dport] = attrs[:destination_port]
25
+ attrs[:firewall_policy] = attrs[:firewall_policy_id]
26
+ attrs[:icmp_type] = attrs[:icmp_type_name]
34
27
  end
35
- attrs
36
28
  end
37
29
 
38
- def ret_val(attributes, key)
39
- attributes[key] || "-"
30
+ def to_row
31
+ attributes.merge(
32
+ protocol: attributes[:protocol] || "-",
33
+ source: attributes[:source] || "-",
34
+ sport: attributes[:sport] || "-",
35
+ destination: attributes[:destination] || "-",
36
+ dport: attributes[:dport] || "-",
37
+ icmp_type: attributes[:icmp_type] || "-"
38
+ )
40
39
  end
41
40
 
42
41
  def self.default_field_order
@@ -68,31 +68,32 @@ module Brightbox
68
68
  end
69
69
 
70
70
  def status
71
- if fog_model.attributes[:status] == "available"
71
+ if fog_attributes[:status] == "available"
72
72
  public? ? "public" : "private"
73
+ elsif fog_attributes[:status] == "deprecated"
74
+ public? ? "deprecated" : "private"
73
75
  else
74
- fog_model.attributes[:status]
76
+ fog_attributes[:status]
75
77
  end
76
78
  end
77
79
 
78
80
  def to_row
79
- o = fog_model.attributes
80
- o[:id] = fog_model.id
81
- o[:status] = status
82
- o[:locked] = locked?
83
- o[:username] = username
84
- o[:arch] = arch
85
- o[:name] = name.to_s + " (#{arch})"
86
- o[:owner] = owner_id
87
- o[:owner] = "brightbox" if official
88
- o[:type] = type
89
- o[:created_at] = created_at
90
- o[:created_on] = created_on
91
- o[:description] = description if description
92
- o[:licence_name] = licence_name
93
- o[:size] = virtual_size
94
- o[:min_ram] = min_ram
95
- o
81
+ fog_attributes.merge(
82
+ id: fog_model.id,
83
+ status: status,
84
+ locked: locked?,
85
+ username: username,
86
+ arch: arch,
87
+ name: name.to_s + " (#{arch})",
88
+ owner: official ? "brightbox" : owner_id,
89
+ type: type,
90
+ created_at: created_at,
91
+ created_on: created_on,
92
+ description: description,
93
+ licence_name: licence_name,
94
+ size: virtual_size,
95
+ min_ram: min_ram
96
+ )
96
97
  end
97
98
 
98
99
  def public?
@@ -100,7 +101,7 @@ module Brightbox
100
101
  end
101
102
 
102
103
  def status_sort_code
103
- case fog_model.attributes[:status]
104
+ case fog_attributes[:status]
104
105
  when "available"
105
106
  (public? ? 1 : 2)
106
107
  when "deprecated"
@@ -0,0 +1,50 @@
1
+ # A simpler wrapper to allows either String or Symbol keys to be used
2
+ # when accessing attributes since fog applies a change on the top
3
+ # level resulting in a mix of both which has introduced issues.
4
+ class IndifferentAccessHash
5
+ def initialize(hash)
6
+ @hash = hash
7
+ end
8
+
9
+ # @param key [String, Symbol] the key to look up
10
+ # @return [Object] the value of the key
11
+ def [](key)
12
+ value = @hash[key.to_s] || @hash[key.to_sym]
13
+ wrap(value)
14
+ end
15
+
16
+ # @param key [String, Symbol] the key to set
17
+ # @param value [Object] the value to set
18
+ # @return [Object] the value of the key
19
+ def []=(key, value)
20
+ @hash[key.to_sym] = value
21
+ end
22
+
23
+ # @param other [Object] the object to compare
24
+ # @return [Object] the result of the comparison
25
+ def ==(other)
26
+ @hash == (other.is_a?(IndifferentAccessHash) ? other.to_h : other)
27
+ end
28
+
29
+ def method_missing(method, *args, &block)
30
+ @hash.send(method, *args, &block)
31
+ end
32
+
33
+ def to_h
34
+ @hash
35
+ end
36
+
37
+ private
38
+
39
+ # This is to handle nested hashes to avoid the original issue again
40
+ def wrap(value)
41
+ case value
42
+ when Hash
43
+ IndifferentAccessHash.new(value)
44
+ when Array
45
+ value.map { |v| wrap(v) }
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
@@ -3,16 +3,48 @@ module Brightbox
3
3
  def self.require_account?; true; end
4
4
 
5
5
  def self.create(options)
6
+ options.delete(:buffer_size) if options[:buffer_size].nil?
7
+ options[:buffer_size] = options[:buffer_size].to_i if options[:buffer_size]
8
+
6
9
  new(conn.load_balancers.create(options))
7
10
  end
8
11
 
9
- def attributes
10
- fog_model.attributes
12
+ def acme_cert
13
+ if attributes[:acme] && attributes[:acme][:certificate]
14
+ OpenStruct.new(
15
+ :expires_at => attributes[:acme][:certificate][:expires_at],
16
+ :fingerprint => attributes[:acme][:certificate][:fingerprint],
17
+ :issued_at => attributes[:acme][:certificate][:issued_at],
18
+ :subjects => attributes[:acme][:certificate][:domains].join(",")
19
+ )
20
+ else
21
+ OpenStruct.new(
22
+ :expires_at => "",
23
+ :fingerprint => "",
24
+ :issued_at => "",
25
+ :subjects => ""
26
+ )
27
+ end
28
+ end
29
+
30
+ def formatted_acme_domains
31
+ return "" unless attributes[:acme]
32
+
33
+ attributes[:acme][:domains].map do |domain|
34
+ [domain[:identifier], domain[:status]].join(":")
35
+ end.join(",")
36
+ rescue StandardError
37
+ ""
11
38
  end
12
39
 
13
40
  def to_row
14
41
  attributes.merge(
15
42
  :locked => locked?,
43
+ :acme_domains => formatted_acme_domains,
44
+ :acme_cert_expires_at => acme_cert.expires_at,
45
+ :acme_cert_fingerprint => acme_cert.fingerprint,
46
+ :acme_cert_issued_at => acme_cert.issued_at,
47
+ :acme_cert_subjects => acme_cert.subjects,
16
48
  :ssl_minimum_version => ssl_minimum_version,
17
49
  :ssl_issuer => certificate_issuer,
18
50
  :ssl_subject => certificate_subject,
@@ -31,11 +63,13 @@ module Brightbox
31
63
  end
32
64
 
33
65
  def cloud_ip_ids
34
- @cloud_ip_ids ||= attributes["cloud_ips"].map { |n| n["id"] } if attributes["cloud_ips"]
66
+ cips = attributes["cloud_ips"] || attributes[:cloud_ips]
67
+ @cloud_ip_ids ||= cips.map { |n| n["id"] } if cips
35
68
  end
36
69
 
37
70
  def cloud_ips
38
- @cloud_ips ||= attributes["cloud_ips"].map { |n| n["public_ip"] } if attributes["cloud_ips"]
71
+ cips = attributes["cloud_ips"] || attributes[:cloud_ips]
72
+ @cloud_ips ||= cips.map { |n| n["public_ip"] } if cips
39
73
  end
40
74
 
41
75
  def listeners
@@ -34,15 +34,11 @@ module Brightbox
34
34
  fog_model.destroy
35
35
  end
36
36
 
37
- def attributes
38
- fog_model.attributes
39
- end
40
-
41
37
  def to_row
42
- o = attributes
43
- o[:servers] = server_string
44
- o[:server_count] = server_count
45
- o
38
+ super.merge(
39
+ servers: server_string,
40
+ server_count: server_count
41
+ ).to_h
46
42
  end
47
43
 
48
44
  def server_ids
@@ -37,25 +37,31 @@ module Brightbox
37
37
  end
38
38
 
39
39
  def attributes
40
- a = fog_model.attributes
41
- a[:image] = image_id
42
- a[:created_at] = created_at
43
- a[:created_on] = created_on
44
- a[:type] = server_type["handle"]
45
- a[:status] = fog_model.state
46
- a[:locked] = locked?
47
- a[:zone] = zone && zone["handle"]
48
- a[:hostname] = id
49
- a[:public_hostname] = "public.#{fqdn}" unless cloud_ips.empty?
50
- a[:ipv6_hostname] = ipv6_fqdn if interfaces.any? { |i| i["ipv6_address"] }
51
- a
40
+ fog_attributes.tap do |attrs|
41
+ attrs[:created_at] = created_at
42
+ attrs[:created_on] = created_on
43
+ attrs[:hostname] = hostname
44
+ attrs[:image] = image_id
45
+ attrs[:locked] = locked?
46
+ attrs[:status] = fog_model.state
47
+ attrs[:type] = server_type["handle"]
48
+ attrs[:zone] = zone && zone["handle"]
49
+
50
+ unless cloud_ips.empty?
51
+ attrs[:public_hostname] = "public.#{fqdn}"
52
+ end
53
+
54
+ if interfaces.any? { |i| i["ipv6_address"] }
55
+ attrs[:ipv6_hostname] = ipv6_fqdn
56
+ end
57
+ end
52
58
  end
53
59
 
54
60
  def to_row
55
- o = attributes
56
- o[:cloud_ip_ids] = cloud_ips.map { |i| i["id"] }
57
- o[:ips] = interfaces.map { |i| i["ipv4_address"] }.join(", ")
58
- o
61
+ attributes.merge(
62
+ cloud_ips: cloud_ips.map { |i| i["public_ip"] }.join(", "),
63
+ ips: interfaces.map { |i| i["ipv4_address"] }.join(", ")
64
+ )
59
65
  end
60
66
 
61
67
  def deleted?
@@ -3,10 +3,10 @@ module Brightbox
3
3
  def self.require_account?; true; end
4
4
 
5
5
  def attributes
6
- o = fog_model.attributes
7
- o[:ram] = ram
8
- o[:disk] = disk
9
- o
6
+ fog_attributes.tap do |attrs|
7
+ attrs[:ram] = ram
8
+ attrs[:disk] = disk
9
+ end
10
10
  end
11
11
 
12
12
  def ram
@@ -17,10 +17,6 @@ module Brightbox
17
17
  fog_model.disk.to_i
18
18
  end
19
19
 
20
- def to_row
21
- attributes
22
- end
23
-
24
20
  def render_cell
25
21
  fog_model.handle
26
22
  end
@@ -69,7 +69,7 @@ module Brightbox
69
69
  def to_row
70
70
  row_attributes = attributes
71
71
  row_attributes[:account] = attributes[:account]["id"]
72
- row_attributes
72
+ row_attributes.to_h
73
73
  end
74
74
  end
75
75
  end
@@ -1,11 +1,9 @@
1
1
  module Brightbox
2
2
  class User < Api
3
- def attributes
4
- fog_model.attributes
5
- end
6
-
7
3
  def to_row
8
- attributes.merge(:accounts => accounts.size)
4
+ attributes.merge(
5
+ accounts: accounts.size
6
+ )
9
7
  end
10
8
 
11
9
  def self.all
@@ -1,3 +1,3 @@
1
1
  module Brightbox
2
- VERSION = "4.8.0".freeze unless defined?(Brightbox::VERSION)
2
+ VERSION = "5.0.0.rc1".freeze unless defined?(Brightbox::VERSION)
3
3
  end
@@ -57,19 +57,15 @@ module Brightbox
57
57
  end
58
58
 
59
59
  def attributes
60
- a = fog_model.attributes
61
- a[:id] = fog_model.id
62
- a[:image] = image_id
63
- a[:locked] = locked?
64
- a[:server] = server_id
65
- a[:status] = state
66
- a[:type] = storage_type
67
- a[:zone] = zone_id
68
- a
69
- end
70
-
71
- def to_row
72
- attributes
60
+ super.merge(
61
+ id: fog_model.id,
62
+ image: image_id,
63
+ locked: locked?,
64
+ server: server_id,
65
+ status: state,
66
+ type: storage_type,
67
+ zone: zone_id
68
+ )
73
69
  end
74
70
 
75
71
  def update(options)
@@ -2,10 +2,6 @@ module Brightbox
2
2
  class Zone < Api
3
3
  def self.require_account?; true; end
4
4
 
5
- def to_row
6
- attributes
7
- end
8
-
9
5
  def self.all
10
6
  conn.zones
11
7
  end
data/lib/brightbox_cli.rb CHANGED
@@ -71,6 +71,7 @@ require_relative "brightbox/cli/config"
71
71
  require_relative "brightbox-cli/connection_manager"
72
72
  require_relative "brightbox-cli/tables"
73
73
  require_relative "brightbox-cli/logging"
74
+ require_relative "brightbox-cli/indifferent_access_hash"
74
75
  require_relative "brightbox-cli/api"
75
76
  require_relative "brightbox-cli/config/cache"
76
77
  require_relative "brightbox-cli/config/gpg_encrypted_passwords"
@@ -59,7 +59,9 @@ describe "brightbox cloudips update" do
59
59
 
60
60
  it "puts new name in update" do
61
61
  expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
62
- expect(stderr).to eq("")
62
+
63
+ expect(stderr).to be_empty unless ENV["DEBUG"]
64
+
63
65
  expect(stdout).to include("cip-12345")
64
66
  expect(stdout).to include("New name")
65
67
  end
@@ -82,7 +84,7 @@ describe "brightbox cloudips update" do
82
84
 
83
85
  it "puts new name in update" do
84
86
  expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
85
- expect(stderr).to eq("")
87
+ expect(stderr).to be_empty unless ENV["DEBUG"]
86
88
  expect(stdout).to include("cip-12345")
87
89
  end
88
90
  end
@@ -114,7 +116,7 @@ describe "brightbox cloudips update" do
114
116
  end
115
117
 
116
118
  it "puts new name in update" do
117
- expect(stderr).to eq("")
119
+ expect(stderr).to be_empty unless ENV["DEBUG"]
118
120
  expect(stdout).to include("cip-dfsa3")
119
121
  expect(stdout).to include("domain.example")
120
122
  end
@@ -146,7 +148,7 @@ describe "brightbox cloudips update" do
146
148
  end
147
149
 
148
150
  it "puts new name in update" do
149
- expect(stderr).to eq("")
151
+ expect(stderr).to be_empty unless ENV["DEBUG"]
150
152
  expect(stdout).to include("cip-dfsa3")
151
153
  end
152
154
  end
@@ -155,7 +157,7 @@ describe "brightbox cloudips update" do
155
157
  let(:argv) { ["cloudips", "update", "--reverse-dns", "domain.example", "--delete-reverse-dns", "cip-dfsa3"] }
156
158
 
157
159
  it "puts new name in update" do
158
- expect(stderr).to eq("ERROR: You must either specify a reverse DNS record or --delete-reverse-dns\n")
160
+ expect(stderr).to include("ERROR: You must either specify a reverse DNS record or --delete-reverse-dns\n")
159
161
  expect(stdout).to eq("")
160
162
  end
161
163
  end
@@ -109,7 +109,7 @@ describe "brightbox configmaps create" do
109
109
  it "does not error" do
110
110
  expect { output }.to_not raise_error
111
111
 
112
- expect(stderr).to eq("ERROR: Config map data was not valid JSON\n")
112
+ expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
113
113
 
114
114
  expect(stdout).to eq("")
115
115
  end
@@ -156,7 +156,7 @@ describe "brightbox configmaps create" do
156
156
  it "does not error" do
157
157
  expect { output }.to_not raise_error
158
158
 
159
- expect(stderr).to eq("Creating config map\n")
159
+ expect(stderr).to include("Creating config map\n")
160
160
 
161
161
  aggregate_failures do
162
162
  expect(stdout).to match("cfg-s432l")
@@ -169,7 +169,7 @@ describe "brightbox configmaps create" do
169
169
  it "does not error" do
170
170
  expect { output }.to_not raise_error
171
171
 
172
- expect(stderr).to eq("ERROR: Config map data was not valid JSON\n")
172
+ expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
173
173
 
174
174
  expect(stdout).to eq("")
175
175
  end
@@ -219,7 +219,7 @@ describe "brightbox configmaps create" do
219
219
  it "does not error" do
220
220
  expect { output }.to_not raise_error
221
221
 
222
- expect(stderr).to eq("Creating config map\n")
222
+ expect(stderr).to include("Creating config map\n")
223
223
 
224
224
  aggregate_failures do
225
225
  expect(stdout).to match("cfg-mj53s")
@@ -232,7 +232,7 @@ describe "brightbox configmaps create" do
232
232
  it "does not error" do
233
233
  expect { output }.to_not raise_error
234
234
 
235
- expect(stderr).to eq("ERROR: Config map data was not valid JSON\n")
235
+ expect(stderr).to include("ERROR: Config map data was not valid JSON\n")
236
236
 
237
237
  expect(stdout).to eq("")
238
238
  end
@@ -248,7 +248,7 @@ describe "brightbox configmaps create" do
248
248
  it "does not error" do
249
249
  expect { output }.to_not raise_error
250
250
 
251
- expect(stderr).to eq("ERROR: Config map data can only be passed by either 'data' or 'data-file'\n")
251
+ expect(stderr).to include("ERROR: Config map data can only be passed by either 'data' or 'data-file'\n")
252
252
 
253
253
  expect(stdout).to eq("")
254
254
  end
@@ -26,7 +26,7 @@ describe "brightbox configmaps destroy" do
26
26
  it "does not error" do
27
27
  expect { output }.to_not raise_error
28
28
 
29
- expect(stderr).to eq("ERROR: You must specify config map IDs as arguments\n")
29
+ expect(stderr).to include("ERROR: You must specify config map IDs as arguments\n")
30
30
 
31
31
  expect(stdout).to match("")
32
32
  end
@@ -35,7 +35,7 @@ describe "brightbox configmaps list" do
35
35
  it "does not error" do
36
36
  expect { output }.to_not raise_error
37
37
 
38
- expect(stderr).to eq("")
38
+ expect(stderr).to be_empty unless ENV["DEBUG"]
39
39
 
40
40
  aggregate_failures do
41
41
  expect(stdout).to match("id.*name")
@@ -35,7 +35,7 @@ describe "brightbox configmaps show" do
35
35
  it "does not error" do
36
36
  expect { output }.to_not raise_error
37
37
 
38
- expect(stderr).to eq("")
38
+ expect(stderr).to be_empty unless ENV["DEBUG"]
39
39
 
40
40
  aggregate_failures do
41
41
  expect(stdout).to match("id: cfg-12345")
@@ -81,7 +81,7 @@ describe "brightbox configmaps show" do
81
81
  it "does not error" do
82
82
  expect { output }.to_not raise_error
83
83
 
84
- expect(stderr).to eq("ERROR: You can only access data for a single config map at a time\n")
84
+ expect(stderr).to include("ERROR: You can only access data for a single config map at a time\n")
85
85
 
86
86
  expect(stdout).to eq("")
87
87
  end
@@ -137,7 +137,7 @@ describe "brightbox configmaps show" do
137
137
  it "does not error" do
138
138
  expect { output }.to_not raise_error
139
139
 
140
- expect(stderr).to eq("")
140
+ expect(stderr).to be_empty unless ENV["DEBUG"]
141
141
 
142
142
  expect(stdout).to eq(%({"key":"value","name":"key name"}\n))
143
143
  end