Class: ConfigOMat::Op::CheckCache

Inherits:
LifecycleVM::OpBase
  • Object
show all
Defined in:
lib/config_o_mat/secrets_loader/op/check_cache.rb

Instance Method Summary collapse

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/config_o_mat/secrets_loader/op/check_cache.rb', line 25

def call
  # If we're referencing a secret by its version stage, never cache it, since these can be
  # updated out from under us.
  return unless loading_secret.version_stage.nil? || loading_secret.version_stage.empty?

  cached_secret = secrets_cache[loading_secret.secret_id]

  if cached_secret && cached_secret.version_id == loading_secret.version_id
    logger&.info(:cached_secret, name: loading_secret.name, version_id: loading_secret.version_id)
    loaded_secrets[loading_secret] = cached_secret
    self.loading_secret = nil
  elsif cached_secret
    logger&.info(
      :invalid_cached_secret,
      name: loading_secret.name,
      expected_version_id: loading_secret.version_id,
      cached_version_id: cached_secret.version_id
    )
  end
end