From 606a8fdde294d123280e7e743f90949a9658a65b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 8 Jul 2015 10:25:32 -0600 Subject: [PATCH] providers/docker: validate create args is list [GH-4850] --- plugins/providers/docker/config.rb | 4 ++++ templates/locales/providers_docker.yml | 2 ++ test/unit/plugins/providers/docker/config_test.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/plugins/providers/docker/config.rb b/plugins/providers/docker/config.rb index 7b36ab70c..45227e7fe 100644 --- a/plugins/providers/docker/config.rb +++ b/plugins/providers/docker/config.rb @@ -231,6 +231,10 @@ module VagrantPlugins end end + if !@create_args.is_a?(Array) + errors << I18n.t("docker_provider.errors.config.create_args_array") + end + @links.each do |link| parts = link.split(":") if parts.length != 2 || parts[0] == "" || parts[1] == "" diff --git a/templates/locales/providers_docker.yml b/templates/locales/providers_docker.yml index f6d6ae960..f642c8624 100644 --- a/templates/locales/providers_docker.yml +++ b/templates/locales/providers_docker.yml @@ -123,6 +123,8 @@ en: "build_dir" must exist and contain a Dockerfile build_dir_or_image: |- One of "build_dir" or "image" must be set + create_args_array: |- + "create_args" must be an array invalid_link: |- Invalid link (should be 'name:alias'): "%{link}" invalid_vagrantfile: |- diff --git a/test/unit/plugins/providers/docker/config_test.rb b/test/unit/plugins/providers/docker/config_test.rb index 0d1937994..54732d2ee 100644 --- a/test/unit/plugins/providers/docker/config_test.rb +++ b/test/unit/plugins/providers/docker/config_test.rb @@ -90,6 +90,18 @@ describe VagrantPlugins::DockerProvider::Config do end end + describe "#create_args" do + before do + valid_defaults + end + + it "is invalid if it isn't an array" do + subject.create_args = "foo" + subject.finalize! + assert_invalid + end + end + describe "#expose" do before do valid_defaults