summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-13 14:12:00 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-13 14:12:00 +0100
commite16fba6726adcf7e82862336fab22c6c6baf2010 (patch)
treee4fc892dfa5e06cf4f5e8852b22663f3b091ebbe
parent937e7f9e9669d4939cd6c5055a90339ff79d216b (diff)
downloadgitlab-ce-e16fba6726adcf7e82862336fab22c6c6baf2010.tar.gz
Improve how we handle persistent runner variables
-rw-r--r--app/models/ci/variable.rb4
-rw-r--r--app/models/concerns/has_variable.rb6
-rw-r--r--lib/gitlab/ci/variables/collection/item.rb12
3 files changed, 3 insertions, 19 deletions
diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb
index 51389fb82bf..7c71291de84 100644
--- a/app/models/ci/variable.rb
+++ b/app/models/ci/variable.rb
@@ -12,9 +12,5 @@ module Ci
}
scope :unprotected, -> { where(protected: false) }
-
- def to_hash
- { key: key, value: value, public: false }
- end
end
end
diff --git a/app/models/concerns/has_variable.rb b/app/models/concerns/has_variable.rb
index 3c29e12ad71..8a241e4374a 100644
--- a/app/models/concerns/has_variable.rb
+++ b/app/models/concerns/has_variable.rb
@@ -20,12 +20,8 @@ module HasVariable
super(new_key.to_s.strip)
end
- def to_hash
- { key: key, value: value, public: false }
- end
-
def to_runner_variable
- to_hash
+ { key: key, value: value, public: false }
end
end
end
diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb
index 47e06566607..939912981e6 100644
--- a/lib/gitlab/ci/variables/collection/item.rb
+++ b/lib/gitlab/ci/variables/collection/item.rb
@@ -3,8 +3,6 @@ module Gitlab
module Variables
class Collection
class Item
- # TODO, public by default?
- #
def initialize(**options)
@variable = {
key: options.fetch(:key),
@@ -34,17 +32,11 @@ module Gitlab
end
def self.fabricate(resource)
- # TODO, to_runner_variable by default for class < ActiveRecord::Base
- #
case resource
when Hash
self.new(resource)
- when ::Ci::Variable
- self.new(resource.to_hash)
- when ::Ci::PipelineVariable
- self.new(resource.to_hash)
- when ::Ci::GroupVariable
- self.new(resource.to_hash)
+ when ::HasVariable
+ self.new(resource.to_runner_variable)
when self
resource.dup
else