kibo 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kibo/commands/create.rb +37 -12
- data/lib/kibo/commands/info.rb +18 -0
- data/lib/kibo/commands/reconfigure.rb +1 -1
- data/lib/kibo/config.rb +12 -9
- data/lib/kibo/helpers.rb +5 -2
- data/lib/kibo/log.rb +2 -2
- data/lib/kibo/version.rb +1 -1
- data/man/kibo.1 +1 -1
- data/man/kibo.1.html +1 -1
- metadata +3 -3
data/lib/kibo/commands/create.rb
CHANGED
@@ -1,13 +1,43 @@
|
|
1
1
|
module Kibo::Commands
|
2
|
-
subcommand :
|
3
|
-
opt :all, "Create all missing
|
2
|
+
subcommand :remotes, "create missing remotes" do
|
3
|
+
opt :all, "Create all missing remotes.", :short => "a"
|
4
4
|
end
|
5
5
|
|
6
|
+
subcommand :create, "create missing apps"
|
7
|
+
|
8
|
+
subcommand :collaborate, "add collaborations"
|
9
|
+
|
6
10
|
def create
|
7
11
|
verify_heroku_login
|
8
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
|
9
39
|
if Kibo.command_line.all?
|
10
|
-
instances = missing_remotes
|
40
|
+
instances = h.missing_remotes
|
11
41
|
if instances.empty?
|
12
42
|
W "Nothing to do."
|
13
43
|
exit 0
|
@@ -20,7 +50,7 @@ module Kibo::Commands
|
|
20
50
|
end
|
21
51
|
|
22
52
|
# only create instances that are actually missing.
|
23
|
-
extra_instances = instances - missing_remotes
|
53
|
+
extra_instances = instances - h.missing_remotes
|
24
54
|
unless extra_instances.empty?
|
25
55
|
E <<-MSG
|
26
56
|
kibo cannot create these instances for you: #{extra_instances.map(&:inspect).join(", ")}, because I don't not know anything about these.
|
@@ -28,13 +58,8 @@ MSG
|
|
28
58
|
end
|
29
59
|
end
|
30
60
|
|
31
|
-
|
32
|
-
|
33
|
-
You are logged in at heroku as #{config.account}.
|
34
|
-
MSG
|
35
|
-
|
36
|
-
instances.each do |instance|
|
37
|
-
create_instance(instance)
|
61
|
+
h.missing_remotes.each do |remote|
|
62
|
+
git "remote", "add", remote, "git@heroku.com:#{remote}.git"
|
38
63
|
end
|
39
64
|
end
|
40
65
|
|
@@ -50,7 +75,7 @@ MSG
|
|
50
75
|
if !whoami
|
51
76
|
E "Please log in ('heroku auth:login') as #{config.account}."
|
52
77
|
elsif whoami != Kibo.config.account
|
53
|
-
E "You are currently logged in as #{whoami}; please log in ('heroku auth:login') as #{config.account}."
|
78
|
+
E "You are currently logged in as #{whoami}; please log in ('heroku auth:login') as #{Kibo.config.account}."
|
54
79
|
end
|
55
80
|
end
|
56
81
|
end
|
data/lib/kibo/commands/info.rb
CHANGED
@@ -10,10 +10,28 @@ module Kibo::Commands
|
|
10
10
|
info.line "current account", h.whoami
|
11
11
|
info.line "expected account", Kibo.config.account
|
12
12
|
|
13
|
+
info.head "processes"
|
14
|
+
Kibo.config.processes.each do |key, value|
|
15
|
+
info.line key, value
|
16
|
+
end
|
17
|
+
|
13
18
|
info.head "remotes"
|
14
19
|
info.line "remotes", h.expected_remotes
|
15
20
|
info.line "configured", h.configured_remotes
|
16
21
|
info.line "missing", h.missing_remotes
|
17
22
|
end
|
18
23
|
end
|
24
|
+
|
25
|
+
subcommand :logs, "Show log files for current instances"
|
26
|
+
def logs
|
27
|
+
h.configured_remotes.each do |remote|
|
28
|
+
fork do
|
29
|
+
cmd = "heroku logs --tail --app #{remote} | sed s/^/\\\\[#{remote}\\\\]\\ /"
|
30
|
+
W cmd
|
31
|
+
exec(cmd)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Process.waitall
|
36
|
+
end
|
19
37
|
end
|
data/lib/kibo/config.rb
CHANGED
@@ -10,6 +10,7 @@ class Kibo::Configfile < Hash
|
|
10
10
|
split("\n").
|
11
11
|
each_with_index do |line, lineno|
|
12
12
|
next if line =~ /^\s*#/
|
13
|
+
next if line =~ /^\s*$/
|
13
14
|
die(lineno, "Can't parse line: #{line.inspect}") unless line =~ /\s*([a-z]+):\s*(.*)$/
|
14
15
|
key, value = $1, $2.gsub(/\s+$/, "")
|
15
16
|
|
@@ -98,6 +99,10 @@ class Kibo::Config
|
|
98
99
|
self["deployment"] || {}
|
99
100
|
end
|
100
101
|
|
102
|
+
def collaborations
|
103
|
+
self["collaborations"] || {}
|
104
|
+
end
|
105
|
+
|
101
106
|
# returns source specific configuration
|
102
107
|
def source
|
103
108
|
self["source"] || {}
|
@@ -117,15 +122,13 @@ class Kibo::Config
|
|
117
122
|
def remotes_by_process
|
118
123
|
remotes = Kibo.git("remote", :quiet).split("\n")
|
119
124
|
|
120
|
-
@remotes_by_process ||=
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
W "#{remote.inspect}: Ignoring target..."
|
126
|
-
nil
|
127
|
-
else
|
125
|
+
@remotes_by_process ||= begin
|
126
|
+
r = processes.map do |process, count|
|
127
|
+
prefix = "#{namespace}-#{environment}-#{process}"
|
128
|
+
remotes = 1.upto(count).map { |idx| "#{prefix}#{idx}" }
|
129
|
+
[ process, remotes ]
|
128
130
|
end
|
129
|
-
|
131
|
+
Hash[r]
|
132
|
+
end
|
130
133
|
end
|
131
134
|
end
|
data/lib/kibo/helpers.rb
CHANGED
@@ -21,6 +21,8 @@ module Kibo::Helpers
|
|
21
21
|
return
|
22
22
|
end
|
23
23
|
|
24
|
+
environment = Kibo.environment
|
25
|
+
|
24
26
|
E <<-MSG
|
25
27
|
Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
|
26
28
|
|
@@ -33,7 +35,8 @@ Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
|
|
33
35
|
# -- configure remotes ----------------------------------------------
|
34
36
|
|
35
37
|
def configure_remote!(remote)
|
36
|
-
|
38
|
+
environment = Kibo.environment
|
39
|
+
sys.heroku "config:set",
|
37
40
|
"RACK_ENV=#{environment}",
|
38
41
|
"RAILS_ENV=#{environment}",
|
39
42
|
"INSTANCE=#{instance_for_remote(remote)}",
|
@@ -41,7 +44,7 @@ Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
|
|
41
44
|
end
|
42
45
|
|
43
46
|
def instance_for_remote(remote)
|
44
|
-
remote[config.namespace.length + 1 .. -1]
|
47
|
+
remote[Kibo.config.namespace.length + 1 .. -1]
|
45
48
|
end
|
46
49
|
|
47
50
|
def configure_remote(remote)
|
data/lib/kibo/log.rb
CHANGED
data/lib/kibo/version.rb
CHANGED
data/man/kibo.1
CHANGED
data/man/kibo.1.html
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kibo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: trollop
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash:
|
130
|
+
hash: 173262939670169996
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|