Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-04-05 09:44:34 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-04-05 09:44:34 +0300
commit07388b30b11f92e45da31d9a96a9a64dfd1a97c2 (patch)
tree64b62bc94d40fb2780904cf5ae7e3178a8c5a61a
parent48022ab3e843c8a4e747fd1a4009656703283044 (diff)
parent9f36097db2a5901312d7ea86c5a0df315311b7ff (diff)
Merge branch 'include-ci-yaml' into 'master'
Fixing single string values in the 'include:' keyword of gitlab-ci.yml validations See merge request gitlab-org/gitlab-ce!26998
-rw-r--r--changelogs/unreleased/fix-include-ci-yaml.yml5
-rw-r--r--lib/gitlab/ci/config/entry/includes.rb2
-rw-r--r--lib/gitlab/config/entry/validators.rb8
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb8
4 files changed, 22 insertions, 1 deletions
diff --git a/changelogs/unreleased/fix-include-ci-yaml.yml b/changelogs/unreleased/fix-include-ci-yaml.yml
new file mode 100644
index 00000000000..042413b89aa
--- /dev/null
+++ b/changelogs/unreleased/fix-include-ci-yaml.yml
@@ -0,0 +1,5 @@
+---
+title: Fix single string values for the 'include' keyword validation of gitlab-ci.yml.
+merge_request: 26998
+author: Paul Bonaud (@paulrbr)
+type: fixed
diff --git a/lib/gitlab/ci/config/entry/includes.rb b/lib/gitlab/ci/config/entry/includes.rb
index 82b2b1ccf4b..43e74dfd628 100644
--- a/lib/gitlab/ci/config/entry/includes.rb
+++ b/lib/gitlab/ci/config/entry/includes.rb
@@ -11,7 +11,7 @@ module Gitlab
include ::Gitlab::Config::Entry::Validatable
validations do
- validates :config, type: Array
+ validates :config, array_or_string: true
end
def self.aspects
diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb
index 746fe83f90f..df34d254c65 100644
--- a/lib/gitlab/config/entry/validators.rb
+++ b/lib/gitlab/config/entry/validators.rb
@@ -54,6 +54,14 @@ module Gitlab
end
end
+ class ArrayOrStringValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ unless value.is_a?(Array) || value.is_a?(String)
+ record.errors.add(attribute, 'should be an array or a string')
+ end
+ end
+ end
+
class BooleanValidator < ActiveModel::EachValidator
include LegacyValidationHelpers
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index 63a0d54dcfc..8b39c4e4dd0 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -615,6 +615,14 @@ module Gitlab
subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config), opts) }
context "when validating a ci config file with no project context" do
+ context "when a single string is provided" do
+ let(:include_content) { "/local.gitlab-ci.yml" }
+
+ it "does not return any error" do
+ expect { subject }.not_to raise_error
+ end
+ end
+
context "when an array is provided" do
let(:include_content) { ["/local.gitlab-ci.yml"] }