Merge branch 'nginx' of ssh://git.karchnu.fr:2202/WeirdOS/service into nginx
commit
519770250f
|
@ -1,7 +1,7 @@
|
||||||
command: nginx -c ${SERVICE_ROOT}/nginx.conf
|
command: nginx -c ${SERVICE_ROOT}/nginx.conf
|
||||||
provides: www
|
provides: www
|
||||||
|
|
||||||
#%directory ${SERVICE_ROOT}/
|
%directory ${SERVICE_ROOT}/
|
||||||
# name: working directory
|
name: working directory
|
||||||
|
|
||||||
%configuration nginx.conf ${SERVICE_ROOT}/nginx.conf
|
%configuration nginx.conf ${SERVICE_ROOT}/nginx.conf
|
||||||
|
|
|
@ -8,10 +8,13 @@ def sanitize_path(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
module GenConfig
|
module GenConfig
|
||||||
|
# FIXME: The fuck has this become.
|
||||||
alias Variables =
|
alias Variables =
|
||||||
String |
|
String |
|
||||||
Array(String) | Array(Variables) |
|
Array(String) | Array(Variables) |
|
||||||
Hash(String, String) | Hash(String, Variables) |
|
Hash(String, String) | Hash(String, Variables) |
|
||||||
|
Array(Hash(String, String?)) |
|
||||||
|
Hash(String, String?) |
|
||||||
Crinja::Callable::Instance
|
Crinja::Callable::Instance
|
||||||
|
|
||||||
def self.parse_options(unparsed : Array(String))
|
def self.parse_options(unparsed : Array(String))
|
||||||
|
@ -51,7 +54,6 @@ class GenConfig::Context
|
||||||
Environment.load ENVIRONMENTS_DIRECTORY
|
Environment.load ENVIRONMENTS_DIRECTORY
|
||||||
ServiceDefinition.load SERVICES_DIRECTORY
|
ServiceDefinition.load SERVICES_DIRECTORY
|
||||||
Service.load RC_DIRECTORY
|
Service.load RC_DIRECTORY
|
||||||
Environment.load ENVIRONMENTS_DIRECTORY
|
|
||||||
|
|
||||||
target_file = File.open target, "w"
|
target_file = File.open target, "w"
|
||||||
|
|
||||||
|
@ -94,10 +96,13 @@ class GenConfig::Context
|
||||||
|
|
||||||
next unless provider
|
next unless provider
|
||||||
|
|
||||||
providers[token] = Hash(String, String).new.tap do |entry|
|
# FIXME: deduplicate
|
||||||
|
providers[token] = Hash(String, String?).new.tap do |entry|
|
||||||
entry["name"] = provider.name
|
entry["name"] = provider.name
|
||||||
entry["id"] = provider.full_id
|
entry["id"] = provider.full_id
|
||||||
entry["environment"] = provider.environment.name
|
entry["environment"] = provider.environment.name
|
||||||
|
entry["root"] = provider.root
|
||||||
|
entry["domain"] = provider.domain
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
options["providers"] = providers
|
options["providers"] = providers
|
||||||
|
@ -106,11 +111,22 @@ class GenConfig::Context
|
||||||
service.provides.each do |provider_data|
|
service.provides.each do |provider_data|
|
||||||
token = provider_data.token
|
token = provider_data.token
|
||||||
|
|
||||||
consumers[token] = Service.all.select do |s2|
|
# FIXME: definitely unreadable
|
||||||
s2.providers.each do |t2, id|
|
consumers[token] = Service.all
|
||||||
token == t2 && id == service.id
|
.select(
|
||||||
|
&.providers.select do |t, provider|
|
||||||
|
t == token && service.is_id?(provider)
|
||||||
|
end
|
||||||
|
.size.>(0))
|
||||||
|
.map do |consumer|
|
||||||
|
Hash(String, String?).new.tap do |entry|
|
||||||
|
entry["name"] = consumer.name
|
||||||
|
entry["id"] = consumer.id
|
||||||
|
entry["environment"] = consumer.environment.name
|
||||||
|
entry["root"] = consumer.root
|
||||||
|
entry["domain"] = consumer.domain
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end.map &.full_id
|
|
||||||
end
|
end
|
||||||
options["consumers"] = consumers
|
options["consumers"] = consumers
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,6 @@ class Environment
|
||||||
|
|
||||||
getter name : String
|
getter name : String
|
||||||
getter type : Type = Type::Prefix
|
getter type : Type = Type::Prefix
|
||||||
getter domain_name : String?
|
|
||||||
getter pre_start_hooks = Array(ServiceDefinition::Hook).new
|
getter pre_start_hooks = Array(ServiceDefinition::Hook).new
|
||||||
|
|
||||||
# The place we’ll put services’ data and configuration.
|
# The place we’ll put services’ data and configuration.
|
||||||
|
|
|
@ -54,6 +54,8 @@ class Service
|
||||||
|
|
||||||
@reference = ServiceDefinition.get assignments["name"].as_s
|
@reference = ServiceDefinition.get assignments["name"].as_s
|
||||||
|
|
||||||
|
@domain = assignments["domain"]?.try &.as_s
|
||||||
|
|
||||||
env = assignments["environment"]?.try &.as_s
|
env = assignments["environment"]?.try &.as_s
|
||||||
@environment = if env.nil? || env == ""
|
@environment = if env.nil? || env == ""
|
||||||
Environment.root
|
Environment.root
|
||||||
|
|
Loading…
Reference in New Issue