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')
-rw-r--r--lib/gitlab/ci/config/entry/current_variables.rb49
-rw-r--r--lib/gitlab/ci/config/entry/legacy_variables.rb46
-rw-r--r--lib/gitlab/ci/config/entry/root.rb3
-rw-r--r--lib/gitlab/ci/config/entry/timeout.rb2
-rw-r--r--lib/gitlab/ci/config/entry/variable.rb31
-rw-r--r--lib/gitlab/ci/config/entry/variables.rb36
-rw-r--r--lib/gitlab/ci/config/entry/workflow.rb7
-rw-r--r--lib/gitlab/ci/config/external/context.rb3
8 files changed, 66 insertions, 111 deletions
diff --git a/lib/gitlab/ci/config/entry/current_variables.rb b/lib/gitlab/ci/config/entry/current_variables.rb
deleted file mode 100644
index 3b6721ec92d..00000000000
--- a/lib/gitlab/ci/config/entry/current_variables.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Ci
- class Config
- module Entry
- ##
- # Entry that represents CI/CD variables.
- # The class will be renamed to `Variables` when removing the FF `ci_variables_refactoring_to_variable`.
- #
- class CurrentVariables < ::Gitlab::Config::Entry::ComposableHash
- include ::Gitlab::Config::Entry::Validatable
-
- validations do
- validates :config, type: Hash
- end
-
- # Enable these lines when removing the FF `ci_variables_refactoring_to_variable`
- # and renaming this class to `Variables`.
- # def self.default(**)
- # {}
- # end
-
- def value
- @entries.to_h do |key, entry|
- [key.to_s, entry.value]
- end
- end
-
- def value_with_data
- @entries.to_h do |key, entry|
- [key.to_s, entry.value_with_data]
- end
- end
-
- private
-
- def composable_class(_name, _config)
- Entry::Variable
- end
-
- def composable_metadata
- { allowed_value_data: opt(:allowed_value_data) }
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/config/entry/legacy_variables.rb b/lib/gitlab/ci/config/entry/legacy_variables.rb
deleted file mode 100644
index 5379f707537..00000000000
--- a/lib/gitlab/ci/config/entry/legacy_variables.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Ci
- class Config
- module Entry
- ##
- # Entry that represents environment variables.
- # This is legacy implementation and will be removed with the FF `ci_variables_refactoring_to_variable`.
- #
- class LegacyVariables < ::Gitlab::Config::Entry::Node
- include ::Gitlab::Config::Entry::Validatable
-
- ALLOWED_VALUE_DATA = %i[value description].freeze
-
- validations do
- validates :config, variables: { allowed_value_data: ALLOWED_VALUE_DATA }, if: :use_value_data?
- validates :config, variables: true, unless: :use_value_data?
- end
-
- def value
- @config.to_h { |key, value| [key.to_s, expand_value(value)[:value]] }
- end
-
- def value_with_data
- @config.to_h { |key, value| [key.to_s, expand_value(value)] }
- end
-
- def use_value_data?
- opt(:use_value_data)
- end
-
- private
-
- def expand_value(value)
- if value.is_a?(Hash)
- { value: value[:value].to_s, description: value[:description] }.compact
- else
- { value: value.to_s }
- end
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/config/entry/root.rb b/lib/gitlab/ci/config/entry/root.rb
index 57e89bd7bc5..1d7d8617c74 100644
--- a/lib/gitlab/ci/config/entry/root.rb
+++ b/lib/gitlab/ci/config/entry/root.rb
@@ -48,10 +48,9 @@ module Gitlab
description: 'Script that will be executed after each job.',
reserved: true
- # use_value_data will be removed with the FF ci_variables_refactoring_to_variable
entry :variables, Entry::Variables,
description: 'Environment variables that will be used.',
- metadata: { use_value_data: true, allowed_value_data: %i[value description] },
+ metadata: { allowed_value_data: %i[value description], allow_array_value: true },
reserved: true
entry :stages, Entry::Stages,
diff --git a/lib/gitlab/ci/config/entry/timeout.rb b/lib/gitlab/ci/config/entry/timeout.rb
index 0bffa9340de..5769ea22b06 100644
--- a/lib/gitlab/ci/config/entry/timeout.rb
+++ b/lib/gitlab/ci/config/entry/timeout.rb
@@ -5,7 +5,7 @@ module Gitlab
class Config
module Entry
##
- # Entry that represents the interrutible value.
+ # Entry that represents the interruptible value.
#
class Timeout < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
diff --git a/lib/gitlab/ci/config/entry/variable.rb b/lib/gitlab/ci/config/entry/variable.rb
index 253888aadeb..54c153c8b07 100644
--- a/lib/gitlab/ci/config/entry/variable.rb
+++ b/lib/gitlab/ci/config/entry/variable.rb
@@ -10,6 +10,7 @@ module Gitlab
class Variable < ::Gitlab::Config::Entry::Simplifiable
strategy :SimpleVariable, if: -> (config) { SimpleVariable.applies_to?(config) }
strategy :ComplexVariable, if: -> (config) { ComplexVariable.applies_to?(config) }
+ strategy :ComplexArrayVariable, if: -> (config) { ComplexArrayVariable.applies_to?(config) }
class SimpleVariable < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
@@ -39,7 +40,7 @@ module Gitlab
class << self
def applies_to?(config)
- config.is_a?(Hash)
+ config.is_a?(Hash) && !config[:value].is_a?(Array)
end
end
@@ -86,6 +87,34 @@ module Gitlab
end
end
+ class ComplexArrayVariable < ComplexVariable
+ include ::Gitlab::Config::Entry::Validatable
+
+ class << self
+ def applies_to?(config)
+ config.is_a?(Hash) && config[:value].is_a?(Array)
+ end
+ end
+
+ validations do
+ validates :config_value, array_of_strings: true, allow_nil: false, if: :config_value_defined?
+
+ validate do
+ next if opt(:allow_array_value)
+
+ errors.add(:config, 'value must be an alphanumeric string')
+ end
+ end
+
+ def value
+ config_value.first
+ end
+
+ def value_with_data
+ super.merge(value_options: config_value).compact
+ end
+ end
+
class UnknownStrategy < ::Gitlab::Config::Entry::Node
def errors
["variable definition must be either a string or a hash"]
diff --git a/lib/gitlab/ci/config/entry/variables.rb b/lib/gitlab/ci/config/entry/variables.rb
index 0284958d9d4..4430a11dda7 100644
--- a/lib/gitlab/ci/config/entry/variables.rb
+++ b/lib/gitlab/ci/config/entry/variables.rb
@@ -6,20 +6,38 @@ module Gitlab
module Entry
##
# Entry that represents CI/CD variables.
- # CurrentVariables will be renamed to this class when removing the FF `ci_variables_refactoring_to_variable`.
- #
- class Variables
- def self.new(...)
- if YamlProcessor::FeatureFlags.enabled?(:ci_variables_refactoring_to_variable)
- CurrentVariables.new(...)
- else
- LegacyVariables.new(...)
- end
+ class Variables < ::Gitlab::Config::Entry::ComposableHash
+ include ::Gitlab::Config::Entry::Validatable
+
+ validations do
+ validates :config, type: Hash
end
def self.default(**)
{}
end
+
+ def value
+ @entries.to_h do |key, entry|
+ [key.to_s, entry.value]
+ end
+ end
+
+ def value_with_data
+ @entries.to_h do |key, entry|
+ [key.to_s, entry.value_with_data]
+ end
+ end
+
+ private
+
+ def composable_class(_name, _config)
+ Entry::Variable
+ end
+
+ def composable_metadata
+ { allowed_value_data: opt(:allowed_value_data), allow_array_value: opt(:allow_array_value) }
+ end
end
end
end
diff --git a/lib/gitlab/ci/config/entry/workflow.rb b/lib/gitlab/ci/config/entry/workflow.rb
index 5bc992a38a0..691d9e2d48b 100644
--- a/lib/gitlab/ci/config/entry/workflow.rb
+++ b/lib/gitlab/ci/config/entry/workflow.rb
@@ -6,12 +6,17 @@ module Gitlab
module Entry
class Workflow < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Configurable
+ include ::Gitlab::Config::Entry::Validatable
+ include ::Gitlab::Config::Entry::Attributable
- ALLOWED_KEYS = %i[rules].freeze
+ ALLOWED_KEYS = %i[rules name].freeze
+
+ attributes :name
validations do
validates :config, type: Hash
validates :config, allowed_keys: ALLOWED_KEYS
+ validates :name, allow_nil: true, length: { minimum: 1, maximum: 255 }
end
entry :rules, Entry::Rules,
diff --git a/lib/gitlab/ci/config/external/context.rb b/lib/gitlab/ci/config/external/context.rb
index ec628399785..138e79db331 100644
--- a/lib/gitlab/ci/config/external/context.rb
+++ b/lib/gitlab/ci/config/external/context.rb
@@ -10,7 +10,6 @@ module Gitlab
TimeoutError = Class.new(StandardError)
MAX_INCLUDES = 100
- TRIAL_MAX_INCLUDES = 250
include ::Gitlab::Utils::StrongMemoize
@@ -31,7 +30,7 @@ module Gitlab
@expandset = Set.new
@execution_deadline = 0
@logger = logger || Gitlab::Ci::Pipeline::Logger.new(project: project)
- @max_includes = Feature.enabled?(:ci_increase_includes_to_250, project) ? TRIAL_MAX_INCLUDES : MAX_INCLUDES
+ @max_includes = MAX_INCLUDES
yield self if block_given?
end