Capture missing key calls in V1 configs and record them as warnings
This commit is contained in:
parent
18492d5d70
commit
d15acde8c0
|
@ -1,3 +1,6 @@
|
|||
require "ostruct"
|
||||
require "set"
|
||||
|
||||
module Vagrant
|
||||
module Config
|
||||
module V1
|
||||
|
@ -11,6 +14,7 @@ module Vagrant
|
|||
def initialize(config_map, keys=nil)
|
||||
@keys = keys || {}
|
||||
@config_map = config_map
|
||||
@missing_key_calls = Set.new
|
||||
end
|
||||
|
||||
# We use method_missing as a way to get the configuration that is
|
||||
|
@ -25,8 +29,9 @@ module Vagrant
|
|||
@keys[name] = config_klass.new
|
||||
return @keys[name]
|
||||
else
|
||||
# Super it up to probably raise a NoMethodError
|
||||
super
|
||||
# Record access to a missing key as an error
|
||||
@missing_key_calls.add(name.to_s)
|
||||
return OpenStruct.new
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,7 +51,8 @@ module Vagrant
|
|||
def __internal_state
|
||||
{
|
||||
"config_map" => @config_map,
|
||||
"keys" => @keys
|
||||
"keys" => @keys,
|
||||
"missing_key_calls" => @missing_key_calls
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -119,6 +119,10 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
old.__internal_state["missing_key_calls"].to_a.sort.each do |key|
|
||||
warnings << I18n.t("vagrant.config.loader.bad_v1_key", :key => key)
|
||||
end
|
||||
|
||||
[root, warnings, errors]
|
||||
end
|
||||
|
||||
|
|
|
@ -397,6 +397,10 @@ en:
|
|||
run_list_empty: "Run list must not be empty."
|
||||
server_url_empty: "Chef server URL must be populated."
|
||||
validation_key_path: "Validation key path must be valid path to your chef server validation key."
|
||||
loader:
|
||||
bad_v1_key: |-
|
||||
Unknown configuration section '%{key}'. If this section was part of
|
||||
a Vagrant 1.0.x plugin, note that 1.0.x plugins are incompatible with 1.1+.
|
||||
root:
|
||||
bad_key: |-
|
||||
Unknown configuration section '%{key}'.
|
||||
|
|
Loading…
Reference in New Issue