Permalink
Browse files

SystemConfig is setup via the ServiceConfig subclasses

  • Loading branch information...
1 parent d07fde9 commit f8b390ff3794b6f154cdb69e86fb1f4851f89abf @drnic drnic committed Mar 10, 2013
@@ -7,6 +7,7 @@ class PostgresqlServiceConfig < ServiceConfig
# name that maps into the cf-release's jobs folder
# for postgresql_gateway and postgresql_node jobs
+ # also used as the key into SystemConfig manifest
def service_name
"postgresql"
end
@@ -7,6 +7,7 @@ class RedisServiceConfig < ServiceConfig
# name that maps into the cf-release's jobs folder
# for redis_gateway and redis_node jobs
+ # also used as the key into SystemConfig manifest
def service_name
"redis"
end
@@ -17,7 +17,7 @@ def initialize(system_dir)
super(config_file, system_dir)
self.system_dir = system_dir
self.system_name = File.basename(system_dir)
- setup_default_service_config
+ setup_services
end
[
@@ -65,24 +65,30 @@ def microbosh
@microbosh ||= Bosh::CloudFoundry::Config::MicroboshConfig.new(bosh_target)
end
+ def setup_services
+ @services = {}
+ service_classes.each do |service_class|
+ service = service_class.build_from_system_config(self)
+ service_name = service.service_name
+ self.send("#{service_name}=", [])
+ @services[service_name] = service
+ end
+ end
+
+ def service_classes
+ [
+ Bosh::CloudFoundry::Config::PostgresqlServiceConfig,
+ Bosh::CloudFoundry::Config::RedisServiceConfig,
+ ]
+ end
+
def supported_services
- %w[postgresql redis]
+ @services.keys
end
def service(service_name)
- case service_name.to_sym
- when :postgresql
- Bosh::CloudFoundry::Config::PostgresqlServiceConfig.build_from_system_config(self)
- when :redis
- Bosh::CloudFoundry::Config::RedisServiceConfig.build_from_system_config(self)
- else
- raise "please add #{service_name} support to SystemConfig#service method"
- end
+ @services[service_name] ||
+ raise("please add #{service_name} support to SystemConfig#service method")
end
- def setup_default_service_config
- supported_services.each do |service_name|
- self.send("#{service_name}=", [])
- end
- end
end

0 comments on commit f8b390f

Please sign in to comment.