dokkaacfg 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27f436055c2acbf271304227311f1dd0ab97c653
4
- data.tar.gz: 824e196bf28aed483de2daec3b0832a20ff3945d
3
+ metadata.gz: 05563bd67c50b029acc101973766c2f0190f09c8
4
+ data.tar.gz: 6a3f66f2ff364dc76ebb7800f9cec752b7116d57
5
5
  SHA512:
6
- metadata.gz: 3183966ca0ffe1bdfd57aeb700699e81e8bcec6ef8a78494cf6cc1f96638a80d309ea63045c525b13a42837743d99b73ed74adb0e67c5c262d3a90557f4646f2
7
- data.tar.gz: 107812cbfc186ffeffb809f523d9c158d21c7d75317b34f40a939695162ba6c4cfe67eecd9f1a6b1a7080233be0a7ea50e1e924d1382d147bcd1b62d25a64d91
6
+ metadata.gz: a1d359f0d7be93ccefd17b3188626609e61c007435e10c6fcda49c459809ce758f91327297b1b5ce282c697e6a2bfd32fd8e12e2d3b5a52cf3caba2b2be049a7
7
+ data.tar.gz: d84cf000121487a7611dc719699e9bc3b30256b8b8806abd1a1fc0d49317c350fcc49f7b0745390e24ed297c934b5de4e0aa54d558313a6bb65ac8777ca1f87c
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  .vagrant
2
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ script: bundle exec rspec
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0
6
+ - 2.1
@@ -13,7 +13,8 @@ module DokkaaCfg
13
13
  @client = Barge::Client.new(access_token: access_token)
14
14
  end
15
15
 
16
- def up(args, options={})
16
+ def up(args, options_={})
17
+ options = options_.clone
17
18
  options[:scale] ||= 1
18
19
  options[:region] ||= 'sfo1'
19
20
  options[:slug] ||= '512mb'
@@ -42,7 +43,7 @@ module DokkaaCfg
42
43
  def scale(args, options=nil)
43
44
  end
44
45
 
45
- def down(args, options=nil)
46
+ def down(args, options={})
46
47
  droplets = @client.droplet.all["droplets"]
47
48
  r = droplet_regexp
48
49
  droplets.each do |d|
@@ -53,8 +54,6 @@ module DokkaaCfg
53
54
  end
54
55
 
55
56
  private
56
- def coreos_user_data
57
- end
58
57
  def droplet_regexp
59
58
  Regexp.new("^#{DROPLET_NAME_PREFIX}")
60
59
  end
@@ -1,3 +1,3 @@
1
1
  module DokkaaCfg
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,47 @@
1
+ require 'dokkaacfg/digitalocean'
2
+ require 'ostruct'
3
+
4
+ module DokkaaCfg
5
+ describe DigitalOcean do
6
+ let(:dio) { DigitalOcean.new("abcdefg") }
7
+ describe "#up" do
8
+ let(:ssh_key) { "k2nr" }
9
+ before do
10
+ @client = dio.instance_variable_get(:@client)
11
+ allow(@client).to receive_message_chain(:key, :all)
12
+ .and_return({"ssh_keys" => [OpenStruct.new(name: ssh_key, id: "id")]})
13
+ allow(UserData).to receive(:make_user_data).and_return("user data")
14
+ end
15
+
16
+ it do
17
+ expect(@client).to receive_message_chain(:droplet, :create).with({
18
+ name: 'dokkaa-1',
19
+ region: 'sfo1',
20
+ size: '512mb',
21
+ image: 'coreos-alpha',
22
+ ssh_keys: ["id"],
23
+ private_networking: true,
24
+ user_data: 'user data'
25
+ })
26
+ dio.up([], {ssh_key: ssh_key})
27
+ end
28
+ end
29
+
30
+ describe "#down" do
31
+ before do
32
+ prefix = DigitalOcean::DROPLET_NAME_PREFIX
33
+ @client = dio.instance_variable_get(:@client)
34
+ allow(@client).to receive_message_chain(:droplet, :all)
35
+ .and_return({"droplets" => [OpenStruct.new(id: "id1",
36
+ name: "#{prefix}name1"),
37
+ OpenStruct.new(id: "id2",
38
+ name: "name2")]})
39
+ end
40
+
41
+ it do
42
+ expect(@client).to receive_message_chain(:droplet, :destroy).with("id1")
43
+ dio.down([])
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ require 'dokkaacfg/provider'
2
+
3
+ module DokkaaCfg
4
+ class Dummy < Provider
5
+ def up; end
6
+ def down; end
7
+ end
8
+
9
+ describe Provider do
10
+ let(:prov){ Dummy.new }
11
+
12
+ describe "#execute" do
13
+ it "call real methods if the provider has" do
14
+ expect(prov).to receive(:up).once
15
+ prov.execute("up", [], {})
16
+ expect(prov).to receive(:down).once
17
+ prov.execute("down", [], {})
18
+ end
19
+
20
+ it "do nothing if real method does not exist" do
21
+ expect{prov.execute("aaa", [], {})}.to_not raise_error
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+
4
+ Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
5
+
6
+ RSpec.configure do |c|
7
+ end
data/user-data CHANGED
@@ -43,7 +43,7 @@ coreos:
43
43
 
44
44
  [Service]
45
45
  ExecStartPre=/usr/bin/docker pull k2nr/dokkaa-conductor
46
- ExecStart=/usr/bin/docker run --name conductor \
46
+ ExecStart=/usr/bin/docker run --name __conductor \
47
47
  -v /var/run/docker.sock:/var/run/docker.sock \
48
48
  -e HOST_IP=$public_ipv4 \
49
49
  -e DOCKER_HOST=unix:///var/run/docker.sock \
@@ -51,7 +51,7 @@ coreos:
51
51
  --restart=always \
52
52
  k2nr/dokkaa-conductor
53
53
  TimeoutStartSec=30m
54
- ExecStop=/usr/bin/docker rm -f conductor
54
+ ExecStop=/usr/bin/docker rm -f __conductor
55
55
  - name: dokkaa-ambassador.service
56
56
  command: start
57
57
  enable: true
@@ -63,14 +63,14 @@ coreos:
63
63
 
64
64
  [Service]
65
65
  ExecStartPre=/usr/bin/docker pull k2nr/dokkaa-ambassador
66
- ExecStart=/usr/bin/docker run --name ambassador \
66
+ ExecStart=/usr/bin/docker run --name __ambassador \
67
67
  -v /var/run/docker.sock:/var/run/docker.sock \
68
68
  -e DOCKER_HOST=unix:///var/run/docker.sock \
69
69
  --dns=$public_ipv4 \
70
70
  --restart=always \
71
71
  k2nr/dokkaa-ambassador
72
72
  TimeoutStartSec=30m
73
- ExecStop=/usr/bin/docker rm -f ambassador
73
+ ExecStop=/usr/bin/docker rm -f __ambassador
74
74
  - name: skydns.service
75
75
  command: start
76
76
  enable: true
@@ -82,11 +82,11 @@ coreos:
82
82
 
83
83
  [Service]
84
84
  ExecStartPre=/usr/bin/docker pull k2nr/skydns-docker
85
- ExecStart=/usr/bin/docker run --name skydns \
85
+ ExecStart=/usr/bin/docker run --name __skydns \
86
86
  -e ETCD_MACHINES=http://$public_ipv4:4001 \
87
87
  -e SKYDNS_ADDR=0.0.0.0:53 \
88
88
  -e SKYDNS_NAMESERVERS=8.8.8.8:53,8.8.4.4:53 \
89
89
  -p $public_ipv4:53:53/udp \
90
90
  k2nr/skydns-docker
91
91
  TimeoutStartSec=30m
92
- ExecStop=/usr/bin/docker rm -f skydns
92
+ ExecStop=/usr/bin/docker rm -f __skydns
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokkaacfg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazunori Kajihiro
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
+ - ".travis.yml"
78
79
  - Gemfile
79
80
  - Gemfile.lock
80
81
  - Vagrantfile
@@ -86,6 +87,9 @@ files:
86
87
  - lib/dokkaacfg/provider.rb
87
88
  - lib/dokkaacfg/user_data.rb
88
89
  - lib/dokkaacfg/version.rb
90
+ - spec/lib/dokkaacfg/digitalocean_spec.rb
91
+ - spec/lib/dokkaacfg/provider_spec.rb
92
+ - spec/spec_helper.rb
89
93
  - user-data
90
94
  homepage: https://github.com/k2nr/dokkaacfg
91
95
  licenses:
@@ -111,4 +115,7 @@ rubygems_version: 2.2.2
111
115
  signing_key:
112
116
  specification_version: 4
113
117
  summary: Configuration management for Dokkaa cluster
114
- test_files: []
118
+ test_files:
119
+ - spec/lib/dokkaacfg/digitalocean_spec.rb
120
+ - spec/lib/dokkaacfg/provider_spec.rb
121
+ - spec/spec_helper.rb