kitchen-digitalocean 0.11.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/digitalocean.rb +39 -44
- data/lib/kitchen/driver/digitalocean_version.rb +1 -1
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e672cac2c1f48149a9137a73ed6de23524007a0166450dab83c4bd5298bb961d
|
4
|
+
data.tar.gz: b87d05c0319e8e5f7c27008c414019991b22f2ad5d8df87c5710e23c69185798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de30257dd64980a1066e3a24ce2e6ff33819948cd6e969da3653a97bef81854835a4611238234af18b5c818f5cafb1dab0e16d487248d0651497b8334e27e217
|
7
|
+
data.tar.gz: 6fb5d6cb238690e9863c67de3c8ef6bfd4c54809b4ea1086f20e2bf0c92c0aec34dfb96df94f03c8f2b5f35d78baff68960f107d120e660cfd02d401df5b49f1
|
@@ -17,12 +17,13 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
20
|
+
require "benchmark" unless defined?(Benchmark)
|
21
|
+
require "droplet_kit" unless defined?(DropletKit)
|
22
|
+
require "kitchen"
|
23
|
+
require "etc" unless defined?(Etc)
|
24
|
+
require "socket" unless defined?(Socket)
|
25
|
+
require "json" unless defined?(JSON)
|
26
|
+
autoload :YAML, "yaml"
|
26
27
|
|
27
28
|
module Kitchen
|
28
29
|
module Driver
|
@@ -30,9 +31,9 @@ module Kitchen
|
|
30
31
|
#
|
31
32
|
# @author Greg Fitzgerald <greg@gregf.org>
|
32
33
|
class Digitalocean < Kitchen::Driver::SSHBase
|
33
|
-
default_config :username,
|
34
|
-
default_config :port,
|
35
|
-
default_config :size,
|
34
|
+
default_config :username, "root"
|
35
|
+
default_config :port, "22"
|
36
|
+
default_config :size, "s-1vcpu-1gb"
|
36
37
|
default_config :monitoring, false
|
37
38
|
default_config(:image, &:default_image)
|
38
39
|
default_config(:server_name, &:default_name)
|
@@ -43,40 +44,34 @@ module Kitchen
|
|
43
44
|
default_config :firewalls, nil
|
44
45
|
default_config :vpcs, nil
|
45
46
|
|
46
|
-
|
47
47
|
default_config :region do
|
48
|
-
ENV[
|
48
|
+
ENV["DIGITALOCEAN_REGION"] || "nyc1"
|
49
49
|
end
|
50
50
|
|
51
51
|
default_config :digitalocean_access_token do
|
52
|
-
ENV[
|
52
|
+
ENV["DIGITALOCEAN_ACCESS_TOKEN"]
|
53
53
|
end
|
54
54
|
|
55
55
|
default_config :ssh_key_ids do
|
56
|
-
ENV[
|
56
|
+
ENV["DIGITALOCEAN_SSH_KEY_IDS"] || ENV["SSH_KEY_IDS"]
|
57
57
|
end
|
58
58
|
|
59
59
|
required_config :digitalocean_access_token
|
60
60
|
required_config :ssh_key_ids
|
61
61
|
|
62
62
|
PLATFORM_SLUG_MAP = {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
'freebsd-12' => 'freebsd-12-x64-zfs',
|
76
|
-
'ubuntu-16' => 'ubuntu-16-04-x64',
|
77
|
-
'ubuntu-18' => 'ubuntu-18-04-x64',
|
78
|
-
'ubuntu-19' => 'ubuntu-19-10-x64',
|
79
|
-
'ubuntu-20' => 'ubuntu-20-04-x64'
|
63
|
+
"centos-7" => "centos-7-x64",
|
64
|
+
"centos-8" => "centos-8-x64",
|
65
|
+
"debian-9" => "debian-9-x64",
|
66
|
+
"debian-10" => "debian-10-x64",
|
67
|
+
"debian-11" => "debian-11-x64",
|
68
|
+
"fedora-32" => "fedora-32-x64",
|
69
|
+
"fedora-33" => "fedora-33-x64",
|
70
|
+
"freebsd-11" => "freebsd-11-x64-zfs",
|
71
|
+
"freebsd-12" => "freebsd-12-x64-zfs",
|
72
|
+
"ubuntu-16" => "ubuntu-16-04-x64",
|
73
|
+
"ubuntu-18" => "ubuntu-18-04-x64",
|
74
|
+
"ubuntu-20" => "ubuntu-20-04-x64",
|
80
75
|
}.freeze
|
81
76
|
|
82
77
|
def create(state)
|
@@ -91,29 +86,29 @@ module Kitchen
|
|
91
86
|
droplet = client.droplets.find(id: state[:server_id])
|
92
87
|
|
93
88
|
break if droplet && droplet.networks[:v4] &&
|
94
|
-
|
89
|
+
droplet.networks[:v4].any? { |n| n[:type] == "public" }
|
95
90
|
end
|
96
91
|
droplet ||= client.droplets.find(id: state[:server_id])
|
97
92
|
|
98
93
|
state[:hostname] = droplet.networks[:v4]
|
99
|
-
|
94
|
+
.find { |n| n[:type] == "public" }["ip_address"]
|
100
95
|
|
101
96
|
if config[:firewalls]
|
102
|
-
debug(
|
97
|
+
debug("trying to add the firewall by id")
|
103
98
|
fw_ids = if config[:firewalls].is_a?(String)
|
104
99
|
config[:firewalls].split(/\s+|,\s+|,+/)
|
105
100
|
elsif config[:firewalls].is_a?(Array)
|
106
101
|
config[:firewalls]
|
107
102
|
else
|
108
|
-
warn(
|
103
|
+
warn("firewalls attribute is not string/array, ignoring")
|
109
104
|
[]
|
110
105
|
end
|
111
|
-
debug("firewall : #{fw_ids.inspect
|
106
|
+
debug("firewall : #{YAML.dump(fw_ids.inspect)}")
|
112
107
|
fw_ids.each do |fw_id|
|
113
108
|
firewall = client.firewalls.find(id: fw_id)
|
114
109
|
if firewall
|
115
110
|
client.firewalls
|
116
|
-
|
111
|
+
.add_droplets([droplet.id], id: firewall.id)
|
117
112
|
debug("firewall added: #{firewall.id}")
|
118
113
|
else
|
119
114
|
warn("firewalls id: '#{fw_id}' was not found in api, ignoring")
|
@@ -135,7 +130,7 @@ module Kitchen
|
|
135
130
|
|
136
131
|
break unless droplet
|
137
132
|
|
138
|
-
if droplet.status !=
|
133
|
+
if droplet.status != "new"
|
139
134
|
client.droplets.delete(id: state[:server_id])
|
140
135
|
break
|
141
136
|
end
|
@@ -168,11 +163,11 @@ module Kitchen
|
|
168
163
|
# Total: 63
|
169
164
|
def default_name
|
170
165
|
[
|
171
|
-
instance.name.gsub(/\W/,
|
172
|
-
(Etc.getlogin ||
|
173
|
-
Socket.gethostname.gsub(/\W/,
|
174
|
-
Array.new(7) { rand(36).to_s(36) }.join
|
175
|
-
].join(
|
166
|
+
instance.name.gsub(/\W/, "")[0..14],
|
167
|
+
(Etc.getlogin || "nologin").gsub(/\W/, "")[0..14],
|
168
|
+
Socket.gethostname.gsub(/\W/, "")[0..22],
|
169
|
+
Array.new(7) { rand(36).to_s(36) }.join,
|
170
|
+
].join("-").tr("_", "-")
|
176
171
|
end
|
177
172
|
|
178
173
|
private
|
@@ -207,8 +202,8 @@ module Kitchen
|
|
207
202
|
resp = client.droplets.create(droplet)
|
208
203
|
|
209
204
|
if resp.class != DropletKit::Droplet
|
210
|
-
error JSON.parse(resp)[
|
211
|
-
error
|
205
|
+
error JSON.parse(resp)["message"]
|
206
|
+
error "Please check your access token is set correctly."
|
212
207
|
else
|
213
208
|
resp
|
214
209
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-digitalocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Fitzgerald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: droplet_kit
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '1.17'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '4'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,21 +49,7 @@ dependencies:
|
|
49
49
|
version: '1.17'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: bundler
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0'
|
60
|
-
type: :development
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0'
|
52
|
+
version: '4'
|
67
53
|
- !ruby/object:Gem::Dependency
|
68
54
|
name: cane
|
69
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,19 +121,19 @@ dependencies:
|
|
135
121
|
- !ruby/object:Gem::Version
|
136
122
|
version: '3.8'
|
137
123
|
- !ruby/object:Gem::Dependency
|
138
|
-
name:
|
124
|
+
name: chefstyle
|
139
125
|
requirement: !ruby/object:Gem::Requirement
|
140
126
|
requirements:
|
141
|
-
- -
|
127
|
+
- - '='
|
142
128
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
129
|
+
version: 2.1.0
|
144
130
|
type: :development
|
145
131
|
prerelease: false
|
146
132
|
version_requirements: !ruby/object:Gem::Requirement
|
147
133
|
requirements:
|
148
|
-
- -
|
134
|
+
- - '='
|
149
135
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
136
|
+
version: 2.1.0
|
151
137
|
- !ruby/object:Gem::Dependency
|
152
138
|
name: simplecov
|
153
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
198
|
requirements:
|
213
199
|
- - ">="
|
214
200
|
- !ruby/object:Gem::Version
|
215
|
-
version: '
|
201
|
+
version: '2.5'
|
216
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
203
|
requirements:
|
218
204
|
- - ">="
|
219
205
|
- !ruby/object:Gem::Version
|
220
206
|
version: '0'
|
221
207
|
requirements: []
|
222
|
-
rubygems_version: 3.
|
208
|
+
rubygems_version: 3.2.22
|
223
209
|
signing_key:
|
224
210
|
specification_version: 4
|
225
211
|
summary: A Test Kitchen Driver for Digital Ocean
|