Class: Kamal::EnvFile

Inherits:
Object
  • Object
show all
Defined in:
lib/kamal/env_file.rb

Overview

Encode an env hash as a string where secret values have been looked up and all values escaped for Docker.

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ EnvFile

Returns a new instance of EnvFile.



3
4
5
# File 'lib/kamal/env_file.rb', line 3

def initialize(env)
  @env = env
end

Instance Method Details

#to_ioObject



18
19
20
# File 'lib/kamal/env_file.rb', line 18

def to_io
  StringIO.new(to_s)
end

#to_sObject Also known as: to_str



7
8
9
10
11
12
13
14
15
16
# File 'lib/kamal/env_file.rb', line 7

def to_s
  env_file = StringIO.new.tap do |contents|
    @env.each do |key, value|
      contents << docker_env_file_line(key, value)
    end
  end.string

  # Ensure the file has some contents to avoid the SSHKIT empty file warning
  env_file.presence || "\n"
end