plugins/kernel_v2/config/vm_provisioner.rb in vagrant-unbundled-2.2.9.0 vs plugins/kernel_v2/config/vm_provisioner.rb in vagrant-unbundled-2.2.10.0

- old
+ new

@@ -54,10 +54,16 @@ # The name of a provisioner to run after it is finished # # @return [String, Symbol] attr_accessor :after + # Boolean, when true signifies that some communicator must + # be available in order for the provisioner to run. + # + # @return [Boolean] + attr_accessor :communicator_required + def initialize(name, type, **options) @logger = Log4r::Logger.new("vagrant::config::vm::provisioner") @logger.debug("Provisioner defined: #{name}") @id = name || SecureRandom.uuid @@ -67,10 +73,11 @@ @preserve_order = false @run = nil @type = type @before = options[:before] @after = options[:after] + @communicator_required = options.fetch(:communicator_required, true) # Attempt to find the provisioner... if !Vagrant.plugin("2").manager.provisioners[type] @logger.warn("Provisioner '#{type}' not found.") @invalid = true @@ -116,20 +123,24 @@ def validate(machine, provisioners) errors = _detected_errors provisioner_names = provisioners.map { |i| i.name.to_s if i.name != name }.compact + if ![TrueClass, FalseClass].include?(@communicator_required.class) + errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "communicator_required", type: "boolean") + end + if @before && @after errors << I18n.t("vagrant.provisioners.base.both_before_after_set") end if @before if !VALID_BEFORE_AFTER_TYPES.include?(@before) if @before.is_a?(Symbol) && !VALID_BEFORE_AFTER_TYPES.include?(@before) errors << I18n.t("vagrant.provisioners.base.invalid_alias_value", opt: "before", alias: VALID_BEFORE_AFTER_TYPES.join(", ")) elsif !@before.is_a?(String) && !VALID_BEFORE_AFTER_TYPES.include?(@before) - errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "before") + errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "before", type: "string") end if !provisioner_names.include?(@before) errors << I18n.t("vagrant.provisioners.base.missing_provisioner_name", name: @before, @@ -151,10 +162,10 @@ if @after if !VALID_BEFORE_AFTER_TYPES.include?(@after) if @after.is_a?(Symbol) errors << I18n.t("vagrant.provisioners.base.invalid_alias_value", opt: "after", alias: VALID_BEFORE_AFTER_TYPES.join(", ")) elsif !@after.is_a?(String) - errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "after") + errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "after", type: "string") end if !provisioner_names.include?(@after) errors << I18n.t("vagrant.provisioners.base.missing_provisioner_name", name: @after,