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
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-15 00:00:15 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 11:07:13 +0300
commit6b979687459ad1ab5f1953bf451ee80fdb899b96 (patch)
treeff19ce3e4386a562a68cf9a9d9071ea7d02934ec /lib
parente1b3ab5af290f6d2eeb56c4b72e341324414a6d2 (diff)
Update support for dynamic environments
Diffstat (limited to 'lib')
-rw-r--r--lib/expand_variables.rb2
-rw-r--r--lib/gitlab/ci/config/node/environment.rb16
-rw-r--r--lib/gitlab/ci/config/node/job.rb10
3 files changed, 12 insertions, 16 deletions
diff --git a/lib/expand_variables.rb b/lib/expand_variables.rb
index 669735cc56c..7b1533d0d32 100644
--- a/lib/expand_variables.rb
+++ b/lib/expand_variables.rb
@@ -1,6 +1,6 @@
module ExpandVariables
class << self
- def expand_variables(value, variables)
+ def expand(value, variables)
# Convert hash array to variables
if variables.is_a?(Array)
variables = variables.reduce({}) do |hash, variable|
diff --git a/lib/gitlab/ci/config/node/environment.rb b/lib/gitlab/ci/config/node/environment.rb
index 629c17e6250..85302589ce6 100644
--- a/lib/gitlab/ci/config/node/environment.rb
+++ b/lib/gitlab/ci/config/node/environment.rb
@@ -8,7 +8,11 @@ module Gitlab
class Environment < Entry
include Validatable
+ ALLOWED_KEYS = %i[name url]
+
validations do
+ validates :config, allowed_keys: ALLOWED_KEYS, if: :hash?
+
validates :name, presence: true
validates :url,
@@ -32,9 +36,9 @@ module Gitlab
end
def name
- case
- when string? then @config
- when hash? then @config[:name]
+ case @config.type
+ when String then @config
+ when Hash then @config[:name]
end
end
@@ -43,9 +47,9 @@ module Gitlab
end
def value
- case
- when string? then { name: @config }
- when hash? then @config
+ case @config.type
+ when String then { name: @config }
+ when Hash then @config
end
end
end
diff --git a/lib/gitlab/ci/config/node/job.rb b/lib/gitlab/ci/config/node/job.rb
index e90e80171a4..3ab34d23d37 100644
--- a/lib/gitlab/ci/config/node/job.rb
+++ b/lib/gitlab/ci/config/node/job.rb
@@ -29,14 +29,6 @@ module Gitlab
inclusion: { in: %w[on_success on_failure always manual],
message: 'should be on_success, on_failure, ' \
'always or manual' }
- validates :environment,
- type: {
- with: String,
- message: Gitlab::Regex.environment_name_regex_message }
- validates :environment,
- format: {
- with: Gitlab::Regex.environment_name_regex,
- message: Gitlab::Regex.environment_name_regex_message }
validates :dependencies, array_of_strings: true
end
@@ -83,7 +75,7 @@ module Gitlab
helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables,
- :artifacts, :commands
+ :artifacts, :commands, :environment
def compose!(deps = nil)
super do