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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulmar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Siegl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-13 00:00:00.000000000 Z
12
+ date: 2017-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '10'
34
+ version: '11'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '10'
41
+ version: '11'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: fulmar-shell
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -60,39 +60,33 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.7.0
62
62
  - !ruby/object:Gem::Dependency
63
- name: ruby_wings
63
+ name: colorize
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.1'
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: 0.1.1
68
+ version: '0'
72
69
  type: :runtime
73
70
  prerelease: false
74
71
  version_requirements: !ruby/object:Gem::Requirement
75
72
  requirements:
76
73
  - - "~>"
77
74
  - !ruby/object:Gem::Version
78
- version: '0.1'
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 0.1.1
75
+ version: '0'
82
76
  - !ruby/object:Gem::Dependency
83
- name: colorize
77
+ name: activesupport
84
78
  requirement: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '0'
82
+ version: '5.0'
89
83
  type: :runtime
90
84
  prerelease: false
91
85
  version_requirements: !ruby/object:Gem::Requirement
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '0'
89
+ version: '5.0'
96
90
  description: Fulmar is a task manager for deployments.
97
91
  email:
98
92
  - j.siegl@core4.de
@@ -113,42 +107,42 @@ files:
113
107
  - Rakefile
114
108
  - bin/fulmar
115
109
  - fulmar.gemspec
110
+ - lib/fulmar/domain/model/application.rb
111
+ - lib/fulmar/domain/model/configuration.rb
116
112
  - lib/fulmar/domain/model/project.rb
117
- - lib/fulmar/domain/service/application_service.rb
118
- - lib/fulmar/domain/service/config_rendering_service.rb
119
113
  - lib/fulmar/domain/service/config_test_service.rb
114
+ - lib/fulmar/domain/service/config_tests/hosts.rb
115
+ - lib/fulmar/domain/service/config_tests/mariadb.rb
116
+ - lib/fulmar/domain/service/config_tests/paths.rb
117
+ - lib/fulmar/domain/service/config_tests/project.rb
120
118
  - lib/fulmar/domain/service/configuration_service.rb
121
119
  - lib/fulmar/domain/service/file_sync_service.rb
122
120
  - lib/fulmar/domain/service/helper/common_helper.rb
123
- - lib/fulmar/domain/service/helper/database_helper.rb
124
- - lib/fulmar/domain/service/helper/flow_helper.rb
125
- - lib/fulmar/domain/service/helper/vhost_helper.rb
126
121
  - lib/fulmar/domain/service/initialization_service.rb
122
+ - lib/fulmar/domain/service/plugin_service.rb
123
+ - lib/fulmar/domain/service/template_rendering_service.rb
127
124
  - lib/fulmar/domain/task/configuration.rake
128
125
  - lib/fulmar/domain/task/console.rake
129
- - lib/fulmar/domain/task/database_sync.rake
130
126
  - lib/fulmar/domain/task/environment.rake
131
127
  - lib/fulmar/domain/task/initialization/base.rake
132
128
  - lib/fulmar/domain/task/versions.rake
133
- - lib/fulmar/infrastructure/service/composer_service.rb
129
+ - lib/fulmar/infrastructure/default_files/Fulmar/project.config.yml
130
+ - lib/fulmar/infrastructure/default_files/Fulmarfile
131
+ - lib/fulmar/infrastructure/model/transfer/base.rb
132
+ - lib/fulmar/infrastructure/model/transfer/rsync.rb
133
+ - lib/fulmar/infrastructure/model/transfer/rsync_with_versions.rb
134
+ - lib/fulmar/infrastructure/model/transfer/tar.rb
134
135
  - lib/fulmar/infrastructure/service/copy_service.rb
135
- - lib/fulmar/infrastructure/service/database/database_service.rb
136
- - lib/fulmar/infrastructure/service/flow_service.rb
137
- - lib/fulmar/infrastructure/service/shell_service.rb
138
136
  - lib/fulmar/infrastructure/service/ssh_config_service.rb
139
- - lib/fulmar/infrastructure/service/transfer/base.rb
140
- - lib/fulmar/infrastructure/service/transfer/rsync.rb
141
- - lib/fulmar/infrastructure/service/transfer/rsync_with_versions.rb
142
- - lib/fulmar/infrastructure/service/transfer/tar.rb
143
137
  - lib/fulmar/infrastructure/service/tunnel_service.rb
144
138
  - lib/fulmar/service/bootstrap_service.rb
145
139
  - lib/fulmar/service/helper_service.rb
146
- - lib/fulmar/service/logger_service.rb
147
140
  - lib/fulmar/task_manager.rb
148
141
  - lib/fulmar/version.rb
142
+ - spec/lib/fulmar/model/configuration_spec.rb
149
143
  - spec/lib/fulmar/service/helper_service_spec.rb
144
+ - spec/lib/fulmar/service/plugin_service_spec.rb
150
145
  - spec/spec_helper.rb
151
- - test/rsync_with_versions.rb
152
146
  homepage: https://github.com/CORE4/fulmar
153
147
  licenses:
154
148
  - MIT
@@ -169,11 +163,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
163
  version: '0'
170
164
  requirements: []
171
165
  rubyforge_project:
172
- rubygems_version: 2.6.8
166
+ rubygems_version: 2.6.11
173
167
  signing_key:
174
168
  specification_version: 4
175
169
  summary: A deployment task manager.
176
170
  test_files:
171
+ - spec/lib/fulmar/model/configuration_spec.rb
177
172
  - spec/lib/fulmar/service/helper_service_spec.rb
173
+ - spec/lib/fulmar/service/plugin_service_spec.rb
178
174
  - spec/spec_helper.rb
179
- - test/rsync_with_versions.rb
@@ -1,14 +0,0 @@
1
- module Fulmar
2
- module Domain
3
- module Service
4
- module Helper
5
- # Provides access helper to the database service from within a task
6
- module DatabaseHelper
7
- def database
8
- storage['database'] ||= Fulmar::Infrastructure::Service::Database::DatabaseService.new configuration
9
- end
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,16 +0,0 @@
1
- require 'fulmar/infrastructure/service/flow_service'
2
-
3
- module Fulmar
4
- module Domain
5
- module Service
6
- module Helper
7
- # Provides access helper to the flow service from within a task
8
- module FlowHelper
9
- def flow
10
- storage['flow'] ||= Fulmar::Infrastructure::Service::FlowService.new remote_shell, configuration
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,21 +0,0 @@
1
- module Fulmar
2
- module Domain
3
- module Service
4
- module Helper
5
- # Provides access helper to the database service from within a task
6
- module VhostHelper
7
- def vhost_name
8
- branch = git.current_branch
9
- match = branch.match(/f\d+_([a-zA-Z0-9\_\-]+)/)
10
- if match
11
- match[1]
12
- else
13
- error "Cannot deploy branch '#{branch}'"
14
- fail 'Branch must match specification for feature branches (f1234_name)'
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,63 +0,0 @@
1
- db_configs = []
2
- configuration.each do |env, target, data|
3
- db_configs << [env, target] if data[:type] == 'maria'
4
- end
5
-
6
- # Expects two hashes as parameters each with { :environment, :target, :name } set
7
- # :name is either environment:target or just the environment, if the is only one target
8
- def create_update_task(from, to)
9
- namespace to[:name] do
10
- task "from_#{from[:name]}" do
11
- configuration.environment = from[:environment]
12
- configuration.target = from[:target]
13
- puts 'Getting dump...'
14
- sql_dump = database.download_dump
15
- if sql_dump == ''
16
- puts 'Cannot create sql dump'
17
- else
18
- configuration.environment = to[:environment]
19
- configuration.target = to[:target]
20
- puts 'Sending dump...'
21
- remote_sql_dump = upload(sql_dump)
22
- database.load_dump(remote_sql_dump)
23
- end
24
- end
25
- end
26
- end
27
-
28
- def name(env, target, counts)
29
- counts[env] > 1 ? "#{env}:#{target}" : env
30
- end
31
-
32
- def create_update_tasks(db_configs)
33
- counts = Hash.new(0)
34
- db_configs.each do |config|
35
- counts[config.first] += 1
36
- end
37
-
38
- namespace :update do
39
- db_configs.each do |from_db|
40
- db_configs.each do |to_db|
41
- next if from_db == to_db # no need to sync a database to itself
42
- next if from_db.last != to_db.last # sync only matching target names
43
- from = {
44
- environment: from_db.first,
45
- target: from_db.last,
46
- name: name(from_db.first, from_db.last, counts)
47
- }
48
- to = {
49
- environment: to_db.first,
50
- target: to_db.last,
51
- name: name(to_db.first, to_db.last, counts)
52
- }
53
- create_update_task(from, to)
54
- end
55
- end
56
- end
57
- end
58
-
59
- if configuration.feature?(:database) && db_configs.any?
60
- namespace :database do
61
- create_update_tasks(db_configs) if db_configs.count > 1
62
- end
63
- end
@@ -1,22 +0,0 @@
1
- module Fulmar
2
- module Infrastructure
3
- module Service
4
- # Provides access to composer
5
- class ComposerService
6
- DEFAULT_PARAMS = ['--no-dev']
7
-
8
- attr_accessor :shell
9
-
10
- def initialize(shell, custom_path = '/usr/bin/env composer')
11
- @shell = shell
12
- @shell.quiet = true
13
- @path = custom_path
14
- end
15
-
16
- def execute(command, arguments = DEFAULT_PARAMS)
17
- @shell.run "#{@path} #{command} #{arguments.join(' ')}"
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,118 +0,0 @@
1
- module Fulmar
2
- module Infrastructure
3
- module Service
4
- module Database
5
- # Provides basic methods common to all database services
6
- class DatabaseService
7
- attr_accessor :client
8
- attr_reader :shell, :connected
9
- alias_method :connected?, :connected
10
-
11
- DEFAULT_CONFIG = {
12
- maria: {
13
- host: '127.0.0.1',
14
- port: 3306,
15
- user: 'root',
16
- password: '',
17
- encoding: 'utf8',
18
- ignore_tables: []
19
- }
20
- }
21
-
22
- def initialize(config)
23
- @config = config
24
- @config.merge DEFAULT_CONFIG
25
- initialize_shell
26
- config_test
27
- end
28
-
29
- def local?
30
- @config[:hostname] == 'localhost'
31
- end
32
-
33
- def command(binary)
34
- command = binary
35
- command << " -h #{@config[:maria][:host]}" unless @config[:maria][:host].blank?
36
- command << " -u #{@config[:maria][:user]}" unless @config[:maria][:user].blank?
37
- command << " --password='#{@config[:maria][:password]}'" unless @config[:maria][:password].blank?
38
- command
39
- end
40
-
41
- def dump(filename = backup_filename)
42
- filename = "#{@config[:remote_path]}/#{filename}" unless filename[0, 1] == '/'
43
-
44
- @shell.run "#{command('mysqldump')} #{@config[:maria][:database]} --single-transaction #{diffable} #{ignore_tables} -r \"#{filename}\""
45
-
46
- filename
47
- end
48
-
49
- def load_dump(dump_file, database = @config[:maria][:database])
50
- @shell.run "#{command('mysql')} -D #{database} < #{dump_file}"
51
- end
52
-
53
- def download_dump(filename = backup_filename)
54
- local_path = filename[0, 1] == '/' ? filename : @config[:local_path] + '/' + filename
55
- remote_path = dump
56
- copy = system("scp -Cq #{@config.ssh_user_and_host}:#{remote_path} #{local_path}")
57
- @shell.run "rm -f \"#{remote_path}\"" # delete temporary file
58
- if copy
59
- local_path
60
- else
61
- ''
62
- end
63
- end
64
-
65
- protected
66
-
67
- # Return mysql command line options to ignore specific tables
68
- def ignore_tables
69
- @config[:maria][:ignore_tables] = [*@config[:maria][:ignore_tables]]
70
- @config[:maria][:ignore_tables].map do |table|
71
- "--ignore-table=#{@config[:maria][:database]}.#{table}"
72
- end.join(' ')
73
- end
74
-
75
- # Return the mysql configuration options to make a dump diffable
76
- def diffable
77
- @config[:maria][:diffable_dump] ? '--skip-comments --skip-extended-insert ' : ''
78
- end
79
-
80
- # Test configuration
81
- def config_test
82
- fail 'Configuration option "database" missing.' unless @config[:maria][:database]
83
- end
84
-
85
- # Builds the filename for a new database backup file
86
- # NOTE: The file might already exist, for example if this is run at the same
87
- # time from to different clients. I won't handle this as it is unlikely and
88
- # would result in more I/O
89
- def backup_filename
90
- "#{@config[:maria][:database]}_#{Time.now.strftime('%Y-%m-%dT%H%M%S')}.sql"
91
- end
92
-
93
- def initialize_shell
94
- path = local? ? @config[:local_path] : @config[:remote_path]
95
- @shell = Fulmar::Infrastructure::Service::ShellService.new(path , @config.ssh_user_and_host)
96
- @shell.debug = true if @config[:debug]
97
- @shell.strict = true
98
- end
99
-
100
- # Compiles a mysql config hash from valid options of the fulmar config
101
- def compile_options
102
- possible_options = [:host, :username, :password, :port, :encoding, :socket, :read_timeout, :write_timeout,
103
- :connect_timeout, :reconnect, :local_infile, :secure_auth, :default_file, :default_group,
104
- :init_command
105
- ]
106
- options = { host: '127.0.0.1', username: @config[:maria][:user] }
107
-
108
- possible_options.each do |option|
109
- options[option] = @config[:maria][option] unless @config[:maria][option].nil?
110
- end
111
-
112
- options
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end
@@ -1,47 +0,0 @@
1
- module Fulmar
2
- module Infrastructure
3
- module Service
4
- # Implements Flow commands
5
- class FlowService
6
- # @param [Fulmar::Infrastructure::Service::ShellService] shell
7
- # @param [Hash] config
8
- def initialize(shell, config)
9
- @remote_shell = shell
10
- @config = config
11
- test_config
12
- end
13
-
14
- def cache_clear
15
- execute('flow:cache:flush --force')
16
- end
17
-
18
- def cache_warmup
19
- execute('flow:cache:warmup')
20
- end
21
-
22
- def site_export(filename = export_filename)
23
- execute("typo3.neos:site:export --filename \"#{filename}\"")
24
- filename
25
- end
26
-
27
- def site_import(filename)
28
- execute("./flow typo3.neos:site:import --filename \"#{filename}\"")
29
- end
30
-
31
- def execute(command)
32
- @remote_shell.run "FLOW_CONTEXT=\"#{@config[:neos][:environment]}\" ./flow #{command}"
33
- end
34
-
35
- protected
36
-
37
- def export_filename
38
- "export_#{Time.now.strftime('%Y-%m-%dT%H%M%S')}.xml"
39
- end
40
-
41
- def test_config
42
- fail 'Neos environment is not set.' unless @config[:neos] && @config[:neos][:environment]
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,10 +0,0 @@
1
- require 'fulmar/shell'
2
-
3
- module Fulmar
4
- module Infrastructure
5
- module Service
6
- # This is only a wrapper to fit the shell into the naming scheme
7
- class ShellService < Fulmar::Shell; end
8
- end
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- require 'logger'
2
-
3
- module Fulmar
4
- module Service
5
- class LoggerService < Logger; end
6
- end
7
- end
@@ -1,20 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'fulmar/infrastructure/service/transfer/rsync_with_versions'
3
-
4
- # Tests RsyncWithVersions
5
- class RsyncWithVersionsTest < MiniTest::Unit::TestCase
6
- def setup
7
- @transfer = Fulmar::Infrastructure::Service::Transfer::RsyncWithVersions.new(
8
- host: 'example.com',
9
- remote_dir: '/tmp',
10
- rsync: {
11
- exclude: 'foo'
12
- },
13
- type: :rsync_with_versions
14
- )
15
- end
16
-
17
- def test_release_dir_contains_current_date
18
- assert_match(/\/#{Time.now.strftime('%Y-%m-%d')}_/, @transfer.release_dir)
19
- end
20
- end