diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2016-12-19 19:09:04 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2016-12-19 19:09:04 +0000 |
commit | 5048baaa371ebaafeb057608d60bcb09a866f07c (patch) | |
tree | f5689998378d710decaeb48f6344672396fc8b5a /lib | |
parent | 8c8c4f8c5a5f5845b9ebca415aaa29278cb904c7 (diff) | |
parent | 4d8a2bc987dbdd417f7ae971c884b084a8982f0a (diff) | |
download | gitlab-ce-5048baaa371ebaafeb057608d60bcb09a866f07c.tar.gz |
Merge branch 'fix-yaml-variables' into 'master'
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
See merge request !8088
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/serialize/ci/variables.rb | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index fef652cb975..7463bd719d5 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, public: true } end end diff --git a/lib/gitlab/serialize/ci/variables.rb b/lib/gitlab/serialize/ci/variables.rb new file mode 100644 index 00000000000..3a9443bfcd9 --- /dev/null +++ b/lib/gitlab/serialize/ci/variables.rb @@ -0,0 +1,27 @@ +module Gitlab + module Serialize + module Ci + # 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 Variables + extend self + + def load(string) + return unless string + + object = YAML.safe_load(string, [Symbol]) + + object.map do |variable| + variable[:key] = variable[:key].to_s + variable + end + end + + def dump(object) + YAML.dump(object) + end + end + end + end +end |