heroku_hatchet 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/hatchet +27 -0
- data/lib/hatchet/reaper.rb +13 -3
- data/lib/hatchet/version.rb +1 -1
- data/test/hatchet/reaper_test.rb +31 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c988335800a9dca89f7a076e3ce6cfdac19d83
|
4
|
+
data.tar.gz: d60e3963f8d0fdb5e9093de065fb0febb76e18c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 329323e1be9617e21c2a23ca6ac0755a7bbf31645bfe0081a8d27ba9936eb328f3a2444b6a650efcd39e0924cfbf7fd5de62fe82eb213764582edf2cb33ab084
|
7
|
+
data.tar.gz: 8bef99fdd2e069e5d81f401a0dc20b790da68fff8ee269568ec1dc05e4e25bfc5d6165fe8114bf4821bc45b48fcd123f680d45c7010e49ca31e1c4d0060cca9b
|
data/CHANGELOG.md
CHANGED
data/bin/hatchet
CHANGED
@@ -13,6 +13,7 @@ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
|
13
13
|
require 'hatchet'
|
14
14
|
require 'thor'
|
15
15
|
require 'threaded'
|
16
|
+
require 'date'
|
16
17
|
|
17
18
|
class HatchetCLI < Thor
|
18
19
|
desc "install", "installs repos defined in 'hatchet.json'"
|
@@ -40,6 +41,22 @@ class HatchetCLI < Thor
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
desc "destroy [NAME]", "Deletes applications"
|
45
|
+
option :all, :type => :boolean
|
46
|
+
def destroy(name=nil)
|
47
|
+
api_key = ENV['HEROKU_API_KEY'] || bundle_exec {`heroku auth:token`.chomp }
|
48
|
+
heroku = Heroku::API.new(api_key: api_key)
|
49
|
+
reaper = Hatchet::Reaper.new(heroku)
|
50
|
+
|
51
|
+
if options[:all]
|
52
|
+
reaper.destroy_all
|
53
|
+
elsif !name.nil?
|
54
|
+
reaper.destroy_by_name(name)
|
55
|
+
else
|
56
|
+
raise "Must provide an app name or --all"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
43
60
|
private
|
44
61
|
|
45
62
|
def warn_dot_ignore!
|
@@ -72,6 +89,16 @@ class HatchetCLI < Thor
|
|
72
89
|
FileUtils.mkdir_p(path)
|
73
90
|
puts `cd #{path} && git clone #{git_repo} --quiet`
|
74
91
|
end
|
92
|
+
|
93
|
+
def bundle_exec
|
94
|
+
if defined?(Bundler)
|
95
|
+
Bundler.with_clean_env do
|
96
|
+
yield
|
97
|
+
end
|
98
|
+
else
|
99
|
+
yield
|
100
|
+
end
|
101
|
+
end
|
75
102
|
end
|
76
103
|
|
77
104
|
HatchetCLI.start(ARGV)
|
data/lib/hatchet/reaper.rb
CHANGED
@@ -34,12 +34,23 @@ module Hatchet
|
|
34
34
|
|
35
35
|
def destroy_oldest
|
36
36
|
oldest_name = @hatchet_apps.pop["name"]
|
37
|
-
|
38
|
-
@heroku.delete_app(oldest_name)
|
37
|
+
destroy_by_name(oldest_name, "Hatchet app limit: #{HATCHET_APP_LIMT}")
|
39
38
|
rescue Heroku::API::Errors::NotFound
|
40
39
|
# app already deleted, cycle will catch if there's still too many
|
41
40
|
end
|
42
41
|
|
42
|
+
def destroy_all
|
43
|
+
get_apps
|
44
|
+
@hatchet_apps.each do |app|
|
45
|
+
destroy_by_name(app["name"])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy_by_name(name, details="")
|
50
|
+
puts "Destroying #{name.inspect}. #{details}"
|
51
|
+
@heroku.delete_app(name)
|
52
|
+
end
|
53
|
+
|
43
54
|
private
|
44
55
|
|
45
56
|
def over_limit?
|
@@ -47,4 +58,3 @@ module Hatchet
|
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
50
|
-
|
data/lib/hatchet/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ReaperTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_destroy_by_name
|
6
|
+
heroku = mock('heroku')
|
7
|
+
reaper = Hatchet::Reaper.new(heroku)
|
8
|
+
heroku.expects(:delete_app).with("my-app-name")
|
9
|
+
reaper.destroy_by_name("my-app-name")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_destroy_all
|
13
|
+
heroku = stub(:get_apps =>
|
14
|
+
stub(:body => [{
|
15
|
+
'name' => 'hatchet-t-123',
|
16
|
+
'created_at' => DateTime.new.to_s
|
17
|
+
},{
|
18
|
+
'name' => 'hatchet-t-abc',
|
19
|
+
'created_at' => DateTime.new.to_s
|
20
|
+
},{
|
21
|
+
'name' => 'my-app-name',
|
22
|
+
'created_at' => DateTime.new.to_s
|
23
|
+
}
|
24
|
+
])
|
25
|
+
)
|
26
|
+
reaper = Hatchet::Reaper.new(heroku)
|
27
|
+
heroku.expects(:delete_app).with('hatchet-t-123')
|
28
|
+
heroku.expects(:delete_app).with('hatchet-t-abc')
|
29
|
+
reaper.destroy_all
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_hatchet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heroku-api
|
@@ -249,6 +249,7 @@ files:
|
|
249
249
|
- test/hatchet/heroku_api_test.rb
|
250
250
|
- test/hatchet/labs_test.rb
|
251
251
|
- test/hatchet/multi_cmd_runner_test.rb
|
252
|
+
- test/hatchet/reaper_test.rb
|
252
253
|
- test/hatchet/runner_test.rb
|
253
254
|
- test/test_helper.rb
|
254
255
|
homepage: https://github.com/heroku/hatchet
|
@@ -321,5 +322,7 @@ test_files:
|
|
321
322
|
- test/hatchet/heroku_api_test.rb
|
322
323
|
- test/hatchet/labs_test.rb
|
323
324
|
- test/hatchet/multi_cmd_runner_test.rb
|
325
|
+
- test/hatchet/reaper_test.rb
|
324
326
|
- test/hatchet/runner_test.rb
|
325
327
|
- test/test_helper.rb
|
328
|
+
has_rdoc:
|