Sha256: 0386216133ed749c9780cc0f8ea1b29bc01f0b2a39c20cdb4b476c2d20a98355

Contents?: true

Size: 1.2 KB

Versions: 232

Compression:

Stored size: 1.2 KB

Contents

require 'puppet/ssl'
require 'puppet/util/yaml'

# This class transforms simple key/value pairs into the equivalent ASN1
# structures. Values may be strings or arrays of strings.
#
# @api private
class Puppet::SSL::CertificateRequestAttributes

  attr_reader :path, :custom_attributes, :extension_requests

  def initialize(path)
    @path = path
    @custom_attributes = {}
    @extension_requests = {}
  end

  # Attempt to load a yaml file at the given @path.
  # @return true if we are able to load the file, false otherwise
  # @raise [Puppet::Error] if there are unexpected attribute keys
  def load
    Puppet.info("csr_attributes file loading from #{path}")
    if Puppet::FileSystem.exist?(path)
      hash = Puppet::Util::Yaml.load_file(path, {})
      if ! hash.is_a?(Hash)
        raise Puppet::Error, "invalid CSR attributes, expected instance of Hash, received instance of #{hash.class}"
      end
      @custom_attributes = hash.delete('custom_attributes') || {}
      @extension_requests = hash.delete('extension_requests') || {}
      if not hash.keys.empty?
        raise Puppet::Error, "unexpected attributes #{hash.keys.inspect} in #{@path.inspect}"
      end
      return true
    end
    return false
  end
end

Version data entries

232 entries across 232 versions & 2 rubygems

Version Path
puppet-4.7.1-x64-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.7.1-universal-darwin lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.1 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.1-x86-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.1-x64-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.1-universal-darwin lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.0 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.0-x86-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.0-x64-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.8.0-universal-darwin lib/puppet/ssl/certificate_request_attributes.rb
puppet-retrospec-1.2.1 vendor/gems/puppet-4.5.2/lib/puppet/ssl/certificate_request_attributes.rb
puppet-retrospec-1.2.0 vendor/gems/puppet-4.5.2/lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.7.0 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.7.0-x86-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.7.0-x64-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.7.0-universal-darwin lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.6.2 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.6.2-x86-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.6.2-x64-mingw32 lib/puppet/ssl/certificate_request_attributes.rb
puppet-4.6.2-universal-darwin lib/puppet/ssl/certificate_request_attributes.rb