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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config/entry/pull_policy.rb')
-rw-r--r--lib/gitlab/ci/config/entry/pull_policy.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/gitlab/ci/config/entry/pull_policy.rb b/lib/gitlab/ci/config/entry/pull_policy.rb
new file mode 100644
index 00000000000..f597134dd2c
--- /dev/null
+++ b/lib/gitlab/ci/config/entry/pull_policy.rb
@@ -0,0 +1,34 @@
+# 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