parent
d3fe317665
commit
c43eb7af42
|
@ -366,9 +366,10 @@ if command.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
context = Service::Context.new
|
context = Service::Context.new
|
||||||
context.load
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
context.load
|
||||||
|
|
||||||
args.shift
|
args.shift
|
||||||
command.[2].call(context, args)
|
command.[2].call(context, args)
|
||||||
rescue e : Service::Exception
|
rescue e : Service::Exception
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Service::Context < Weird::Base
|
||||||
load_services
|
load_services
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_service_by_id(id)
|
def get_service_by_id(id : String) : Service?
|
||||||
matches = id.match /[^\/]*/
|
matches = id.match /[^\/]*/
|
||||||
unless matches # Should not happen, above regex would always match.
|
unless matches # Should not happen, above regex would always match.
|
||||||
raise Exception.new "FIXME"
|
raise Exception.new "FIXME"
|
||||||
|
@ -102,7 +102,7 @@ class Service::Context < Weird::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_environment_by_name(name)
|
def get_environment_by_name(name : String) : Environment
|
||||||
_def = @environments.find &.name.==(name)
|
_def = @environments.find &.name.==(name)
|
||||||
|
|
||||||
if _def.nil?
|
if _def.nil?
|
||||||
|
@ -131,7 +131,7 @@ class Service::Context < Weird::Base
|
||||||
port
|
port
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_service_definition_by_name(name)
|
def get_service_definition_by_name(name : String) : ServiceDefinition
|
||||||
_def = @service_definitions.find &.name.==(name)
|
_def = @service_definitions.find &.name.==(name)
|
||||||
|
|
||||||
if _def.nil?
|
if _def.nil?
|
||||||
|
|
|
@ -37,6 +37,8 @@ class Service
|
||||||
property domain : String?
|
property domain : String?
|
||||||
getter ports = Hash(String, Int32).new
|
getter ports = Hash(String, Int32).new
|
||||||
|
|
||||||
|
@reference : ServiceDefinition
|
||||||
|
|
||||||
# The place we’ll store configuration and data.
|
# The place we’ll store configuration and data.
|
||||||
@root : String?
|
@root : String?
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ class Service
|
||||||
|
|
||||||
def initialize(@context : Context, name, environment_name : String?)
|
def initialize(@context : Context, name, environment_name : String?)
|
||||||
@providers = ProvidersList.new @context
|
@providers = ProvidersList.new @context
|
||||||
@reference = ServiceDefinition.get name
|
@reference = context.get_service_definition_by_name name
|
||||||
@environment = if environment_name.nil? || environment_name == ""
|
@environment = if environment_name.nil? || environment_name == ""
|
||||||
@context.root_environment
|
@context.root_environment
|
||||||
else
|
else
|
||||||
|
@ -81,7 +83,7 @@ class Service
|
||||||
# name and their types were their name.
|
# name and their types were their name.
|
||||||
type = assignments["type"]?.try &.as_s
|
type = assignments["type"]?.try &.as_s
|
||||||
@name = (assignments["name"]?.try(&.as_s) || type).not_nil!
|
@name = (assignments["name"]?.try(&.as_s) || type).not_nil!
|
||||||
@reference = ServiceDefinition.get type || @name
|
@reference = context.get_service_definition_by_name (type || @name).not_nil!
|
||||||
|
|
||||||
@domain = assignments["domain"]?.try &.as_s
|
@domain = assignments["domain"]?.try &.as_s
|
||||||
|
|
||||||
|
|
|
@ -150,16 +150,6 @@ class ServiceDefinition
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get(name) : ServiceDefinition
|
|
||||||
_def = @@all.find &.name.==(name)
|
|
||||||
|
|
||||||
if _def.nil?
|
|
||||||
raise ::Service::Exception.new "Service '#{name}' does not exist."
|
|
||||||
end
|
|
||||||
|
|
||||||
_def
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue