knife-google 1.3.1 → 2.0.0
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 +5 -13
- data/.gitignore +1 -0
- data/.travis.yml +15 -3
- data/CHANGELOG.md +4 -6
- data/Gemfile +3 -9
- data/README.md +208 -355
- data/RELEASE_NOTES.md +8 -17
- data/Rakefile +8 -49
- data/knife-google.gemspec +20 -17
- data/lib/chef/knife/cloud/google_service.rb +491 -0
- data/lib/chef/knife/cloud/google_service_helpers.rb +62 -0
- data/lib/chef/knife/cloud/google_service_options.rb +58 -0
- data/lib/chef/knife/google_disk_create.rb +40 -44
- data/lib/chef/knife/google_disk_delete.rb +22 -40
- data/lib/chef/knife/google_disk_list.rb +57 -51
- data/lib/chef/knife/google_project_quotas.rb +59 -0
- data/lib/chef/knife/google_region_list.rb +43 -102
- data/lib/chef/knife/google_region_quotas.rb +77 -0
- data/lib/chef/knife/google_server_create.rb +224 -505
- data/lib/chef/knife/google_server_delete.rb +20 -78
- data/lib/chef/knife/google_server_list.rb +42 -53
- data/lib/chef/knife/google_server_show.rb +44 -0
- data/lib/chef/knife/google_zone_list.rb +39 -50
- data/lib/knife-google/version.rb +3 -2
- data/spec/cloud/google_service_helpers_spec.rb +120 -0
- data/spec/cloud/google_service_spec.rb +832 -0
- data/spec/google_disk_create_spec.rb +72 -0
- data/spec/google_disk_delete_spec.rb +64 -0
- data/spec/google_disk_list_spec.rb +93 -0
- data/spec/google_project_quotas_spec.rb +63 -0
- data/spec/google_region_list_spec.rb +65 -0
- data/spec/google_region_quotas_spec.rb +108 -0
- data/spec/google_server_create_spec.rb +177 -0
- data/spec/google_server_delete_spec.rb +39 -0
- data/spec/google_server_list_spec.rb +77 -0
- data/spec/google_server_show_spec.rb +60 -0
- data/spec/google_zone_list_spec.rb +59 -0
- metadata +91 -114
- data/CONTRIB.md +0 -64
- data/lib/chef/knife/google_base.rb +0 -76
- data/lib/chef/knife/google_project_list.rb +0 -178
- data/lib/chef/knife/google_setup.rb +0 -31
- data/lib/google/compute.rb +0 -47
- data/lib/google/compute/client.rb +0 -216
- data/lib/google/compute/config.rb +0 -23
- data/lib/google/compute/creatable_resource_collection.rb +0 -55
- data/lib/google/compute/deletable_resource_collection.rb +0 -51
- data/lib/google/compute/disk.rb +0 -38
- data/lib/google/compute/exception.rb +0 -30
- data/lib/google/compute/firewall.rb +0 -65
- data/lib/google/compute/global_operation.rb +0 -60
- data/lib/google/compute/image.rb +0 -29
- data/lib/google/compute/listable_resource_collection.rb +0 -33
- data/lib/google/compute/machine_type.rb +0 -36
- data/lib/google/compute/mixins/utils.rb +0 -58
- data/lib/google/compute/network.rb +0 -29
- data/lib/google/compute/project.rb +0 -76
- data/lib/google/compute/region.rb +0 -31
- data/lib/google/compute/region_operation.rb +0 -62
- data/lib/google/compute/resource.rb +0 -81
- data/lib/google/compute/resource_collection.rb +0 -78
- data/lib/google/compute/server.rb +0 -88
- data/lib/google/compute/server/attached_disk.rb +0 -39
- data/lib/google/compute/server/network_interface.rb +0 -38
- data/lib/google/compute/server/network_interface/access_config.rb +0 -35
- data/lib/google/compute/server/serial_port_output.rb +0 -31
- data/lib/google/compute/snapshot.rb +0 -30
- data/lib/google/compute/version.rb +0 -19
- data/lib/google/compute/zone.rb +0 -34
- data/lib/google/compute/zone_operation.rb +0 -62
- data/spec/chef/knife/google_base_spec.rb +0 -46
- data/spec/chef/knife/google_disk_create_spec.rb +0 -37
- data/spec/chef/knife/google_disk_delete_spec.rb +0 -64
- data/spec/chef/knife/google_disk_list_spec.rb +0 -36
- data/spec/chef/knife/google_region_list_spec.rb +0 -32
- data/spec/chef/knife/google_server_create_spec.rb +0 -138
- data/spec/chef/knife/google_server_delete_spec.rb +0 -127
- data/spec/chef/knife/google_server_list_spec.rb +0 -39
- data/spec/chef/knife/google_setup_spec.rb +0 -24
- data/spec/chef/knife/google_zone_list_spec.rb +0 -32
- data/spec/data/client.json +0 -14
- data/spec/data/compute-v1.json +0 -6734
- data/spec/data/disk.json +0 -14
- data/spec/data/firewall.json +0 -13
- data/spec/data/global_operation.json +0 -36
- data/spec/data/image.json +0 -12
- data/spec/data/machine_type.json +0 -24
- data/spec/data/network.json +0 -10
- data/spec/data/project.json +0 -21
- data/spec/data/region.json +0 -23
- data/spec/data/serial_port_output.json +0 -5
- data/spec/data/server.json +0 -46
- data/spec/data/snapshot.json +0 -12
- data/spec/data/zone.json +0 -22
- data/spec/data/zone_operation.json +0 -36
- data/spec/google/compute/disk_spec.rb +0 -115
- data/spec/google/compute/firewall_spec.rb +0 -129
- data/spec/google/compute/global_operation_spec.rb +0 -62
- data/spec/google/compute/image_spec.rb +0 -75
- data/spec/google/compute/machine_type_spec.rb +0 -53
- data/spec/google/compute/network_spec.rb +0 -68
- data/spec/google/compute/project_spec.rb +0 -71
- data/spec/google/compute/region_spec.rb +0 -51
- data/spec/google/compute/server_spec.rb +0 -118
- data/spec/google/compute/snapshot_spec.rb +0 -57
- data/spec/google/compute/zone_operation_spec.rb +0 -62
- data/spec/google/compute/zone_spec.rb +0 -51
- data/spec/spec_helper.rb +0 -45
- data/spec/support/mocks.rb +0 -62
- data/spec/support/resource_examples.rb +0 -70
- data/spec/support/spec_google_base.rb +0 -60
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
|
3
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "spec_helper"
|
|
20
|
+
require "chef/knife/google_server_create"
|
|
21
|
+
require "support/shared_examples_for_command"
|
|
22
|
+
require "gcewinpass"
|
|
23
|
+
|
|
24
|
+
describe Chef::Knife::Cloud::GoogleServerCreate do
|
|
25
|
+
let(:command) { described_class.new(["test_instance"]) }
|
|
26
|
+
let(:service) { double("service") }
|
|
27
|
+
let(:server) { double("server") }
|
|
28
|
+
|
|
29
|
+
before do
|
|
30
|
+
allow(command).to receive(:service).and_return(service)
|
|
31
|
+
allow(command).to receive(:server).and_return(server)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
|
35
|
+
|
|
36
|
+
describe '#validate_params!' do
|
|
37
|
+
before do
|
|
38
|
+
allow(command).to receive(:check_for_missing_config_values!)
|
|
39
|
+
allow(command).to receive(:valid_disk_size?).and_return(true)
|
|
40
|
+
allow(command).to receive(:boot_disk_size)
|
|
41
|
+
command.config[:bootstrap_protocol] = "ssh"
|
|
42
|
+
command.config[:identity_file] = "/path/to/file"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "when no instance name has been provided" do
|
|
46
|
+
let(:command) { described_class.new }
|
|
47
|
+
|
|
48
|
+
it "raises an exception" do
|
|
49
|
+
expect { command.validate_params! }.to raise_error(RuntimeError, "You must supply an instance name.")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "checks for missing config values" do
|
|
54
|
+
expect(command).to receive(:check_for_missing_config_values!).with(:machine_type, :image, :boot_disk_size, :network)
|
|
55
|
+
|
|
56
|
+
command.validate_params!
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "raises an exception if the boot disk size is not valid" do
|
|
60
|
+
expect(command).to receive(:valid_disk_size?).and_return(false)
|
|
61
|
+
expect { command.validate_params! }.to raise_error(RuntimeError)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "raises an exception if bootstrap is WinRM but no gcloud user email as supplied" do
|
|
65
|
+
expect(command).to receive(:locate_config_value).with(:bootstrap_protocol).and_return("winrm")
|
|
66
|
+
expect(command).to receive(:locate_config_value).with(:gce_email).and_return(nil)
|
|
67
|
+
expect { command.validate_params! }.to raise_error(RuntimeError)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe '#before_bootstrap' do
|
|
72
|
+
before do
|
|
73
|
+
allow(command).to receive(:ip_address_for_bootstrap)
|
|
74
|
+
allow(command).to receive(:locate_config_value)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "sets the node name to what the user provided if a name was provided" do
|
|
78
|
+
expect(command).to receive(:locate_config_value).with(:chef_node_name).at_least(:once).and_return("my-node")
|
|
79
|
+
command.before_bootstrap
|
|
80
|
+
|
|
81
|
+
expect(command.config[:chef_node_name]).to eq("my-node")
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "sets the node name to the instance name if a node name was not provided" do
|
|
85
|
+
expect(command).to receive(:locate_config_value).with(:chef_node_name).at_least(:once).and_return(nil)
|
|
86
|
+
expect(command).to receive(:instance_name).and_return("my-instance")
|
|
87
|
+
command.before_bootstrap
|
|
88
|
+
|
|
89
|
+
expect(command.config[:chef_node_name]).to eq("my-instance")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "sets the bootstrap IP" do
|
|
93
|
+
expect(command).to receive(:ip_address_for_bootstrap).and_return("1.2.3.4")
|
|
94
|
+
command.before_bootstrap
|
|
95
|
+
|
|
96
|
+
expect(command.config[:bootstrap_ip_address]).to eq("1.2.3.4")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "sets the winrm password if winrm is used" do
|
|
100
|
+
allow(command.ui).to receive(:msg)
|
|
101
|
+
expect(command).to receive(:locate_config_value).with(:bootstrap_protocol).at_least(:once).and_return("winrm")
|
|
102
|
+
expect(command).to receive(:reset_windows_password).and_return("new_password")
|
|
103
|
+
command.before_bootstrap
|
|
104
|
+
|
|
105
|
+
expect(command.config[:winrm_password]).to eq("new_password")
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe '#get_node_name' do
|
|
110
|
+
it "overrides the original method to return nil" do
|
|
111
|
+
expect(command.get_node_name("name", "prefix")).to eq(nil)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe '#project' do
|
|
116
|
+
it "returns the project from the config" do
|
|
117
|
+
expect(command).to receive(:locate_config_value).with(:gce_project).and_return("test_project")
|
|
118
|
+
expect(command.project).to eq("test_project")
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe '#zone' do
|
|
123
|
+
it "returns the zone from the config" do
|
|
124
|
+
expect(command).to receive(:locate_config_value).with(:gce_zone).and_return("test_zone")
|
|
125
|
+
expect(command.zone).to eq("test_zone")
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe '#email' do
|
|
130
|
+
it "returns the email from the config" do
|
|
131
|
+
expect(command).to receive(:locate_config_value).with(:gce_email).and_return("test_email")
|
|
132
|
+
expect(command.email).to eq("test_email")
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe '#ip_address_for_bootstrap' do
|
|
137
|
+
it "returns the public IP by default" do
|
|
138
|
+
expect(command).to receive(:locate_config_value).with(:use_private_ip).and_return(false)
|
|
139
|
+
expect(command).to receive(:public_ip_for).and_return("1.2.3.4")
|
|
140
|
+
expect(command.ip_address_for_bootstrap).to eq("1.2.3.4")
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "returns the private IP if requested by the user" do
|
|
144
|
+
expect(command).to receive(:locate_config_value).with(:use_private_ip).and_return(true)
|
|
145
|
+
expect(command).to receive(:private_ip_for).and_return("4.3.2.1")
|
|
146
|
+
expect(command.ip_address_for_bootstrap).to eq("4.3.2.1")
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "raises an exception if an IP cannot be found" do
|
|
150
|
+
expect(command).to receive(:locate_config_value).with(:use_private_ip).and_return(false)
|
|
151
|
+
expect(command).to receive(:public_ip_for).and_return("unknown")
|
|
152
|
+
expect { command.ip_address_for_bootstrap }.to raise_error(RuntimeError)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
describe '#metadata' do
|
|
157
|
+
it "returns a hash of metadata" do
|
|
158
|
+
expect(command).to receive(:locate_config_value).with(:metadata).and_return(["key1=value1", "key2=value2"])
|
|
159
|
+
expect(command.metadata).to eq({ "key1" => "value1", "key2" => "value2" })
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe '#boot_disk_size' do
|
|
164
|
+
it "returns the disk size as an integer" do
|
|
165
|
+
expect(command).to receive(:locate_config_value).with(:boot_disk_size).and_return("20")
|
|
166
|
+
expect(command.boot_disk_size).to eq(20)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe '#reset_windows_password' do
|
|
171
|
+
it "returns the password from the gcewinpass instance" do
|
|
172
|
+
winpass = double("winpass", new_password: "my_password")
|
|
173
|
+
expect(GoogleComputeWindowsPassword).to receive(:new).and_return(winpass)
|
|
174
|
+
expect(command.reset_windows_password).to eq("my_password")
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
|
3
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "spec_helper"
|
|
20
|
+
require "chef/knife/google_server_delete"
|
|
21
|
+
require "support/shared_examples_for_serverdeletecommand"
|
|
22
|
+
|
|
23
|
+
describe Chef::Knife::Cloud::GoogleServerDelete do
|
|
24
|
+
let(:command) { described_class.new(["test_instance"]) }
|
|
25
|
+
let(:service) { double("service") }
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
allow(command).to receive(:service).and_return(service)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_behaves_like Chef::Knife::Cloud::ServerDeleteCommand, described_class.new(["test_instance"])
|
|
32
|
+
|
|
33
|
+
describe '#validate_params!' do
|
|
34
|
+
it "checks for missing config values" do
|
|
35
|
+
expect(command).to receive(:check_for_missing_config_values!)
|
|
36
|
+
command.validate_params!
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
|
3
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "spec_helper"
|
|
20
|
+
require "chef/knife/google_server_list"
|
|
21
|
+
require "support/shared_examples_for_command"
|
|
22
|
+
|
|
23
|
+
describe Chef::Knife::Cloud::GoogleServerList do
|
|
24
|
+
let(:command) { described_class.new }
|
|
25
|
+
let(:service) { double("service") }
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
allow(command).to receive(:service).and_return(service)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
|
32
|
+
|
|
33
|
+
describe '#validate_params!' do
|
|
34
|
+
it "checks for missing config values" do
|
|
35
|
+
expect(command).to receive(:check_for_missing_config_values!)
|
|
36
|
+
|
|
37
|
+
command.validate_params!
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe '#format_status_value' do
|
|
42
|
+
it "returns green when the status is ready" do
|
|
43
|
+
expect(command.ui).to receive(:color).with("ready", :green)
|
|
44
|
+
command.format_status_value("ready")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "returns red when the status is stopped" do
|
|
48
|
+
expect(command.ui).to receive(:color).with("stopped", :red)
|
|
49
|
+
command.format_status_value("stopped")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "returns red when the status is stopping" do
|
|
53
|
+
expect(command.ui).to receive(:color).with("stopping", :red)
|
|
54
|
+
command.format_status_value("stopping")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "returns red when the status is terminated" do
|
|
58
|
+
expect(command.ui).to receive(:color).with("terminated", :red)
|
|
59
|
+
command.format_status_value("terminated")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "returns yellow when the status is requested" do
|
|
63
|
+
expect(command.ui).to receive(:color).with("requested", :yellow)
|
|
64
|
+
command.format_status_value("requested")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "returns yellow when the status is provisioning" do
|
|
68
|
+
expect(command.ui).to receive(:color).with("provisioning", :yellow)
|
|
69
|
+
command.format_status_value("provisioning")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "returns yellow when the status is staging" do
|
|
73
|
+
expect(command.ui).to receive(:color).with("staging", :yellow)
|
|
74
|
+
command.format_status_value("staging")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
|
3
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "spec_helper"
|
|
20
|
+
require "chef/knife/google_server_show"
|
|
21
|
+
require "support/shared_examples_for_command"
|
|
22
|
+
|
|
23
|
+
describe Chef::Knife::Cloud::GoogleServerShow do
|
|
24
|
+
let(:command) { described_class.new(["test_instance"]) }
|
|
25
|
+
let(:service) { double("service") }
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
allow(command).to receive(:service).and_return(service)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
|
32
|
+
|
|
33
|
+
describe '#validate_params!' do
|
|
34
|
+
before do
|
|
35
|
+
allow(command).to receive(:check_for_missing_config_values!)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "checks for missing config values" do
|
|
39
|
+
expect(command).to receive(:check_for_missing_config_values!)
|
|
40
|
+
|
|
41
|
+
command.validate_params!
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "when no server name is provided" do
|
|
45
|
+
let(:command) { described_class.new }
|
|
46
|
+
|
|
47
|
+
it "raises an exception" do
|
|
48
|
+
expect { command.validate_params! }.to raise_error(RuntimeError, "You must supply an instance name to display")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "when more than one server name is provided" do
|
|
53
|
+
let(:command) { described_class.new(%w{server1 server2}) }
|
|
54
|
+
|
|
55
|
+
it "raises an exception" do
|
|
56
|
+
expect { command.validate_params! }.to raise_error(RuntimeError, "You may only supply one instance name")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
|
3
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "spec_helper"
|
|
20
|
+
require "chef/knife/google_zone_list"
|
|
21
|
+
require "support/shared_examples_for_command"
|
|
22
|
+
|
|
23
|
+
describe Chef::Knife::Cloud::GoogleZoneList do
|
|
24
|
+
let(:command) { described_class.new }
|
|
25
|
+
let(:service) { double("service") }
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
allow(command).to receive(:service).and_return(service)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
|
32
|
+
|
|
33
|
+
describe '#validate_params!' do
|
|
34
|
+
it "checks for missing config values" do
|
|
35
|
+
expect(command).to receive(:check_for_missing_config_values!)
|
|
36
|
+
|
|
37
|
+
command.validate_params!
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe '#query_resource' do
|
|
42
|
+
it "uses the service to list zones" do
|
|
43
|
+
expect(service).to receive(:list_zones).and_return("zones")
|
|
44
|
+
expect(command.query_resource).to eq("zones")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '#format_status_value' do
|
|
49
|
+
it "returns green when the status is up" do
|
|
50
|
+
expect(command.ui).to receive(:color).with("up", :green)
|
|
51
|
+
command.format_status_value("up")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "returns red when the status is stopped" do
|
|
55
|
+
expect(command.ui).to receive(:color).with("stopped", :red)
|
|
56
|
+
command.format_status_value("stopped")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knife-google
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chiraq Jog
|
|
@@ -9,211 +9,188 @@ authors:
|
|
|
9
9
|
- James Tucker
|
|
10
10
|
- Paul Rossman
|
|
11
11
|
- Eric Johnson
|
|
12
|
+
- Chef Partner Engineering
|
|
12
13
|
autorequire:
|
|
13
14
|
bindir: bin
|
|
14
15
|
cert_chain: []
|
|
15
|
-
date:
|
|
16
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
|
16
17
|
dependencies:
|
|
17
18
|
- !ruby/object:Gem::Dependency
|
|
18
19
|
name: chef
|
|
19
20
|
requirement: !ruby/object:Gem::Requirement
|
|
20
21
|
requirements:
|
|
21
|
-
- -
|
|
22
|
+
- - "~>"
|
|
22
23
|
- !ruby/object:Gem::Version
|
|
23
|
-
version:
|
|
24
|
+
version: '12.0'
|
|
24
25
|
type: :runtime
|
|
25
26
|
prerelease: false
|
|
26
27
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
28
|
requirements:
|
|
28
|
-
- -
|
|
29
|
+
- - "~>"
|
|
29
30
|
- !ruby/object:Gem::Version
|
|
30
|
-
version:
|
|
31
|
+
version: '12.0'
|
|
31
32
|
- !ruby/object:Gem::Dependency
|
|
32
|
-
name:
|
|
33
|
+
name: knife-cloud
|
|
33
34
|
requirement: !ruby/object:Gem::Requirement
|
|
34
35
|
requirements:
|
|
35
|
-
- -
|
|
36
|
+
- - "~>"
|
|
36
37
|
- !ruby/object:Gem::Version
|
|
37
|
-
version:
|
|
38
|
+
version: 1.2.0
|
|
38
39
|
type: :runtime
|
|
39
40
|
prerelease: false
|
|
40
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
42
|
requirements:
|
|
42
|
-
- -
|
|
43
|
+
- - "~>"
|
|
43
44
|
- !ruby/object:Gem::Version
|
|
44
|
-
version:
|
|
45
|
+
version: 1.2.0
|
|
45
46
|
- !ruby/object:Gem::Dependency
|
|
46
|
-
name:
|
|
47
|
+
name: google-api-client
|
|
47
48
|
requirement: !ruby/object:Gem::Requirement
|
|
48
49
|
requirements:
|
|
49
|
-
- -
|
|
50
|
+
- - "~>"
|
|
50
51
|
- !ruby/object:Gem::Version
|
|
51
|
-
version:
|
|
52
|
+
version: 0.9.0
|
|
52
53
|
type: :runtime
|
|
53
54
|
prerelease: false
|
|
54
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
55
56
|
requirements:
|
|
56
|
-
- -
|
|
57
|
+
- - "~>"
|
|
57
58
|
- !ruby/object:Gem::Version
|
|
58
|
-
version:
|
|
59
|
+
version: 0.9.0
|
|
59
60
|
- !ruby/object:Gem::Dependency
|
|
60
|
-
name:
|
|
61
|
+
name: gcewinpass
|
|
61
62
|
requirement: !ruby/object:Gem::Requirement
|
|
62
63
|
requirements:
|
|
63
|
-
- -
|
|
64
|
+
- - "~>"
|
|
64
65
|
- !ruby/object:Gem::Version
|
|
65
|
-
version: '0'
|
|
66
|
+
version: '1.0'
|
|
66
67
|
type: :runtime
|
|
67
68
|
prerelease: false
|
|
68
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
69
70
|
requirements:
|
|
70
|
-
- -
|
|
71
|
+
- - "~>"
|
|
71
72
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: '0'
|
|
73
|
+
version: '1.0'
|
|
74
|
+
- !ruby/object:Gem::Dependency
|
|
75
|
+
name: rake
|
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '10.0'
|
|
81
|
+
type: :development
|
|
82
|
+
prerelease: false
|
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - "~>"
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '10.0'
|
|
73
88
|
- !ruby/object:Gem::Dependency
|
|
74
89
|
name: rspec
|
|
75
90
|
requirement: !ruby/object:Gem::Requirement
|
|
76
91
|
requirements:
|
|
77
|
-
- -
|
|
92
|
+
- - "~>"
|
|
78
93
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '
|
|
94
|
+
version: '3.1'
|
|
80
95
|
type: :development
|
|
81
96
|
prerelease: false
|
|
82
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
83
98
|
requirements:
|
|
84
|
-
- -
|
|
99
|
+
- - "~>"
|
|
85
100
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: '
|
|
101
|
+
version: '3.1'
|
|
87
102
|
- !ruby/object:Gem::Dependency
|
|
88
|
-
name:
|
|
103
|
+
name: simplecov
|
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - "~>"
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0.9'
|
|
109
|
+
type: :development
|
|
110
|
+
prerelease: false
|
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - "~>"
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0.9'
|
|
116
|
+
- !ruby/object:Gem::Dependency
|
|
117
|
+
name: rubocop
|
|
89
118
|
requirement: !ruby/object:Gem::Requirement
|
|
90
119
|
requirements:
|
|
91
|
-
- -
|
|
120
|
+
- - ">="
|
|
92
121
|
- !ruby/object:Gem::Version
|
|
93
122
|
version: '0'
|
|
94
123
|
type: :development
|
|
95
124
|
prerelease: false
|
|
96
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
97
126
|
requirements:
|
|
98
|
-
- -
|
|
127
|
+
- - ">="
|
|
99
128
|
- !ruby/object:Gem::Version
|
|
100
129
|
version: '0'
|
|
101
130
|
- !ruby/object:Gem::Dependency
|
|
102
|
-
name:
|
|
131
|
+
name: pry
|
|
103
132
|
requirement: !ruby/object:Gem::Requirement
|
|
104
133
|
requirements:
|
|
105
|
-
- -
|
|
134
|
+
- - ">="
|
|
106
135
|
- !ruby/object:Gem::Version
|
|
107
136
|
version: '0'
|
|
108
137
|
type: :development
|
|
109
138
|
prerelease: false
|
|
110
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
111
140
|
requirements:
|
|
112
|
-
- -
|
|
141
|
+
- - ">="
|
|
113
142
|
- !ruby/object:Gem::Version
|
|
114
143
|
version: '0'
|
|
115
144
|
description: Google Compute Engine Support for Chef's Knife Command
|
|
116
|
-
email:
|
|
145
|
+
email:
|
|
146
|
+
- paulrossman@google.com
|
|
147
|
+
- partnereng@chef.io
|
|
117
148
|
executables: []
|
|
118
149
|
extensions: []
|
|
119
150
|
extra_rdoc_files:
|
|
120
151
|
- README.md
|
|
121
152
|
- LICENSE
|
|
122
|
-
- CONTRIB.md
|
|
123
153
|
files:
|
|
124
|
-
- .gitignore
|
|
125
|
-
- .travis.yml
|
|
154
|
+
- ".gitignore"
|
|
155
|
+
- ".travis.yml"
|
|
126
156
|
- CHANGELOG.md
|
|
127
|
-
- CONTRIB.md
|
|
128
157
|
- Gemfile
|
|
129
158
|
- LICENSE
|
|
130
159
|
- README.md
|
|
131
160
|
- RELEASE_NOTES.md
|
|
132
161
|
- Rakefile
|
|
133
162
|
- knife-google.gemspec
|
|
134
|
-
- lib/chef/knife/
|
|
163
|
+
- lib/chef/knife/cloud/google_service.rb
|
|
164
|
+
- lib/chef/knife/cloud/google_service_helpers.rb
|
|
165
|
+
- lib/chef/knife/cloud/google_service_options.rb
|
|
135
166
|
- lib/chef/knife/google_disk_create.rb
|
|
136
167
|
- lib/chef/knife/google_disk_delete.rb
|
|
137
168
|
- lib/chef/knife/google_disk_list.rb
|
|
138
|
-
- lib/chef/knife/
|
|
169
|
+
- lib/chef/knife/google_project_quotas.rb
|
|
139
170
|
- lib/chef/knife/google_region_list.rb
|
|
171
|
+
- lib/chef/knife/google_region_quotas.rb
|
|
140
172
|
- lib/chef/knife/google_server_create.rb
|
|
141
173
|
- lib/chef/knife/google_server_delete.rb
|
|
142
174
|
- lib/chef/knife/google_server_list.rb
|
|
143
|
-
- lib/chef/knife/
|
|
175
|
+
- lib/chef/knife/google_server_show.rb
|
|
144
176
|
- lib/chef/knife/google_zone_list.rb
|
|
145
|
-
- lib/google/compute.rb
|
|
146
|
-
- lib/google/compute/client.rb
|
|
147
|
-
- lib/google/compute/config.rb
|
|
148
|
-
- lib/google/compute/creatable_resource_collection.rb
|
|
149
|
-
- lib/google/compute/deletable_resource_collection.rb
|
|
150
|
-
- lib/google/compute/disk.rb
|
|
151
|
-
- lib/google/compute/exception.rb
|
|
152
|
-
- lib/google/compute/firewall.rb
|
|
153
|
-
- lib/google/compute/global_operation.rb
|
|
154
|
-
- lib/google/compute/image.rb
|
|
155
|
-
- lib/google/compute/listable_resource_collection.rb
|
|
156
|
-
- lib/google/compute/machine_type.rb
|
|
157
|
-
- lib/google/compute/mixins/utils.rb
|
|
158
|
-
- lib/google/compute/network.rb
|
|
159
|
-
- lib/google/compute/project.rb
|
|
160
|
-
- lib/google/compute/region.rb
|
|
161
|
-
- lib/google/compute/region_operation.rb
|
|
162
|
-
- lib/google/compute/resource.rb
|
|
163
|
-
- lib/google/compute/resource_collection.rb
|
|
164
|
-
- lib/google/compute/server.rb
|
|
165
|
-
- lib/google/compute/server/attached_disk.rb
|
|
166
|
-
- lib/google/compute/server/network_interface.rb
|
|
167
|
-
- lib/google/compute/server/network_interface/access_config.rb
|
|
168
|
-
- lib/google/compute/server/serial_port_output.rb
|
|
169
|
-
- lib/google/compute/snapshot.rb
|
|
170
|
-
- lib/google/compute/version.rb
|
|
171
|
-
- lib/google/compute/zone.rb
|
|
172
|
-
- lib/google/compute/zone_operation.rb
|
|
173
177
|
- lib/knife-google/version.rb
|
|
174
|
-
- spec/
|
|
175
|
-
- spec/
|
|
176
|
-
- spec/
|
|
177
|
-
- spec/
|
|
178
|
-
- spec/
|
|
179
|
-
- spec/
|
|
180
|
-
- spec/
|
|
181
|
-
- spec/
|
|
182
|
-
- spec/
|
|
183
|
-
- spec/
|
|
184
|
-
- spec/
|
|
185
|
-
- spec/
|
|
186
|
-
- spec/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
-
|
|
190
|
-
- spec/data/machine_type.json
|
|
191
|
-
- spec/data/network.json
|
|
192
|
-
- spec/data/project.json
|
|
193
|
-
- spec/data/region.json
|
|
194
|
-
- spec/data/serial_port_output.json
|
|
195
|
-
- spec/data/server.json
|
|
196
|
-
- spec/data/snapshot.json
|
|
197
|
-
- spec/data/zone.json
|
|
198
|
-
- spec/data/zone_operation.json
|
|
199
|
-
- spec/google/compute/disk_spec.rb
|
|
200
|
-
- spec/google/compute/firewall_spec.rb
|
|
201
|
-
- spec/google/compute/global_operation_spec.rb
|
|
202
|
-
- spec/google/compute/image_spec.rb
|
|
203
|
-
- spec/google/compute/machine_type_spec.rb
|
|
204
|
-
- spec/google/compute/network_spec.rb
|
|
205
|
-
- spec/google/compute/project_spec.rb
|
|
206
|
-
- spec/google/compute/region_spec.rb
|
|
207
|
-
- spec/google/compute/server_spec.rb
|
|
208
|
-
- spec/google/compute/snapshot_spec.rb
|
|
209
|
-
- spec/google/compute/zone_operation_spec.rb
|
|
210
|
-
- spec/google/compute/zone_spec.rb
|
|
211
|
-
- spec/spec_helper.rb
|
|
212
|
-
- spec/support/mocks.rb
|
|
213
|
-
- spec/support/resource_examples.rb
|
|
214
|
-
- spec/support/spec_google_base.rb
|
|
215
|
-
homepage: http://wiki.opscode.com/display/chef
|
|
216
|
-
licenses: []
|
|
178
|
+
- spec/cloud/google_service_helpers_spec.rb
|
|
179
|
+
- spec/cloud/google_service_spec.rb
|
|
180
|
+
- spec/google_disk_create_spec.rb
|
|
181
|
+
- spec/google_disk_delete_spec.rb
|
|
182
|
+
- spec/google_disk_list_spec.rb
|
|
183
|
+
- spec/google_project_quotas_spec.rb
|
|
184
|
+
- spec/google_region_list_spec.rb
|
|
185
|
+
- spec/google_region_quotas_spec.rb
|
|
186
|
+
- spec/google_server_create_spec.rb
|
|
187
|
+
- spec/google_server_delete_spec.rb
|
|
188
|
+
- spec/google_server_list_spec.rb
|
|
189
|
+
- spec/google_server_show_spec.rb
|
|
190
|
+
- spec/google_zone_list_spec.rb
|
|
191
|
+
homepage: https://github.com/chef/knife-google
|
|
192
|
+
licenses:
|
|
193
|
+
- Apache-2.0
|
|
217
194
|
metadata: {}
|
|
218
195
|
post_install_message:
|
|
219
196
|
rdoc_options: []
|
|
@@ -221,18 +198,18 @@ require_paths:
|
|
|
221
198
|
- lib
|
|
222
199
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
200
|
requirements:
|
|
224
|
-
- -
|
|
201
|
+
- - ">="
|
|
225
202
|
- !ruby/object:Gem::Version
|
|
226
203
|
version: '0'
|
|
227
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
205
|
requirements:
|
|
229
|
-
- -
|
|
206
|
+
- - ">="
|
|
230
207
|
- !ruby/object:Gem::Version
|
|
231
208
|
version: '0'
|
|
232
209
|
requirements: []
|
|
233
210
|
rubyforge_project:
|
|
234
|
-
rubygems_version: 2.
|
|
211
|
+
rubygems_version: 2.4.8
|
|
235
212
|
signing_key:
|
|
236
213
|
specification_version: 4
|
|
237
|
-
summary:
|
|
214
|
+
summary: Google Compute Engine Support for Chef's Knife Command
|
|
238
215
|
test_files: []
|