Module: Kamal::Lint::SecretsFile

Defined in:
lib/kamal/lint/secrets_file.rb

Overview

Reads .kamal/secrets (shell-style KEY=value, with optional ‘export` prefix and `#` comments). Returns the set of declared keys. We don’t expand or substitute — we only care whether a name is declared.

Class Method Summary collapse

Class Method Details

.read_keys(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kamal/lint/secrets_file.rb', line 11

def read_keys(path)
  return [] unless path && File.exist?(path)

  keys = []
  File.foreach(path) do |raw|
    line = raw.strip
    next if line.empty?
    next if line.start_with?("#")

    line = line.sub(/\Aexport\s+/, "")
    name, _eq, _value = line.partition("=")
    name = name.strip
    keys << name unless name.empty?
  end
  keys.uniq
end