13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/docktor_rails/checks/compose_env_file_present.rb', line 13
def run(ctx)
root = ctx.fetch(:root)
compose_path = Compose.find_file(root)
return pass("No compose file found (skipping env_file check)") unless compose_path
doc = Compose.load_file(compose_path)
services = Compose.services(doc)
missing = []
services.each do |_name, svc|
next unless svc.is_a?(Hash)
env_file = svc["env_file"]
files = case env_file
when String then [env_file]
when Array then env_file
else []
end
files.each do |f|
next unless f.is_a?(String)
path = File.expand_path(f, root)
missing << f unless File.file?(path)
end
end
if missing.empty?
pass("All compose env_file entries exist")
else
fail("Missing compose env_file files", files: missing.uniq.sort)
end
end
|