fulmar 1.9.2 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c0254651c027ef775ad9e568f66d86aad0ae858
4
- data.tar.gz: eaac4a6a2a32db19ce421432f4151bac017ba12f
3
+ metadata.gz: 375aee75cd020abdfdefb0622dd2f90e547c31c0
4
+ data.tar.gz: 8b8ae5c411d00386e02ad4be9ef1d515d0f541b1
5
5
  SHA512:
6
- metadata.gz: c3a2380798df491fc87e15ceb44d7d48576df1c98d015c91101f35ae86878e32424395098d48cfd1c322fc2a1a9b18d60b9802671ee84bc0e3324b4135d0c314
7
- data.tar.gz: 89334e747f73215ec35e5b7f733c5f6dbfe9d89815bcd72987beb0bb7fdff2c1dafc5720dbc6f84b0948ca887a0b07339de5932627d095bca7c6be1bf899350c
6
+ metadata.gz: 44e7234acfce670e208e86ca23f299b31488049f0d9578e0ba252806d0a329c5c17b205b8a3c42f3567ed73519d9cf939f89c3270ffba1e651e3e313e84dbeda
7
+ data.tar.gz: 0d0c3b6b2e6501f5c2a2df70f017147622f420f0c6ea909903515aa36c2689fd2c9d17914aa482983352ef978afd1826767821f0ccc485a1e5267d02b31f4862
data/README.md CHANGED
@@ -15,6 +15,14 @@ compatible (i.e. database).
15
15
  It has (yet limited) support for MySQL / MariaDB and git. Remote databases can be accessed
16
16
  through an ssh tunnel.
17
17
 
18
+ ## Warning
19
+
20
+ Version 1.10.0 of Fulmar removes some features that we (CORE4) rarely used and which
21
+ caused the deployments to slow down the gems needed to be compiled against the
22
+ installed libraries. If you need support to query databases (more than just dumps)
23
+ or use dependencies, you will need to explicitly specify version `~> 1.9.0`.
24
+ Fulmar 2.0 will support these features via plugins.
25
+
18
26
  ## Prerequisites
19
27
 
20
28
  Fulmar currently requires the [mysql2](https://github.com/brianmario/mysql2) gem which
@@ -24,7 +32,8 @@ libmariadbclient-dev/libmysqlclient-dev or similar.
24
32
  You also need cmake and pkg-config to build the dependencies.
25
33
 
26
34
  - OSX: brew install mariadb cmake pkg-config
27
- - Ubuntu: apt-get install libmariadbclient-dev build-essential cmake
35
+ - Ubuntu: apt-get install libmariadb-client-lgpl-dev build-essential cmake
36
+ - Ubuntu (pre-xenial): apt-get install libmariadbclient-dev build-essential cmake
28
37
 
29
38
  ## Installation
30
39
 
@@ -55,7 +64,7 @@ several files.
55
64
  $ mkdir Fulmar
56
65
  $ touch Fulmar/project.config.yml
57
66
 
58
- You can now now test your configuration.
67
+ You can now test your configuration.
59
68
 
60
69
  $ fulmar test:config
61
70
 
data/fulmar.gemspec CHANGED
@@ -21,8 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler', '~> 1.7'
22
22
 
23
23
  spec.add_runtime_dependency 'rake', '~>10'
24
- spec.add_runtime_dependency 'rugged', '~> 0.23.0'
25
- spec.add_runtime_dependency 'mysql2', '~>0.3'
26
24
  spec.add_runtime_dependency 'fulmar-shell', '~>1', '>=1.7.0'
27
25
  spec.add_runtime_dependency 'ruby_wings', '~>0.1', '>=0.1.1'
28
26
  spec.add_runtime_dependency 'colorize', '~>0'
@@ -1,6 +1,7 @@
1
1
  require 'yaml'
2
2
  require 'pp'
3
3
  require 'fulmar/domain/model/project'
4
+ require 'singleton'
4
5
 
5
6
  module Fulmar
6
7
  module Domain
@@ -22,7 +23,7 @@ module Fulmar
22
23
  dependencies: { all: {} }
23
24
  }
24
25
 
25
- include Singleton
26
+ include ::Singleton
26
27
 
27
28
  attr_reader :environment, :target
28
29
  attr_accessor :load_user_config
@@ -216,7 +217,7 @@ module Fulmar
216
217
  def check_version
217
218
  return if @config[:project][:fulmar_version].nil?
218
219
  unless Gem::Dependency.new('', @config[:project][:fulmar_version]).match?('', Fulmar::VERSION)
219
- fail "Project requires a newer version of fulmar: #{@config[:project][:fulmar_version]}"
220
+ fail "Project requires another version of fulmar: #{@config[:project][:fulmar_version]}"
220
221
  end
221
222
  end
222
223
  end
@@ -10,12 +10,3 @@ if configuration.feature? :flow
10
10
  require 'fulmar/domain/service/helper/flow_helper'
11
11
  include Fulmar::Domain::Service::Helper::FlowHelper
12
12
  end
13
-
14
- if full_configuration[:dependencies].any?
15
- require 'fulmar/domain/service/helper/dependencies_helper'
16
- include Fulmar::Domain::Service::Helper::DependenciesHelper
17
- end
18
-
19
- if configuration.feature?(:vhost) && configuration.any? { |data| !data[:vhost_template].blank? }
20
- require 'fulmar/domain/task/optional/vhost'
21
- end
@@ -1,6 +1,3 @@
1
- require 'mysql2'
2
- require 'fulmar/infrastructure/service/tunnel_service'
3
-
4
1
  module Fulmar
5
2
  module Infrastructure
6
3
  module Service
@@ -25,55 +22,14 @@ module Fulmar
25
22
  def initialize(config)
26
23
  @config = config
27
24
  @config.merge DEFAULT_CONFIG
28
- @tunnel = nil
29
- @client = nil
30
25
  initialize_shell
31
26
  config_test
32
27
  end
33
28
 
34
- def connect
35
- options = compile_options
36
-
37
- unless local?
38
- tunnel.open
39
- options[:port] = tunnel.local_port
40
- end
41
-
42
- # Wait max 3 seconds for the tunnel to establish
43
- 6.times do |i|
44
- break if try_connect(options, i)
45
- end
46
-
47
- @connected = true
48
- query("USE #{@config[:maria][:database]}")
49
- end
50
-
51
- def disconnect
52
- @connected = false
53
- @client.close
54
- @tunnel.close if @tunnel # using the variable directly avoids creating a tunnel instance when closing the database connection
55
- end
56
-
57
29
  def local?
58
30
  @config[:hostname] == 'localhost'
59
31
  end
60
32
 
61
- def tunnel
62
- @tunnel ||= Fulmar::Infrastructure::Service::TunnelService.new(@config.ssh_user_and_host, @config[:maria][:port], @config[:maria][:hostname])
63
- end
64
-
65
- # shortcut for DatabaseService.client.query
66
- def query(*arguments)
67
- @client.query(*arguments)
68
- end
69
-
70
- def create(name)
71
- state_before = connected?
72
- connect unless connected?
73
- @client.query "CREATE DATABASE IF NOT EXISTS `#{name}`"
74
- disconnect unless state_before
75
- end
76
-
77
33
  def command(binary)
78
34
  command = binary
79
35
  command << " -h #{@config[:maria][:host]}" unless @config[:maria][:host].blank?
@@ -106,34 +62,8 @@ module Fulmar
106
62
  end
107
63
  end
108
64
 
109
- def clear
110
- clear_statements = <<-EOD.gsub(/^\s+\|/, '')
111
- |SET FOREIGN_KEY_CHECKS = 0;
112
- |SET GROUP_CONCAT_MAX_LEN=32768;
113
- |SET @tables = NULL;
114
- |SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
115
- |FROM information_schema.tables
116
- |WHERE table_schema = (SELECT DATABASE());
117
- |SELECT IFNULL(@tables,'dummy') INTO @tables;
118
- |
119
- |SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
120
- |PREPARE stmt FROM @tables;
121
- |EXECUTE stmt;
122
- |DEALLOCATE PREPARE stmt;
123
- |SET FOREIGN_KEY_CHECKS = 1;
124
- EOD
125
- @client.query clear_statements
126
- end
127
-
128
65
  protected
129
66
 
130
- def try_connect(options, i)
131
- @client = Mysql2::Client.new options
132
- rescue Mysql2::Error => e
133
- sleep 1 if i < 5
134
- raise e.message if i == 5
135
- end
136
-
137
67
  # Return mysql command line options to ignore specific tables
138
68
  def ignore_tables
139
69
  @config[:maria][:ignore_tables] = [*@config[:maria][:ignore_tables]]
@@ -1,4 +1,4 @@
1
1
  # Provides a global version number
2
2
  module Fulmar
3
- VERSION = '1.9.2'
3
+ VERSION = '1.10.0'
4
4
  end
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.9.2
4
+ version: 1.10.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-01 00:00:00.000000000 Z
12
+ date: 2017-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -39,34 +39,6 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '10'
42
- - !ruby/object:Gem::Dependency
43
- name: rugged
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: 0.23.0
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: 0.23.0
56
- - !ruby/object:Gem::Dependency
57
- name: mysql2
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '0.3'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '0.3'
70
42
  - !ruby/object:Gem::Dependency
71
43
  name: fulmar-shell
72
44
  requirement: !ruby/object:Gem::Requirement
@@ -146,11 +118,9 @@ files:
146
118
  - lib/fulmar/domain/service/config_rendering_service.rb
147
119
  - lib/fulmar/domain/service/config_test_service.rb
148
120
  - lib/fulmar/domain/service/configuration_service.rb
149
- - lib/fulmar/domain/service/dependency_service.rb
150
121
  - lib/fulmar/domain/service/file_sync_service.rb
151
122
  - lib/fulmar/domain/service/helper/common_helper.rb
152
123
  - lib/fulmar/domain/service/helper/database_helper.rb
153
- - lib/fulmar/domain/service/helper/dependencies_helper.rb
154
124
  - lib/fulmar/domain/service/helper/flow_helper.rb
155
125
  - lib/fulmar/domain/service/helper/vhost_helper.rb
156
126
  - lib/fulmar/domain/service/initialization_service.rb
@@ -159,7 +129,6 @@ files:
159
129
  - lib/fulmar/domain/task/database_sync.rake
160
130
  - lib/fulmar/domain/task/environment.rake
161
131
  - lib/fulmar/domain/task/initialization/base.rake
162
- - lib/fulmar/domain/task/optional/vhost.rb
163
132
  - lib/fulmar/domain/task/versions.rake
164
133
  - lib/fulmar/infrastructure/service/composer_service.rb
165
134
  - lib/fulmar/infrastructure/service/copy_service.rb
@@ -1,106 +0,0 @@
1
- require 'rugged'
2
-
3
- module Fulmar
4
- module Domain
5
- module Service
6
- # Manages dependencies to subrepositories
7
- class DependencyService
8
- def initialize(config)
9
- @config = config
10
- end
11
-
12
- def setup(env = @config.environment)
13
- shell = Fulmar::Infrastructure::Service::ShellService.new(@config[:local_path])
14
- @config.dependencies(env).each_pair do |_key, data|
15
- next unless data[:type].blank? || data[:type] == 'git'
16
- shell.quiet = true
17
-
18
- if Dir.exist? "#{data[:path]}/.git"
19
- shell.run 'git fetch -q', in: data[:path]
20
- else
21
- shell.run "git clone \"#{data[:source]}\" \"#{data[:path]}\" -q"
22
- shell.last_error.each do |line|
23
- puts line unless line.include? 'already exists and is not an empty directory'
24
- end
25
- end
26
-
27
- git = Rugged::Repository.new(data[:path])
28
- checkout(git, data)
29
- end
30
- end
31
-
32
- def update(env = @config.environment)
33
- @config.dependencies(env).each_pair do |_key, data|
34
- next unless data[:type].blank? || data[:type] == 'git'
35
- git = Rugged::Repository.new(data[:path])
36
-
37
- handle_uncommitted_changes(git, data)
38
-
39
- # Pull
40
- shell = Fulmar::Infrastructure::Service::ShellService.new data[:path]
41
- unless shell.run 'git pull --rebase -q'
42
- fail "Cannot update repository #{data[:path]}. Please update manually."
43
- end
44
- end
45
- end
46
-
47
- protected
48
-
49
- ##
50
- # Runs a defined update policy to avoid git conflicts
51
- # @param git [Rugged::Repository]
52
- # @param dependency [Hash]
53
- def handle_uncommitted_changes(git, dependency)
54
- policy = dependency[:update_policy] || ''
55
-
56
- case policy
57
- when 'reset'
58
- reset(git)
59
- when -> (p) { p.nil? || p.empty? }
60
- puts 'No update policy configured' if @config[:debug]
61
- else
62
- puts "Unexpected update policy #{policy}"
63
- end
64
- end
65
-
66
- ##
67
- # Reset changes
68
- # @param git [Rugged::Repository]
69
- def reset(git)
70
- head = git.head
71
- git.reset(head.target_id, :hard) unless head.nil?
72
- end
73
-
74
- def checkout(git, dependency)
75
- handle_uncommitted_changes(git, dependency)
76
-
77
- # Switch to the configured branch/tag/commit
78
- if git.branches.select { |b| b.name.split('/').last == dependency[:ref] }.any?
79
- checkout_branch(git, dependency[:ref])
80
- elsif git.tags.map(&:name).include?(dependency[:ref])
81
- git.checkout("refs/tags/#{dependency[:ref]}")
82
- elsif dependency[:ref].match(/^[a-zA-Z0-9]{40}$/) && git.exists?(dependency[:ref])
83
- git.checkout(dependency[:ref])
84
- else
85
- fail "Cannot find ref #{dependency[:ref]} in repo #{dependency[:path]}"
86
- end
87
- end
88
-
89
- def checkout_branch(git, branch, remote = 'origin')
90
- if git.branches.collect(&:name).include? branch
91
- git.checkout(branch)
92
- else
93
- remote_branch = git.branches.find do |b|
94
- b.name == "#{remote}/#{branch}"
95
- end
96
-
97
- new_branch = git.branches.create(branch, remote_branch.name)
98
- new_branch.upstream=(remote_branch)
99
-
100
- git.checkout(new_branch)
101
- end
102
- end
103
- end
104
- end
105
- end
106
- end
@@ -1,16 +0,0 @@
1
- require 'fulmar/domain/service/dependency_service'
2
-
3
- module Fulmar
4
- module Domain
5
- module Service
6
- module Helper
7
- # Provides access helper to the database service from within a task
8
- module DependenciesHelper
9
- def dependencies
10
- storage['dependecies'] ||= Fulmar::Domain::Service::DependencyService.new configuration
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,80 +0,0 @@
1
- require 'fulmar/domain/service/helper/vhost_helper'
2
- include Fulmar::Domain::Service::Helper::VhostHelper
3
-
4
- VHOST_DEFAULT_CONFIG = {
5
- webserver: 'nginx',
6
- sites_enabled_dir: '../sites-enabled'
7
- }
8
-
9
- vhost_count = 0
10
- configuration.each { |_env, _target, data| vhost_count += 1 unless data[:vhost_template].blank? }
11
-
12
- namespace :vhost do
13
- configuration.each do |env, target, data|
14
- next if data[:vhost_template].blank?
15
-
16
- task_environment = vhost_count > 1 ? ":#{env}" : ''
17
-
18
- desc "Create a vhost for #{env}"
19
- task "create#{task_environment}" do
20
- configuration.environment = env
21
- configuration.target = target
22
- configuration.merge(VHOST_DEFAULT_CONFIG)
23
-
24
- # Store remote_path for recovery
25
- remote_path = configuration[:remote_path]
26
-
27
- # Set some default variables:
28
- configuration[:sites_available_dir] ||= "/etc/#{configuration[:webserver]}/sites-available"
29
- configuration[:remote_path] = configuration[:sites_available_dir]
30
- configuration[:vhost_name] = vhost_name
31
-
32
- render_templates
33
- rendered_vhost_config = File.dirname(configuration[:local_path] + '/' + configuration[:vhost_template]) + \
34
- '/' + File.basename(configuration[:vhost_template], '.erb')
35
- config_file_name = "#{File.dirname(rendered_vhost_config)}/auto_vhost_#{configuration[:vhost_name]}.conf"
36
- FileUtils.mv rendered_vhost_config, config_file_name
37
- upload config_file_name
38
- config_remote_path = configuration[:sites_available_dir] + '/' + File.basename(config_file_name)
39
- remote_shell.run [
40
- "rm -f #{configuration[:sites_enabled_dir]}/#{File.basename(config_file_name)}", # remove any existing link
41
- "ln -s #{config_remote_path} #{configuration[:sites_enabled_dir]}/#{File.basename(config_file_name)}",
42
- "service #{configuration[:webserver]} reload"
43
- ]
44
-
45
- FileUtils.rm config_file_name
46
-
47
- # recover remote path
48
- configuration[:remote_path] = remote_path
49
- end
50
-
51
- desc "List existing vhosts for #{env}"
52
- task "list#{task_environment}" do
53
- configuration.environment = env
54
- configuration.target = target
55
- configuration.merge(VHOST_DEFAULT_CONFIG)
56
-
57
- remote_shell.run 'ls -1'
58
- remote_shell.last_output.each do |line|
59
- match = line.match(/auto_vhost_(.*)\.conf/)
60
- if match
61
- name = match[1]
62
- puts "- #{name}, delete via 'fulmar vhost:delete[#{name}]'"
63
- end
64
- end
65
- end
66
-
67
- desc "Delete a vhost for #{env}"
68
- task "delete#{task_environment}", [:name] do |_t, argv|
69
- configuration.environment = env
70
- configuration.target = target
71
- configuration.merge(VHOST_DEFAULT_CONFIG)
72
-
73
- remote_shell.run [
74
- "rm auto_vhost_#{argv[:name]}.conf",
75
- "rm #{configuration[:sites_enabled_dir]}/auto_vhost_#{argv[:name]}.conf",
76
- "service #{configuration[:webserver] || 'nginx'} reload"
77
- ]
78
- end
79
- end
80
- end