kibo 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +45 -0
- data/YUILICENSE.md +29 -0
- data/lib/kibo/commandline.rb +1 -2
- data/lib/kibo/commands/compress.rb +17 -12
- data/lib/kibo/commands/deploy.rb +14 -18
- data/lib/kibo/commands/helpers.rb +15 -0
- data/lib/kibo/commands/info.rb +21 -18
- data/lib/kibo/commands/logs.rb +30 -0
- data/lib/kibo/commands/setup.rb +67 -0
- data/lib/kibo/commands/spin.rb +7 -24
- data/lib/kibo/commands.rb +0 -21
- data/lib/kibo/config.rb +84 -99
- data/lib/kibo/ext/ruby_ext.rb +30 -0
- data/lib/kibo/helpers/info.rb +2 -0
- data/lib/kibo/{helpers/heroku.rb → heroku.rb} +16 -2
- data/lib/kibo/log.rb +5 -3
- data/lib/kibo/system.rb +8 -17
- data/lib/kibo/version.rb +1 -1
- data/lib/kibo.rb +13 -9
- data/man/kibo.1 +1 -1
- data/man/kibo.1.html +2 -2
- data/test/Kibofile +33 -0
- data/test/kibo_test.rb +59 -0
- data/test/test_helper.rb +25 -0
- metadata +64 -8
- data/lib/kibo/commands/create.rb +0 -81
- data/lib/kibo/commands/reconfigure.rb +0 -12
- data/lib/kibo/helpers.rb +0 -77
data/lib/kibo/commands/create.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
module Kibo::Commands
|
2
|
-
subcommand :remotes, "create missing remotes" do
|
3
|
-
opt :all, "Create all missing remotes.", :short => "a"
|
4
|
-
end
|
5
|
-
|
6
|
-
subcommand :create, "create missing apps"
|
7
|
-
|
8
|
-
subcommand :collaborate, "add collaborations"
|
9
|
-
|
10
|
-
def create
|
11
|
-
verify_heroku_login
|
12
|
-
|
13
|
-
apps = heroku("apps").split("\n").reject { |line| line =~ /===/ }
|
14
|
-
missing_apps = h.expected_remotes - apps
|
15
|
-
|
16
|
-
confirm! <<-MSG
|
17
|
-
I am going to create these instances: #{missing_apps.map(&:inspect).join(", ")} for you [#{Kibo.config.account}].
|
18
|
-
MSG
|
19
|
-
|
20
|
-
missing_apps.each do |instance|
|
21
|
-
create_instance(instance)
|
22
|
-
Kibo.config.collaborations.each do |email|
|
23
|
-
heroku "sharing:add", email
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def collaborate
|
29
|
-
verify_heroku_login
|
30
|
-
|
31
|
-
h.expected_remotes.each do |instance|
|
32
|
-
Kibo.config.collaborations.each do |email|
|
33
|
-
heroku "sharing:add", email, "--app", instance
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def remotes
|
39
|
-
if Kibo.command_line.all?
|
40
|
-
instances = h.missing_remotes
|
41
|
-
if instances.empty?
|
42
|
-
W "Nothing to do."
|
43
|
-
exit 0
|
44
|
-
end
|
45
|
-
else
|
46
|
-
instances = Kibo.command_line.args
|
47
|
-
if instances.empty?
|
48
|
-
W "Add the names of the remotes to create on the command line or use the --all parameter."
|
49
|
-
exit 0
|
50
|
-
end
|
51
|
-
|
52
|
-
# only create instances that are actually missing.
|
53
|
-
extra_instances = instances - h.missing_remotes
|
54
|
-
unless extra_instances.empty?
|
55
|
-
E <<-MSG
|
56
|
-
kibo cannot create these instances for you: #{extra_instances.map(&:inspect).join(", ")}, because I don't not know anything about these.
|
57
|
-
MSG
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
h.missing_remotes.each do |remote|
|
62
|
-
git "remote", "add", remote, "git@heroku.com:#{remote}.git"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def create_instance(remote)
|
69
|
-
# TODO: Test whether these instances already exist, using `heroku apps`
|
70
|
-
heroku "apps:create", remote, "--remote", remote
|
71
|
-
end
|
72
|
-
|
73
|
-
def verify_heroku_login
|
74
|
-
whoami = h.whoami
|
75
|
-
if !whoami
|
76
|
-
E "Please log in ('heroku auth:login') as #{config.account}."
|
77
|
-
elsif whoami != Kibo.config.account
|
78
|
-
E "You are currently logged in as #{whoami}; please log in ('heroku auth:login') as #{Kibo.config.account}."
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Kibo::Commands
|
2
|
-
subcommand :reconfigure, "reconfigure all existing targets"
|
3
|
-
|
4
|
-
# kibo [options] reconfigure ... reconfigure all existing remotes
|
5
|
-
def reconfigure
|
6
|
-
h.check_missing_remotes :warn
|
7
|
-
|
8
|
-
h.configured_remotes.each do |remote|
|
9
|
-
h.configure_remote! remote
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/lib/kibo/helpers.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module Kibo::Helpers
|
2
|
-
end
|
3
|
-
|
4
|
-
require_relative "./helpers/heroku"
|
5
|
-
require_relative "./helpers/info"
|
6
|
-
|
7
|
-
module Kibo::Helpers
|
8
|
-
extend self
|
9
|
-
|
10
|
-
extend Heroku
|
11
|
-
|
12
|
-
def sys
|
13
|
-
Kibo::System
|
14
|
-
end
|
15
|
-
|
16
|
-
def check_missing_remotes(mode = :warn)
|
17
|
-
return if missing_remotes.empty?
|
18
|
-
|
19
|
-
if mode == :warn
|
20
|
-
W "Ignoring missing remote(s)", *missing_remotes
|
21
|
-
return
|
22
|
-
end
|
23
|
-
|
24
|
-
environment = Kibo.environment
|
25
|
-
|
26
|
-
E <<-MSG
|
27
|
-
Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
|
28
|
-
|
29
|
-
kibo --environment #{environment} create --all # ... to create all missing remotes.
|
30
|
-
kibo --environment #{environment} spinup --force # ... to ignore missing remotes.
|
31
|
-
|
32
|
-
MSG
|
33
|
-
end
|
34
|
-
|
35
|
-
# -- configure remotes ----------------------------------------------
|
36
|
-
|
37
|
-
def configure_remote!(remote)
|
38
|
-
environment = Kibo.environment
|
39
|
-
sys.heroku "config:set",
|
40
|
-
"RACK_ENV=#{environment}",
|
41
|
-
"RAILS_ENV=#{environment}",
|
42
|
-
"INSTANCE=#{instance_for_remote(remote)}",
|
43
|
-
"--app", remote
|
44
|
-
end
|
45
|
-
|
46
|
-
def instance_for_remote(remote)
|
47
|
-
remote[Kibo.config.namespace.length + 1 .. -1]
|
48
|
-
end
|
49
|
-
|
50
|
-
def configure_remote(remote)
|
51
|
-
# the correct value for the INSTANCE configuration setting is the
|
52
|
-
# name of the of the remote without the namespace part; e.g. the
|
53
|
-
# INSTANCE for the remote named "bountyhill-staging-twirl2" is
|
54
|
-
# "staging-twirl2".
|
55
|
-
instance = remote[Kibo.config.namespace.length + 1 .. -1]
|
56
|
-
current_instance = sys.heroku "config:get", "INSTANCE", "--app", remote
|
57
|
-
return if instance == current_instance
|
58
|
-
end
|
59
|
-
|
60
|
-
# -- which remotes are defined, present and configured --------------
|
61
|
-
|
62
|
-
def expected_remotes
|
63
|
-
namespace, environment = Kibo.config.namespace, Kibo.environment
|
64
|
-
|
65
|
-
Kibo.config.processes.map do |name, count|
|
66
|
-
1.upto(count).map { |idx| "#{namespace}-#{environment}-#{name}#{idx}" }
|
67
|
-
end.flatten.sort
|
68
|
-
end
|
69
|
-
|
70
|
-
def configured_remotes
|
71
|
-
Kibo.config.remotes_by_process.values.flatten
|
72
|
-
end
|
73
|
-
|
74
|
-
def missing_remotes
|
75
|
-
expected_remotes - configured_remotes
|
76
|
-
end
|
77
|
-
end
|