Class: ContainerConfig::Provider::SecretVolume

Inherits:
Base
  • Object
show all
Defined in:
lib/container_config/provider/secret_volume.rb

Overview

Secret volume mount config value provider

Constant Summary collapse

DEFAULT_SECRET_PATH =

Default secret volume mount path used when globbing secret files

"/etc/*-secrets"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSecretVolume

Initializes a new ContainerConfig::Provider::SecretVolume



22
23
24
25
26
# File 'lib/container_config/provider/secret_volume.rb', line 22

def initialize
  super
  @default_directory = DEFAULT_SECRET_PATH
  @directory = nil
end

Instance Attribute Details

#default_directoryObject

Returns the value of attribute default_directory.



12
13
14
# File 'lib/container_config/provider/secret_volume.rb', line 12

def default_directory
  @default_directory
end

#directoryObject

Returns the value of attribute directory.



12
13
14
# File 'lib/container_config/provider/secret_volume.rb', line 12

def directory
  @directory
end

Instance Method Details

#load(key, *dig_keys, **options) ⇒ Object

Loads a secret volume mount configuration setting

Parameters:

  • key (String)

    Configuration key to load

  • dig_keys (Array)

    Variable keys to use to load from providers that accept a dig structure defaults to the lowercase key split by underscores “MY_PASSWORD” => [“my”, “password”]

  • options (Hash)

    Options Hash

Options Hash (**options):

  • :secret_mount_directory (String)

    directory where secret files are mounted

Returns:

  • (Object)

    configuration setting value



40
41
42
43
44
45
46
# File 'lib/container_config/provider/secret_volume.rb', line 40

def load(key, *dig_keys, **options)
  super
  secret_file = Dir.glob(File.join(secret_mount_directory(**options), "**", key)).first
  return if secret_file.nil? || !File.exist?(secret_file)

  File.read(secret_file)
end

#nameObject

See Also:



15
16
17
# File 'lib/container_config/provider/secret_volume.rb', line 15

def name
  "Secret Volume"
end