Class: Gitlab::Ci::Config::External::File::Component
- Inherits:
-
Base
- Object
- Base
- Gitlab::Ci::Config::External::File::Component
show all
- Extended by:
- Utils::Override
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/config/external/file/component.rb
Constant Summary
Constants inherited
from Base
Base::YAML_ALLOWLIST_EXTENSION
Instance Attribute Summary
Attributes inherited from Base
#context, #errors, #location, #params
Instance Method Summary
collapse
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
Methods inherited from Base
#eql?, #error_message, #hash, #inputs_only!, #inputs_only?, #invalid_extension?, #invalid_location_type?, #load_uninterpolated_yaml, #matching?, #preload_content, #preload_context, #to_hash, #valid?, #validate_content_keys!
Constructor Details
#initialize(params, context) ⇒ Component
Returns a new instance of Component.
12
13
14
15
16
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 12
def initialize(params, context)
@location = params[:component]
super
end
|
Instance Method Details
#content ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 18
def content
return unless component_result.success?
if context.user.present?
::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(
'cicd_component_usage',
values: context.user.id
)
end
component_payload.fetch(:content)
end
|
#load_and_validate_expanded_hash! ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 62
def load_and_validate_expanded_hash!
validate_component_spec!
return if errors.any?
super
end
|
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 32
def metadata
super.merge(
type: :component,
location: masked_location,
blob: masked_blob,
raw: nil,
extra: {},
component: component_attrs )
end
|
#validate_content_presence! ⇒ Object
57
58
59
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 57
def validate_content_presence!
errors.push(component_result.message) unless content.present?
end
|
#validate_context! ⇒ Object
51
52
53
54
55
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 51
def validate_context!
return if context.project&.repository
errors.push('Unable to use components outside of a project context')
end
|
#validate_location! ⇒ Object
45
46
47
48
49
|
# File 'lib/gitlab/ci/config/external/file/component.rb', line 45
def validate_location!
return unless invalid_location_type?
errors.push("Included file `#{masked_location}` needs to be a string")
end
|