Update trigger classes with comments
This commit is contained in:
parent
e7274f1b6c
commit
a5d8cc1caa
|
@ -1,5 +1,4 @@
|
||||||
require "vagrant"
|
require "vagrant"
|
||||||
|
|
||||||
require File.expand_path("../vm_trigger", __FILE__)
|
require File.expand_path("../vm_trigger", __FILE__)
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
|
@ -48,6 +47,7 @@ module VagrantPlugins
|
||||||
# and the rest are commands for the trigger
|
# and the rest are commands for the trigger
|
||||||
blk = command.pop
|
blk = command.pop
|
||||||
else
|
else
|
||||||
|
# TODO:
|
||||||
# No config block given at all, validation step should throw error?
|
# No config block given at all, validation step should throw error?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ module VagrantPlugins
|
||||||
# and the rest are commands for the trigger
|
# and the rest are commands for the trigger
|
||||||
blk = command.pop
|
blk = command.pop
|
||||||
else
|
else
|
||||||
|
# TODO:
|
||||||
# No config block given at all, validation step should throw error?
|
# No config block given at all, validation step should throw error?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,9 +149,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Iterates over all defined triggers and finalizes their config objects
|
||||||
def finalize!
|
def finalize!
|
||||||
# read through configured settings blocks and set their values
|
|
||||||
# and then set up action hooks here?
|
|
||||||
if !@_before_triggers.empty?
|
if !@_before_triggers.empty?
|
||||||
@_before_triggers.map { |t| t.finalize! }
|
@_before_triggers.map { |t| t.finalize! }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
require 'log4r'
|
require 'log4r'
|
||||||
|
|
||||||
require Vagrant.source_root.join('plugins/provisioners/shell/config')
|
require Vagrant.source_root.join('plugins/provisioners/shell/config')
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Kernel_V2
|
module Kernel_V2
|
||||||
# Represents a single configured provisioner for a VM.
|
# Represents a single configured provisioner for a VM.
|
||||||
class VagrantConfigTrigger < Vagrant.plugin("2", :config)
|
class VagrantConfigTrigger < Vagrant.plugin("2", :config)
|
||||||
|
# Defaults
|
||||||
DEFAULT_ON_ERROR = :halt
|
DEFAULT_ON_ERROR = :halt
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
@ -68,7 +68,6 @@ module VagrantPlugins
|
||||||
|
|
||||||
def initialize(command)
|
def initialize(command)
|
||||||
@logger = Log4r::Logger.new("vagrant::config::vm::trigger::config")
|
@logger = Log4r::Logger.new("vagrant::config::vm::trigger::config")
|
||||||
#@logger.debug("Trigger defined: #{name}")
|
|
||||||
|
|
||||||
@name = UNSET_VALUE
|
@name = UNSET_VALUE
|
||||||
@info = UNSET_VALUE
|
@info = UNSET_VALUE
|
||||||
|
@ -82,10 +81,13 @@ module VagrantPlugins
|
||||||
# Internal options
|
# Internal options
|
||||||
@id = SecureRandom.uuid
|
@id = SecureRandom.uuid
|
||||||
@command = command.to_sym
|
@command = command.to_sym
|
||||||
|
|
||||||
|
@logger.debug("Trigger defined for command: #{command}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
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
|
@name = nil if @name == UNSET_VALUE
|
||||||
@info = nil if @info == UNSET_VALUE
|
@info = nil if @info == UNSET_VALUE
|
||||||
@warn = nil if @warn == UNSET_VALUE
|
@warn = nil if @warn == UNSET_VALUE
|
||||||
|
|
Loading…
Reference in New Issue