diff options
Diffstat (limited to 'lib/gitlab/ci/config/entry/need.rb')
-rw-r--r-- | lib/gitlab/ci/config/entry/need.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/gitlab/ci/config/entry/need.rb b/lib/gitlab/ci/config/entry/need.rb index 46191eca842..b3cf0f9e0fd 100644 --- a/lib/gitlab/ci/config/entry/need.rb +++ b/lib/gitlab/ci/config/entry/need.rb @@ -35,7 +35,14 @@ module Gitlab end def value - { name: @config, artifacts: true } + if ::Feature.enabled?(:ci_needs_optional, default_enabled: :yaml) + { name: @config, + artifacts: true, + optional: false } + else + { name: @config, + artifacts: true } + end end end @@ -43,14 +50,15 @@ module Gitlab include ::Gitlab::Config::Entry::Validatable include ::Gitlab::Config::Entry::Attributable - ALLOWED_KEYS = %i[job artifacts].freeze - attributes :job, :artifacts + ALLOWED_KEYS = %i[job artifacts optional].freeze + attributes :job, :artifacts, :optional validations do validates :config, presence: true validates :config, allowed_keys: ALLOWED_KEYS validates :job, type: String, presence: true validates :artifacts, boolean: true, allow_nil: true + validates :optional, boolean: true, allow_nil: true end def type @@ -58,7 +66,14 @@ module Gitlab end def value - { name: job, artifacts: artifacts || artifacts.nil? } + if ::Feature.enabled?(:ci_needs_optional, default_enabled: :yaml) + { name: job, + artifacts: artifacts || artifacts.nil?, + optional: !!optional } + else + { name: job, + artifacts: artifacts || artifacts.nil? } + end end end |