debian-mirror-gitlab/lib/gitlab/ci/build/cache.rb

30 lines
642 B
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Build
class Cache
include ::Gitlab::Utils::StrongMemoize
def initialize(cache, pipeline)
2021-06-08 01:23:25 +05:30
cache = Array.wrap(cache)
@cache = cache.map do |cache|
Gitlab::Ci::Pipeline::Seed::Build::Cache
.new(pipeline, cache)
2021-04-17 20:07:23 +05:30
end
end
def cache_attributes
strong_memoize(:cache_attributes) do
2021-06-08 01:23:25 +05:30
if @cache.empty?
{}
2021-04-17 20:07:23 +05:30
else
2021-06-08 01:23:25 +05:30
{ options: { cache: @cache.map(&:attributes) } }
2021-04-17 20:07:23 +05:30
end
end
end
end
end
end
end