Skip to content
This repository
Browse code

ServiceConfig subclasses dynamically register themselves when loaded …

…into memory
  • Loading branch information...
commit f7e3cae7e356e8dce3c3d0fcc5f2e64f88ddcf10 1 parent 8a8ef4f
Dr Nic Williams authored March 10, 2013
2  lib/bosh-cloudfoundry/config/postgresql_service_config.rb
@@ -46,4 +46,6 @@ def merge_manifest_properties(manifest)
46 46
       end
47 47
     end
48 48
   end
  49
+
  50
+  SystemConfig.register_service_config(PostgresqlServiceConfig)
49 51
 end
2  lib/bosh-cloudfoundry/config/redis_service_config.rb
@@ -39,4 +39,6 @@ def merge_manifest_properties(manifest)
39 39
       end
40 40
     end
41 41
   end
  42
+
  43
+  SystemConfig.register_service_config(RedisServiceConfig)
42 44
 end
20  lib/bosh-cloudfoundry/config/system_config.rb
@@ -20,13 +20,6 @@ def initialize(system_dir)
20 20
     setup_services
21 21
   end
22 22
 
23  
-  def service_classes
24  
-    [
25  
-      Bosh::CloudFoundry::Config::PostgresqlServiceConfig,
26  
-      Bosh::CloudFoundry::Config::RedisServiceConfig,
27  
-    ]
28  
-  end
29  
-
30 23
   def self.create_config_accessor(attr)
31 24
     define_method attr do
32 25
       read(attr, false)
@@ -75,6 +68,19 @@ def microbosh
75 68
     @microbosh ||= Bosh::CloudFoundry::Config::MicroboshConfig.new(bosh_target)
76 69
   end
77 70
 
  71
+  def self.register_service_config(service_config_class)
  72
+    @service_classes ||= []
  73
+    @service_classes << service_config_class
  74
+  end
  75
+
  76
+  def self.service_classes
  77
+    @service_classes
  78
+  end
  79
+
  80
+  def service_classes
  81
+    self.class.service_classes
  82
+  end
  83
+
78 84
   def setup_services
79 85
     @services_by_name = {}
80 86
     service_classes.each do |service_class|

0 notes on commit f7e3cae

Please sign in to comment.
Something went wrong with that request. Please try again.