47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/openc3/operators/microservice_operator.rb', line 47
def convert_microservice_to_process_definition(microservice_name, microservice_config)
process_definition = ["ruby", "plugin_microservice.rb"]
work_dir = "/openc3/lib/openc3/microservices"
env = microservice_config["env"].dup
if microservice_config["needs_dependencies"]
env['GEM_HOME'] = '/gems'
else
env['GEM_HOME'] = nil
end
env['OPENC3_MICROSERVICE_NAME'] = microservice_name
container = microservice_config["container"]
scope = microservice_name.split("__")[0]
secrets = microservice_config["secrets"]
if secrets
secrets.each do |type, secret_name, env_name_or_path|
secret_value = @secrets.get(secret_name, scope: scope)
if secret_value
case type
when 'ENV'
env[env_name_or_path] = secret_value
when 'FILE'
FileUtils.mkdir_p(File.dirname(env_name_or_path))
File.open(env_name_or_path, 'wb') do |file|
file.write(secret_value)
end
end
else
Logger.error("Microservice #{microservice_name} references unknown secret: #{secret_name}")
end
end
end
return process_definition, work_dir, env, scope, container
end
|