Sha256: a0bbfbfba0801b44b99bb54854252aebe1445d352ab8d2fce9662c6a4e73ef18

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'vagrant/util/hash_with_indifferent_access'

module Berkshelf::Vagrant
  class BerksConfig < ::Vagrant::Util::HashWithIndifferentAccess
    class << self
      # @return [String]
      def store_location
        File.join(Berkshelf.berkshelf_path, 'config.json')
      end

      # @return [String]
      def local_location
        ENV['BERKSHELF_CONFIG'] || File.join('.', '.berkshelf', 'config.json')
      end

      # @return [String]
      def path
        path = File.exists?(local_location) ? local_location : store_location
        File.expand_path(path)
      end

      # Instantiate and return or just return the currently instantiated Berkshelf
      # configuration
      #
      # @return [Config]
      def instance
        @instance ||= if File.exists?(path) && File.readable?(path)
          new(JSON.parse(File.read(path)))
        else
          new
        end
      end
    end

    def initialize(attributes = {})
      attributes.merge!(chef: ChefConfig.instance, ssl: ::Vagrant::Util::HashWithIndifferentAccess.new(verify: false))
      super(attributes)
    end

    def chef
      self[:chef]
    end

    def ssl
      self[:ssl]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-berkshelf-3.0.1 lib/berkshelf/vagrant/berks_config.rb