Class: Gitlab::Ci::Config::External::File::Artifact
- Extended by:
- Utils::Override
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/config/external/file/artifact.rb
Constant Summary
Constants inherited from Base
Base::YAML_ALLOWLIST_EXTENSION
Instance Attribute Summary collapse
-
#job_name ⇒ Object
readonly
Returns the value of attribute job_name.
Attributes inherited from Base
#context, #errors, #location, #params
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(params, context) ⇒ Artifact
constructor
A new instance of Artifact.
- #metadata ⇒ Object
- #validate_content! ⇒ Object
- #validate_context! ⇒ Object
Methods included from Utils::Override
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
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_location!
Constructor Details
#initialize(params, context) ⇒ Artifact
Returns a new instance of Artifact.
14 15 16 17 18 19 |
# File 'lib/gitlab/ci/config/external/file/artifact.rb', line 14 def initialize(params, context) @location = params[:artifact] @job_name = params[:job] super end |
Instance Attribute Details
#job_name ⇒ Object (readonly)
Returns the value of attribute job_name.
12 13 14 |
# File 'lib/gitlab/ci/config/external/file/artifact.rb', line 12 def job_name @job_name end |
Instance Method Details
#content ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gitlab/ci/config/external/file/artifact.rb', line 21 def content return unless context.parent_pipeline.present? # We define max archive size to be equal to content size # as a good enough approximation to provide a sane limit with a single setting max_content_size = Gitlab::CurrentSettings.current_application_settings.max_artifacts_content_include_size file_reader = Gitlab::Ci::ArtifactFileReader.new(artifact_job, max_archive_size: max_content_size) file_reader.read(location, max_size: max_content_size) rescue Gitlab::Ci::ArtifactFileReader::Error => error errors.push(error.) nil end |
#metadata ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/gitlab/ci/config/external/file/artifact.rb', line 37 def super.merge( type: :artifact, location: masked_location, extra: { job_name: masked_job_name } ) end |
#validate_content! ⇒ Object
57 58 59 |
# File 'lib/gitlab/ci/config/external/file/artifact.rb', line 57 def validate_content! errors.push("File `#{masked_location}` is empty!") unless content.present? end |
#validate_context! ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gitlab/ci/config/external/file/artifact.rb', line 45 def validate_context! context.logger.instrument(:config_file_artifact_validate_context) do if !creating_child_pipeline? errors.push('Including configs from artifacts is only allowed when triggering child pipelines') elsif !job_name.present? errors.push("Job must be provided when including configs from artifacts") elsif !artifact_job.present? errors.push("Job `#{masked_job_name}` not found in parent pipeline or does not have artifacts!") end end end |