Welcome to mirror list, hosted at ThFree Co, Russian Federation.

image.rb « entry « config « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 613f7ff33701ea1ec5d26596f502e086491ee72e (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
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Gitlab
  module Ci
    class Config
      module Entry
        ##
        # Entry that represents a Docker image.
        #
        class Image < ::Gitlab::Config::Entry::Node
          include ::Gitlab::Ci::Config::Entry::Imageable

          validations do
            validates :config, allowed_keys: IMAGEABLE_ALLOWED_KEYS,
                               if: :ci_docker_image_pull_policy_enabled?
            validates :config, allowed_keys: IMAGEABLE_LEGACY_ALLOWED_KEYS,
                               unless: :ci_docker_image_pull_policy_enabled?
          end

          def value
            if string?
              { name: @config }
            elsif hash?
              {
                name: @config[:name],
                entrypoint: @config[:entrypoint],
                ports: (ports_value if ports_defined?),
                pull_policy: (ci_docker_image_pull_policy_enabled? ? pull_policy_value : nil)
              }.compact
            else
              {}
            end
          end
        end
      end
    end
  end
end