summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-14 22:38:40 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-12-15 17:05:53 +0800
commit05bc71c856c735fa364e15db62ba5d40cfd7c5ef (patch)
tree319a6aadfda6b3867df342ed5f9565101d9f3dcb /lib
parent3e90aa1119fc4c77e92e6492f1906f252d90b64e (diff)
downloadgitlab-ce-05bc71c856c735fa364e15db62ba5d40cfd7c5ef.tar.gz
Convert CI YAML variables keys into strings
So that this would be more consistent with the other variables, which all of them are string based. Closes #25554
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb2
-rw-r--r--lib/gitlab/serialize/yaml_variables.rb30
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index fef652cb975..8806a506ffa 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -118,7 +118,7 @@ module Ci
.merge(job_variables(name))
variables.map do |key, value|
- { key: key, value: value, public: true }
+ { key: key.to_s, value: value.to_s, public: true }
end
end
diff --git a/lib/gitlab/serialize/yaml_variables.rb b/lib/gitlab/serialize/yaml_variables.rb
new file mode 100644
index 00000000000..ca44acbd906
--- /dev/null
+++ b/lib/gitlab/serialize/yaml_variables.rb
@@ -0,0 +1,30 @@
+
+module Gitlab
+ module Serialize
+ # This serializer could make sure our YAML variables' keys and values
+ # are always strings. This is more for legacy build data because
+ # from now on we convert them into strings before saving to database.
+ module YamlVariables
+ extend self
+
+ def load(string)
+ return unless string
+
+ YAML.load(string).
+ map(&YamlVariables.method(:convert_key_value_to_string))
+ end
+
+ def dump(object)
+ YAML.dump(object)
+ end
+
+ private
+
+ def convert_key_value_to_string(variable)
+ variable[:key] = variable[:key].to_s
+ variable[:value] = variable[:value].to_s
+ variable
+ end
+ end
+ end
+end