Commit 4b8337d4 authored by Kamil Trzciński's avatar Kamil Trzciński

Add Variables entry into Processable

Variables handling is generic for Job and Bridge
it is better to keep it's behaviour in a single place
parent 67502abd
...@@ -67,6 +67,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do ...@@ -67,6 +67,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do
ignore: false, ignore: false,
stage: 'test', stage: 'test',
only: { refs: %w[branches tags] }, only: { refs: %w[branches tags] },
variables: {},
scheduling_type: :dag) scheduling_type: :dag)
end end
end end
......
...@@ -11,7 +11,7 @@ module Gitlab ...@@ -11,7 +11,7 @@ module Gitlab
class Bridge < ::Gitlab::Config::Entry::Node class Bridge < ::Gitlab::Config::Entry::Node
include ::Gitlab::Ci::Config::Entry::Processable include ::Gitlab::Ci::Config::Entry::Processable
ALLOWED_KEYS = %i[trigger allow_failure when variables needs].freeze ALLOWED_KEYS = %i[trigger allow_failure when needs].freeze
validations do validations do
validates :config, allowed_keys: ALLOWED_KEYS + PROCESSABLE_ALLOWED_KEYS validates :config, allowed_keys: ALLOWED_KEYS + PROCESSABLE_ALLOWED_KEYS
...@@ -45,10 +45,6 @@ module Gitlab ...@@ -45,10 +45,6 @@ module Gitlab
inherit: false, inherit: false,
metadata: { allowed_needs: %i[job bridge] } metadata: { allowed_needs: %i[job bridge] }
entry :variables, ::Gitlab::Ci::Config::Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
attributes :when, :allow_failure attributes :when, :allow_failure
def self.matching?(name, config) def self.matching?(name, config)
...@@ -67,7 +63,6 @@ module Gitlab ...@@ -67,7 +63,6 @@ module Gitlab
needs: (needs_value if needs_defined?), needs: (needs_value if needs_defined?),
ignore: !!allow_failure, ignore: !!allow_failure,
when: self.when, when: self.when,
variables: (variables_value if variables_defined?),
scheduling_type: needs_defined? && !bridge_needs ? :dag : :stage scheduling_type: needs_defined? && !bridge_needs ? :dag : :stage
).compact ).compact
end end
......
...@@ -112,10 +112,6 @@ module Gitlab ...@@ -112,10 +112,6 @@ module Gitlab
metadata: { allowed_needs: %i[job cross_dependency] }, metadata: { allowed_needs: %i[job cross_dependency] },
inherit: false inherit: false
entry :variables, Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
entry :environment, Entry::Environment, entry :environment, Entry::Environment,
description: 'Environment configuration for this job.', description: 'Environment configuration for this job.',
inherit: false inherit: false
...@@ -174,7 +170,6 @@ module Gitlab ...@@ -174,7 +170,6 @@ module Gitlab
when: self.when, when: self.when,
start_in: self.start_in, start_in: self.start_in,
dependencies: dependencies, dependencies: dependencies,
variables: variables_defined? ? variables_value : {},
environment: environment_defined? ? environment_value : nil, environment: environment_defined? ? environment_value : nil,
environment_name: environment_defined? ? environment_value[:name] : nil, environment_name: environment_defined? ? environment_value[:name] : nil,
coverage: coverage_defined? ? coverage_value : nil, coverage: coverage_defined? ? coverage_value : nil,
......
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
include ::Gitlab::Config::Entry::Attributable include ::Gitlab::Config::Entry::Attributable
include ::Gitlab::Config::Entry::Inheritable include ::Gitlab::Config::Entry::Inheritable
PROCESSABLE_ALLOWED_KEYS = %i[extends stage only except rules].freeze PROCESSABLE_ALLOWED_KEYS = %i[extends stage only except rules variables].freeze
included do included do
validations do validations do
...@@ -54,6 +54,10 @@ module Gitlab ...@@ -54,6 +54,10 @@ module Gitlab
allowed_when: %w[on_success on_failure always never manual delayed].freeze allowed_when: %w[on_success on_failure always never manual delayed].freeze
} }
entry :variables, ::Gitlab::Ci::Config::Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
attributes :extends, :rules attributes :extends, :rules
end end
...@@ -90,6 +94,7 @@ module Gitlab ...@@ -90,6 +94,7 @@ module Gitlab
stage: stage_value, stage: stage_value,
extends: extends, extends: extends,
rules: rules_value, rules: rules_value,
variables: variables_defined? ? variables_value : {},
only: only_value, only: only_value,
except: except_value }.compact except: except_value }.compact
end end
......
...@@ -106,6 +106,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do ...@@ -106,6 +106,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do
ignore: false, ignore: false,
stage: 'test', stage: 'test',
only: { refs: %w[branches tags] }, only: { refs: %w[branches tags] },
variables: {},
scheduling_type: :stage) scheduling_type: :stage)
end end
end end
...@@ -128,6 +129,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do ...@@ -128,6 +129,7 @@ describe Gitlab::Ci::Config::Entry::Bridge do
ignore: false, ignore: false,
stage: 'test', stage: 'test',
only: { refs: %w[branches tags] }, only: { refs: %w[branches tags] },
variables: {},
scheduling_type: :stage) scheduling_type: :stage)
end end
end end
......
...@@ -99,6 +99,7 @@ describe Gitlab::Ci::Config::Entry::Jobs do ...@@ -99,6 +99,7 @@ describe Gitlab::Ci::Config::Entry::Jobs do
only: { refs: %w[branches tags] }, only: { refs: %w[branches tags] },
stage: 'test', stage: 'test',
trigger: { project: 'my/project' }, trigger: { project: 'my/project' },
variables: {},
scheduling_type: :stage scheduling_type: :stage
}, },
regular_job: { regular_job: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment