Commit 69269efb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove duplication between bridge and job only policies

parent 536eb638
......@@ -15,15 +15,6 @@ module EE
ALLOWED_KEYS = %i[trigger stage allow_failure only except].freeze
# TODO we probably need a common ancestor for a status / job
#
DEFAULT_ONLY_POLICY = {
refs: %w(branches tags)
}.freeze
DEFAULT_EXCEPT_POLICY = {
}.freeze
validations do
validates :config, allowed_keys: ALLOWED_KEYS
validates :config, presence: true
......@@ -39,7 +30,8 @@ module EE
description: 'Pipeline stage this job will be executed into.'
entry :only, ::Gitlab::Ci::Config::Entry::Policy,
description: 'Refs policy this job will be executed for.'
description: 'Refs policy this job will be executed for.',
default: ::Gitlab::Ci::Config::Entry::Policy::DEFAULT_ONLY
entry :except, ::Gitlab::Ci::Config::Entry::Policy,
description: 'Refs policy this job will be executed for.'
......@@ -56,8 +48,8 @@ module EE
trigger: trigger_value,
ignore: !!allow_failure,
stage: stage_value,
only: DEFAULT_ONLY_POLICY.deep_merge(only_value.to_h),
except: DEFAULT_EXCEPT_POLICY.deep_merge(except_value.to_h) }
only: only_value,
except: except_value }.compact
end
end
end
......
......@@ -63,7 +63,6 @@ describe Gitlab::Ci::Config::Entry::Jobs do
trigger: { project: 'my/project' },
stage: 'test',
only: { refs: %w[branches tags] },
except: {},
ignore: false
},
regular_job: {
......@@ -71,7 +70,6 @@ describe Gitlab::Ci::Config::Entry::Jobs do
name: :regular_job,
stage: 'test',
only: { refs: %w[branches tags] },
except: {},
ignore: false
})
end
......
......@@ -67,7 +67,7 @@ module Gitlab
entry :only, Entry::Policy,
description: 'Refs policy this job will be executed for.',
default: { refs: %w[branches tags] }
default: Entry::Policy::DEFAULT_ONLY
entry :except, Entry::Policy,
description: 'Refs policy this job will be executed for.'
......
......@@ -11,6 +11,8 @@ module Gitlab
strategy :RefsPolicy, if: -> (config) { config.is_a?(Array) }
strategy :ComplexPolicy, if: -> (config) { config.is_a?(Hash) }
DEFAULT_ONLY = { refs: %w[branches tags] }.freeze
class RefsPolicy < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
......
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