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