kitchen-google 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -7
- data/CHANGELOG.md +13 -1
- data/README.md +58 -1
- data/lib/kitchen/driver/gce.rb +22 -17
- data/lib/kitchen/driver/gce_version.rb +1 -1
- data/spec/kitchen/driver/gce_spec.rb +38 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de129cbfac2e9fe5573b026c9afeccc09f1cf36
|
4
|
+
data.tar.gz: 844a3ac15fbfe368d8e1bb11f8735d4aaeda9048
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc2c20c9b86b5172da99dd5b19c007456d0cf6a6391b66ef7cff44a27282bfa3ee699b5afede66b664cbfe0fac8e29b47c8d7264611151690353df407ebba036
|
7
|
+
data.tar.gz: 3e711713b9f28027b5f8529e8c0752a4434962e7bf1ac230b8188cc46bc04f635ae9503193ce5ed682cd4a2078b0017d953db45911bd0ff96e6cc4825ad04d91
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 1.3.0 / 2017-09-15
|
2
|
+
|
3
|
+
* #43: support adding custom metadata to instances
|
4
|
+
* #52: update user agent string, doc update to replace deprecated gcloud switches
|
5
|
+
* #53: Rubocop and Travis updates
|
6
|
+
* #54: option to set a custom instance name
|
7
|
+
* #55: doc update on how to inject ssh keys with custom metadata
|
8
|
+
|
9
|
+
## 1.2.0 / 2017-02-02
|
10
|
+
|
11
|
+
* #44: support image_family
|
12
|
+
|
1
13
|
## 1.1.0 / 2016-03-17
|
2
14
|
|
3
15
|
* #32: Rubocop and Rake fixes to address Travis test issues
|
@@ -47,7 +59,7 @@
|
|
47
59
|
|
48
60
|
### Improvements
|
49
61
|
|
50
|
-
* #9: Dependency updates: Remove faraday version constraint; require newer
|
62
|
+
* #9: Dependency updates: Remove faraday version constraint; require newer
|
51
63
|
ridley gem.
|
52
64
|
|
53
65
|
## 0.1.0 / 2014-03-29
|
data/README.md
CHANGED
@@ -38,6 +38,8 @@ If you already have a file you'd like to use that is in a different location, se
|
|
38
38
|
|
39
39
|
### SSH Keys
|
40
40
|
|
41
|
+
#### Project Level Keys
|
42
|
+
|
41
43
|
In order to bootstrap Linux nodes, you will first need to ensure your SSH
|
42
44
|
keys are set up correctly. Ensure your SSH public key is properly entered
|
43
45
|
into your project's Metadata tab in the GCP Console. GCE will add your key
|
@@ -57,7 +59,7 @@ Alternatively, the Google Cloud SDK (a.k.a. `gcloud`) will create a SSH key
|
|
57
59
|
for you when you create and access your first instance:
|
58
60
|
|
59
61
|
1. Create a small test instance:
|
60
|
-
`gcloud compute instances create instance1 --zone us-central1-f --image
|
62
|
+
`gcloud compute instances create instance1 --zone us-central1-f --image-family=debian-8 --image-project=debian-cloud --machine-type g1-small`
|
61
63
|
1. Ensure your SSH keys allow access to the new instance
|
62
64
|
`gcloud compute ssh instance1 --zone us-central1-f`
|
63
65
|
1. Log out and delete the instance
|
@@ -77,6 +79,28 @@ transport:
|
|
77
79
|
You can find [more information on configuring SSH keys](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys) in
|
78
80
|
the Google Compute Engine documentation.
|
79
81
|
|
82
|
+
#### Instance Level Keys
|
83
|
+
|
84
|
+
It is possible to [add keys](https://cloud.google.com/compute/docs/storing-retrieving-metadata#default)
|
85
|
+
that are not included in the project's metadata to an instance. Do this by
|
86
|
+
listing additional keys in custom metadata (see below for more about [setting
|
87
|
+
metadata](#metadata)).
|
88
|
+
|
89
|
+
For example, given a workspace that has environment variables set for `USER`
|
90
|
+
(the username to connect as) and `SSH_KEY` (the path to the private key to use):
|
91
|
+
|
92
|
+
```yaml
|
93
|
+
driver:
|
94
|
+
name: gce
|
95
|
+
...
|
96
|
+
metadata:
|
97
|
+
ssh-keys: <%= ENV['USER'] + ':' + IO.binread("#{ENV['SSH_KEY']}.pub").rstrip! %>
|
98
|
+
|
99
|
+
transport:
|
100
|
+
username: <%= ENV['USER'] %>
|
101
|
+
ssh_key: <%= ENV['SSH_KEY'] %>
|
102
|
+
```
|
103
|
+
|
80
104
|
## Installation
|
81
105
|
|
82
106
|
Install the gem with:
|
@@ -157,6 +181,15 @@ Example: `us-central1`
|
|
157
181
|
|
158
182
|
This parameter will be ignored if `zone` is specified.
|
159
183
|
|
184
|
+
### `inst_name`
|
185
|
+
|
186
|
+
**Optional** Name to give to instance. If given, must be under 63 characters
|
187
|
+
in length. Any character that is not alphanumeric or a hyphen will be converted
|
188
|
+
to a hyphen. Unlike EC2's "Name" tag, this is used as an instance identifier and
|
189
|
+
must be unique. By default, a unique name will be auto-generated; note that
|
190
|
+
auto-generated names must be used if there is more than one test suite. Default:
|
191
|
+
`tk-<suite>-<platform>-<UUID>`
|
192
|
+
|
160
193
|
### `autodelete_disk`
|
161
194
|
|
162
195
|
Boolean specifying whether or not to automatically delete boot disk
|
@@ -248,6 +281,18 @@ Amount of time, in seconds, to wait for any API interactions. Default: 600
|
|
248
281
|
|
249
282
|
Amount of time, in seconds, to refresh the status of an API interaction. Default: 2
|
250
283
|
|
284
|
+
### `metadata`
|
285
|
+
|
286
|
+
Allows custom instance metadata to be set.
|
287
|
+
The following metadata is set by default if no metadata configuration is provided:
|
288
|
+
Default:
|
289
|
+
|
290
|
+
|
291
|
+
"created-by" => "test-kitchen",
|
292
|
+
"test-kitchen-instance" => <instance.name>,
|
293
|
+
"test-kitchen-user" => <env_user>,
|
294
|
+
|
295
|
+
|
251
296
|
### Transport Settings
|
252
297
|
|
253
298
|
Beginning with Test Kitchen 1.4, settings related to the transport (i.e. how to connect
|
@@ -301,15 +346,27 @@ platforms:
|
|
301
346
|
driver:
|
302
347
|
image_project: centos-cloud
|
303
348
|
image_name: centos-7-v20170124
|
349
|
+
metadata:
|
350
|
+
application: centos
|
351
|
+
release: a
|
352
|
+
version: 7
|
304
353
|
- name: ubuntu-16.04
|
305
354
|
driver:
|
306
355
|
image_project: ubuntu-os-cloud
|
307
356
|
image_family: ubuntu-1604-lts
|
357
|
+
metadata:
|
358
|
+
application: ubuntu
|
359
|
+
release: a
|
360
|
+
version: 1604
|
308
361
|
- name: windows
|
309
362
|
driver:
|
310
363
|
image_project: windows-cloud
|
311
364
|
image_name: windows-server-2012-r2-dc-v20170117
|
312
365
|
disk_size: 50
|
366
|
+
metadata:
|
367
|
+
application: windows
|
368
|
+
release: a
|
369
|
+
version: cloud
|
313
370
|
|
314
371
|
suites:
|
315
372
|
- name: default
|
data/lib/kitchen/driver/gce.rb
CHANGED
@@ -81,6 +81,7 @@ module Kitchen
|
|
81
81
|
default_config :use_private_ip, false
|
82
82
|
default_config :wait_time, 600
|
83
83
|
default_config :refresh_rate, 2
|
84
|
+
default_config :metadata, {}
|
84
85
|
|
85
86
|
def name
|
86
87
|
"Google Compute (GCE)"
|
@@ -165,7 +166,7 @@ module Kitchen
|
|
165
166
|
@connection = Google::Apis::ComputeV1::ComputeService.new
|
166
167
|
@connection.authorization = authorization
|
167
168
|
@connection.client_options = Google::Apis::ClientOptions.new.tap do |opts|
|
168
|
-
opts.application_name = "
|
169
|
+
opts.application_name = "GoogleChefTestKitchen"
|
169
170
|
opts.application_version = Kitchen::Driver::GCE_VERSION
|
170
171
|
end
|
171
172
|
|
@@ -327,7 +328,11 @@ module Kitchen
|
|
327
328
|
end
|
328
329
|
|
329
330
|
def generate_server_name
|
330
|
-
name =
|
331
|
+
name = if config[:inst_name]
|
332
|
+
config[:inst_name]
|
333
|
+
else
|
334
|
+
"tk-#{instance.name.downcase}-#{SecureRandom.hex(3)}"
|
335
|
+
end
|
331
336
|
|
332
337
|
if name.length > 63
|
333
338
|
warn("The TK instance name (#{instance.name}) has been removed from the GCE instance name due to size limitations. Consider setting shorter platform or suite names.")
|
@@ -373,18 +378,20 @@ module Kitchen
|
|
373
378
|
"zones/#{zone}/machineTypes/#{config[:machine_type]}"
|
374
379
|
end
|
375
380
|
|
376
|
-
def
|
377
|
-
metadata
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
381
|
+
def metadata
|
382
|
+
config[:metadata].merge({
|
383
|
+
"created-by" => "test-kitchen",
|
384
|
+
"test-kitchen-instance" => instance.name,
|
385
|
+
"test-kitchen-user" => env_user,
|
386
|
+
})
|
387
|
+
end
|
382
388
|
|
389
|
+
def instance_metadata
|
383
390
|
Google::Apis::ComputeV1::Metadata.new.tap do |metadata_obj|
|
384
391
|
metadata_obj.items = metadata.each_with_object([]) do |(k, v), memo|
|
385
392
|
memo << Google::Apis::ComputeV1::Metadata::Item.new.tap do |item|
|
386
|
-
item.key = k
|
387
|
-
item.value = v
|
393
|
+
item.key = k.to_s
|
394
|
+
item.value = v.to_s
|
388
395
|
end
|
389
396
|
end
|
390
397
|
end
|
@@ -519,13 +526,11 @@ module Kitchen
|
|
519
526
|
end
|
520
527
|
|
521
528
|
def wait_for_server
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
raise
|
528
|
-
end
|
529
|
+
instance.transport.connection(state).wait_until_ready
|
530
|
+
rescue
|
531
|
+
error("Server not reachable. Destroying server...")
|
532
|
+
destroy(state)
|
533
|
+
raise
|
529
534
|
end
|
530
535
|
|
531
536
|
def zone_operation(operation_name)
|
@@ -329,7 +329,7 @@ describe Kitchen::Driver::Gce do
|
|
329
329
|
client_options = double("client_options")
|
330
330
|
|
331
331
|
expect(Google::Apis::ClientOptions).to receive(:new).and_return(client_options)
|
332
|
-
expect(client_options).to receive(:application_name=).with("
|
332
|
+
expect(client_options).to receive(:application_name=).with("GoogleChefTestKitchen")
|
333
333
|
expect(client_options).to receive(:application_version=).with(Kitchen::Driver::GCE_VERSION)
|
334
334
|
|
335
335
|
expect(Google::Apis::ComputeV1::ComputeService).to receive(:new).and_return(compute_service)
|
@@ -630,6 +630,12 @@ describe Kitchen::Driver::Gce do
|
|
630
630
|
expect(SecureRandom).to receive(:uuid).and_return("lmnop")
|
631
631
|
expect(driver.generate_server_name).to eq("tk-lmnop")
|
632
632
|
end
|
633
|
+
|
634
|
+
it "returns a specific name for the server if given in the config" do
|
635
|
+
config[:inst_name] = "the_instance_name"
|
636
|
+
|
637
|
+
expect(driver.generate_server_name).to eq("the-instance-name")
|
638
|
+
end
|
633
639
|
end
|
634
640
|
|
635
641
|
describe "#boot_disk" do
|
@@ -710,11 +716,12 @@ describe Kitchen::Driver::Gce do
|
|
710
716
|
end
|
711
717
|
|
712
718
|
describe "#instance_metadata" do
|
719
|
+
let(:item1 ) { double("item1") }
|
720
|
+
let(:item2 ) { double("item2") }
|
721
|
+
let(:item3 ) { double("item3") }
|
722
|
+
let(:metadata) { double("metadata") }
|
723
|
+
|
713
724
|
it "returns a properly-configured metadata object" do
|
714
|
-
item1 = double("item1")
|
715
|
-
item2 = double("item2")
|
716
|
-
item3 = double("item3")
|
717
|
-
metadata = double("metadata")
|
718
725
|
|
719
726
|
expect(instance).to receive(:name).and_return("instance_name")
|
720
727
|
expect(driver).to receive(:env_user).and_return("env_user")
|
@@ -732,6 +739,32 @@ describe Kitchen::Driver::Gce do
|
|
732
739
|
|
733
740
|
expect(driver.instance_metadata).to eq(metadata)
|
734
741
|
end
|
742
|
+
|
743
|
+
it "accepts custom metadata" do
|
744
|
+
foo = double("foo")
|
745
|
+
config[:metadata] = { "foo" => "bar" }
|
746
|
+
|
747
|
+
expect(instance).to receive(:name).and_return("instance_name")
|
748
|
+
expect(driver).to receive(:env_user).and_return("env_user")
|
749
|
+
|
750
|
+
expect(Google::Apis::ComputeV1::Metadata).to receive(:new).and_return(metadata)
|
751
|
+
expect(Google::Apis::ComputeV1::Metadata::Item).to receive(:new).and_return(foo)
|
752
|
+
expect(Google::Apis::ComputeV1::Metadata::Item).to receive(:new).and_return(item1)
|
753
|
+
expect(Google::Apis::ComputeV1::Metadata::Item).to receive(:new).and_return(item2)
|
754
|
+
expect(Google::Apis::ComputeV1::Metadata::Item).to receive(:new).and_return(item3)
|
755
|
+
expect(item1).to receive(:key=).with("created-by")
|
756
|
+
expect(item1).to receive(:value=).with("test-kitchen")
|
757
|
+
expect(item2).to receive(:key=).with("test-kitchen-instance")
|
758
|
+
expect(item2).to receive(:value=).with("instance_name")
|
759
|
+
expect(item3).to receive(:key=).with("test-kitchen-user")
|
760
|
+
expect(item3).to receive(:value=).with("env_user")
|
761
|
+
expect(foo).to receive(:key=).with("foo")
|
762
|
+
expect(foo).to receive(:value=).with("bar")
|
763
|
+
|
764
|
+
expect(metadata).to receive(:items=).with([foo, item1, item2, item3])
|
765
|
+
|
766
|
+
expect(driver.instance_metadata).to eq(metadata)
|
767
|
+
end
|
735
768
|
end
|
736
769
|
|
737
770
|
describe "#env_user" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Leonard
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.6.
|
168
|
+
rubygems_version: 2.6.11
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: Kitchen::Driver::Gce
|