debian-mirror-gitlab/lib/gitlab/ci/config/entry/pull_policy.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
955 B
Ruby
Raw Normal View History

2022-07-23 23:45:48 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Entry
##
# Entry that represents a configuration of the pull policies of an image.
#
class PullPolicy < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
ALLOWED_POLICIES = %w[always never if-not-present].freeze
validations do
validates :config, array_of_strings_or_string: true
validates :config,
allowed_array_values: { in: ALLOWED_POLICIES },
presence: true,
if: :array?
validates :config,
inclusion: { in: ALLOWED_POLICIES },
if: :string?
end
def value
# We either return an array with policies or nothing
Array(@config).presence
end
end
end
end
end
end