itamae 1.0.0.beta21 → 1.0.0.beta22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 696b6b9d0d4dde941a436b0cab7a717ad510740a
4
- data.tar.gz: d06f0329589a1cb8bf19c5f99e68e4ab7edb91ed
3
+ metadata.gz: 28493e2eaf44936882d8448d4d3c1af21194061a
4
+ data.tar.gz: b0dcb302ff3f116bfbe2ba72d8d2c680a9c84820
5
5
  SHA512:
6
- metadata.gz: 7222275191cb7581380abe17733226854fc37024bbc0d3f6c7e1654240ffccc6def6adddaaab8408a2abe6b595485e64aa46e9f18ec1878b008d0945f238737c
7
- data.tar.gz: 3c65feb51906ffe4cc552b4f940ffcfdf359a805a948a70fda21ad012d8c757fea61961a2bb434a3be216b4d05f27f6e433ccb88c5b11c98d8ae79b117b34244
6
+ metadata.gz: 0eefb41ff82485abaf708b8f51febd907d106c9adf58bcf8318284525e544d91a7c5032cd8aacfdc790b3663a6dd5ffb23a19c8364689b15d3e220d1479ca03d
7
+ data.tar.gz: e724ae0b62d69039583f6a1e455814a9b9faf6d892814e40dde21cad32488babe60188a12e2518b7efef7595a38e7cb148740b760326a4164d881429ef99b60d
@@ -0,0 +1,22 @@
1
+ require 'net/https'
2
+ require 'json'
3
+ require 'time'
4
+
5
+ http = Net::HTTP.new("api.digitalocean.com", 443)
6
+ http.use_ssl = true
7
+
8
+ res = http.start do
9
+ http.get("/v2/droplets", "Authorization" => "Bearer #{ENV['DIGITALOCEAN_TOKEN']}")
10
+ end
11
+
12
+ droplets = JSON.parse(res.body)['droplets']
13
+ droplets.each do |droplet|
14
+ next unless /^itamae-/ =~ droplet['name']
15
+ if Time.now - Time.parse(droplet['created_at']) >= 60 * 60
16
+ puts "destroying #{droplet}..."
17
+ res = http.start do
18
+ http.delete("/v2/droplets/#{droplet['id']}", "Authorization" => "Bearer #{ENV['DIGITALOCEAN_TOKEN']}")
19
+ end
20
+ end
21
+ end
22
+
@@ -5,8 +5,12 @@ require 'io/console'
5
5
  module Specinfra
6
6
  module Configuration
7
7
  def self.sudo_password
8
+ return ENV['SUDO_PASSWORD'] if ENV['SUDO_PASSWORD']
8
9
  return @sudo_password if @sudo_password
9
10
 
11
+ # TODO: Fix this dirty hack
12
+ return nil unless caller.any? {|call| call.include?('channel_data') }
13
+
10
14
  print "sudo password: "
11
15
  @sudo_password = STDIN.noecho(&:gets).strip
12
16
  end
@@ -1 +1 @@
1
- 1.0.0.beta21
1
+ 1.0.0.beta22
data/wercker.yml CHANGED
@@ -74,3 +74,8 @@ build:
74
74
  name: shutdown vm
75
75
  code: vagrant destroy -f
76
76
  cwd: spec/integration
77
+
78
+ - script:
79
+ name: shutdown old vms
80
+ code: ruby ci/destroy_old_droplets.rb
81
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta21
4
+ version: 1.0.0.beta22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
@@ -151,6 +151,7 @@ files:
151
151
  - README.md
152
152
  - Rakefile
153
153
  - bin/itamae
154
+ - ci/destroy_old_droplets.rb
154
155
  - itamae.gemspec
155
156
  - lib/itamae.rb
156
157
  - lib/itamae/backend.rb