Sha256: 815e22a655b34ffc5f247626a2ba76468424ead1bbf95df737a27ece6397d33e

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require 'r10k/logging'

require 'r10k/git'
require 'r10k/git/cache'

require 'r10k/forge/module_release'

module R10K
  module Initializers
    class BaseInitializer

      include R10K::Logging

      def initialize(settings)
        @settings = settings
      end

      private

      def with_setting(key)
        if !@settings[key].nil?
          yield @settings[key]
        end
      end
    end

    class GlobalInitializer < BaseInitializer
      def call
        with_setting(:purgedirs) do |_|
          logger.warn("the purgedirs key in r10k.yaml is deprecated. it is currently ignored.")
        end

        with_setting(:cachedir) { |value| R10K::Git::Cache.settings[:cache_root] = value }

        with_setting(:git) { |value| GitInitializer.new(value).call }
        with_setting(:forge) { |value| ForgeInitializer.new(value).call }
      end
    end

    class GitInitializer < BaseInitializer
      def call
        with_setting(:provider) { |value| R10K::Git.provider = value }
        with_setting(:username) { |value| R10K::Git.settings[:username] = value }
        with_setting(:private_key) { |value| R10K::Git.settings[:private_key] = value }
        with_setting(:proxy) { |value| R10K::Git.settings[:proxy] = value }
        with_setting(:repositories) { |value| R10K::Git.settings[:repositories] = value }
      end
    end

    class ForgeInitializer < BaseInitializer
      def call
        with_setting(:baseurl) { |value| PuppetForge.host = value }
        with_setting(:proxy) { |value| PuppetForge::Connection.proxy = value }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
r10k-2.3.1 lib/r10k/initializers.rb
r10k-2.3.0 lib/r10k/initializers.rb