Method: Puppet::SSL::CertificateRequestAttributes#load

Defined in:
lib/puppet/ssl/certificate_request_attributes.rb

#loadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Attempt to load a yaml file at the given @path.

Returns:

  • true if we are able to load the file, false otherwise

Raises:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/puppet/ssl/certificate_request_attributes.rb', line 22

def load
  Puppet.info(_("csr_attributes file loading from %{path}") % { path: path })
  if Puppet::FileSystem.exist?(path)
    hash = Puppet::Util::Yaml.safe_load_file(path, [Symbol]) || {}
    unless hash.is_a?(Hash)
      raise Puppet::Error, _("invalid CSR attributes, expected instance of Hash, received instance of %{klass}") % { klass: hash.class }
    end

    @custom_attributes = hash.delete('custom_attributes') || {}
    @extension_requests = hash.delete('extension_requests') || {}
    unless hash.keys.empty?
      raise Puppet::Error, _("unexpected attributes %{keys} in %{path}") % { keys: hash.keys.inspect, path: @path.inspect }
    end

    return true
  end
  false
end