Class: Gitlab::Ci::Pipeline::Seed::Build::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/pipeline/seed/build/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(pipeline, cache) ⇒ Cache

Returns a new instance of Cache.

Raises:

  • (ArgumentError)

9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gitlab/ci/pipeline/seed/build/cache.rb', line 9

def initialize(pipeline, cache)
  @pipeline = pipeline
  local_cache = cache.to_h.deep_dup
  @key = local_cache.delete(:key)
  @paths = local_cache.delete(:paths)
  @policy = local_cache.delete(:policy)
  @untracked = local_cache.delete(:untracked)
  @when = local_cache.delete(:when)

  raise ArgumentError, "unknown cache keys: #{local_cache.keys}" if local_cache.any?
end

Instance Method Details

#attributesObject


21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/ci/pipeline/seed/build/cache.rb', line 21

def attributes
  {
    key: key_string,
    paths: @paths,
    policy: @policy,
    untracked: @untracked,
    when: @when
  }.compact
end

#build_attributesObject


31
32
33
# File 'lib/gitlab/ci/pipeline/seed/build/cache.rb', line 31

def build_attributes
  { options: { cache: attributes.presence }.compact }
end