Module: Ci::Artifactable

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::Ci::Artifacts::Logger, ObjectStorable
Included in:
JobArtifact, PipelineArtifact
Defined in:
app/models/concerns/ci/artifactable.rb

Constant Summary collapse

STORE_COLUMN =
:file_store
NotSupportedAdapterError =
Class.new(StandardError)
FILE_FORMAT_ADAPTERS =
{
  # While zip is a streamable file format, performing streaming
  # reads requires that each entry in the zip has certain headers
  # present at the front of the entry. These headers are OPTIONAL
  # according to the file format specification. GitLab Runner uses
  # Go's `archive/zip` to create zip archives, which does not include
  # these headers. Go maintainers have expressed that they don't intend
  # to support them: https://github.com/golang/go/issues/23301#issuecomment-363240781
  #
  # If you need GitLab to be able to read Artifactables, store them in
  # raw or gzip format instead of zip.
  gzip: Gitlab::Ci::Build::Artifacts::Adapters::GzipStream,
  raw: Gitlab::Ci::Build::Artifacts::Adapters::RawStream
}.freeze

Instance Method Summary collapse

Methods included from Gitlab::Ci::Artifacts::Logger

#log_artifacts_context, #log_artifacts_filesize, #log_build_dependencies, log_created, log_deleted

Instance Method Details

#each_blob(&blk) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/concerns/ci/artifactable.rb', line 40

def each_blob(&blk)
  unless file_format_adapter_class
    raise NotSupportedAdapterError, 'This file format requires a dedicated adapter'
  end

  ::Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator
    .new(file: file, file_format: file_format.to_sym).validate!

  log_artifacts_filesize(file.model)

  file.open do |stream|
    file_format_adapter_class.new(stream).each_blob(&blk)
  end
end