fulmar 1.10.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +11 -4
  4. data/README.md +87 -102
  5. data/fulmar.gemspec +2 -2
  6. data/lib/fulmar/domain/{service/application_service.rb → model/application.rb} +16 -2
  7. data/lib/fulmar/domain/model/configuration.rb +185 -0
  8. data/lib/fulmar/domain/service/config_test_service.rb +32 -114
  9. data/lib/fulmar/domain/service/config_tests/hosts.rb +23 -0
  10. data/lib/fulmar/domain/service/config_tests/mariadb.rb +19 -0
  11. data/lib/fulmar/domain/service/config_tests/paths.rb +15 -0
  12. data/lib/fulmar/domain/service/config_tests/project.rb +5 -0
  13. data/lib/fulmar/domain/service/configuration_service.rb +13 -131
  14. data/lib/fulmar/domain/service/file_sync_service.rb +7 -7
  15. data/lib/fulmar/domain/service/helper/common_helper.rb +18 -32
  16. data/lib/fulmar/domain/service/plugin_service.rb +60 -0
  17. data/lib/fulmar/domain/service/{config_rendering_service.rb → template_rendering_service.rb} +3 -3
  18. data/lib/fulmar/domain/task/configuration.rake +9 -7
  19. data/lib/fulmar/domain/task/console.rake +3 -3
  20. data/lib/fulmar/domain/task/environment.rake +5 -12
  21. data/lib/fulmar/domain/task/initialization/base.rake +3 -9
  22. data/lib/fulmar/domain/task/versions.rake +8 -12
  23. data/lib/fulmar/infrastructure/default_files/Fulmar/project.config.yml +26 -0
  24. data/lib/fulmar/infrastructure/default_files/Fulmarfile +22 -0
  25. data/lib/fulmar/infrastructure/{service → model}/transfer/base.rb +4 -4
  26. data/lib/fulmar/infrastructure/{service → model}/transfer/rsync.rb +4 -2
  27. data/lib/fulmar/infrastructure/{service → model}/transfer/rsync_with_versions.rb +18 -20
  28. data/lib/fulmar/infrastructure/{service → model}/transfer/tar.rb +2 -2
  29. data/lib/fulmar/infrastructure/service/copy_service.rb +2 -2
  30. data/lib/fulmar/infrastructure/service/ssh_config_service.rb +8 -21
  31. data/lib/fulmar/service/bootstrap_service.rb +1 -5
  32. data/lib/fulmar/task_manager.rb +2 -8
  33. data/lib/fulmar/version.rb +1 -1
  34. data/spec/lib/fulmar/model/configuration_spec.rb +193 -0
  35. data/spec/lib/fulmar/service/plugin_service_spec.rb +29 -0
  36. metadata +29 -34
  37. data/lib/fulmar/domain/service/helper/database_helper.rb +0 -14
  38. data/lib/fulmar/domain/service/helper/flow_helper.rb +0 -16
  39. data/lib/fulmar/domain/service/helper/vhost_helper.rb +0 -21
  40. data/lib/fulmar/domain/task/database_sync.rake +0 -63
  41. data/lib/fulmar/infrastructure/service/composer_service.rb +0 -22
  42. data/lib/fulmar/infrastructure/service/database/database_service.rb +0 -118
  43. data/lib/fulmar/infrastructure/service/flow_service.rb +0 -47
  44. data/lib/fulmar/infrastructure/service/shell_service.rb +0 -10
  45. data/lib/fulmar/service/logger_service.rb +0 -7
  46. data/test/rsync_with_versions.rb +0 -20
@@ -5,137 +5,55 @@ module Fulmar
5
5
  module Service
6
6
  # Tests the configuration
7
7
  class ConfigTestService
8
+ include Fulmar::Domain::Model
9
+
8
10
  def initialize(config)
9
11
  @config = config
10
- @config.load_user_config = false
11
- @config.reset
12
- end
13
-
14
- # Runs all methods beginning with test_ and returns the report
15
- def run
16
- @report = []
17
- tests = methods.select { |name| name.to_s[0, 5] == 'test_' }
18
- tests.each do |test|
19
- send(test)
20
- end
21
- @report
22
- end
23
-
24
- def test_hostnames_exist
25
- @config.each do |env, target, data|
26
- if data[:hostname].blank? && !data[:host].blank?
27
- @report << {
28
- message: "#{env}:#{target} has a host (#{data[:host]}) but is missing a hostname",
29
- severity: :warning
30
- }
12
+ @tests = {}
13
+ end
14
+
15
+ def target_test(name, &block)
16
+ @tests[name] = Proc.new do
17
+ results = []
18
+ @config.each do |env, target, _data|
19
+ @config.set env, target
20
+ result = block.call(@config)
21
+ if result
22
+ result[:message] = "in [#{env}:#{target}]: #{result[:message]}"
23
+ results << result
24
+ end
31
25
  end
26
+ results.reject(&:nil?)
32
27
  end
33
- end
34
28
 
35
- def test_project_name_exists
36
- if @config.project.name.blank?
37
- add_report 'Project is missing a name', :warning
38
- end
39
29
  end
40
30
 
41
- def test_hostnames_in_ssh_config
42
- hostnames = ssh_hostnames
43
-
44
- @config.each do |env, target, data|
45
- next if data[:hostname].blank?
46
-
47
- unless hostnames.include? data[:hostname]
48
- @report << {
49
- message: "#{env}:#{target} has a hostname (#{data[:hostname]}) which is not found in your ssh config",
50
- severity: :info
51
- }
52
- end
53
- end
54
- end
55
-
56
- def test_required_hostnames
57
- types = %i(rsync rsync_with_version maria)
58
- @config.each do |env, target, data|
59
- if types.include?(data[:type]) && data[:hostname].blank?
60
- @report << {
61
- message: "#{env}:#{target} requires a hostname (#{data[:hostname]})",
62
- severity: :error
63
- }
64
- end
65
- end
31
+ def global_test(name, &block)
32
+ @tests[name] = block
66
33
  end
67
34
 
68
- def test_vhost_template_is_set
69
- vhost_template = false
70
-
71
- @config.each do |_env, _target, data|
72
- vhost_template = true unless data[:vhost_template].blank?
73
- end
74
-
75
- add_report(
76
- 'The configuration uses the vhost feature but misses a valid configuration for it (missing :vhost_template)',
77
- :warning
78
- ) if @config.feature?(:vhost) && !vhost_template
79
- end
80
-
81
- # Run simple test which only require one configuration
82
- def test_simple_tests
83
- @config.each do |env, target, data|
84
- tests = methods.select { |name| name.to_s[0, 12] == 'simple_test_' }
85
- tests.each do |test|
86
- send(test, env, target, data)
87
- end
88
- end
89
- end
90
-
91
- def simple_test_local_path_exists(env, target, data)
92
- unless File.exist? data[:local_path]
93
- add_report("#{env}:#{target} has no valid local_path (#{data[:local_path]})", :warning)
94
- end
95
- end
96
-
97
- def simple_test_mariadb_feature_is_set(env, target, data)
98
- if data[:type] == :maria && !@config.feature?(:database)
99
- @report << {
100
- message: "#{env}:#{target} uses mysql/mariadb but your config is missing the database feature",
101
- severity: :notice
102
- }
103
- end
104
- end
105
-
106
- def simple_test_vhost_feature_is_set(env, target, data)
107
- if data[:vhost_template] && !@config.feature?(:vhost)
108
- @report << {
109
- message: "#{env}:#{target} refers to a vhost_template but your config is missing the vhost feature",
110
- severity: :warning
111
- }
112
- end
113
- end
114
-
115
- def simple_test_maria_db_config_exists(env, target, data)
116
- if data[:type] == :maria && data[:maria][:database].blank?
117
- add_report "#{env}:#{target} is missing a database name in maria:database", :error
35
+ # Runs all methods beginning with test_ and returns the report
36
+ def run
37
+ test_dirs = ["#{File.dirname(__FILE__)}/config_tests/"]
38
+ test_files = test_dirs.collect{ |dir| Dir.glob("#{dir}/*.rb") }.flatten
39
+ test_files.each do |file|
40
+ eval File.read(file)
118
41
  end
119
- end
120
42
 
121
- def simple_test_remote_path_exists_for_rsync(env, target, data)
122
- types = [:rsync, :rsync_with_version]
123
- if types.include?(data[:type]) && data[:remote_path].blank?
124
- add_report "#{env}:#{target} is missing a remote path", :error
43
+ results = []
44
+ @tests.each_pair do |name, test|
45
+ results << test.call(@config)
125
46
  end
47
+ results.reject!(&:nil?)
48
+ results.reject!(&:empty?)
49
+ results.flatten!
50
+ results
126
51
  end
127
52
 
128
53
  protected
129
54
 
130
- def add_report(message, severity)
131
- @report << {
132
- message: message,
133
- severity: severity
134
- }
135
- end
136
-
137
55
  def ssh_hostnames
138
- `grep -E '^Host [^ *]+$' ~/.ssh/config | sort | uniq | cut -d ' ' -f 2`.split("\n")
56
+ @ssh_hostnames ||= `grep -E '^Host [^ *]+$' ~/.ssh/config | sort | uniq | cut -d ' ' -f 2`.split("\n")
139
57
  end
140
58
  end
141
59
  end
@@ -0,0 +1,23 @@
1
+ target_test 'hostname is set' do |config|
2
+ if config[:hostname].blank? && !config[:host].blank?
3
+ next {
4
+ severity: :warning,
5
+ message: "config has a host (#{[:host]}) but is missing a hostname"
6
+ }
7
+ end
8
+ end
9
+
10
+ target_test 'hostnames in ssh config' do |config|
11
+ next if config[:hostname].blank?
12
+
13
+ unless ssh_hostnames.include? config[:hostname]
14
+ {severity: :info, message: "config has a hostname (#{config[:hostname]}) which is not in your ssh config"}
15
+ end
16
+ end
17
+
18
+ target_test 'required hostnames' do |config|
19
+ types = %i(rsync rsync_with_version maria)
20
+ if types.include?(config[:type]) && config[:hostname].blank?
21
+ next {severity: :error, message: "config requires a hostname (#{config[:hostname]})"}
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # Move this file into the plugin
2
+
3
+ target_test 'mariadb is loaded' do |config|
4
+ if config[:type] == :mariadb && !config.plugins.include?(:mariadb)
5
+ next {
6
+ severity: :warning,
7
+ message: 'config uses mysql/mariadb but your config is missing the maria plugin'
8
+ }
9
+ end
10
+ end
11
+
12
+ target_test 'database name exists' do |config|
13
+ if config.plugins.include?(:mariadb) && config[:maria] && config[:maria][:database].blank?
14
+ next {
15
+ severity: :error,
16
+ message: 'config is missing a database name in maria:database'
17
+ }
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ target_test 'local path exists' do |config|
2
+ if config[:local_path] && !File.exist?(config[:local_path])
3
+ next {
4
+ severity: :warning,
5
+ message: "local_path does not exist (#{config[:local_path]})"
6
+ }
7
+ end
8
+ end
9
+
10
+ target_test 'remote_path is set' do |config|
11
+ types = %w(rsync rsync_with_version)
12
+ if types.include?(config[:type]) && config[:remote_path].blank?
13
+ next {severity: :error, message: 'config is missing a remote path for rsync'}
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ global_test 'project name is set' do |config|
2
+ next {severity: :warning,
3
+ message: 'Project name is not set (must be short, no spaces)'
4
+ } if config.project.name.blank?
5
+ end
@@ -1,7 +1,8 @@
1
1
  require 'yaml'
2
2
  require 'pp'
3
3
  require 'fulmar/domain/model/project'
4
- require 'singleton'
4
+ require 'fulmar/domain/model/configuration'
5
+ require 'active_support/core_ext/hash/keys'
5
6
 
6
7
  module Fulmar
7
8
  module Domain
@@ -20,39 +21,17 @@ module Fulmar
20
21
  environments: {},
21
22
  features: {},
22
23
  hosts: {},
23
- dependencies: { all: {} }
24
24
  }
25
25
 
26
- include ::Singleton
26
+ include Singleton
27
27
 
28
28
  attr_reader :environment, :target
29
- attr_accessor :load_user_config
29
+ attr_accessor :load_user_config, :debug
30
30
 
31
31
  def initialize
32
- @environment = nil
33
- @target = nil
34
32
  @load_user_config = true
35
33
  end
36
34
 
37
- # Allow access of configuration via array/hash access methods (read access)
38
- def [](id)
39
- ready? ? configuration[:environments][@environment][@target][id] : nil
40
- end
41
-
42
- # Allow access of configuration via array/hash access methods (write access)
43
- def []=(id, value)
44
- if ready?
45
- configuration[:environments][@environment][@target][id] = value
46
- else
47
- fail 'Environment or target not set. Please set both variables via configuration.environment = \'xxx\' / '\
48
- 'configuration.target = \'yyy\''
49
- end
50
- end
51
-
52
- def to_hash
53
- ready? ? configuration[:environments][@environment][@target] : configuration
54
- end
55
-
56
35
  def base_path
57
36
  @base_path ||= lookup_base_path
58
37
  end
@@ -61,68 +40,6 @@ module Fulmar
61
40
  @config ||= load_configuration
62
41
  end
63
42
 
64
- def project
65
- @project ||= Fulmar::Domain::Model::Project.new(configuration[:project])
66
- end
67
-
68
- def method_missing(name)
69
- environment(name) if configuration[:environments][name]
70
- end
71
-
72
- def environment=(env)
73
- @environment = env ? env.to_sym : nil
74
- end
75
-
76
- def target=(target)
77
- @target = target ? target.to_sym : nil
78
- end
79
-
80
- def ssh_user_and_host
81
- self[:user].blank? ? self[:hostname] : self[:user] + '@' + self[:hostname]
82
- end
83
-
84
- def dependencies(env = nil)
85
- if env.nil? || !@config[:dependencies].has_key?(env)
86
- @config[:dependencies][:all]
87
- else
88
- @config[:dependencies][:all].deep_merge(@config[:dependencies][env])
89
- end
90
- end
91
-
92
- def ready?
93
- return false if @environment.nil? || @target.nil?
94
- fail 'Environment is invalid' if configuration[:environments][@environment].nil?
95
- fail 'Target is invalid' if configuration[:environments][@environment][@target].nil?
96
- true
97
- end
98
-
99
- def feature?(feature)
100
- return configuration[:features].include? feature.to_s unless configuration[:features].nil?
101
- case feature
102
- when :database
103
- any? { |data| data[:type] == 'maria' }
104
- else
105
- false
106
- end
107
- end
108
-
109
- def each
110
- configuration[:environments].each_key do |env|
111
- configuration[:environments][env].each_pair do |target, data|
112
- yield(env, target, data)
113
- end
114
- end
115
- end
116
-
117
- def any?
118
- if block_given?
119
- each { |_env, _target, data| return true if yield(data) }
120
- false
121
- else
122
- configuration[:environments].any?
123
- end
124
- end
125
-
126
43
  # Merge another configuration into the currently active one
127
44
  # Useful for supplying a default configuration, as values are not overwritten.
128
45
  # Hashes are merged.
@@ -158,45 +75,17 @@ module Fulmar
158
75
  File.dirname(fulmar_file)
159
76
  end
160
77
 
161
- # Fills a target with all globally set variables so all necessary information
162
- # is found within each target
163
- def fill_target(env, target)
164
- @config[:environments][env][target] = @config[:environments][:all].deep_merge(@config[:environments][env][target]) if @config[:environments][:all]
165
-
166
- return if @config[:environments][env][target][:host].blank?
167
-
168
- host = @config[:environments][env][target][:host].to_sym
169
- return unless @config[:hosts] && @config[:hosts][host]
170
- @config[:hosts][host].each do
171
- @config[:environments][env][target] = @config[:hosts][host].deep_merge(@config[:environments][env][target])
172
- end
173
- end
174
-
175
78
  # Loads the configuration from the YAML file and populates all targets
176
79
  def load_configuration
177
- @config = BLANK_CONFIG
80
+ config = BLANK_CONFIG
178
81
  config_files.each do |config_file|
179
- @config = @config.deep_merge((YAML.load_file(config_file) || {}).symbolize)
180
- end
181
-
182
- prepare_environments
183
- prepare_dependencies
184
- # Iterate over all environments and targets to prepare them
185
- @config[:environments].delete(:all)
186
- check_version
187
- @config
188
- end
189
-
190
- def prepare_environments
191
- @config[:environments].each_key do |env|
192
- next if env == :all
193
- @config[:environments][env].each_key do |target|
194
- fill_target(env, target)
195
- check_path(env, target)
196
- end
82
+ config = config.deep_merge((YAML.load_file(config_file) || {}).deep_symbolize_keys)
197
83
  end
84
+ check_version(config[:project][:fulmar_version])
85
+ Fulmar::Domain::Model::Configuration.new(config, base_path, @debug)
198
86
  end
199
87
 
88
+ # @todo Move to configuration model if I know what this was or if it is relevant
200
89
  def prepare_dependencies
201
90
  @config[:dependencies].each_pair do |_env, repos|
202
91
  repos.each_pair do |_name, repo|
@@ -207,17 +96,10 @@ module Fulmar
207
96
  end
208
97
  end
209
98
 
210
- def check_path(env, target)
211
- path = @config[:environments][env][target][:local_path]
212
- return if path.blank?
213
- return if path[0,1] == '/'
214
- @config[:environments][env][target][:local_path] = File.expand_path("#{base_path}/#{path}")
215
- end
216
-
217
- def check_version
218
- return if @config[:project][:fulmar_version].nil?
219
- unless Gem::Dependency.new('', @config[:project][:fulmar_version]).match?('', Fulmar::VERSION)
220
- fail "Project requires another version of fulmar: #{@config[:project][:fulmar_version]}"
99
+ def check_version(version)
100
+ return if version.nil?
101
+ unless Gem::Dependency.new('', version).match?('', Fulmar::VERSION)
102
+ fail "Project requires a newer version of fulmar: #{version}"
221
103
  end
222
104
  end
223
105
  end
@@ -1,19 +1,19 @@
1
1
 
2
- require 'fulmar/infrastructure/service/transfer/rsync'
3
- require 'fulmar/infrastructure/service/transfer/rsync_with_versions'
4
- require 'fulmar/infrastructure/service/transfer/tar'
2
+ require 'fulmar/infrastructure/model/transfer/rsync'
3
+ require 'fulmar/infrastructure/model/transfer/rsync_with_versions'
4
+ require 'fulmar/infrastructure/model/transfer/tar'
5
5
 
6
6
  module Fulmar
7
7
  # Creates the required transfer model from the configuration
8
8
  class FileSync
9
- def self.create_transfer(config)
9
+ def self.get_model(config)
10
10
  case config[:type]
11
11
  when 'rsync_with_versions'
12
- transfer_model = Fulmar::Infrastructure::Service::Transfer::RsyncWithVersions.new(config)
12
+ transfer_model = Fulmar::Infrastructure::Model::Transfer::RsyncWithVersions.new(config)
13
13
  when 'rsync'
14
- transfer_model = Fulmar::Infrastructure::Service::Transfer::Rsync.new(config)
14
+ transfer_model = Fulmar::Infrastructure::Model::Transfer::Rsync.new(config)
15
15
  when 'tar'
16
- transfer_model = Fulmar::Infrastructure::Service::Transfer::Tar.new(config)
16
+ transfer_model = Fulmar::Infrastructure::Model::Transfer::Tar.new(config)
17
17
  else
18
18
  help = config[:type] == '' ? 'Add a "type: " field to your deployment yaml file. ' : ''
19
19
  transfer_model = nil
@@ -1,4 +1,5 @@
1
1
  require 'fulmar/domain/service/configuration_service'
2
+ require 'fulmar/shell'
2
3
  require 'colorize'
3
4
 
4
5
  module Fulmar
@@ -9,73 +10,58 @@ module Fulmar
9
10
  module CommonHelper
10
11
  attr_accessor :environment
11
12
 
12
- # @return [Hash]
13
- def full_configuration
14
- configuration.configuration
15
- end
16
-
17
13
  # @return [Fulmar::Domain::Service::ConfigurationService]
18
- def configuration
19
- (@_config_service ||= Fulmar::Domain::Service::ConfigurationService.instance)
14
+ def config
15
+ (@_config_service ||= Fulmar::Domain::Service::ConfigurationService.instance.configuration)
20
16
  end
21
17
 
22
18
  # @return [Fulmar::Domain::Model::Project]
23
19
  def project
24
- full_configuration[:project]
25
- end
26
-
27
- def composer(command, arguments = Fulmar::Infrastructure::Service::ComposerService::DEFAULT_PARAMS)
28
- storage['composer'] ||= Fulmar::Infrastructure::Service::ComposerService.new(local_shell)
29
- storage['composer'].shell.quiet = !configuration[:debug]
30
- storage['composer'].execute(command, arguments)
20
+ config.project
31
21
  end
32
22
 
33
23
  # @return [Fulmar::Shell]
34
24
  def local_shell
35
- storage['local_shell'] ||= new_shell(configuration[:local_path])
25
+ storage['local_shell'] ||= new_shell(config[:local_path])
36
26
  end
37
27
 
38
28
  # @return [Fulmar::Shell]
39
29
  def remote_shell
40
- storage['remote_shell'] ||= new_shell(configuration[:remote_path], configuration.ssh_user_and_host)
30
+ storage['remote_shell'] ||= new_shell(config[:remote_path], config.ssh_user_and_host)
41
31
  end
42
32
 
43
33
  def file_sync
44
- storage['file_sync'] ||= Fulmar::FileSync.create_transfer configuration
34
+ storage['file_sync'] ||= Fulmar::FileSync.get_model config
45
35
  end
46
36
 
47
37
  def render_templates
48
- (Fulmar::Domain::Service::ConfigRenderingService.new configuration).render
49
- end
50
-
51
- def git
52
- storage['git'] ||= Fulmar::Infrastructure::Service::GitService.new configuration
38
+ (Fulmar::Domain::Service::TemplateRenderingService.new config).render
53
39
  end
54
40
 
55
- def upload(filename)
56
- Fulmar::Infrastructure::Service::CopyService.upload(local_shell, filename, configuration.ssh_user_and_host, configuration[:remote_path])
41
+ def upload(filename, target = config[:remote_path])
42
+ Fulmar::Infrastructure::Service::CopyService.upload(local_shell, filename, config.ssh_user_and_host, target)
57
43
  end
58
44
 
59
- def download(filename)
60
- Fulmar::Infrastructure::Service::CopyService.download(local_shell, configuration.ssh_user_and_host, filename, configuration[:local_path])
45
+ def download(filename, target = config[:local_path])
46
+ Fulmar::Infrastructure::Service::CopyService.download(local_shell, config.ssh_user_and_host, filename, target)
61
47
  end
62
48
 
63
49
  def new_shell(path, hostname = 'localhost')
64
- shell = Fulmar::Infrastructure::Service::ShellService.new(path, hostname)
50
+ shell = Fulmar::Shell.new(path, hostname)
65
51
  shell.strict = true
66
- shell.debug = configuration[:debug]
52
+ shell.debug = config[:debug]
67
53
  shell
68
54
  end
69
55
 
70
56
  def ssh_config
71
- storage['ssh_config'] ||= Fulmar::Infrastructure::Service::SSHConfigService.new configuration
57
+ storage['ssh_config'] ||= Fulmar::Infrastructure::Service::SSHConfigService.new config
72
58
  end
73
59
 
74
60
  def storage
75
- fail 'You need to set an environment and a target first' unless configuration.ready?
61
+ fail 'You need to set an environment and a target first' unless config.ready?
76
62
  @storage ||= {}
77
- @storage[configuration.environment] ||= {}
78
- @storage[configuration.environment][configuration.target] ||= {}
63
+ @storage[config.environment] ||= {}
64
+ @storage[config.environment][config.target] ||= {}
79
65
  end
80
66
 
81
67
  def info(text)
@@ -0,0 +1,60 @@
1
+ require 'singleton'
2
+ require 'active_support/core_ext/string/inflections'
3
+ require 'fulmar/domain/service/configuration_service'
4
+
5
+ module Fulmar
6
+ module Domain
7
+ module Service
8
+ class PluginService
9
+ include Singleton
10
+
11
+ def self.instance
12
+ @@instance ||= new
13
+ end
14
+
15
+ def initialize
16
+ @plugins = {}
17
+ config = ConfigurationService.instance.configuration
18
+
19
+ if config.plugins.class == Array
20
+ fail 'Plugin list must not be an array. Have a look at https://github.com/CORE4/fulmar#plugins for ' +
21
+ 'more information'
22
+ end
23
+
24
+ config.plugins.each_pair do |name, plugin_config|
25
+ puts "Loading plugin '#{name}'..." if config.debug
26
+ require_plugin(name)
27
+ @plugins[name] = classname(name, :configuration).new(plugin_config)
28
+ end
29
+
30
+ end
31
+
32
+ def classname(plugin, name = nil)
33
+ "Fulmar::Plugin::#{class_map[plugin.to_s.downcase]}#{name.nil? ? '' : '::'+name.to_s.camelize}".constantize
34
+ end
35
+
36
+ def class_map
37
+ map = {}
38
+ Fulmar::Plugin.constants.each do |classname|
39
+ map[classname.to_s.downcase] = classname.to_s
40
+ end
41
+ map
42
+ end
43
+
44
+ def require_plugin(name)
45
+ require "fulmar/plugin/#{name}/configuration"
46
+ end
47
+
48
+ def helpers
49
+ @plugins.keys.select { |plugin| classname(plugin).constants.include? (:DslHelper) }.collect do |plugin|
50
+ classname(plugin, :DslHelper)
51
+ end
52
+ end
53
+
54
+ def rake_files
55
+ @plugins.values.collect(&:rake_files).flatten
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -4,14 +4,14 @@ module Fulmar
4
4
  module Domain
5
5
  module Service
6
6
  # Renders templates of config files
7
- class ConfigRenderingService
7
+ class TemplateRenderingService
8
8
  def initialize(config)
9
9
  @config = config
10
10
  end
11
11
 
12
12
  def render
13
- return unless @config[:config_templates]
14
- @config[:config_templates].each do |template_file|
13
+ return unless @config[:templates]
14
+ @config[:templates].each do |template_file|
15
15
  template = template_path(template_file)
16
16
 
17
17
  renderer = ERB.new(File.read(template))
@@ -3,7 +3,7 @@ require 'pp'
3
3
  namespace :test do
4
4
  task :config do
5
5
  require 'fulmar/domain/service/config_test_service'
6
- test_service = Fulmar::Domain::Service::ConfigTestService.new(configuration)
6
+ test_service = Fulmar::Domain::Service::ConfigTestService.new(config)
7
7
  results = test_service.run
8
8
 
9
9
  results.each do |report|
@@ -22,18 +22,20 @@ namespace :test do
22
22
 
23
23
  task :hosts do
24
24
  error_count = 0
25
- configuration.each do |env, target, _data|
26
- configuration.environment = env
27
- configuration.target = target
25
+ config.each do |env, target, _data|
26
+ config.environment = env
27
+ config.target = target
28
28
 
29
- next if configuration[:hostname].blank?
29
+ next if config[:hostname].blank?
30
30
  remote_shell.quiet = true
31
31
  remote_shell.strict = false
32
32
 
33
- message = "Cannot open remote shell to host '#{configuration[:hostname]}' (#{env}:#{target})"
33
+ info "Testing #{env}:#{target}..."
34
+
35
+ message = "Cannot open remote shell to host '#{config[:hostname]}' (#{env}:#{target})"
34
36
 
35
37
  begin
36
- remote_shell.run 'true' || error(message)
38
+ remote_shell.run('true') || error(message)
37
39
  rescue
38
40
  error(message)
39
41
  end