Add validation method and todo

This commit is contained in:
Brian Cain 2019-07-26 10:42:32 -07:00
parent b82b33d204
commit e05437ddf2
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
1 changed files with 22 additions and 0 deletions

View File

@ -4,6 +4,9 @@ module VagrantPlugins
module Kernel_V2
# Represents a single configured provisioner for a VM.
class VagrantConfigProvisioner
# Defaults
VALID_BEFORE_AFTER_TYPES = [:each, :all].freeze
# Unique name for this provisioner
#
# @return [String]
@ -102,6 +105,25 @@ module VagrantPlugins
@config.finalize!
end
# TODO: This isn't being called
#
# @return [Array] array of strings of error messages from config option validation
def validate(machine)
errors = _detected_errors
if @before
if @before.is_a?(Symbol) && !VALID_BEFORE_AFTER_TYPES.include?(@before)
errors << "Before symbol is not a valid symbol"
end
end
if @after
if @after.is_a?(Symbol) && !VALID_BEFORE_AFTER_TYPES.include?(@after)
errors << "After symbol is not a valid symbol"
end
end
end
# Returns whether the provisioner used was invalid or not. A provisioner
# is invalid if it can't be found.
#