borg-rb 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -12
- data/bin/borg +2 -17
- data/borg.gemspec +13 -12
- data/cap/initializers/performance.rb +6 -7
- data/cap/initializers/role_reset.rb +1 -1
- data/cap/initializers/sigint.rb +2 -4
- data/lib/borg-rb.rb +2 -9
- data/lib/borg.rb +15 -0
- data/lib/borg/cli.rb +28 -0
- data/lib/borg/cli/applications.rb +4 -6
- data/lib/borg/cli/assimilator.rb +1 -3
- data/lib/borg/configuration.rb +17 -0
- data/lib/borg/configuration/applications.rb +5 -8
- data/lib/borg/configuration/assimilator.rb +6 -7
- data/lib/borg/configuration/stages.rb +1 -3
- data/lib/borg/version.rb +1 -1
- data/spec/acceptance/borgify_plugin_spec.rb +4 -4
- data/spec/acceptance/borgify_spec.rb +11 -11
- data/spec/lib/borg/cli/applications_spec.rb +83 -50
- data/spec/lib/borg/cli_spec.rb +187 -0
- data/spec/lib/borg/configuration/applications_spec.rb +31 -34
- data/spec/lib/borg/configuration/assimilator_spec.rb +34 -20
- data/spec/lib/borg/configuration/stages_spec.rb +33 -36
- data/spec/lib/borg/configuration_spec.rb +19 -0
- data/spec/support/shared_examples/application_configuration.rb +14 -0
- metadata +12 -5
- data/cap/applications/app1.rb +0 -15
- data/cap/initializers/output.rb +0 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjQ4NTU4YjI0N2JiZDRlZjdlYTAwOTY5NDU3MGQxOGM3YjE2OGNjNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmYzNTQ1N2FkYjViYzNlZjAyM2Q2ODY5MzYyNzI0OTk5NWFjMWI5Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGJjOWIwNWE3ZGJlM2NiMTM5MTE2N2QxYzgyNTAxZTQ5MGRmZTc5ZjVkMWYz
|
10
|
+
MGY0NjE4NmE0MTM2MDAyZTYyN2Y2MjZkYjEwZWVkODE2N2M4Yjk2YzA5NTli
|
11
|
+
NzAxNjJkMGQzY2RkOWYxYmIwODc4YTQwNmJjNmRiMzU4NGUwMjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDcxNmIxMTE4ODBiNDYyYzQ2YTQ3YTI4MmJmMzY1YjJkZDE5MzZmZmFiNDg2
|
14
|
+
ZDU3YTkzN2FmNzZkODY2YjQxZmY4OTJhOWU5ODIwYjM0NTcyMTI2YTQyMDYw
|
15
|
+
ZTQwOGU5MGIxNjc3YTE4ZDdiYTZmNTczMzNjNjYxMjEwMDM1MmQ=
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
-
## 0.0
|
4
|
-
|
5
|
-
* Allow access to `application` and `stage` in an application configuration by creating a capistrano variable for them (0.0.4)
|
6
|
-
* Change load borg-rb to a require (0.0.3)
|
7
|
-
* Fix load problem in Capfile in generated skeleton (0.0.2)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
## 0.0.1 / 3-21-2013
|
12
|
-
|
13
|
-
* Created initial project skeleton: application config, multi-stage app config
|
14
|
-
* Created initial plugin skeleton for adding recipes
|
3
|
+
## 0.1.0 / 4-1-2013
|
4
|
+
Initial Release
|
data/bin/borg
CHANGED
@@ -1,18 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
require 'borg/cli/applications'
|
5
|
-
require 'borg/cli/assimilator'
|
6
|
-
require 'borg/configuration/applications'
|
7
|
-
require 'borg/configuration/stages'
|
8
|
-
require 'borg/configuration/assimilator'
|
9
|
-
require 'erb'
|
10
|
-
|
11
|
-
require 'borg/errors'
|
12
|
-
require 'borg/server/base'
|
13
|
-
require 'borg/servers/base'
|
14
|
-
|
15
|
-
# Ensure ruby 1.9.X
|
16
|
-
raise "Ruby 1.9.X required" unless RUBY_VERSION =~ /^1\.9\.\d$/ || RUBY_VERSION =~ /^2\.0\.\d$/
|
17
|
-
|
18
|
-
Capistrano::CLI.execute
|
2
|
+
require 'borg'
|
3
|
+
Borg::CLI.execute
|
data/borg.gemspec
CHANGED
@@ -4,26 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'borg/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
7
|
+
s.name = 'borg-rb'
|
8
8
|
s.version = Borg::VERSION
|
9
|
-
s.authors =
|
10
|
-
s.email =
|
9
|
+
s.authors = %w(Identified)
|
10
|
+
s.email = %w(phil@identified.com tejas@identified.com)
|
11
11
|
s.description = %q{Ruby-based software provisioning and deployment framework}
|
12
12
|
s.summary = %q{Ruby-based software provisioning and deployment framework}
|
13
|
-
s.homepage =
|
14
|
-
s.license =
|
13
|
+
s.homepage = 'https://github.com/B0RG/borg'
|
14
|
+
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split($/)
|
17
17
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
-
s.require_paths =
|
19
|
+
s.require_paths = %w(lib)
|
20
20
|
|
21
|
-
s.
|
22
|
-
s.add_dependency "capistrano_colors"
|
23
|
-
s.add_dependency "colored"
|
24
|
-
s.add_dependency "term-ansicolor"
|
21
|
+
s.required_ruby_version = '>= 1.9.2'
|
25
22
|
|
26
|
-
s.
|
27
|
-
s.
|
23
|
+
s.add_dependency 'capistrano', '~> 2.14.2'
|
24
|
+
s.add_dependency 'capistrano_colors'
|
25
|
+
s.add_dependency 'colored'
|
26
|
+
s.add_dependency 'term-ansicolor'
|
28
27
|
|
28
|
+
s.add_development_dependency 'rspec'
|
29
|
+
s.add_development_dependency 'childprocess'
|
29
30
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
if borg_performance_reports
|
1
|
+
if fetch(:borg_performance_reports, true)
|
3
2
|
# source: https://github.com/PagerDuty/pd-cap-recipes/blob/master/lib/pd-cap-recipes/tasks/performance.rb
|
4
3
|
start_times = {}
|
5
4
|
end_times = {}
|
@@ -24,19 +23,19 @@ if borg_performance_reports
|
|
24
23
|
logger.info s
|
25
24
|
end
|
26
25
|
|
27
|
-
l
|
28
|
-
l
|
26
|
+
l ' Performance Report'
|
27
|
+
l '=========================================================='
|
29
28
|
indent = 0
|
30
29
|
(order + [nil]).each_cons(2) do |payload1, payload2|
|
31
30
|
action, task = payload1
|
32
31
|
if action == :start
|
33
|
-
l "#{
|
32
|
+
l "#{'..' * indent}#{task.fully_qualified_name}" unless task == payload2.last
|
34
33
|
indent += 1
|
35
34
|
else
|
36
35
|
indent -= 1
|
37
|
-
l "#{
|
36
|
+
l "#{'..' * indent}#{task.fully_qualified_name} #{(end_times[task] - start_times[task]).to_i}s"
|
38
37
|
end
|
39
38
|
end
|
40
|
-
l
|
39
|
+
l '=========================================================='
|
41
40
|
end
|
42
41
|
end
|
data/cap/initializers/sigint.rb
CHANGED
data/lib/borg-rb.rb
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def _cset(name, *args, &block)
|
4
|
-
unless exists?(name)
|
5
|
-
set(name, *args, &block)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
assimilate "borg-rb"
|
1
|
+
Borg::Configuration.instance(:must_exist).load do
|
2
|
+
assimilate 'borg-rb'
|
10
3
|
end
|
data/lib/borg.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Ensure ruby 1.9.X
|
2
|
+
raise 'Ruby 1.9.x or 2.0.x required' unless RUBY_VERSION =~ /^1\.9\.\d$/ || RUBY_VERSION =~ /^2\.0\.\d$/
|
3
|
+
|
4
|
+
# Colors
|
5
|
+
require 'capistrano_colors'
|
6
|
+
require 'colored'
|
7
|
+
require 'term/ansicolor'
|
8
|
+
|
9
|
+
require 'borg/cli'
|
10
|
+
require 'borg/configuration'
|
11
|
+
require 'borg/errors'
|
12
|
+
require 'borg/server/base'
|
13
|
+
require 'borg/servers/base'
|
14
|
+
|
15
|
+
require 'erb'
|
data/lib/borg/cli.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'capistrano/cli'
|
2
|
+
require 'borg/cli/applications'
|
3
|
+
require 'borg/cli/assimilator'
|
4
|
+
require 'borg/configuration'
|
5
|
+
require 'borg/errors'
|
6
|
+
|
7
|
+
module Borg
|
8
|
+
class CLI < Capistrano::CLI
|
9
|
+
# override method in Capistrano::CLI::Execute
|
10
|
+
def instantiate_configuration(options = {}) #:nodoc:
|
11
|
+
Borg::Configuration.new(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# override method in Capistrano::CLI::Execute
|
15
|
+
def handle_error(error) #:nodoc:
|
16
|
+
case error
|
17
|
+
when Net::SSH::AuthenticationFailed
|
18
|
+
abort "authentication failed for `#{error.message}'"
|
19
|
+
when Borg::BaseError
|
20
|
+
abort(error.message)
|
21
|
+
else raise error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Mix-in our own behavior
|
26
|
+
include Applications, Assimilator
|
27
|
+
end
|
28
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Borg
|
2
|
-
|
2
|
+
class CLI < Capistrano::CLI
|
3
3
|
module Applications
|
4
4
|
def self.included(base) #:nodoc:
|
5
5
|
base.send :alias_method, :execute_requested_actions_without_applications, :execute_requested_actions
|
@@ -26,7 +26,7 @@ module Borg
|
|
26
26
|
|
27
27
|
def load_applications(config)
|
28
28
|
unless @apps_loaded
|
29
|
-
Dir[
|
29
|
+
Dir['./cap/applications/**/*.rb'].each { |file| config.load(file) }
|
30
30
|
@apps_loaded = true
|
31
31
|
end
|
32
32
|
end
|
@@ -35,7 +35,7 @@ module Borg
|
|
35
35
|
options[:applications] = []
|
36
36
|
found_non_application = false
|
37
37
|
options[:actions] = Array(options[:actions]).keep_if do |action|
|
38
|
-
app, stg = action.split(
|
38
|
+
app, stg = action.split(':').map(&:to_sym)
|
39
39
|
ret = if config.applications[app] and config.applications[app].stages[stg]
|
40
40
|
options[:applications] << config.applications[app].stages[stg]
|
41
41
|
false
|
@@ -50,12 +50,10 @@ module Borg
|
|
50
50
|
found_non_application = true
|
51
51
|
true
|
52
52
|
end
|
53
|
-
raise ArgumentError,
|
53
|
+
raise ArgumentError, 'Can not have non application configs between application configs' if !ret and found_non_application
|
54
54
|
ret
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
|
-
Capistrano::CLI.send(:include, Borg::CLI::Applications)
|
data/lib/borg/cli/assimilator.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Borg
|
2
|
-
|
2
|
+
class CLI < Capistrano::CLI
|
3
3
|
module Assimilator
|
4
4
|
def self.included(base) #:nodoc:
|
5
5
|
base.send :alias_method, :execute_requested_actions_without_assimilator, :execute_requested_actions
|
@@ -13,5 +13,3 @@ module Borg
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
|
-
Capistrano::CLI.send :include, Borg::CLI::Assimilator
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'capistrano/configuration'
|
2
|
+
require 'borg/configuration/applications'
|
3
|
+
require 'borg/configuration/assimilator'
|
4
|
+
require 'borg/configuration/stages'
|
5
|
+
|
6
|
+
module Borg
|
7
|
+
class Configuration < Capistrano::Configuration
|
8
|
+
# Mix-in our own behavior
|
9
|
+
include Applications, Assimilator, Stages
|
10
|
+
|
11
|
+
# source: capistrano/recipes/deploy.rb
|
12
|
+
def _cset(name, *args, &block)
|
13
|
+
set(name, *args, &block) unless exists?(name)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Borg
|
2
|
-
|
2
|
+
class Configuration < Capistrano::Configuration
|
3
3
|
module Applications
|
4
|
-
|
5
4
|
def self.included(base) #:nodoc:
|
6
5
|
base.send :alias_method, :initialize_without_applications, :initialize
|
7
6
|
base.send :alias_method, :initialize, :initialize_with_applications
|
@@ -14,7 +13,7 @@ module Borg
|
|
14
13
|
end
|
15
14
|
private :initialize_with_applications
|
16
15
|
|
17
|
-
def application
|
16
|
+
def application(name, &block)
|
18
17
|
name = name.to_sym
|
19
18
|
namespace name do
|
20
19
|
desc "Load Application #{name} (All Stages if any)"
|
@@ -31,14 +30,14 @@ module Borg
|
|
31
30
|
attr_accessor :stages
|
32
31
|
attr_reader :name
|
33
32
|
|
34
|
-
def initialize
|
33
|
+
def initialize(name, namespace)
|
35
34
|
@execution_blocks = []
|
36
35
|
@name = name
|
37
36
|
@namespace = namespace
|
38
37
|
@stages = {}
|
39
38
|
end
|
40
39
|
|
41
|
-
def load_into
|
40
|
+
def load_into(config)
|
42
41
|
if config.respond_to?(:application)
|
43
42
|
# Undefine the stage method now that the app:stage config is created
|
44
43
|
config_metaclass = class << config; self; end
|
@@ -47,11 +46,9 @@ module Borg
|
|
47
46
|
# Create a capistrano variable for stage
|
48
47
|
config.instance_exec(@name, &(lambda { |name| set :application, name }))
|
49
48
|
end
|
50
|
-
@execution_blocks.each {|blk| config.load &blk}
|
49
|
+
@execution_blocks.each { |blk| config.load &blk }
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
55
54
|
end
|
56
|
-
|
57
|
-
Capistrano::Configuration.send :include, Borg::Configuration::Applications
|
@@ -1,21 +1,20 @@
|
|
1
1
|
module Borg
|
2
|
-
|
2
|
+
class Configuration < Capistrano::Configuration
|
3
3
|
module Assimilator
|
4
|
-
def assimilate
|
4
|
+
def assimilate(borg_plugin, plugin_path = nil)
|
5
5
|
@to_assimilate ||= {}
|
6
|
-
@to_assimilate[
|
6
|
+
@to_assimilate[borg_plugin] = plugin_path || Gem::Specification.find_by_name(borg_plugin).gem_dir
|
7
7
|
end
|
8
8
|
|
9
9
|
def assimilate!
|
10
10
|
@to_assimilate ||= {}
|
11
|
-
@to_assimilate.each do |
|
12
|
-
Dir["#{
|
11
|
+
@to_assimilate.each do |borg_plugin, plugin_path|
|
12
|
+
Dir["#{plugin_path}/cap/initializers/**/*.rb"].each do |file|
|
13
13
|
load file
|
14
14
|
end
|
15
|
-
@load_paths << "#{
|
15
|
+
@load_paths << "#{plugin_path}/cap"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
-
Capistrano::Configuration.send :include, Borg::Configuration::Assimilator
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Borg
|
2
|
-
|
2
|
+
class Configuration < Capistrano::Configuration
|
3
3
|
module Stages
|
4
4
|
def stage(app, name, &block)
|
5
5
|
app = app.to_sym
|
@@ -48,5 +48,3 @@ module Borg
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
52
|
-
Capistrano::Configuration.send(:include, Borg::Configuration::Stages)
|
data/lib/borg/version.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
include_context
|
3
|
+
describe 'borgify plugin' do
|
4
|
+
include_context 'acceptance'
|
5
5
|
|
6
6
|
before do
|
7
|
-
assert_execute(
|
7
|
+
assert_execute('borgify', 'plugin')
|
8
8
|
@workdir = environment.workdir_path
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'creates the right files and directories' do
|
12
12
|
# the gemspec
|
13
13
|
directory_name = File.basename(@workdir = environment.workdir_path)
|
14
14
|
gemspec = @workdir = environment.workdir_path.join("#{directory_name}.gemspec")
|
@@ -1,34 +1,34 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
include_context
|
3
|
+
describe 'borgify' do
|
4
|
+
include_context 'acceptance'
|
5
5
|
|
6
6
|
before do
|
7
|
-
assert_execute(
|
7
|
+
assert_execute('borgify')
|
8
8
|
@workdir = environment.workdir_path
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'creates the right files and directories' do
|
12
12
|
# Gemfile
|
13
|
-
gemfile = @workdir.join(
|
13
|
+
gemfile = @workdir.join('Gemfile')
|
14
14
|
expect(gemfile.file?).to be_true
|
15
15
|
gemfile_contents = gemfile.read
|
16
16
|
expect(gemfile_contents).to match(/^source "https:\/\/rubygems.org"$/)
|
17
17
|
expect(gemfile_contents).to match(/borg-rb/)
|
18
18
|
|
19
19
|
# Capfile
|
20
|
-
capfile = @workdir.join(
|
20
|
+
capfile = @workdir.join('Capfile')
|
21
21
|
expect(capfile.file?).to be_true
|
22
22
|
|
23
23
|
# lib directory
|
24
|
-
capfile = @workdir.join(
|
24
|
+
capfile = @workdir.join('lib')
|
25
25
|
expect(capfile.directory?).to be_true
|
26
26
|
|
27
27
|
# cap directory with the subdirectories: applications, initializers, recipes
|
28
|
-
cap_dir = @workdir.join(
|
28
|
+
cap_dir = @workdir.join('cap')
|
29
29
|
expect(cap_dir.directory?).to be_true
|
30
|
-
expect(cap_dir.join(
|
31
|
-
expect(cap_dir.join(
|
32
|
-
expect(cap_dir.join(
|
30
|
+
expect(cap_dir.join('applications').directory?).to be_true
|
31
|
+
expect(cap_dir.join('initializers').directory?).to be_true
|
32
|
+
expect(cap_dir.join('recipes').directory?).to be_true
|
33
33
|
end
|
34
34
|
end
|