Sha256: f78c61da3685662b75f8d7c63bb0b91c346f6373c03693d0ae0406eba5a808ba

Contents?: true

Size: 953 Bytes

Versions: 6

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

module Bolt
  class Boltdir
    BOLTDIR_NAME = 'Boltdir'

    attr_reader :path, :config_file, :inventory_file, :modulepath, :hiera_config, :puppetfile

    def self.default_boltdir
      Boltdir.new(File.join('~', '.puppetlabs', 'bolt'))
    end

    def self.find_boltdir(dir)
      local_boltdir = Pathname.new(dir).ascend do |path|
        boltdir = path + BOLTDIR_NAME
        break new(boltdir) if boltdir.directory?
      end

      local_boltdir || default_boltdir
    end

    def initialize(path)
      @path = Pathname.new(path).expand_path
      @config_file = @path + 'bolt.yaml'
      @inventory_file = @path + 'inventory.yaml'
      @modulepath = [(@path + 'modules').to_s]
      @hiera_config = @path + 'hiera.yaml'
      @puppetfile = @path + 'Puppetfile'
    end

    def to_s
      @path.to_s
    end

    def eql?(other)
      path == other.path
    end
    alias == eql?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bolt-0.22.0 lib/bolt/boltdir.rb
bolt-0.21.8 lib/bolt/boltdir.rb
bolt-0.21.7 lib/bolt/boltdir.rb
bolt-0.21.6 lib/bolt/boltdir.rb
bolt-0.21.5 lib/bolt/boltdir.rb
bolt-0.21.4 lib/bolt/boltdir.rb