Warn users about unknown requested experimental features
This commit is contained in:
parent
01ec72cac2
commit
accabdd7ca
|
@ -172,6 +172,13 @@ begin
|
|||
logger.debug("Experimental flag is enabled")
|
||||
if Vagrant::Util::Experimental.global_enabled?
|
||||
ui.warn(I18n.t("vagrant.general.experimental.all"), bold: true, prefix: true, channel: :error)
|
||||
else
|
||||
ui.warn(I18n.t("vagrant.general.experimental.features", features: experimental.join(", ")), bold: true, prefix: true, channel: :error)
|
||||
|
||||
diff = Vagrant::Util::Experimental.features_valid?
|
||||
if !diff.empty?
|
||||
ui.error(I18n.t("vagrant.general.experimental.unknown_features", unknown: diff.join(", ")), bold: true, prefix: true, channel: :error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,14 +45,19 @@ module Vagrant
|
|||
experimental = features_requested
|
||||
feature = feature.to_s
|
||||
|
||||
if experimental.size == 1 && experimental.first == "1"
|
||||
return true
|
||||
elsif VALID_FEATURES.include?(feature) &&
|
||||
experimental.include?(feature)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
return global_enabled? || (VALID_FEATURES.include?(feature) && experimental.include?(feature))
|
||||
end
|
||||
|
||||
# Determines if there are any unrecognized requested features
|
||||
#
|
||||
# @return [Array]
|
||||
def features_valid?
|
||||
if !defined?(@_features_diff)
|
||||
@_features_diff = []
|
||||
features = features_requested
|
||||
features.each { |f| @_features_diff << f if !VALID_FEATURES.include?(f) }
|
||||
end
|
||||
@_features_diff
|
||||
end
|
||||
|
||||
# Returns the features requested for the experimental flag
|
||||
|
|
|
@ -405,6 +405,10 @@ en:
|
|||
|
||||
Please use with caution, as some of the features may not be fully
|
||||
functional yet.
|
||||
unknown_features: |-
|
||||
Requested unknown feature flags will be ignored:
|
||||
|
||||
Unknown: %{unknown}
|
||||
not_in_installer: |-
|
||||
You appear to be running Vagrant outside of the official installers.
|
||||
Note that the installers are what ensure that Vagrant has all required
|
||||
|
|
|
@ -98,6 +98,22 @@ describe Vagrant::Util::Experimental do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#features_valid" do
|
||||
before(:each) do
|
||||
stub_const("Vagrant::Util::Experimental::VALID_FEATURES", ["cool_feature", "other_feature", "secret_feature"])
|
||||
end
|
||||
|
||||
it "returns an empty array if no diffs found" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("cool_feature,other_feature")
|
||||
expect(subject.features_valid?).to eq([])
|
||||
end
|
||||
|
||||
it "returns the invalid flag if found" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("fake_feature")
|
||||
expect(subject.features_valid?).to eq(["fake_feature"])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#features_requested" do
|
||||
it "returns an array of requested features" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("secret_feature,other_secret")
|
||||
|
|
Loading…
Reference in New Issue