diff options
author | tylercloke <tylercloke@gmail.com> | 2015-04-29 16:04:50 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-04-30 09:56:59 -0700 |
commit | 3d11fd861949c31096bc60e56914f74447bc604b (patch) | |
tree | 244af6eca09cd53d135459039131f596c4705a3d /lib/chef/key.rb | |
parent | 75cb417e2edbf21427d778b4675c806bdb312b3f (diff) | |
download | chef-3d11fd861949c31096bc60e56914f74447bc604b.tar.gz |
Fixed a bug where create_key would conflict with public_key in hash returned from server on update.
Diffstat (limited to 'lib/chef/key.rb')
-rw-r--r-- | lib/chef/key.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/key.rb b/lib/chef/key.rb index 3c8229f859..b52aaebf50 100644 --- a/lib/chef/key.rb +++ b/lib/chef/key.rb @@ -99,6 +99,10 @@ class Chef @public_key = nil end + def delete_create_key + @create_key = nil + end + def create_key(arg=nil) raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set create_key to true if the public_key field exists" if arg == true && !@public_key.nil? set_or_return(:create_key, arg, @@ -171,6 +175,10 @@ class Chef put_name = @name if put_name.nil? new_key = chef_rest.put_rest("#{api_base}/#{@actor}/keys/#{put_name}", to_hash) + # if the server returned a public_key, remove the create_key field, as we now have a key + if new_key["public_key"] + self.delete_create_key + end Chef::Key.from_hash(self.to_hash.merge(new_key)) end |