kitchen-google 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -0
- data/lib/kitchen/driver/gce.rb +16 -6
- data/lib/kitchen/driver/gce_version.rb +1 -1
- data/spec/kitchen/driver/gce_spec.rb +26 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c0faf16d29ec697042b36e75a9120db978ca042
|
4
|
+
data.tar.gz: b11fe7fd427c9a50eec9ab53ee08d324ab7c45dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07e4218aff46c02b4cf32d2304bf4368df47d5445e025cf7bab5b4955a5b12432a32d6d4f78d8d27cccd0c11b5602a274b1c13e980ed11b902e3fb7f9b3c7ed
|
7
|
+
data.tar.gz: 99f3bcb22f2dd3382b6a8444a9e83acf52dee3899a9e2711335fcf399dffb3ee3b322966b1441cc824c08577afc3a675b8e2beee8dc51b34ee7fd44eb5297f44
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -232,10 +232,18 @@ GCE instance type (size) to launch; default: `n1-standard-1`
|
|
232
232
|
|
233
233
|
GCE network that instance will be attached to; default: `default`
|
234
234
|
|
235
|
+
### `network_project`
|
236
|
+
|
237
|
+
GCE project which network belongs to; default is same as `project`
|
238
|
+
|
235
239
|
### `subnet`
|
236
240
|
|
237
241
|
GCE subnetwork that instance will be attached to. Only applies to custom networks.
|
238
242
|
|
243
|
+
### `subnet_project`
|
244
|
+
|
245
|
+
GCE project which subnet belongs to. Only applies when `subnet` is used; default is same as `project`
|
246
|
+
|
239
247
|
### `preemptible`
|
240
248
|
|
241
249
|
If set to `true`, GCE instance will be brought up as a [preemptible](https://cloud.google.com/compute/docs/instances/preemptible) virtual machine,
|
data/lib/kitchen/driver/gce.rb
CHANGED
@@ -66,7 +66,9 @@ module Kitchen
|
|
66
66
|
default_config :disk_type, "pd-standard"
|
67
67
|
default_config :machine_type, "n1-standard-1"
|
68
68
|
default_config :network, "default"
|
69
|
+
default_config :network_project, nil
|
69
70
|
default_config :subnet, nil
|
71
|
+
default_config :subnet_project, nil
|
70
72
|
default_config :inst_name, nil
|
71
73
|
default_config :service_account_name, "default"
|
72
74
|
default_config :service_account_scopes, []
|
@@ -156,6 +158,7 @@ module Kitchen
|
|
156
158
|
warn("Both zone and region specified - region will be ignored.") if config[:zone] && config[:region]
|
157
159
|
warn("Both image family and name specified - image family will be ignored") if config[:image_family] && config[:image_name]
|
158
160
|
warn("Image project not specified - searching current project only") unless config[:image_project]
|
161
|
+
warn("Subnet project not specified - searching current project only") if config[:subnet] && !config[:subnet_project]
|
159
162
|
warn("Auto-migrate disabled for preemptible instance") if preemptible? && config[:auto_migrate]
|
160
163
|
warn("Auto-restart disabled for preemptible instance") if preemptible? && config[:auto_restart]
|
161
164
|
end
|
@@ -224,12 +227,12 @@ module Kitchen
|
|
224
227
|
|
225
228
|
def valid_network?
|
226
229
|
return false if config[:network].nil?
|
227
|
-
check_api_call { connection.get_network(
|
230
|
+
check_api_call { connection.get_network(network_project, config[:network]) }
|
228
231
|
end
|
229
232
|
|
230
233
|
def valid_subnet?
|
231
234
|
return false if config[:subnet].nil?
|
232
|
-
check_api_call { connection.get_subnetwork(
|
235
|
+
check_api_call { connection.get_subnetwork(subnet_project, region, config[:subnet]) }
|
233
236
|
end
|
234
237
|
|
235
238
|
def valid_zone?
|
@@ -267,6 +270,14 @@ module Kitchen
|
|
267
270
|
config[:image_project].nil? ? project : config[:image_project]
|
268
271
|
end
|
269
272
|
|
273
|
+
def subnet_project
|
274
|
+
config[:subnet_project].nil? ? project : config[:subnet_project]
|
275
|
+
end
|
276
|
+
|
277
|
+
def network_project
|
278
|
+
config[:network_project].nil? ? project : config[:network_project]
|
279
|
+
end
|
280
|
+
|
270
281
|
def region
|
271
282
|
config[:region].nil? ? region_for_zone : config[:region]
|
272
283
|
end
|
@@ -403,7 +414,7 @@ module Kitchen
|
|
403
414
|
|
404
415
|
def instance_network_interfaces
|
405
416
|
interface = Google::Apis::ComputeV1::NetworkInterface.new
|
406
|
-
interface.network = network_url
|
417
|
+
interface.network = network_url if config[:subnet_project].nil?
|
407
418
|
interface.subnetwork = subnet_url if subnet_url
|
408
419
|
interface.access_configs = interface_access_configs
|
409
420
|
|
@@ -411,13 +422,12 @@ module Kitchen
|
|
411
422
|
end
|
412
423
|
|
413
424
|
def network_url
|
414
|
-
"projects/#{
|
425
|
+
"projects/#{network_project}/global/networks/#{config[:network]}"
|
415
426
|
end
|
416
427
|
|
417
428
|
def subnet_url
|
418
429
|
return unless config[:subnet]
|
419
|
-
|
420
|
-
"projects/#{project}/regions/#{region}/subnetworks/#{config[:subnet]}"
|
430
|
+
"projects/#{subnet_project}/regions/#{region}/subnetworks/#{config[:subnet]}"
|
421
431
|
end
|
422
432
|
|
423
433
|
def interface_access_configs
|
@@ -823,9 +823,18 @@ describe Kitchen::Driver::Gce do
|
|
823
823
|
end
|
824
824
|
|
825
825
|
describe "#network_url" do
|
826
|
-
|
827
|
-
|
828
|
-
|
826
|
+
context "when the user does not provide network_project" do
|
827
|
+
it "returns a network URL" do
|
828
|
+
allow(driver).to receive(:config).and_return(network: "test_network")
|
829
|
+
expect(driver.network_url).to eq("projects/test_project/global/networks/test_network")
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
833
|
+
context "when the user provides network_project" do
|
834
|
+
it "returns a network URL" do
|
835
|
+
allow(driver).to receive(:config).and_return(network: "test_network", network_project: "test_xpn_project")
|
836
|
+
expect(driver.network_url).to eq("projects/test_xpn_project/global/networks/test_network")
|
837
|
+
end
|
829
838
|
end
|
830
839
|
end
|
831
840
|
|
@@ -835,10 +844,20 @@ describe Kitchen::Driver::Gce do
|
|
835
844
|
expect(driver.subnet_url).to eq(nil)
|
836
845
|
end
|
837
846
|
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
847
|
+
context "when the user does not provide subnet_project" do
|
848
|
+
it "returns a properly-formatted subnet URL" do
|
849
|
+
allow(driver).to receive(:config).and_return(subnet: "test_subnet")
|
850
|
+
expect(driver).to receive(:region).and_return("test_region")
|
851
|
+
expect(driver.subnet_url).to eq("projects/test_project/regions/test_region/subnetworks/test_subnet")
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
context "when the user provides subnet_project" do
|
856
|
+
it "returns a properly-formatted subnet URL" do
|
857
|
+
allow(driver).to receive(:config).and_return(subnet_project: "test_xpn_project", subnet: "test_subnet")
|
858
|
+
expect(driver).to receive(:region).and_return("test_region")
|
859
|
+
expect(driver.subnet_url).to eq("projects/test_xpn_project/regions/test_region/subnetworks/test_subnet")
|
860
|
+
end
|
842
861
|
end
|
843
862
|
end
|
844
863
|
|