wip, stuff
This commit is contained in:
parent
358c7441e6
commit
9a74130efa
@ -1,7 +1,7 @@
|
||||
command: nginx -c ${SERVICE_ROOT}/nginx.conf
|
||||
provides: www
|
||||
|
||||
#%directory ${SERVICE_ROOT}/
|
||||
# name: working directory
|
||||
%directory ${SERVICE_ROOT}/
|
||||
name: working directory
|
||||
|
||||
%configuration nginx.conf ${SERVICE_ROOT}/nginx.conf
|
||||
|
@ -8,10 +8,13 @@ def sanitize_path(path)
|
||||
end
|
||||
|
||||
module GenConfig
|
||||
# FIXME: The fuck has this become.
|
||||
alias Variables =
|
||||
String |
|
||||
Array(String) | Array(Variables) |
|
||||
Hash(String, String) | Hash(String, Variables) |
|
||||
Array(Hash(String, String?)) |
|
||||
Hash(String, String?) |
|
||||
Crinja::Callable::Instance
|
||||
|
||||
def self.parse_options(unparsed : Array(String))
|
||||
@ -51,7 +54,6 @@ class GenConfig::Context
|
||||
Environment.load ENVIRONMENTS_DIRECTORY
|
||||
ServiceDefinition.load SERVICES_DIRECTORY
|
||||
Service.load RC_DIRECTORY
|
||||
Environment.load ENVIRONMENTS_DIRECTORY
|
||||
|
||||
target_file = File.open target, "w"
|
||||
|
||||
@ -94,10 +96,13 @@ class GenConfig::Context
|
||||
|
||||
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["id"] = provider.full_id
|
||||
entry["environment"] = provider.environment.name
|
||||
entry["root"] = provider.root
|
||||
entry["domain"] = provider.domain
|
||||
end
|
||||
end
|
||||
options["providers"] = providers
|
||||
@ -106,11 +111,22 @@ class GenConfig::Context
|
||||
service.provides.each do |provider_data|
|
||||
token = provider_data.token
|
||||
|
||||
consumers[token] = Service.all.select do |s2|
|
||||
s2.providers.each do |t2, id|
|
||||
token == t2 && id == service.id
|
||||
# FIXME: definitely unreadable
|
||||
consumers[token] = Service.all
|
||||
.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.map &.full_id
|
||||
end
|
||||
options["consumers"] = consumers
|
||||
end
|
||||
|
@ -8,7 +8,6 @@ class Environment
|
||||
|
||||
getter name : String
|
||||
getter type : Type = Type::Prefix
|
||||
getter domain_name : String?
|
||||
getter pre_start_hooks = Array(ServiceDefinition::Hook).new
|
||||
|
||||
# The place we’ll put services’ data and configuration.
|
||||
|
@ -54,6 +54,8 @@ class Service
|
||||
|
||||
@reference = ServiceDefinition.get assignments["name"].as_s
|
||||
|
||||
@domain = assignments["domain"]?.try &.as_s
|
||||
|
||||
env = assignments["environment"]?.try &.as_s
|
||||
@environment = if env.nil? || env == ""
|
||||
Environment.root
|
||||
|
Loading…
Reference in New Issue
Block a user