From 813ffd06ec7abfe3e63d73d09a7a719a58068eaa Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 8 Mar 2018 15:31:58 -0800 Subject: [PATCH] Add more trigger config options --- plugins/kernel_v2/config/trigger.rb | 56 ++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/plugins/kernel_v2/config/trigger.rb b/plugins/kernel_v2/config/trigger.rb index 7e23ee8c8..32946629b 100644 --- a/plugins/kernel_v2/config/trigger.rb +++ b/plugins/kernel_v2/config/trigger.rb @@ -3,24 +3,65 @@ require "vagrant" module VagrantPlugins module Kernel_V2 class TriggerConfig < Vagrant.plugin("2", :config) + DEFAULT_ON_ERROR = :halt + # Name for the given Trigger. Defaults to nil. + # + # @return [String] attr_accessor :name + # A string to print at the WARN level + # + # @return [String] + attr_accessor :info + + # A string to print at the WARN level + # + # @return [String] + attr_accessor :warn + + # Determines what how a Trigger should behave if it runs into an error. + # Defaults to :halt, otherwise can only be set to :continue. + # + # @return [Symbol] + attr_accessor :on_error + + # If set, will not run trigger for the configured Vagrant commands. + # + # @return [String, Array] + attr_accessor :ignore + + + # If set, will only run trigger for guests that match keys for this parameter. + # + # @return [String, Array] + attr_accessor :only_on + def initialize @logger = Log4r::Logger.new("vagrant::config::trigger") # Internal state @name = UNSET_VALUE + @info = UNSET_VALUE + @warn = UNSET_VALUE + @on_error = UNSET_VALUE + @ignore = UNSET_VALUE + @only_on = UNSET_VALUE end - # @param [Symbol] command Vagrant command to create trigger on + # @param [Array, Symbol] command Vagrant command to create trigger on # @param [Block] block The defined after block - def before(command, &block) + def before(**command, &block) end - # @param [Symbol] command Vagrant command to create trigger on + # @param [Array, Symbol] command Vagrant command to create trigger on # @param [Block] block The defined after block - def after(command, &block) + def after(**command, &block) + end + + # @param [Array, Symbol] command Vagrant command to create trigger on + # @return [ActionHook] returns action hook? + def parse_trigger_block(**command) end #------------------------------------------------------------------- @@ -29,9 +70,14 @@ module VagrantPlugins def finalize! @name = nil if @name == UNSET_VALUE + @info = nil if @info == UNSET_VALUE + @warn = nil if @warn == UNSET_VALUE + @on_error = DEFAULT_ON_ERROR if @on_error == UNSET_VALUE + @ignore = nil if @ignore == UNSET_VALUE + @only_on = :halt if @only_on == UNSET_VALUE end - # Validate all pushes + # Validate Trigger settings def validate(machine) end