ridley 1.4.1 → 1.5.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 +4 -4
- data/README.md +9 -0
- data/lib/ridley/client.rb +19 -11
- data/lib/ridley/errors.rb +1 -1
- data/lib/ridley/resources/cookbook_resource.rb +2 -0
- data/lib/ridley/version.rb +1 -1
- data/spec/unit/ridley/client_spec.rb +10 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27b40a345544eb449674ad567eaead7152ede778
|
4
|
+
data.tar.gz: e3497d278e48998c2ac805cc851e3cc3561c0b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aba56e71a839b5343a3fdca96dd56ad10ff855f80ba3821cbee5c53bc3539d2e5e3547004139947b5f1353b72361ebadfbd086c7c4d3fc655ccae56bda8b4abc
|
7
|
+
data.tar.gz: 0d38cd57cd4c756c10af5be8a3d036d4658adb2596a37c90477d01e049b38d9ff5490552cae7427c14de58dc9b320d8385eeb1e22a015c6c0c717ede99e874c2
|
data/README.md
CHANGED
@@ -42,6 +42,15 @@ Creating a new instance of Ridley requires the following options:
|
|
42
42
|
- client_name
|
43
43
|
- client_key
|
44
44
|
|
45
|
+
client_key can be either a file path or the client key as a string. You can also optionally supply an encrypted data bag secret for decrypting encrypted data bags. The option is "encrypted_data_bag_secret" This can be a file name or the key itself as a string.
|
46
|
+
|
47
|
+
ridley = Ridley.new(
|
48
|
+
server_url: "https://api.opscode.com/organizations/ridley",
|
49
|
+
client_name: "reset",
|
50
|
+
client_key: "some key data",
|
51
|
+
encrypted_data_bag_secret: "File path or key as a string"
|
52
|
+
)
|
53
|
+
|
45
54
|
Ridley exposes a number of functions that return resources which you can use to retrieve or create objects on your Chef server. Here is a simple example of getting a list of all the roles on your Chef server.
|
46
55
|
|
47
56
|
```ruby
|
data/lib/ridley/client.rb
CHANGED
@@ -124,8 +124,8 @@ module Ridley
|
|
124
124
|
# @option options [Integer] :pool_size (4)
|
125
125
|
# size of the connection pool
|
126
126
|
#
|
127
|
-
# @raise [Errors::
|
128
|
-
# a file path pointing to a readable client key
|
127
|
+
# @raise [Errors::ClientKeyFileNotFoundOrInvalid] if the option for :client_key does not contain
|
128
|
+
# a file path pointing to a readable client key, or is a string containing a valid key
|
129
129
|
def initialize(options = {})
|
130
130
|
@options = options.reverse_merge(
|
131
131
|
ssh: Hash.new,
|
@@ -139,22 +139,23 @@ module Ridley
|
|
139
139
|
@chef_version = @options[:chef_version]
|
140
140
|
@validator_client = @options[:validator_client]
|
141
141
|
|
142
|
-
@options[:client_key] = File.expand_path(@options[:client_key])
|
143
|
-
|
144
142
|
if @options[:validator_path]
|
145
143
|
@validator_path = File.expand_path(@options[:validator_path])
|
146
144
|
end
|
147
145
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
@options[:encrypted_data_bag_secret] = encrypted_data_bag_secret
|
146
|
+
@options[:encrypted_data_bag_secret] ||= begin
|
147
|
+
if @options[:encrypted_data_bag_secret_path]
|
148
|
+
@encrypted_data_bag_secret_path = File.expand_path(@options[:encrypted_data_bag_secret_path])
|
149
|
+
end
|
153
150
|
|
154
|
-
|
155
|
-
raise Errors::ClientKeyFileNotFound, "client key not found at: '#{@options[:client_key]}'"
|
151
|
+
encrypted_data_bag_secret
|
156
152
|
end
|
157
153
|
|
154
|
+
unless verify_client_key(@options[:client_key])
|
155
|
+
@options[:client_key] = File.expand_path(@options[:client_key])
|
156
|
+
raise Errors::ClientKeyFileNotFoundOrInvalid, "client key is invalid or not found at: '#{@options[:client_key]}'" unless File.exist?(@options[:client_key]) && verify_client_key(::IO.read(@options[:client_key]))
|
157
|
+
end
|
158
|
+
|
158
159
|
@connection_registry = Celluloid::Registry.new
|
159
160
|
@resources_registry = Celluloid::Registry.new
|
160
161
|
@connection_supervisor = ConnectionSupervisor.new(@connection_registry, @options)
|
@@ -273,6 +274,13 @@ module Ridley
|
|
273
274
|
|
274
275
|
private
|
275
276
|
|
277
|
+
def verify_client_key(key)
|
278
|
+
OpenSSL::PKey::RSA.new(key)
|
279
|
+
true
|
280
|
+
rescue
|
281
|
+
false
|
282
|
+
end
|
283
|
+
|
276
284
|
def connection
|
277
285
|
@connection_registry[:connection_pool]
|
278
286
|
end
|
data/lib/ridley/errors.rb
CHANGED
@@ -44,7 +44,7 @@ module Ridley
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class BootstrapError < RidleyError; end
|
47
|
-
class
|
47
|
+
class ClientKeyFileNotFoundOrInvalid < BootstrapError; end
|
48
48
|
class EncryptedDataBagSecretNotFound < BootstrapError; end
|
49
49
|
|
50
50
|
class HostConnectionError < RidleyError; end
|
data/lib/ridley/version.rb
CHANGED
@@ -87,18 +87,24 @@ describe Ridley::Client do
|
|
87
87
|
}.to raise_error(ArgumentError, "Missing required option(s): 'client_key'")
|
88
88
|
end
|
89
89
|
|
90
|
-
it "raises a ClientKeyFileNotFound if the
|
90
|
+
it "raises a ClientKeyFileNotFound if the client_key is not found or an invalid key" do
|
91
91
|
config[:client_key] = "/tmp/nofile.xxsa"
|
92
92
|
|
93
93
|
expect {
|
94
94
|
described_class.new(config)
|
95
|
-
}.to raise_error(Ridley::Errors::
|
95
|
+
}.to raise_error(Ridley::Errors::ClientKeyFileNotFoundOrInvalid)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "expands the path of the client_key" do
|
99
|
-
config[:client_key] = "
|
99
|
+
config[:client_key] = "spec/fixtures/reset.pem"
|
100
100
|
|
101
|
-
described_class.new(config).client_key.should_not == "
|
101
|
+
described_class.new(config).client_key[0..4].should_not == "spec/"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "accepts a client key as a string" do
|
105
|
+
key = File.read(fixtures_path.join("reset.pem").to_s)
|
106
|
+
config[:client_key] = key.dup
|
107
|
+
described_class.new(config).client_key.should == key
|
102
108
|
end
|
103
109
|
|
104
110
|
it "assigns a 'ssh' attribute from the given 'ssh' option" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|