Class: Gitlab::Template::GitlabCiYmlTemplate

Inherits:
BaseTemplate show all
Extended by:
Utils::Override, Utils::StrongMemoize
Defined in:
lib/gitlab/template/gitlab_ci_yml_template.rb

Constant Summary collapse

BASE_EXCLUDED_PATTERNS =
[%r{\.latest\.}].freeze
BASE_DIR =
'lib/gitlab/ci/templates'
TEMPLATES_WITH_LATEST_VERSION =
{}.freeze

Instance Attribute Summary

Attributes inherited from BaseTemplate

#category

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

clear_memoization, strong_memoize, strong_memoized?

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods inherited from BaseTemplate

#<=>, all, by_category, category_directory, #content, #full_name, #initialize, #name, #project_id, repository_template_names, #resolve!, template_names_by_category, template_subsets, #to_json

Constructor Details

This class inherits a constructor from Gitlab::Template::BaseTemplate

Class Method Details

.additional_excluded_patternsObject


44
45
46
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 44

def additional_excluded_patterns
  [%r{Verify/Browser-Performance}]
end

.base_dirObject


48
49
50
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 48

def base_dir
  Rails.root.join(BASE_DIR)
end

.categoriesObject


23
24
25
26
27
28
29
30
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 23

def categories
  {
    'General' => '',
    'Pages' => 'Pages',
    'Verify' => 'Verify',
    'Auto deploy' => 'autodeploy'
  }
end

.excluded_patternsObject


38
39
40
41
42
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 38

def excluded_patterns
  strong_memoize(:excluded_patterns) do
    BASE_EXCLUDED_PATTERNS + additional_excluded_patterns
  end
end

.extensionObject


19
20
21
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 19

def extension
  '.gitlab-ci.yml'
end

.find(key, project = nil) ⇒ Object


63
64
65
66
67
68
69
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 63

def find(key, project = nil)
  if try_redirect_to_latest?(key, project)
    key += '.latest'
  end

  super(key, project)
end

.finder(project = nil) ⇒ Object


52
53
54
55
56
57
58
59
60
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 52

def finder(project = nil)
  Gitlab::Template::Finders::GlobalTemplateFinder.new(
    self.base_dir,
    self.extension,
    self.categories,
    self.include_categories_for_file,
    excluded_patterns: self.excluded_patterns
  )
end

.include_categories_for_fileObject


32
33
34
35
36
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 32

def include_categories_for_file
  {
    "SAST#{self.extension}" => { 'Security' => 'Security' }
  }
end

Instance Method Details

#descriptionObject


11
12
13
# File 'lib/gitlab/template/gitlab_ci_yml_template.rb', line 11

def description
  "# This file is a template, and might need editing before it works on your project."
end