diff --git a/lib/on_container/load_env_secrets.rb b/lib/on_container/load_env_secrets.rb index 243920b..49fd4fc 100644 --- a/lib/on_container/load_env_secrets.rb +++ b/lib/on_container/load_env_secrets.rb @@ -12,10 +12,10 @@ # Process only a known list of env vars that can filled by reading a file (i.e. # a docker secret): -Dir["#{ENV.fetch('SECRETS_PATH', '/run/secrets/')}*"].each do |secret_filepath| - next unless File.file?(secret_filepath) - - secret_envvarname = File.basename(secret_filepath, '.*').upcase +Dir["#{ENV.fetch('SECRETS_PATH', '/run/secrets')}/**/*"].map do |path| + Pathname.new(path) +end.select(&:file?).each do |secret_filepath| + secret_envvarname = secret_filepath.basename('.*').to_s.upcase # Skip if variable is already set - already-set variables have precedence over # the secret files: @@ -55,4 +55,4 @@ ENV[url_key] = uri.to_s end -# STDERR.puts ENV.inspect \ No newline at end of file +# STDERR.puts ENV.inspect