Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cache.rb « build « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1cddc9fcc981b71a763a4398a961ae937da7c750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  module Ci
    module Build
      class Cache
        include ::Gitlab::Utils::StrongMemoize

        def initialize(cache, pipeline)
          cache = Array.wrap(cache)
          @cache = cache.map.with_index do |cache, index|
            Gitlab::Ci::Pipeline::Seed::Build::Cache
            .new(pipeline, cache, index)
          end
        end

        def cache_attributes
          strong_memoize(:cache_attributes) do
            if @cache.empty?
              {}
            else
              { options: { cache: @cache.map(&:attributes) } }
            end
          end
        end
      end
    end
  end
end