Class: Puma::RuntimeEnv::K8s

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/runtime_env/k8s.rb

Instance Method Summary collapse

Instance Method Details

#get_envObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puma/runtime_env/k8s.rb', line 4

def get_env
  env = {}

  secrets_mount_path = ENV["SECRETS_MOUNT_PATH"]

  return env if secrets_mount_path.nil?

  if File.directory? secrets_mount_path
    Dir.foreach(secrets_mount_path) do |filename|
      file_path = "#{secrets_mount_path}/#{filename}"

      begin
        env[filename] = File.read(file_path)
      rescue StandardError => e
        puts "ERROR: Failed to read secrets file #{file_path}"
        puts e
      end
    end
  end

  env
end