From a5d8cc1caa52e3bd86a760a3cfef7731036279d6 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 21 Mar 2018 10:23:03 -0700 Subject: [PATCH] Update trigger classes with comments --- plugins/kernel_v2/config/trigger.rb | 6 +++--- plugins/kernel_v2/config/vm_trigger.rb | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/kernel_v2/config/trigger.rb b/plugins/kernel_v2/config/trigger.rb index 0535e0565..8a9b49cd3 100644 --- a/plugins/kernel_v2/config/trigger.rb +++ b/plugins/kernel_v2/config/trigger.rb @@ -1,5 +1,4 @@ require "vagrant" - require File.expand_path("../vm_trigger", __FILE__) module VagrantPlugins @@ -48,6 +47,7 @@ module VagrantPlugins # and the rest are commands for the trigger blk = command.pop else + # TODO: # No config block given at all, validation step should throw error? end @@ -71,6 +71,7 @@ module VagrantPlugins # and the rest are commands for the trigger blk = command.pop else + # TODO: # No config block given at all, validation step should throw error? end @@ -148,9 +149,8 @@ module VagrantPlugins end end + # Iterates over all defined triggers and finalizes their config objects def finalize! - # read through configured settings blocks and set their values - # and then set up action hooks here? if !@_before_triggers.empty? @_before_triggers.map { |t| t.finalize! } end diff --git a/plugins/kernel_v2/config/vm_trigger.rb b/plugins/kernel_v2/config/vm_trigger.rb index 5ce358431..ed09d8900 100644 --- a/plugins/kernel_v2/config/vm_trigger.rb +++ b/plugins/kernel_v2/config/vm_trigger.rb @@ -1,11 +1,11 @@ require 'log4r' - require Vagrant.source_root.join('plugins/provisioners/shell/config') module VagrantPlugins module Kernel_V2 # Represents a single configured provisioner for a VM. class VagrantConfigTrigger < Vagrant.plugin("2", :config) + # Defaults DEFAULT_ON_ERROR = :halt #------------------------------------------------------------------- @@ -68,7 +68,6 @@ module VagrantPlugins def initialize(command) @logger = Log4r::Logger.new("vagrant::config::vm::trigger::config") - #@logger.debug("Trigger defined: #{name}") @name = UNSET_VALUE @info = UNSET_VALUE @@ -82,10 +81,13 @@ module VagrantPlugins # Internal options @id = SecureRandom.uuid @command = command.to_sym + + @logger.debug("Trigger defined for command: #{command}") end def finalize! - # Ensure all config options are set to nil if untouched by user + # Ensure all config options are set to nil or default value if untouched + # by user @name = nil if @name == UNSET_VALUE @info = nil if @info == UNSET_VALUE @warn = nil if @warn == UNSET_VALUE