summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-07 10:09:53 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-07 10:09:53 +0100
commita194b1982426b5f2411ee4a62ac3432de293528b (patch)
tree5f303c65b50395ae35eaf9c3b4e9875cfbbc83c3
parenta2a8e36178853b5f8fa2eda306b33f8f97970745 (diff)
downloadgitlab-ce-a194b1982426b5f2411ee4a62ac3432de293528b.tar.gz
Make variables collection to runner mapping explicit
-rw-r--r--app/models/project_services/kubernetes_service.rb2
-rw-r--r--lib/gitlab/ci/variables/collection.rb4
-rw-r--r--spec/lib/gitlab/ci/variables/collection_spec.rb6
3 files changed, 5 insertions, 7 deletions
diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb
index c1c68be5ed9..edf80bbd509 100644
--- a/app/models/project_services/kubernetes_service.rb
+++ b/app/models/project_services/kubernetes_service.rb
@@ -115,7 +115,7 @@ class KubernetesService < DeploymentService
collection.append(key: 'KUBE_CA_PEM_FILE', value: ca_pem, public: true, file: true)
end
- variables.to_hash
+ variables.to_runner_variables
end
# Constructs a list of terminals from the reactive cache
diff --git a/lib/gitlab/ci/variables/collection.rb b/lib/gitlab/ci/variables/collection.rb
index 0d830293c3c..e9aa7f9a31c 100644
--- a/lib/gitlab/ci/variables/collection.rb
+++ b/lib/gitlab/ci/variables/collection.rb
@@ -27,7 +27,7 @@ module Gitlab
end
end
- def to_h
+ def to_runner_variables
self.map do |variable|
variable.to_h.reject do |key, value|
key == :file && value == false
@@ -35,8 +35,6 @@ module Gitlab
end
end
- alias_method :to_hash, :to_h
-
private
def fabricate(resource)
diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb
index 39ed1cb4c26..16c23ae450a 100644
--- a/spec/lib/gitlab/ci/variables/collection_spec.rb
+++ b/spec/lib/gitlab/ci/variables/collection_spec.rb
@@ -52,11 +52,11 @@ describe Gitlab::Ci::Variables::Collection do
end
end
- describe '#to_hash' do
- it 'creates a hash / value mapping' do
+ describe '#to_runner_variables' do
+ it 'creates an array of hashes in a runner-compatible format' do
collection = described_class.new([{ key: 'TEST', value: 1 }])
- expect(collection.to_hash)
+ expect(collection.to_runner_variables)
.to eq [{ key: 'TEST', value: 1, public: false }]
end
end