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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /lib/gitlab/template
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/gitlab/template')
-rw-r--r--lib/gitlab/template/gitlab_ci_yml_template.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb
index e1ca4b5ff6a..e302865c897 100644
--- a/lib/gitlab/template/gitlab_ci_yml_template.rb
+++ b/lib/gitlab/template/gitlab_ci_yml_template.rb
@@ -5,11 +5,19 @@ module Gitlab
class GitlabCiYmlTemplate < BaseTemplate
BASE_EXCLUDED_PATTERNS = [%r{\.latest\.}].freeze
+ TEMPLATES_WITH_LATEST_VERSION = {
+ 'Jobs/Browser-Performance-Testing' => true,
+ 'Security/API-Fuzzing' => true,
+ 'Security/DAST' => true,
+ 'Terraform' => true
+ }.freeze
+
def description
"# This file is a template, and might need editing before it works on your project."
end
class << self
+ extend ::Gitlab::Utils::Override
include Gitlab::Utils::StrongMemoize
def extension
@@ -54,6 +62,31 @@ module Gitlab
excluded_patterns: self.excluded_patterns
)
end
+
+ override :find
+ def find(key, project = nil)
+ if try_redirect_to_latest?(key, project)
+ key += '.latest'
+ end
+
+ super(key, project)
+ end
+
+ private
+
+ # To gauge the impact of the latest template,
+ # you can redirect the stable template to the latest template by enabling the feature flag.
+ # See https://docs.gitlab.com/ee/development/cicd/templates.html#versioning for more information.
+ def try_redirect_to_latest?(key, project)
+ return false unless templates_with_latest_version[key]
+
+ flag_name = "redirect_to_latest_template_#{key.underscore.tr('/', '_')}"
+ ::Feature.enabled?(flag_name, project, default_enabled: :yaml)
+ end
+
+ def templates_with_latest_version
+ TEMPLATES_WITH_LATEST_VERSION
+ end
end
end
end