Class: Gitlab::Ci::Config::External::File::Template

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/ci/config/external/file/template.rb

Constant Summary collapse

SUFFIX =
'.gitlab-ci.yml'
HOST =
'https://gitlab.com/gitlab-org/gitlab/-/raw/master'

Constants inherited from Base

Base::YAML_WHITELIST_EXTENSION

Instance Attribute Summary collapse

Attributes inherited from Base

#context, #errors, #params

Instance Method Summary collapse

Methods inherited from Base

#eql?, #error_message, #hash, #invalid_extension?, #invalid_location_type?, #load_and_validate_expanded_hash!, #matching?, #preload_content, #preload_context, #to_hash, #valid?, #validate_content!

Constructor Details

#initialize(params, context) ⇒ Template

Returns a new instance of Template.



14
15
16
17
18
# File 'lib/gitlab/ci/config/external/file/template.rb', line 14

def initialize(params, context)
  @location = params[:template]

  super
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



9
10
11
# File 'lib/gitlab/ci/config/external/file/template.rb', line 9

def location
  @location
end

Instance Method Details

#contentObject



20
21
22
# File 'lib/gitlab/ci/config/external/file/template.rb', line 20

def content
  strong_memoize(:content) { fetch_template_content }
end

#metadataObject



24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/ci/config/external/file/template.rb', line 24

def 
  super.merge(
    type: :template,
    location: masked_location,
    blob: nil,
    raw: masked_raw,
    extra: {}
  )
end

#validate_context!Object



34
35
36
# File 'lib/gitlab/ci/config/external/file/template.rb', line 34

def validate_context!
  # no-op
end

#validate_location!Object



38
39
40
41
42
43
44
# File 'lib/gitlab/ci/config/external/file/template.rb', line 38

def validate_location!
  super

  unless template_name_valid?
    errors.push("Template file `#{masked_location}` is not a valid location!")
  end
end