provisioners/salt: error if minion_config missing [GH-2893]
This commit is contained in:
parent
7abcea35b8
commit
6c5179602c
|
@ -83,6 +83,13 @@ module VagrantPlugins
|
|||
|
||||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
if @minion_config
|
||||
expanded = Pathname.new(@minion_config).expand_path(machine.env.root_path)
|
||||
if !expanded.file?
|
||||
errors << I18n.t("vagrant.provisioners.salt.minion_config_nonexist")
|
||||
end
|
||||
end
|
||||
|
||||
if @minion_key || @minion_pub
|
||||
if !@minion_key || !@minion_pub
|
||||
errors << @minion_pub
|
||||
|
|
|
@ -1548,6 +1548,8 @@ en:
|
|||
install_failed: "Docker installation failed."
|
||||
|
||||
salt:
|
||||
minion_config_nonexist: |-
|
||||
The specified minion_config file could not be found.
|
||||
missing_key: |-
|
||||
You must include both public and private keys.
|
||||
must_accept_keys: |-
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
require File.expand_path("../../../../base", __FILE__)
|
||||
|
||||
require Vagrant.source_root.join("plugins/provisioners/salt/config")
|
||||
|
||||
describe VagrantPlugins::Salt::Config do
|
||||
include_context "unit"
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
let(:iso_env) do
|
||||
# We have to create a Vagrantfile so there is a root path
|
||||
env = isolated_environment
|
||||
env.vagrantfile("")
|
||||
env.create_vagrant_env
|
||||
end
|
||||
|
||||
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
|
||||
|
||||
describe "validate" do
|
||||
let(:error_key) { "salt provisioner" }
|
||||
|
||||
it "passes by default" do
|
||||
subject.finalize!
|
||||
result = subject.validate(machine)
|
||||
expect(result[error_key]).to be_empty
|
||||
end
|
||||
|
||||
context "minion_config" do
|
||||
it "fails if minion_config is set and missing" do
|
||||
subject.minion_config = "/nope/nope/i/dont/exist"
|
||||
subject.finalize!
|
||||
|
||||
result = subject.validate(machine)
|
||||
expect(result[error_key]).to_not be_empty
|
||||
end
|
||||
|
||||
it "is valid if is set and not missing" do
|
||||
subject.minion_config = File.expand_path(__FILE__)
|
||||
subject.finalize!
|
||||
|
||||
result = subject.validate(machine)
|
||||
expect(result[error_key]).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue