Sha256: 2a98b2adf0c2557688ce75ea169d107ddf544f5ec09bef52d0da5f879365f733

Contents?: true

Size: 1.85 KB

Versions: 55

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

require 'bolt/project'
require 'bolt/config'
require 'bolt/error'

module Bolt
  class ApplyInventory
    class InvalidFunctionCall < Bolt::Error
      def initialize(function)
        super("The function '#{function}' is not callable within an apply block",
              'bolt.inventory/invalid-function-call')
      end
    end

    attr_reader :config_hash

    def initialize(config_hash = {})
      @config_hash = config_hash
      @targets = {}
    end

    def create_apply_target(target)
      @targets[target.name] = target
    end

    def validate
      @groups.validate
    end

    def version
      2
    end

    def target_implementation_class
      Bolt::ApplyTarget
    end

    def get_targets(*_params)
      raise InvalidFunctionCall, 'get_targets'
    end

    def get_target(*_params)
      raise InvalidFunctionCall, 'get_target'
    end

    # rubocop:disable Naming/AccessorMethodName
    def set_var(*_params)
      raise InvalidFunctionCall, 'set_var'
    end

    def set_feature(*_params)
      raise InvalidFunctionCall, 'set_feature'
    end
    # rubocop:enable Naming/AccessorMethodName

    def vars(target)
      @targets[target.name].vars
    end

    def add_facts(*_params)
      raise InvalidFunctionCall, 'add_facts'
    end

    def facts(target)
      @targets[target.name].facts
    end

    def features(target)
      @targets[target.name].features
    end

    def resource(target, type, title)
      @targets[target.name].resource(type, title)
    end

    def add_to_group(*_params)
      raise InvalidFunctionCall, 'add_to_group'
    end

    def plugin_hooks(target)
      @targets[target.name].plugin_hooks
    end

    def set_config(_target, _key_or_key_path, _value)
      raise InvalidFunctionCall, 'set_config'
    end

    def target_config(target)
      @targets[target.name].config
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
bolt-3.17.0 lib/bolt/apply_inventory.rb
bolt-3.16.1 lib/bolt/apply_inventory.rb
bolt-3.16.0 lib/bolt/apply_inventory.rb
bolt-3.15.0 lib/bolt/apply_inventory.rb
bolt-3.14.1 lib/bolt/apply_inventory.rb
bolt-3.13.0 lib/bolt/apply_inventory.rb
bolt-3.12.0 lib/bolt/apply_inventory.rb
bolt-3.11.0 lib/bolt/apply_inventory.rb
bolt-3.10.0 lib/bolt/apply_inventory.rb
bolt-3.9.2 lib/bolt/apply_inventory.rb
bolt-3.9.1 lib/bolt/apply_inventory.rb
bolt-3.9.0 lib/bolt/apply_inventory.rb
bolt-3.8.1 lib/bolt/apply_inventory.rb
bolt-3.8.0 lib/bolt/apply_inventory.rb
bolt-3.7.1 lib/bolt/apply_inventory.rb
bolt-3.7.0 lib/bolt/apply_inventory.rb
bolt-3.6.1 lib/bolt/apply_inventory.rb
bolt-3.6.0 lib/bolt/apply_inventory.rb
bolt-3.5.0 lib/bolt/apply_inventory.rb
bolt-3.4.0 lib/bolt/apply_inventory.rb