ridley 0.10.2 → 0.11.0.rc1

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.
Files changed (85) hide show
  1. data/README.md +147 -216
  2. data/lib/ridley.rb +2 -0
  3. data/lib/ridley/bootstrap_bindings/unix_template_binding.rb +21 -25
  4. data/lib/ridley/bootstrap_bindings/windows_template_binding.rb +29 -34
  5. data/lib/ridley/bootstrapper.rb +2 -2
  6. data/lib/ridley/bootstrapper/context.rb +5 -5
  7. data/lib/ridley/chef.rb +0 -1
  8. data/lib/ridley/chef/cookbook.rb +0 -9
  9. data/lib/ridley/chef_object.rb +128 -0
  10. data/lib/ridley/chef_objects.rb +3 -0
  11. data/lib/ridley/chef_objects/client_object.rb +55 -0
  12. data/lib/ridley/chef_objects/cookbook_object.rb +190 -0
  13. data/lib/ridley/chef_objects/data_bag_item_obect.rb +104 -0
  14. data/lib/ridley/chef_objects/data_bag_object.rb +31 -0
  15. data/lib/ridley/chef_objects/environment_object.rb +59 -0
  16. data/lib/ridley/chef_objects/node_object.rb +161 -0
  17. data/lib/ridley/chef_objects/role_object.rb +62 -0
  18. data/lib/ridley/chef_objects/sandbox_object.rb +58 -0
  19. data/lib/ridley/client.rb +76 -45
  20. data/lib/ridley/connection.rb +1 -1
  21. data/lib/ridley/errors.rb +8 -1
  22. data/lib/ridley/host_connector.rb +26 -6
  23. data/lib/ridley/host_connector/ssh.rb +3 -3
  24. data/lib/ridley/host_connector/ssh/worker.rb +7 -9
  25. data/lib/ridley/host_connector/winrm/worker.rb +4 -5
  26. data/lib/ridley/mixin/bootstrap_binding.rb +1 -12
  27. data/lib/ridley/resource.rb +51 -171
  28. data/lib/ridley/resources/client_resource.rb +18 -68
  29. data/lib/ridley/resources/cookbook_resource.rb +181 -381
  30. data/lib/ridley/resources/data_bag_item_resource.rb +55 -161
  31. data/lib/ridley/resources/data_bag_resource.rb +20 -61
  32. data/lib/ridley/resources/environment_resource.rb +9 -64
  33. data/lib/ridley/resources/node_resource.rb +135 -311
  34. data/lib/ridley/resources/role_resource.rb +1 -57
  35. data/lib/ridley/resources/sandbox_resource.rb +80 -65
  36. data/lib/ridley/resources/search_resource.rb +99 -0
  37. data/lib/ridley/sandbox_uploader.rb +12 -52
  38. data/lib/ridley/version.rb +1 -1
  39. data/spec/acceptance/bootstrapping_spec.rb +1 -1
  40. data/spec/acceptance/client_resource_spec.rb +15 -37
  41. data/spec/acceptance/data_bag_item_resource_spec.rb +8 -14
  42. data/spec/acceptance/data_bag_resource_spec.rb +1 -1
  43. data/spec/acceptance/environment_resource_spec.rb +13 -22
  44. data/spec/acceptance/node_resource_spec.rb +10 -29
  45. data/spec/acceptance/role_resource_spec.rb +14 -13
  46. data/spec/acceptance/sandbox_resource_spec.rb +2 -2
  47. data/spec/support/shared_examples/ridley_resource.rb +2 -23
  48. data/spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb +3 -4
  49. data/spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb +3 -5
  50. data/spec/unit/ridley/bootstrapper/context_spec.rb +2 -3
  51. data/spec/unit/ridley/bootstrapper_spec.rb +1 -1
  52. data/spec/unit/ridley/chef_object_spec.rb +240 -0
  53. data/spec/unit/ridley/chef_objects/client_object_spec.rb +11 -0
  54. data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +93 -0
  55. data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +74 -0
  56. data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +9 -0
  57. data/spec/unit/ridley/chef_objects/environment_object_spec.rb +57 -0
  58. data/spec/unit/ridley/chef_objects/node_object_spec.rb +252 -0
  59. data/spec/unit/ridley/chef_objects/role_object_spec.rb +57 -0
  60. data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +66 -0
  61. data/spec/unit/ridley/client_spec.rb +51 -51
  62. data/spec/unit/ridley/host_connector/ssh/worker_spec.rb +4 -4
  63. data/spec/unit/ridley/host_connector/ssh_spec.rb +26 -24
  64. data/spec/unit/ridley/host_connector/winrm/worker_spec.rb +3 -4
  65. data/spec/unit/ridley/host_connector/winrm_spec.rb +4 -4
  66. data/spec/unit/ridley/host_connector_spec.rb +40 -3
  67. data/spec/unit/ridley/mixin/bootstrap_binding_spec.rb +1 -1
  68. data/spec/unit/ridley/resource_spec.rb +81 -109
  69. data/spec/unit/ridley/resources/client_resource_spec.rb +18 -33
  70. data/spec/unit/ridley/resources/cookbook_resource_spec.rb +56 -230
  71. data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +2 -57
  72. data/spec/unit/ridley/resources/data_bag_resource_spec.rb +12 -7
  73. data/spec/unit/ridley/resources/environment_resource_spec.rb +10 -118
  74. data/spec/unit/ridley/resources/node_resource_spec.rb +83 -394
  75. data/spec/unit/ridley/resources/role_resource_spec.rb +2 -56
  76. data/spec/unit/ridley/resources/sandbox_resource_spec.rb +139 -136
  77. data/spec/unit/ridley/resources/search_resource_spec.rb +234 -0
  78. data/spec/unit/ridley/sandbox_uploader_spec.rb +13 -58
  79. metadata +36 -17
  80. data/lib/ridley/chef/chefignore.rb +0 -76
  81. data/lib/ridley/resources/encrypted_data_bag_item_resource.rb +0 -55
  82. data/lib/ridley/resources/search.rb +0 -101
  83. data/spec/fixtures/chefignore +0 -8
  84. data/spec/unit/ridley/chef/chefignore_spec.rb +0 -40
  85. data/spec/unit/ridley/resources/search_spec.rb +0 -221
@@ -1,8 +0,0 @@
1
- #
2
- # The ignore file allows you to skip files in cookbooks with the same name that appear
3
- # later in the search path.
4
- #
5
-
6
- recipes/ignoreme.rb
7
- # comments can be indented
8
- ignored
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Ridley::Chef::Chefignore do
4
- describe "ClassMethods" do
5
- subject { described_class }
6
-
7
- describe "::find_relative_to" do
8
- let(:path) { tmp_path.join('chefignore-test') }
9
- before(:each) { FileUtils.mkdir_p(path) }
10
-
11
- it "finds a chefignore file in a 'cookbooks' directory relative to the given path" do
12
- FileUtils.touch(path.join('chefignore'))
13
- subject.find_relative_to(path)
14
- end
15
-
16
- it "finds a chefignore file relative to the given path" do
17
- FileUtils.mkdir_p(path.join('cookbooks'))
18
- FileUtils.touch(path.join('cookbooks', 'chefignore'))
19
- subject.find_relative_to(path)
20
- end
21
- end
22
- end
23
-
24
- subject { described_class.new(File.join(fixtures_path)) }
25
-
26
- it "loads the globs in the chefignore file" do
27
- subject.ignores.should =~ %w[recipes/ignoreme.rb ignored]
28
- end
29
-
30
- it "removes items from an array that match the ignores" do
31
- file_list = %w[ recipes/ignoreme.rb recipes/dontignoreme.rb ]
32
- subject.remove_ignores_from(file_list).should == %w[recipes/dontignoreme.rb]
33
- end
34
-
35
- it "determines if a file is ignored" do
36
- subject.ignored?('ignored').should be_true
37
- subject.ignored?('recipes/ignoreme.rb').should be_true
38
- subject.ignored?('recipes/dontignoreme.rb').should be_false
39
- end
40
- end
@@ -1,221 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Ridley::Search do\
4
- let(:client) do
5
- double('client',
6
- connection: double('connection')
7
- )
8
- end
9
- let(:index) { :role }
10
- let(:query) { "*:*" }
11
- let(:response) do
12
- double(
13
- "response",
14
- body: {
15
- rows: Array.new,
16
- total: 0,
17
- start: 0
18
- }
19
- )
20
- end
21
-
22
- describe "ClassMethods" do
23
- subject { Ridley::Search }
24
-
25
- describe "::indexes" do
26
- it "sends a get request to the client to receive the indexes" do
27
- client.connection.should_receive(:get).with("search").and_return(response)
28
-
29
- subject.indexes(client)
30
- end
31
- end
32
- end
33
-
34
- describe "#run" do
35
- subject do
36
- Ridley::Search.new(client, index, query)
37
- end
38
-
39
- it "sends a get request to the client to the index's location with the given query" do
40
- client.connection.should_receive(:get).with("search/#{index}", q: query).and_return(response)
41
-
42
- subject.run
43
- end
44
-
45
- context "when 'sort' is set" do
46
- let(:sort) { "DESC" }
47
- before(:each) { subject.sort = sort }
48
-
49
- it "sends a get request to the client with a query parameter for 'set'" do
50
- client.connection.should_receive(:get).with("search/#{index}", q: query, sort: sort).and_return(response)
51
-
52
- subject.run
53
- end
54
- end
55
-
56
- context "when 'start' is set" do
57
- let(:start) { 1 }
58
- before(:each) { subject.start = start }
59
-
60
- it "sends a get request to the client with a query parameter for 'start'" do
61
- client.connection.should_receive(:get).with("search/#{index}", q: query, start: start).and_return(response)
62
-
63
- subject.run
64
- end
65
- end
66
-
67
- context "when 'rows' is set" do
68
- let(:rows) { 1 }
69
- before(:each) { subject.rows = rows }
70
-
71
- it "sends a get request to the client with a query parameter for 'rows'" do
72
- client.connection.should_receive(:get).with("search/#{index}", q: query, rows: rows).and_return(response)
73
-
74
- subject.run
75
- end
76
- end
77
-
78
- context "when ':node' is given as index" do
79
- let(:index) { :node }
80
- let(:response) do
81
- double(
82
- "response",
83
- body: {
84
- rows: [
85
- {
86
- chef_type: "node",
87
- json_class: "Chef::Node",
88
- name: "ridley-one",
89
- chef_environment: "_default",
90
- automatic: {},
91
- normal: {},
92
- default: {},
93
- override: {},
94
- run_list: [
95
- "recipe[one]",
96
- "recipe[two]"
97
- ]
98
- }
99
- ],
100
- total: 1,
101
- start: 0
102
- }
103
- )
104
- end
105
-
106
- subject { Ridley::Search.new(client, index, query) }
107
-
108
- it "returns an array of Ridley::NodeResource" do
109
- client.connection.should_receive(:get).with("search/#{index}", q: query).and_return(response)
110
- result = subject.run
111
-
112
- result.should be_a(Array)
113
- result.should each be_a(Ridley::NodeResource)
114
- end
115
- end
116
-
117
- context "when ':role' is given as index" do
118
- let(:index) { :role }
119
- let(:response) do
120
- double(
121
- "response",
122
- body: {
123
- rows: [
124
- {
125
- chef_type: "role",
126
- json_class: "Chef::Role",
127
- name: "ridley-role-one",
128
- description: "",
129
- default_attributes: {},
130
- override_attributes: {},
131
- run_list: [],
132
- env_run_lists: {}
133
- }
134
- ],
135
- total: 1,
136
- start: 0
137
- }
138
- )
139
- end
140
-
141
- subject { Ridley::Search.new(client, index, query) }
142
-
143
- it "returns an array of Ridley::RoleResource" do
144
- client.connection.should_receive(:get).with("search/#{index}", q: query).and_return(response)
145
- result = subject.run
146
-
147
- result.should be_a(Array)
148
- result.should each be_a(Ridley::RoleResource)
149
- end
150
- end
151
-
152
- context "when ':environment' is given as index" do
153
- let(:index) { :environment }
154
- let(:response) do
155
- double(
156
- "response",
157
- body: {
158
- rows: [
159
- {
160
- chef_type: "environment",
161
- json_class: "Chef::Environment",
162
- name: "ridley-env-test",
163
- description: "ridley testing environment",
164
- default_attributes: {},
165
- override_attributes: {},
166
- cookbook_versions: {}
167
- }
168
- ],
169
- total: 1,
170
- start: 0
171
- }
172
- )
173
- end
174
-
175
- subject { Ridley::Search.new(client, index, query) }
176
-
177
- it "returns an array of Ridley::EnvironmentResource" do
178
- client.connection.should_receive(:get).with("search/#{index}", q: query).and_return(response)
179
- result = subject.run
180
-
181
- result.should be_a(Array)
182
- result.should each be_a(Ridley::EnvironmentResource)
183
- end
184
- end
185
-
186
- context "when ':client' is given as index" do
187
- let(:index) { :client }
188
- let(:response) do
189
- double(
190
- "response",
191
- body: {
192
- rows: [
193
- {
194
- chef_type: "client",
195
- name: nil,
196
- admin: false,
197
- validator: false,
198
- certificate: "-----BEGIN CERTIFICATE-----\nMIIDOjCCAqOgAwIBAgIE47eOmDANBgkqhkiG9w0BAQUFADCBnjELMAkGA1UEBhMC\nVVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxFjAUBgNV\nBAoMDU9wc2NvZGUsIEluYy4xHDAaBgNVBAsME0NlcnRpZmljYXRlIFNlcnZpY2Ux\nMjAwBgNVBAMMKW9wc2NvZGUuY29tL2VtYWlsQWRkcmVzcz1hdXRoQG9wc2NvZGUu\nY29tMCAXDTEyMTAwOTAwMTUxNVoYDzIxMDExMTA0MDAxNTE1WjCBnTEQMA4GA1UE\nBxMHU2VhdHRsZTETMBEGA1UECBMKV2FzaGluZ3RvbjELMAkGA1UEBhMCVVMxHDAa\nBgNVBAsTE0NlcnRpZmljYXRlIFNlcnZpY2UxFjAUBgNVBAoTDU9wc2NvZGUsIElu\nYy4xMTAvBgNVBAMUKFVSSTpodHRwOi8vb3BzY29kZS5jb20vR1VJRFMvY2xpZW50\nX2d1aWQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqB9KEGzl7Wcm/\nwz/x8HByZANCn6WQC+R12qQso5I6nLbTNkRP668jXG3j0R5/F5i/KearAB9ePzL/\nQe3iHtwW6u1qLI1hVNFNB+I1fGu1p6fZyIOjnLn3bqsbOkBplHOIqHsp4GVSsHKb\nD32UXZDa9S9ZFXnR4iT6hUGm5895ReZG9TDiHvBpi9NJFDZXz+AQ6JuQY8UgYMMA\nm80KbO8/NJlXbRW+siRuvr+LIsi9Mx4i63pBWAN46my291rQU31PF3IB+btfGtR/\nyDWDgMSB37bTzZeOf1Dg9fpl2vIXyu3PoHER0oYmrMQbrdwAt7qCHZNuNWn51WPb\n1PHxXL1rAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAGnJUVAv951fUhGyPOrl+LbQG\nqgchMwIn7oDLE863e66BYTDj7koK3jjhx3EBkrT2vt/xS4yW0ZRV1BNqfnNKWbBq\nMNQiKkYdTr+oq2O3plOg/q/M1eG1B5pxGXqvH0O76DVWQcV/svO+HQEi1n8y5UQd\n+pBJCygpuv78wPCM+c4=\n-----END CERTIFICATE-----\n",
199
- public_key: nil,
200
- private_key: nil,
201
- orgname: "ridley"
202
- }
203
- ],
204
- total: 1,
205
- start: 0
206
- }
207
- )
208
- end
209
-
210
- subject { Ridley::Search.new(client, index, query) }
211
-
212
- it "returns an array of Ridley::ClientResource" do
213
- client.connection.should_receive(:get).with("search/#{index}", q: query).and_return(response)
214
- result = subject.run
215
-
216
- result.should be_a(Array)
217
- result.should each be_a(Ridley::ClientResource)
218
- end
219
- end
220
- end
221
- end