summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/entry/workflow.rb
blob: 1d9007c9b9b84044e7066386717234b4ad15cc42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  module Ci
    class Config
      module Entry
        class Workflow < ::Gitlab::Config::Entry::Node
          include ::Gitlab::Config::Entry::Configurable

          ALLOWED_KEYS = %i[rules].freeze

          validations do
            validates :config, type: Hash
            validates :config, allowed_keys: ALLOWED_KEYS
            validates :config, presence: true
          end

          entry :rules, Entry::Rules,
            description: 'List of evaluable Rules to determine Pipeline status.',
            metadata: { allowed_when: %w[always never] }

          def has_rules?
            @config.try(:key?, :rules)
          end
        end
      end
    end
  end
end