Service definitions can export environment variables.
This commit is contained in:
parent
5b864dcb58
commit
21f8d2d7d2
16
src/main.cr
16
src/main.cr
@ -67,6 +67,11 @@ class ServiceDefinition
|
||||
checks: {
|
||||
type: Array(Checks),
|
||||
default: [] of Checks
|
||||
},
|
||||
environment_variables: {
|
||||
type: Array(String),
|
||||
key: "environment-variables",
|
||||
default: [] of String
|
||||
}
|
||||
})
|
||||
|
||||
@ -259,6 +264,17 @@ class Service
|
||||
def export_environment_variables
|
||||
ENV["SERVICE_ENVIRONMENT"] = @environment.name
|
||||
ENV["SERVICE_ENVIRONMENT_TYPE"] = @environment.type.to_s
|
||||
|
||||
# FIXME: Parsing should probably be done… when parsing the file.
|
||||
# FIXME: Parsing is probably a bit primitive. Maybe this isn’t the right way of defining this.
|
||||
@reference.environment_variables.each do |string|
|
||||
# FIXME: Should probably deserve a warning.
|
||||
variable = string.match(/^[^=]*=/).not_nil![0]
|
||||
value = string[variable.size..string.size]
|
||||
variable = variable[0..variable.size-2]
|
||||
|
||||
ENV[variable] = value
|
||||
end
|
||||
end
|
||||
private def evaluate(string)
|
||||
string.gsub /%{[a-zA-Z]+}/ do |match|
|
||||
|
Loading…
Reference in New Issue
Block a user