Permalink
Browse files

ServiceConfig subclasses dynamically register themselves when loaded …

…into memory
  • Loading branch information...
1 parent 8a8ef4f commit f7e3cae7e356e8dce3c3d0fcc5f2e64f88ddcf10 @drnic drnic committed Mar 11, 2013
@@ -46,4 +46,6 @@ def merge_manifest_properties(manifest)
end
end
end
+
+ SystemConfig.register_service_config(PostgresqlServiceConfig)
end
@@ -39,4 +39,6 @@ def merge_manifest_properties(manifest)
end
end
end
+
+ SystemConfig.register_service_config(RedisServiceConfig)
end
@@ -20,13 +20,6 @@ def initialize(system_dir)
setup_services
end
- def service_classes
- [
- Bosh::CloudFoundry::Config::PostgresqlServiceConfig,
- Bosh::CloudFoundry::Config::RedisServiceConfig,
- ]
- end
-
def self.create_config_accessor(attr)
define_method attr do
read(attr, false)
@@ -75,6 +68,19 @@ def microbosh
@microbosh ||= Bosh::CloudFoundry::Config::MicroboshConfig.new(bosh_target)
end
+ def self.register_service_config(service_config_class)
+ @service_classes ||= []
+ @service_classes << service_config_class
+ end
+
+ def self.service_classes
+ @service_classes
+ end
+
+ def service_classes
+ self.class.service_classes
+ end
+
def setup_services
@services_by_name = {}
service_classes.each do |service_class|

0 comments on commit f7e3cae

Please sign in to comment.