ridley 0.10.2 → 0.11.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -4,6 +4,7 @@ describe "Client API operations", type: "acceptance" do
4
4
  let(:server_url) { "https://api.opscode.com/organizations/ridley" }
5
5
  let(:client_name) { "reset" }
6
6
  let(:client_key) { "/Users/reset/.chef/reset.pem" }
7
+ let(:resource) { double('client-resource') }
7
8
 
8
9
  let(:connection) do
9
10
  Ridley.new(
@@ -21,39 +22,28 @@ describe "Client API operations", type: "acceptance" do
21
22
  end
22
23
 
23
24
  describe "finding a client" do
24
- let(:target) do
25
- Ridley::ClientResource.new(
26
- connection,
27
- name: "motherbrain-test",
28
- admin: false
29
- )
30
- end
25
+ let(:target) { Ridley::ClientObject.new(resource, name: "motherbrain-test", admin: false) }
31
26
 
32
27
  before(:each) do
33
28
  connection.client.create(target)
34
29
  end
35
30
 
36
- it "returns a valid Ridley::ClientResource" do
31
+ it "returns a valid Ridley::ClientObject" do
37
32
  connection.sync do
38
33
  obj = client.find(target)
39
34
 
40
- obj.should be_a(Ridley::ClientResource)
35
+ obj.should be_a(Ridley::ClientObject)
41
36
  obj.should be_valid
42
37
  end
43
38
  end
44
39
  end
45
40
 
46
41
  describe "creating a client" do
47
- let(:target) do
48
- Ridley::ClientResource.new(
49
- connection,
50
- name: "motherbrain_test"
51
- )
52
- end
42
+ let(:target) { Ridley::ClientObject.new(resource, name: "motherbrain-test", admin: false) }
53
43
 
54
- it "returns a Ridley::ClientResource object" do
44
+ it "returns a Ridley::ClientObject object" do
55
45
  connection.sync do
56
- client.create(target).should be_a(Ridley::ClientResource)
46
+ client.create(target).should be_a(Ridley::ClientObject)
57
47
  end
58
48
  end
59
49
 
@@ -65,20 +55,14 @@ describe "Client API operations", type: "acceptance" do
65
55
  end
66
56
 
67
57
  describe "deleting a client" do
68
- let(:target) do
69
- Ridley::ClientResource.new(
70
- connection,
71
- name: "motherbrain-test",
72
- admin: false
73
- )
74
- end
58
+ let(:target) { Ridley::ClientObject.new(resource, name: "motherbrain-test", admin: false) }
75
59
 
76
60
  before(:each) do
77
61
  connection.client.create(target)
78
62
  end
79
63
 
80
- it "returns a Ridley::ClientResource object" do
81
- connection.client.delete(target).should be_a(Ridley::ClientResource)
64
+ it "returns a Ridley::ClientObject object" do
65
+ connection.client.delete(target).should be_a(Ridley::ClientObject)
82
66
  end
83
67
  end
84
68
 
@@ -91,7 +75,7 @@ describe "Client API operations", type: "acceptance" do
91
75
  end
92
76
 
93
77
  it "returns an array of Ridley::ClientResource objects" do
94
- connection.client.delete_all.should each be_a(Ridley::ClientResource)
78
+ connection.client.delete_all.should each be_a(Ridley::ClientObject)
95
79
  end
96
80
 
97
81
  it "deletes all clients from the remote" do
@@ -104,25 +88,19 @@ describe "Client API operations", type: "acceptance" do
104
88
  end
105
89
 
106
90
  describe "listing all clients" do
107
- it "returns an array of Ridley::ClientResource objects" do
108
- connection.client.all.should each be_a(Ridley::ClientResource)
91
+ it "returns an array of Ridley::ClientObject objects" do
92
+ connection.client.all.should each be_a(Ridley::ClientObject)
109
93
  end
110
94
  end
111
95
 
112
96
  describe "regenerating a client's private key" do
113
- let(:target) do
114
- Ridley::ClientResource.new(
115
- connection,
116
- name: "motherbrain-test",
117
- admin: false
118
- )
119
- end
97
+ let(:target) { Ridley::ClientObject.new(resource, name: "motherbrain-test", admin: false) }
120
98
 
121
99
  before(:each) do
122
100
  connection.client.create(target)
123
101
  end
124
102
 
125
- it "returns a Ridley::ClientResource object with a value for 'private_key'" do
103
+ it "returns a Ridley::ClientObject object with a value for 'private_key'" do
126
104
  connection.sync do
127
105
  obj = client.regenerate_key(target)
128
106
 
@@ -5,7 +5,7 @@ describe "DataBag API operations", type: "acceptance" do
5
5
  let(:client_name) { "reset" }
6
6
  let(:client_key) { "/Users/reset/.chef/reset.pem" }
7
7
 
8
- let(:connection) do
8
+ let(:client) do
9
9
  Ridley.new(
10
10
  server_url: server_url,
11
11
  client_name: client_name,
@@ -17,20 +17,14 @@ describe "DataBag API operations", type: "acceptance" do
17
17
  after(:all) { WebMock.disable_net_connect! }
18
18
 
19
19
  before(:all) do
20
- connection.data_bag.delete_all
21
- @databag = connection.data_bag.create(name: "ridley-test")
20
+ client.data_bag.delete_all
21
+ @databag = client.data_bag.create(name: "ridley-test")
22
22
  end
23
23
 
24
- before(:each) do
25
- @databag.item.delete_all
26
- end
24
+ before { @databag.item.delete_all }
27
25
 
28
26
  describe "listing data bag items" do
29
27
  context "when the data bag has no items" do
30
- before(:each) do
31
- @databag.item.delete_all
32
- end
33
-
34
28
  it "returns an empty array" do
35
29
  @databag.item.all.should have(0).items
36
30
  end
@@ -57,9 +51,9 @@ describe "DataBag API operations", type: "acceptance" do
57
51
 
58
52
  context "when an 'id' field is missing" do
59
53
  it "raises an Ridley::Errors::InvalidResource error" do
60
- lambda {
54
+ expect {
61
55
  @databag.item.create(name: "jamie")
62
- }.should raise_error(Ridley::Errors::InvalidResource)
56
+ }.to raise_error(Ridley::Errors::InvalidResource)
63
57
  end
64
58
  end
65
59
  end
@@ -96,7 +90,7 @@ describe "DataBag API operations", type: "acceptance" do
96
90
  it "returns the deleted data bag item" do
97
91
  dbi = @databag.item.delete(attributes["id"])
98
92
 
99
- dbi.should be_a(Ridley::DataBagItemResource)
93
+ dbi.should be_a(Ridley::DataBagItemObject)
100
94
  dbi.attributes.should eql(attributes)
101
95
  end
102
96
 
@@ -114,7 +108,7 @@ describe "DataBag API operations", type: "acceptance" do
114
108
  end
115
109
 
116
110
  it "returns the array of deleted data bag items" do
117
- @databag.item.delete_all.should each be_a(Ridley::DataBagItemResource)
111
+ @databag.item.delete_all.should each be_a(Ridley::DataBagItemObject)
118
112
  end
119
113
 
120
114
  it "removes all data bag items from the data bag" do
@@ -34,7 +34,7 @@ describe "DataBag API operations", type: "acceptance" do
34
34
  end
35
35
 
36
36
  it "returns an array of data bags" do
37
- connection.data_bag.all.should each be_a(Ridley::DataBagResource)
37
+ connection.data_bag.all.should each be_a(Ridley::DataBagObject)
38
38
  end
39
39
 
40
40
  it "returns all of the data bags on the server" do
@@ -4,6 +4,7 @@ describe "Environment API operations", type: "acceptance" do
4
4
  let(:server_url) { "https://api.opscode.com/organizations/ridley" }
5
5
  let(:client_name) { "reset" }
6
6
  let(:client_key) { "/Users/reset/.chef/reset.pem" }
7
+ let(:resource) { double('environment-resource') }
7
8
 
8
9
  let(:connection) do
9
10
  Ridley.new(
@@ -21,22 +22,17 @@ describe "Environment API operations", type: "acceptance" do
21
22
  end
22
23
 
23
24
  describe "finding an environment" do
24
- let(:target) do
25
- Ridley::EnvironmentResource.new(
26
- connection,
27
- name: "ridley-test-env"
28
- )
29
- end
25
+ let(:target) { Ridley::EnvironmentObject.new(resource, name: "ridley-test-env") }
30
26
 
31
27
  before(:each) do
32
28
  connection.environment.create(target)
33
29
  end
34
30
 
35
- it "returns a valid Ridley::EnvironmentResource object" do
31
+ it "returns a valid Ridley::EnvironmentObject object" do
36
32
  connection.sync do
37
33
  obj = environment.find(target)
38
34
 
39
- obj.should be_a(Ridley::EnvironmentResource)
35
+ obj.should be_a(Ridley::EnvironmentObject)
40
36
  obj.should be_valid
41
37
  end
42
38
  end
@@ -44,18 +40,18 @@ describe "Environment API operations", type: "acceptance" do
44
40
 
45
41
  describe "creating an environment" do
46
42
  let(:target) do
47
- Ridley::EnvironmentResource.new(
48
- connection,
43
+ Ridley::EnvironmentObject.new(
44
+ resource,
49
45
  name: "ridley-test-env",
50
46
  description: "a testing environment for ridley"
51
47
  )
52
48
  end
53
49
 
54
- it "returns a valid Ridley::EnvironmentResource object" do
50
+ it "returns a valid Ridley::EnvironmentObject object" do
55
51
  connection.sync do
56
52
  obj = environment.create(target)
57
53
 
58
- obj.should be_a(Ridley::EnvironmentResource)
54
+ obj.should be_a(Ridley::EnvironmentObject)
59
55
  obj.should be_valid
60
56
  end
61
57
  end
@@ -77,8 +73,8 @@ describe "Environment API operations", type: "acceptance" do
77
73
  end
78
74
  end
79
75
 
80
- it "returns an array of Ridley::EnvironmentResource objects" do
81
- connection.environment.delete_all.should each be_a(Ridley::EnvironmentResource)
76
+ it "returns an array of Ridley::EnvironmentObject objects" do
77
+ connection.environment.delete_all.should each be_a(Ridley::EnvironmentObject)
82
78
  end
83
79
 
84
80
  it "deletes all environments but '_default' from the remote" do
@@ -92,18 +88,13 @@ describe "Environment API operations", type: "acceptance" do
92
88
  end
93
89
 
94
90
  describe "listing all environments" do
95
- it "should return an array of Ridley::EnvironmentResource objects" do
96
- connection.environment.all.should each be_a(Ridley::EnvironmentResource)
91
+ it "should return an array of Ridley::EnvironmentObject objects" do
92
+ connection.environment.all.should each be_a(Ridley::EnvironmentObject)
97
93
  end
98
94
  end
99
95
 
100
96
  describe "updating an environment" do
101
- let(:target) do
102
- Ridley::EnvironmentResource.new(
103
- connection,
104
- name: "ridley-env-test"
105
- )
106
- end
97
+ let(:target) { Ridley::EnvironmentObject.new(resource, name: "ridley-test-env") }
107
98
 
108
99
  before(:each) do
109
100
  connection.environment.create(target)
@@ -4,6 +4,7 @@ describe "Node API operations", type: "acceptance" do
4
4
  let(:server_url) { "https://api.opscode.com/organizations/ridley" }
5
5
  let(:client_name) { "reset" }
6
6
  let(:client_key) { "/Users/reset/.chef/reset.pem" }
7
+ let(:resource) { double('node-resource') }
7
8
 
8
9
  let(:connection) do
9
10
  Ridley.new(
@@ -21,12 +22,7 @@ describe "Node API operations", type: "acceptance" do
21
22
  end
22
23
 
23
24
  describe "finding a node" do
24
- let(:target) do
25
- Ridley::NodeResource.new(
26
- connection,
27
- name: "ridley-one"
28
- )
29
- end
25
+ let(:target) { Ridley::NodeObject.new(resource, name: "ridley-one") }
30
26
 
31
27
  before(:each) do
32
28
  connection.node.create(target)
@@ -38,14 +34,9 @@ describe "Node API operations", type: "acceptance" do
38
34
  end
39
35
 
40
36
  describe "creating a node" do
41
- let(:target) do
42
- Ridley::NodeResource.new(
43
- connection,
44
- name: "ridley-one"
45
- )
46
- end
47
-
48
- it "returns a new Ridley::NodeResource object" do
37
+ let(:target) { Ridley::NodeObject.new(resource, name: "ridley-one") }
38
+
39
+ it "returns a new Ridley::NodeObject object" do
49
40
  connection.node.create(target).should eql(target)
50
41
  end
51
42
 
@@ -59,12 +50,7 @@ describe "Node API operations", type: "acceptance" do
59
50
  end
60
51
 
61
52
  describe "deleting a node" do
62
- let(:target) do
63
- Ridley::NodeResource.new(
64
- connection,
65
- name: "ridley-one"
66
- )
67
- end
53
+ let(:target) { Ridley::NodeObject.new(resource, name: "ridley-one") }
68
54
 
69
55
  before(:each) do
70
56
  connection.node.create(target)
@@ -101,23 +87,18 @@ describe "Node API operations", type: "acceptance" do
101
87
  end
102
88
  end
103
89
 
104
- it "returns an array of Ridley::NodeResource objects" do
90
+ it "returns an array of Ridley::NodeObject" do
105
91
  connection.sync do
106
92
  obj = node.all
107
-
108
- obj.should each be_a(Ridley::NodeResource)
93
+
94
+ obj.should each be_a(Ridley::NodeObject)
109
95
  obj.should have(2).nodes
110
96
  end
111
97
  end
112
98
  end
113
99
 
114
100
  describe "updating a node" do
115
- let(:target) do
116
- Ridley::NodeResource.new(
117
- connection,
118
- name: "ridley-one"
119
- )
120
- end
101
+ let(:target) { Ridley::NodeObject.new(resource, name: "ridley-one") }
121
102
 
122
103
  before(:each) do
123
104
  connection.node.create(target)
@@ -4,6 +4,7 @@ describe "Role API operations", type: "acceptance" do
4
4
  let(:server_url) { "https://api.opscode.com/organizations/ridley" }
5
5
  let(:client_name) { "reset" }
6
6
  let(:client_key) { "/Users/reset/.chef/reset.pem" }
7
+ let(:resource) { double('role-resource') }
7
8
 
8
9
  let(:connection) do
9
10
  Ridley.new(
@@ -20,8 +21,8 @@ describe "Role API operations", type: "acceptance" do
20
21
 
21
22
  describe "finding a role" do
22
23
  let(:target) do
23
- Ridley::RoleResource.new(
24
- connection,
24
+ Ridley::RoleObject.new(
25
+ resource,
25
26
  name: "ridley-test",
26
27
  description: "a testing role for ridley"
27
28
  )
@@ -31,21 +32,21 @@ describe "Role API operations", type: "acceptance" do
31
32
  connection.role.create(target)
32
33
  end
33
34
 
34
- it "returns the target Ridley::RoleResource from the server" do
35
+ it "returns the target Ridley::RoleObject from the server" do
35
36
  connection.role.find(target.name).should eql(target)
36
37
  end
37
38
  end
38
39
 
39
40
  describe "creating a role" do
40
41
  let(:target) do
41
- Ridley::RoleResource.new(
42
- connection,
42
+ Ridley::RoleObject.new(
43
+ resource,
43
44
  name: "ridley-test",
44
45
  description: "a testing role for ridley"
45
46
  )
46
47
  end
47
48
 
48
- it "returns a new Ridley::RoleResource" do
49
+ it "returns a new Ridley::RoleObject" do
49
50
  connection.role.create(target).should eql(target)
50
51
  end
51
52
 
@@ -60,8 +61,8 @@ describe "Role API operations", type: "acceptance" do
60
61
 
61
62
  describe "deleting a role" do
62
63
  let(:target) do
63
- Ridley::RoleResource.new(
64
- connection,
64
+ Ridley::RoleObject.new(
65
+ resource,
65
66
  name: "ridley-role-one"
66
67
  )
67
68
  end
@@ -70,7 +71,7 @@ describe "Role API operations", type: "acceptance" do
70
71
  connection.role.create(target)
71
72
  end
72
73
 
73
- it "returns the deleted Ridley::RoleResource resource" do
74
+ it "returns the deleted Ridley::RoleObject resource" do
74
75
  connection.role.delete(target).should eql(target)
75
76
  end
76
77
 
@@ -106,15 +107,15 @@ describe "Role API operations", type: "acceptance" do
106
107
  obj = role.all
107
108
 
108
109
  obj.should have(2).roles
109
- obj.should each be_a(Ridley::RoleResource)
110
+ obj.should each be_a(Ridley::RoleObject)
110
111
  end
111
112
  end
112
113
  end
113
114
 
114
115
  describe "updating a role" do
115
116
  let(:target) do
116
- Ridley::RoleResource.new(
117
- connection,
117
+ Ridley::RoleObject.new(
118
+ resource,
118
119
  name: "ridley-role-one"
119
120
  )
120
121
  end
@@ -123,7 +124,7 @@ describe "Role API operations", type: "acceptance" do
123
124
  connection.role.create(target)
124
125
  end
125
126
 
126
- it "returns an updated Ridley::RoleResource object" do
127
+ it "returns an updated Ridley::RoleObject object" do
127
128
  connection.role.update(target).should eql(target)
128
129
  end
129
130
 
@@ -24,8 +24,8 @@ describe "Sandbox API operations", type: "acceptance" do
24
24
  end
25
25
 
26
26
  describe "creating a new sandbox" do
27
- it "returns an instance of Ridley::SandboxResource" do
28
- connection.sandbox.create(checksums).should be_a(Ridley::SandboxResource)
27
+ it "returns an instance of Ridley::SandboxObject" do
28
+ connection.sandbox.create(checksums).should be_a(Ridley::SandboxObject)
29
29
  end
30
30
 
31
31
  it "contains a value for sandbox_id" do