ridley 0.7.0.beta → 0.7.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 (54) hide show
  1. data/README.md +51 -54
  2. data/lib/ridley.rb +7 -13
  3. data/lib/ridley/client.rb +251 -0
  4. data/lib/ridley/connection.rb +32 -188
  5. data/lib/ridley/middleware/chef_auth.rb +4 -1
  6. data/lib/ridley/resource.rb +36 -42
  7. data/lib/ridley/resources.rb +3 -0
  8. data/lib/ridley/resources/{client.rb → client_resource.rb} +7 -20
  9. data/lib/ridley/resources/cookbook_resource.rb +121 -0
  10. data/lib/ridley/resources/{data_bag_item.rb → data_bag_item_resource.rb} +52 -63
  11. data/lib/ridley/resources/data_bag_resource.rb +74 -0
  12. data/lib/ridley/resources/encrypted_data_bag_item_resource.rb +55 -0
  13. data/lib/ridley/resources/{environment.rb → environment_resource.rb} +8 -21
  14. data/lib/ridley/resources/{node.rb → node_resource.rb} +24 -37
  15. data/lib/ridley/resources/{role.rb → role_resource.rb} +1 -14
  16. data/lib/ridley/resources/sandbox_resource.rb +86 -0
  17. data/lib/ridley/resources/search.rb +24 -55
  18. data/lib/ridley/sandbox_uploader.rb +118 -0
  19. data/lib/ridley/ssh.rb +2 -2
  20. data/lib/ridley/ssh/worker.rb +2 -1
  21. data/lib/ridley/version.rb +1 -1
  22. data/ridley.gemspec +1 -1
  23. data/spec/acceptance/bootstrapping_spec.rb +1 -1
  24. data/spec/acceptance/client_resource_spec.rb +18 -20
  25. data/spec/acceptance/cookbook_resource_spec.rb +4 -22
  26. data/spec/acceptance/data_bag_item_resource_spec.rb +5 -7
  27. data/spec/acceptance/data_bag_resource_spec.rb +4 -6
  28. data/spec/acceptance/environment_resource_spec.rb +14 -16
  29. data/spec/acceptance/node_resource_spec.rb +12 -14
  30. data/spec/acceptance/role_resource_spec.rb +13 -15
  31. data/spec/acceptance/sandbox_resource_spec.rb +7 -9
  32. data/spec/acceptance/search_resource_spec.rb +6 -8
  33. data/spec/support/shared_examples/ridley_resource.rb +23 -22
  34. data/spec/unit/ridley/client_spec.rb +153 -0
  35. data/spec/unit/ridley/connection_spec.rb +8 -221
  36. data/spec/unit/ridley/resources/{client_spec.rb → client_resource_spec.rb} +4 -4
  37. data/spec/unit/ridley/resources/cookbook_resource_spec.rb +5 -0
  38. data/spec/unit/ridley/resources/{data_bag_item_spec.rb → data_bag_item_resource_spec.rb} +2 -2
  39. data/spec/unit/ridley/resources/{data_bag_spec.rb → data_bag_resource_spec.rb} +3 -3
  40. data/spec/unit/ridley/resources/{environment_spec.rb → environment_resource_spec.rb} +4 -4
  41. data/spec/unit/ridley/resources/{node_spec.rb → node_resource_spec.rb} +4 -4
  42. data/spec/unit/ridley/resources/{role_spec.rb → role_resource_spec.rb} +3 -3
  43. data/spec/unit/ridley/resources/sandbox_resource_spec.rb +172 -0
  44. data/spec/unit/ridley/resources/search_spec.rb +34 -30
  45. data/spec/unit/ridley/sandbox_uploader_spec.rb +99 -0
  46. data/spec/unit/ridley/ssh_spec.rb +2 -2
  47. data/spec/unit/ridley_spec.rb +4 -12
  48. metadata +36 -28
  49. data/lib/ridley/dsl.rb +0 -58
  50. data/lib/ridley/resources/cookbook.rb +0 -51
  51. data/lib/ridley/resources/data_bag.rb +0 -81
  52. data/lib/ridley/resources/encrypted_data_bag_item.rb +0 -54
  53. data/lib/ridley/resources/sandbox.rb +0 -154
  54. data/spec/unit/ridley/resources/cookbook_spec.rb +0 -5
@@ -8,7 +8,7 @@ module Ridley
8
8
  autoload :Worker, 'ridley/ssh/worker'
9
9
 
10
10
  class << self
11
- # @param [Ridley::Node, Array<Ridley::Node>] nodes
11
+ # @param [Ridley::NodeResource, Array<Ridley::NodeResource>] nodes
12
12
  # @param [Hash] options
13
13
  def start(nodes, options = {}, &block)
14
14
  runner = new(nodes, options)
@@ -25,7 +25,7 @@ module Ridley
25
25
  attr_reader :nodes
26
26
  attr_reader :options
27
27
 
28
- # @param [Ridley::Node, Array<Ridley::Node>] nodes
28
+ # @param [Ridley::NodeResource, Array<Ridley::NodeResource>] nodes
29
29
  # @param [Hash] options
30
30
  # @see Net::SSH
31
31
  def initialize(nodes, options = {})
@@ -8,11 +8,12 @@ module Ridley
8
8
 
9
9
  attr_reader :sudo
10
10
  attr_reader :user
11
+ # @return [Hashie::Mash]
11
12
  attr_reader :options
12
13
 
13
14
  # @param [Hash] options
14
15
  def initialize(options = {})
15
- @options = options.dup
16
+ @options = options.deep_symbolize_keys
16
17
  @sudo = @options[:sudo]
17
18
  @user = @options[:user]
18
19
 
@@ -1,3 +1,3 @@
1
1
  module Ridley
2
- VERSION = "0.7.0.beta"
2
+ VERSION = "0.7.0.rc1"
3
3
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency 'mixlib-log'
24
24
  s.add_runtime_dependency 'mixlib-authentication'
25
25
  s.add_runtime_dependency 'addressable'
26
- s.add_runtime_dependency 'faraday'
26
+ s.add_runtime_dependency 'faraday', '>= 0.8.4'
27
27
  s.add_runtime_dependency 'activesupport', '>= 3.2.0'
28
28
  s.add_runtime_dependency 'celluloid'
29
29
  s.add_runtime_dependency 'net-ssh'
@@ -7,7 +7,7 @@ describe "Bootstrapping a node", type: "acceptance" do
7
7
  let(:organization) { "vialstudios" }
8
8
 
9
9
  let(:connection) do
10
- Ridley.connection(
10
+ Ridley.new(
11
11
  server_url: server_url,
12
12
  client_name: client_name,
13
13
  client_key: client_key,
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Client API operations", type: "acceptance" do
4
- let(:server_url) { "https://api.opscode.com" }
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(:organization) { "ridley" }
8
7
 
9
8
  let(:connection) do
10
- Ridley.connection(
9
+ Ridley.new(
11
10
  server_url: server_url,
12
11
  client_name: client_name,
13
- client_key: client_key,
14
- organization: organization
12
+ client_key: client_key
15
13
  )
16
14
  end
17
15
 
@@ -24,7 +22,7 @@ describe "Client API operations", type: "acceptance" do
24
22
 
25
23
  describe "finding a client" do
26
24
  let(:target) do
27
- Ridley::Client.new(
25
+ Ridley::ClientResource.new(
28
26
  connection,
29
27
  name: "motherbrain-test",
30
28
  admin: false
@@ -35,11 +33,11 @@ describe "Client API operations", type: "acceptance" do
35
33
  connection.client.create(target)
36
34
  end
37
35
 
38
- it "returns a valid Ridley::Client" do
36
+ it "returns a valid Ridley::ClientResource" do
39
37
  connection.sync do
40
38
  obj = client.find(target)
41
39
 
42
- obj.should be_a(Ridley::Client)
40
+ obj.should be_a(Ridley::ClientResource)
43
41
  obj.should be_valid
44
42
  end
45
43
  end
@@ -47,15 +45,15 @@ describe "Client API operations", type: "acceptance" do
47
45
 
48
46
  describe "creating a client" do
49
47
  let(:target) do
50
- Ridley::Client.new(
48
+ Ridley::ClientResource.new(
51
49
  connection,
52
50
  name: "motherbrain_test"
53
51
  )
54
52
  end
55
53
 
56
- it "returns a Ridley::Client object" do
54
+ it "returns a Ridley::ClientResource object" do
57
55
  connection.sync do
58
- client.create(target).should be_a(Ridley::Client)
56
+ client.create(target).should be_a(Ridley::ClientResource)
59
57
  end
60
58
  end
61
59
 
@@ -68,7 +66,7 @@ describe "Client API operations", type: "acceptance" do
68
66
 
69
67
  describe "deleting a client" do
70
68
  let(:target) do
71
- Ridley::Client.new(
69
+ Ridley::ClientResource.new(
72
70
  connection,
73
71
  name: "motherbrain-test",
74
72
  admin: false
@@ -79,8 +77,8 @@ describe "Client API operations", type: "acceptance" do
79
77
  connection.client.create(target)
80
78
  end
81
79
 
82
- it "returns a Ridley::Client object" do
83
- connection.client.delete(target).should be_a(Ridley::Client)
80
+ it "returns a Ridley::ClientResource object" do
81
+ connection.client.delete(target).should be_a(Ridley::ClientResource)
84
82
  end
85
83
  end
86
84
 
@@ -92,8 +90,8 @@ describe "Client API operations", type: "acceptance" do
92
90
  end
93
91
  end
94
92
 
95
- it "returns an array of Ridley::Client objects" do
96
- connection.client.delete_all.should each be_a(Ridley::Client)
93
+ it "returns an array of Ridley::ClientResource objects" do
94
+ connection.client.delete_all.should each be_a(Ridley::ClientResource)
97
95
  end
98
96
 
99
97
  it "deletes all clients from the remote" do
@@ -106,14 +104,14 @@ describe "Client API operations", type: "acceptance" do
106
104
  end
107
105
 
108
106
  describe "listing all clients" do
109
- it "returns an array of Ridley::Client objects" do
110
- connection.client.all.should each be_a(Ridley::Client)
107
+ it "returns an array of Ridley::ClientResource objects" do
108
+ connection.client.all.should each be_a(Ridley::ClientResource)
111
109
  end
112
110
  end
113
111
 
114
112
  describe "regenerating a client's private key" do
115
113
  let(:target) do
116
- Ridley::Client.new(
114
+ Ridley::ClientResource.new(
117
115
  connection,
118
116
  name: "motherbrain-test",
119
117
  admin: false
@@ -124,7 +122,7 @@ describe "Client API operations", type: "acceptance" do
124
122
  connection.client.create(target)
125
123
  end
126
124
 
127
- it "returns a Ridley::Client object with a value for 'private_key'" do
125
+ it "returns a Ridley::ClientResource object with a value for 'private_key'" do
128
126
  connection.sync do
129
127
  obj = client.regenerate_key(target)
130
128
 
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Cookbook API operations", type: "acceptance" do
4
- let(:server_url) { "https://api.opscode.com" }
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(:organization) { "ridley" }
8
7
 
9
8
  let(:connection) do
10
- Ridley.connection(
9
+ Ridley.new(
11
10
  server_url: server_url,
12
11
  client_name: client_name,
13
- client_key: client_key,
14
- organization: organization
12
+ client_key: client_key
15
13
  )
16
14
  end
17
15
 
@@ -22,25 +20,9 @@ describe "Cookbook API operations", type: "acceptance" do
22
20
  pending
23
21
  end
24
22
 
25
- describe "creating a cookbook" do
26
- pending
27
- end
28
-
29
- describe "deleting a cookbook" do
30
- pending
31
- end
32
-
33
- describe "deleting all cookbooks" do
34
- pending
35
- end
36
-
37
23
  describe "listing all cookbooks" do
38
24
  it "should return an array of environment objects" do
39
- connection.cookbook.all.should each be_a(Ridley::Cookbook)
25
+ connection.cookbook.all.should each be_a(Ridley::CookbookResource)
40
26
  end
41
27
  end
42
-
43
- describe "updating a cookbook" do
44
- pending
45
- end
46
28
  end
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "DataBag API operations", type: "acceptance" do
4
- let(:server_url) { "https://api.opscode.com" }
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(:organization) { "ridley" }
8
7
 
9
8
  let(:connection) do
10
- Ridley.connection(
9
+ Ridley.new(
11
10
  server_url: server_url,
12
11
  client_name: client_name,
13
- client_key: client_key,
14
- organization: organization
12
+ client_key: client_key
15
13
  )
16
14
  end
17
15
 
@@ -98,7 +96,7 @@ describe "DataBag API operations", type: "acceptance" do
98
96
  it "returns the deleted data bag item" do
99
97
  dbi = @databag.item.delete(attributes["id"])
100
98
 
101
- dbi.should be_a(Ridley::DataBagItem)
99
+ dbi.should be_a(Ridley::DataBagItemResource)
102
100
  dbi.attributes.should eql(attributes)
103
101
  end
104
102
 
@@ -116,7 +114,7 @@ describe "DataBag API operations", type: "acceptance" do
116
114
  end
117
115
 
118
116
  it "returns the array of deleted data bag items" do
119
- @databag.item.delete_all.should each be_a(Ridley::DataBagItem)
117
+ @databag.item.delete_all.should each be_a(Ridley::DataBagItemResource)
120
118
  end
121
119
 
122
120
  it "removes all data bag items from the data bag" do
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "DataBag API operations", type: "acceptance" do
4
- let(:server_url) { "https://api.opscode.com" }
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(:organization) { "ridley" }
8
7
 
9
8
  let(:connection) do
10
- Ridley.connection(
9
+ Ridley.new(
11
10
  server_url: server_url,
12
11
  client_name: client_name,
13
- client_key: client_key,
14
- organization: organization
12
+ client_key: client_key
15
13
  )
16
14
  end
17
15
 
@@ -36,7 +34,7 @@ describe "DataBag API operations", type: "acceptance" do
36
34
  end
37
35
 
38
36
  it "returns an array of data bags" do
39
- connection.data_bag.all.should each be_a(Ridley::DataBag)
37
+ connection.data_bag.all.should each be_a(Ridley::DataBagResource)
40
38
  end
41
39
 
42
40
  it "returns all of the data bags on the server" do
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Environment API operations", type: "acceptance" do
4
- let(:server_url) { "https://api.opscode.com" }
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(:organization) { "ridley" }
8
7
 
9
8
  let(:connection) do
10
- Ridley.connection(
9
+ Ridley.new(
11
10
  server_url: server_url,
12
11
  client_name: client_name,
13
- client_key: client_key,
14
- organization: organization
12
+ client_key: client_key
15
13
  )
16
14
  end
17
15
 
@@ -24,7 +22,7 @@ describe "Environment API operations", type: "acceptance" do
24
22
 
25
23
  describe "finding an environment" do
26
24
  let(:target) do
27
- Ridley::Environment.new(
25
+ Ridley::EnvironmentResource.new(
28
26
  connection,
29
27
  name: "ridley-test-env"
30
28
  )
@@ -34,11 +32,11 @@ describe "Environment API operations", type: "acceptance" do
34
32
  connection.environment.create(target)
35
33
  end
36
34
 
37
- it "returns a valid Ridley::Environment object" do
35
+ it "returns a valid Ridley::EnvironmentResource object" do
38
36
  connection.sync do
39
37
  obj = environment.find(target)
40
38
 
41
- obj.should be_a(Ridley::Environment)
39
+ obj.should be_a(Ridley::EnvironmentResource)
42
40
  obj.should be_valid
43
41
  end
44
42
  end
@@ -46,18 +44,18 @@ describe "Environment API operations", type: "acceptance" do
46
44
 
47
45
  describe "creating an environment" do
48
46
  let(:target) do
49
- Ridley::Environment.new(
47
+ Ridley::EnvironmentResource.new(
50
48
  connection,
51
49
  name: "ridley-test-env",
52
50
  description: "a testing environment for ridley"
53
51
  )
54
52
  end
55
53
 
56
- it "returns a valid Ridley::Environment object" do
54
+ it "returns a valid Ridley::EnvironmentResource object" do
57
55
  connection.sync do
58
56
  obj = environment.create(target)
59
57
 
60
- obj.should be_a(Ridley::Environment)
58
+ obj.should be_a(Ridley::EnvironmentResource)
61
59
  obj.should be_valid
62
60
  end
63
61
  end
@@ -79,8 +77,8 @@ describe "Environment API operations", type: "acceptance" do
79
77
  end
80
78
  end
81
79
 
82
- it "returns an array of Ridley::Environment objects" do
83
- connection.environment.delete_all.should each be_a(Ridley::Environment)
80
+ it "returns an array of Ridley::EnvironmentResource objects" do
81
+ connection.environment.delete_all.should each be_a(Ridley::EnvironmentResource)
84
82
  end
85
83
 
86
84
  it "deletes all environments but '_default' from the remote" do
@@ -94,14 +92,14 @@ describe "Environment API operations", type: "acceptance" do
94
92
  end
95
93
 
96
94
  describe "listing all environments" do
97
- it "should return an array of Ridley::Environment objects" do
98
- connection.environment.all.should each be_a(Ridley::Environment)
95
+ it "should return an array of Ridley::EnvironmentResource objects" do
96
+ connection.environment.all.should each be_a(Ridley::EnvironmentResource)
99
97
  end
100
98
  end
101
99
 
102
100
  describe "updating an environment" do
103
101
  let(:target) do
104
- Ridley::Environment.new(
102
+ Ridley::EnvironmentResource.new(
105
103
  connection,
106
104
  name: "ridley-env-test"
107
105
  )
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Node API operations", type: "acceptance" do
4
- let(:server_url) { "https://api.opscode.com" }
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(:organization) { "ridley" }
8
7
 
9
8
  let(:connection) do
10
- Ridley.connection(
9
+ Ridley.new(
11
10
  server_url: server_url,
12
11
  client_name: client_name,
13
- client_key: client_key,
14
- organization: organization
12
+ client_key: client_key
15
13
  )
16
14
  end
17
15
 
@@ -24,7 +22,7 @@ describe "Node API operations", type: "acceptance" do
24
22
 
25
23
  describe "finding a node" do
26
24
  let(:target) do
27
- Ridley::Node.new(
25
+ Ridley::NodeResource.new(
28
26
  connection,
29
27
  name: "ridley-one"
30
28
  )
@@ -34,20 +32,20 @@ describe "Node API operations", type: "acceptance" do
34
32
  connection.node.create(target)
35
33
  end
36
34
 
37
- it "returns a Ridley::Node object" do
35
+ it "returns a Ridley::NodeResource object" do
38
36
  connection.node.find(target.name).should eql(target)
39
37
  end
40
38
  end
41
39
 
42
40
  describe "creating a node" do
43
41
  let(:target) do
44
- Ridley::Node.new(
42
+ Ridley::NodeResource.new(
45
43
  connection,
46
44
  name: "ridley-one"
47
45
  )
48
46
  end
49
47
 
50
- it "returns a new Ridley::Node object" do
48
+ it "returns a new Ridley::NodeResource object" do
51
49
  connection.node.create(target).should eql(target)
52
50
  end
53
51
 
@@ -62,7 +60,7 @@ describe "Node API operations", type: "acceptance" do
62
60
 
63
61
  describe "deleting a node" do
64
62
  let(:target) do
65
- Ridley::Node.new(
63
+ Ridley::NodeResource.new(
66
64
  connection,
67
65
  name: "ridley-one"
68
66
  )
@@ -90,7 +88,7 @@ describe "Node API operations", type: "acceptance" do
90
88
  connection.sync do
91
89
  node.delete_all
92
90
 
93
- connection.node.all.should have(0).nodes
91
+ node.all.should have(0).nodes
94
92
  end
95
93
  end
96
94
  end
@@ -103,11 +101,11 @@ describe "Node API operations", type: "acceptance" do
103
101
  end
104
102
  end
105
103
 
106
- it "returns an array of Ridley::Node objects" do
104
+ it "returns an array of Ridley::NodeResource objects" do
107
105
  connection.sync do
108
106
  obj = node.all
109
107
 
110
- obj.should each be_a(Ridley::Node)
108
+ obj.should each be_a(Ridley::NodeResource)
111
109
  obj.should have(2).nodes
112
110
  end
113
111
  end
@@ -115,7 +113,7 @@ describe "Node API operations", type: "acceptance" do
115
113
 
116
114
  describe "updating a node" do
117
115
  let(:target) do
118
- Ridley::Node.new(
116
+ Ridley::NodeResource.new(
119
117
  connection,
120
118
  name: "ridley-one"
121
119
  )