Sha256: c12266262f2c1572b147553b05d42a7d695c82cef0e098199a49177130ceca76

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 KB

Contents

require "chef-config/config"
require "chef-config/workstation_config_loader"
require "socket" unless defined?(Socket) # FIXME: why?

module Berkshelf
  class ChefConfigCompat
    # Create a new Chef Config object.
    #
    # @param [#to_s] path
    #   the path to the configuration file
    # @param [Hash] options
    def initialize(path, options = {})
      ChefConfig::WorkstationConfigLoader.new(path).load
      ChefConfig::Config.merge!(options)
      ChefConfig::Config.export_proxies # Set proxy settings as environment variables
      ChefConfig::Config.init_openssl # setup openssl + fips mode
    end

    # Keep defaults that aren't in ChefConfig::Config
    def cookbook_copyright(*args, &block)
      ChefConfig::Config.cookbook_copyright(*args, &block) || "YOUR_NAME"
    end

    def cookbook_email(*args, &block)
      ChefConfig::Config.cookbook_email(*args, &block) || "YOUR_EMAIL"
    end

    def cookbook_license(*args, &block)
      ChefConfig::Config.cookbook_license(*args, &block) || "reserved"
    end

    # The configuration as a hash
    def to_hash
      ChefConfig::Config.save(true)
    end

    # Load from a file
    def self.from_file(file)
      new(file)
    end

    # Behave just like ChefConfig::Config in general
    def method_missing(name, *args, &block)
      ChefConfig::Config.send(name, *args, &block)
    end

    def respond_to_missing?(name)
      ChefConfig::Config.respond_to?(name)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
berkshelf-8.0.15 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.13 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.12 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.9 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.7 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.5 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.2 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.1 lib/berkshelf/chef_config_compat.rb
berkshelf-8.0.0 lib/berkshelf/chef_config_compat.rb
berkshelf-7.2.2 lib/berkshelf/chef_config_compat.rb
berkshelf-7.2.1 lib/berkshelf/chef_config_compat.rb
berkshelf-7.2.0 lib/berkshelf/chef_config_compat.rb