diff options
author | tylercloke <tylercloke@gmail.com> | 2015-04-29 18:06:52 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-04-30 09:56:59 -0700 |
commit | 00fff6a2dd7a33554413b1f1b140d0cf9856f303 (patch) | |
tree | 34d5014ea29045a62f45f96d4050f83fcc512403 /lib/chef/key.rb | |
parent | 2c84bcd43685aef0cbafec2f2dbfb0410212370f (diff) | |
download | chef-00fff6a2dd7a33554413b1f1b140d0cf9856f303.tar.gz |
Fixed small bug in Chef::Key.load_by_(user|client) where actor wasn't populated.
Diffstat (limited to 'lib/chef/key.rb')
-rw-r--r-- | lib/chef/key.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/chef/key.rb b/lib/chef/key.rb index b52aaebf50..be4be7f230 100644 --- a/lib/chef/key.rb +++ b/lib/chef/key.rb @@ -204,8 +204,10 @@ class Chef def self.from_hash(key_hash) if key_hash.has_key?("user") key = Chef::Key.new(key_hash["user"], "user") - else + elsif key_hash.has_key?("client") key = Chef::Key.new(key_hash["client"], "client") + else + raise Chef::Exceptions::MissingKeyAttribute, "The hash passed to from_hash does not contain the key 'user' or 'client'. Please pass a hash that defines one of those keys." end key.name key_hash['name'] if key_hash.key?('name') key.public_key key_hash['public_key'] if key_hash.key?('public_key') @@ -235,12 +237,12 @@ class Chef def self.load_by_user(actor, key_name) response = Chef::REST.new(Chef::Config[:chef_server_root]).get_rest("users/#{actor}/keys/#{key_name}") - Chef::Key.from_hash(response) + Chef::Key.from_hash(response.merge({"user" => actor})) end def self.load_by_client(actor, key_name) response = Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("clients/#{actor}/keys/#{key_name}") - Chef::Key.from_hash(response) + Chef::Key.from_hash(response.merge({"client" => actor})) end def self.generate_fingerprint(public_key) |