lib/chef-api/resources/client.rb in chef-api-0.10.0 vs lib/chef-api/resources/client.rb in chef-api-0.10.2
- old
+ new
@@ -1,9 +1,9 @@
module ChefAPI
class Resource::Client < Resource::Base
include ChefAPI::AclAble
- collection_path '/clients'
+ collection_path "/clients"
schema do
attribute :name, type: String, primary: true, required: true
attribute :admin, type: Boolean, default: false
attribute :public_key, type: String
@@ -12,11 +12,11 @@
ignore :certificate, :clientname, :orgname
end
# @todo implement
- protect 'chef-webui', 'chef-validator'
+ protect "chef-webui", "chef-validator"
class << self
#
# Load the client from a .pem file on disk. Lots of assumptions are made
# here.
@@ -47,11 +47,11 @@
#
# @see Resource::Base#initialize
#
def initialize(attributes = {}, prefix = {})
if certificate = attributes.delete(:certificate) ||
- attributes.delete('certificate')
+ attributes.delete("certificate")
x509 = OpenSSL::X509::Certificate.new(certificate)
attributes[:public_key] = x509.public_key.to_pem
end
super
@@ -75,9 +75,10 @@
# @return [self]
# the current resource with the new public and private key attributes
#
def regenerate_keys
raise Error::CannotRegenerateKey if new_resource?
+
update(private_key: true).save!
self
end
end
end