fulmar 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ddda32a4d9e3c7843c763f983ceb4e0aba8dcb1
4
- data.tar.gz: af45f53450e669157ba9a389c3b73d0f7df096e0
3
+ metadata.gz: 4b677f5683a979d761f27915ec1181cf120f9e57
4
+ data.tar.gz: 4af0a8618226dd09f4deda014c8fa0151e1d4841
5
5
  SHA512:
6
- metadata.gz: 7b11cf1ec6da68384117a78f4a143a2d49edfc7227a1e42f928ba4a2b3d1b9c408f714e65231b5bfba866d6de2052770d577c68341edab8e3adf899e8fbc52aa
7
- data.tar.gz: 4819b51d5fc2b07adc59729f0e34ef521251108cd1dd846fbe3257825ca85d380e5de2951b7af78d4d4950e1ad1f5f682a56464898cae690e08c001fea551a4c
6
+ metadata.gz: 2037bd7be61b50fea042250a59b639c8dc85876039dd9bb3ade4804f9d128ee7d4b5eedf774a4308184270af5972cbe053245d3c6eeeb2feb826e406478dbbde
7
+ data.tar.gz: aa06a04c726ae5f7588bc0b655639af26f78eac65afd74800167840483efd8b17d94396b114eaf66b8302cd1faea24a330dada3957e3fdc773718e7450b31a87
@@ -12,6 +12,13 @@ module Fulmar
12
12
  FULMAR_CONFIGURATION_DIR = 'Fulmar'
13
13
  DEPLOYMENT_CONFIG_FILE = 'deployment.yml'
14
14
 
15
+ BLANK_CONFIG = {
16
+ environments: {},
17
+ features: {},
18
+ hosts: {},
19
+ dependencies: { all: {} }
20
+ }
21
+
15
22
  include Singleton
16
23
 
17
24
  attr_reader :environment, :target
@@ -60,6 +67,10 @@ module Fulmar
60
67
  @target = target ? target.to_sym : nil
61
68
  end
62
69
 
70
+ def dependencies(env = nil)
71
+ env.nil? ? @config[:dependencies][:all] : @config[:dependencies][:all].deep_merge(@config[:dependencies][env])
72
+ end
73
+
63
74
  def ready?
64
75
  return false if @environment.nil? || @target.nil?
65
76
  fail 'Environment is invalid' if configuration[:environments][@environment].nil?
@@ -104,7 +115,9 @@ module Fulmar
104
115
  end
105
116
 
106
117
  def config_files
107
- Dir.glob(File.join(base_path, FULMAR_CONFIGURATION_DIR, '*.config.yml')).sort
118
+ files = Dir.glob(File.join(base_path, FULMAR_CONFIGURATION_DIR, '*.config.yml')).sort
119
+ files << "#{ENV['HOME']}/.fulmar.yml" if File.exist? "#{ENV['HOME']}/.fulmar.yml"
120
+ files
108
121
  end
109
122
 
110
123
  protected
@@ -139,7 +152,7 @@ module Fulmar
139
152
 
140
153
  # Loads the configuration from the YAML file and populates all targets
141
154
  def load_configuration
142
- @config = { environments: {}, features: {}, hosts: {} }
155
+ @config = BLANK_CONFIG
143
156
  config_files.each do |config_file|
144
157
  @config = @config.deep_merge((YAML.load_file(config_file) || {}).symbolize)
145
158
  end
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'fulmar/infrastructure/service/transfer/rsync'
3
3
  require 'fulmar/infrastructure/service/transfer/rsync_with_versions'
4
+ require 'fulmar/infrastructure/service/transfer/tar'
4
5
 
5
6
  module Fulmar
6
7
  # Creates the required transfer model from the configuration
@@ -11,6 +12,8 @@ module Fulmar
11
12
  transfer_model = Fulmar::Infrastructure::Service::Transfer::RsyncWithVersions.new(config)
12
13
  when 'rsync'
13
14
  transfer_model = Fulmar::Infrastructure::Service::Transfer::Rsync.new(config)
15
+ when 'tar'
16
+ transfer_model = Fulmar::Infrastructure::Service::Transfer::Tar.new(config)
14
17
  else
15
18
  help = config[:type] == '' ? 'Add a "type: " field to your deployment yaml file. ' : ''
16
19
  transfer_model = nil
@@ -1,5 +1,3 @@
1
- require 'pp'
2
-
3
1
  db_configs = []
4
2
  configuration.each do |env, target, data|
5
3
  db_configs << [env, target] if data[:type] == 'maria'
@@ -12,26 +12,33 @@ namespace :versions do
12
12
  end
13
13
 
14
14
  unless @versioned_servers.empty?
15
- namespace :list do
16
- @versioned_servers.each_key do |env|
17
- desc "List available versions for environment \"#{env}\""
18
- task env do
15
+
16
+ @versioned_servers.each_key do |env|
17
+ target_count = @versioned_servers.keys.reduce(0) { |sum, target| sum + 1 if target.split(':').first == env.split(':').first }
18
+ namespace :list do
19
+
20
+ # Count of there are multiple targets within the environment
21
+ # if not, we can omit the target name in the task and shorten it a bit
22
+ # This should work in most cases.
23
+
24
+ desc "List available versions for environment/target \"#{env}\""
25
+ task (target_count > 1 ? env : env.split(':').first) do
19
26
  configuration.environment = env.split(':').first
20
27
  configuration.target = env.split(':').last
21
28
  file_sync.list_releases(false).each { |item| puts item }
22
29
  end
23
30
  end
24
- end
25
31
 
26
- namespace :clean do
27
- @versioned_servers.each_key do |env|
32
+
33
+ namespace :clean do
28
34
  desc "Delete obsolete versions for target \"#{env}\""
29
- task env do
35
+ task (target_count > 1 ? env : env.split(':').first) do
30
36
  configuration.environment = env.split(':').first
31
37
  configuration.target = env.split(':').last
32
38
  file_sync.cleanup
33
39
  end
34
40
  end
35
41
  end
42
+
36
43
  end
37
44
  end
@@ -8,8 +8,8 @@ module Fulmar
8
8
  @path = custom_path
9
9
  end
10
10
 
11
- def execute(command, arguments = [])
12
- @local_shell.run "#{@path} #{command} #{arguments.join(' ')} > /dev/null"
11
+ def execute(command, arguments = %w(--no-dev -q))
12
+ @local_shell.run "#{@path} #{command} #{arguments.join(' ')}"
13
13
  end
14
14
  end
15
15
  end
@@ -0,0 +1,62 @@
1
+
2
+ require 'fulmar/infrastructure/service/transfer/base'
3
+
4
+ module Fulmar
5
+ module Infrastructure
6
+ module Service
7
+ module Transfer
8
+ # Implements the rsync transfer
9
+ class Tar < Base
10
+ DEFAULT_CONFIG = {
11
+ tar: {
12
+ format: 'gz', # 'bz2'
13
+ file_base: nil,
14
+ # exclude: "*.bak",
15
+ # filename: "site.tar.gz"
16
+ }
17
+ }
18
+
19
+ def initialize(config)
20
+ @config = DEFAULT_CONFIG.deep_merge(config)
21
+
22
+ @config[:tar][:file_base] = File.basename(@config[:local_path]) if @config[:tar][:file_base].nil?
23
+
24
+ super(@config)
25
+ end
26
+
27
+ def transfer
28
+ prepare unless @prepared
29
+ @local_shell.run tar_command
30
+ filename
31
+ end
32
+
33
+ # Build the rsync command from the given options
34
+ def tar_command
35
+ "tar #{tar_command_options} '#{filename}' '#{config[:local_path]}'"
36
+ end
37
+
38
+ protected
39
+
40
+ def filename
41
+ return @config[:tar][:filename] unless @config[:tar][:filename].blank?
42
+ @config[:tar][:file_base] + '_' + Time.now.strftime('%Y-%m-%d') + extension
43
+ end
44
+
45
+ def extension
46
+ @config[:tar][:format].blank? ? '.tar' : '.tar.' + @config[:tar][:format]
47
+ end
48
+
49
+ # Assembles all rsync command line parameters from the configuration options
50
+ def tar_command_options
51
+ options = ['-c']
52
+ options << '-j' if @config[:tar][:format] == 'bz2'
53
+ options << '-z' if @config[:tar][:format] == 'gz'
54
+ options << "--exclude #{@config[:tar][:exclude]}" if @config[:tar][:exclude]
55
+ options << '-f'
56
+ options.join(' ')
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,4 +1,4 @@
1
1
  # Provides a global version number
2
2
  module Fulmar
3
- VERSION = '1.2.1'
3
+ VERSION = '1.3.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.2.1
4
+ version: 1.3.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: 2015-04-01 00:00:00.000000000 Z
12
+ date: 2015-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -155,6 +155,7 @@ files:
155
155
  - lib/fulmar/infrastructure/service/transfer/base.rb
156
156
  - lib/fulmar/infrastructure/service/transfer/rsync.rb
157
157
  - lib/fulmar/infrastructure/service/transfer/rsync_with_versions.rb
158
+ - lib/fulmar/infrastructure/service/transfer/tar.rb
158
159
  - lib/fulmar/infrastructure/service/tunnel_service.rb
159
160
  - lib/fulmar/service/bootstrap_service.rb
160
161
  - lib/fulmar/service/helper/common_helper.rb