kelbim 0.0.4 → 0.1.0
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 +4 -4
- data/README.md +9 -1
- data/bin/kelbim +30 -6
- data/lib/kelbim/client.rb +9 -6
- data/lib/kelbim/dsl/converter.rb +1 -1
- data/lib/kelbim/dsl/ec2.rb +1 -1
- data/lib/kelbim/rspec_formatter.rb +22 -0
- data/lib/kelbim/tester.rb +0 -1
- data/lib/kelbim/version.rb +1 -1
- data/lib/kelbim/wrapper/listener.rb +1 -1
- data/lib/kelbim/wrapper/load-balancer-collection.rb +2 -2
- metadata +17 -3
- data/lib/kelbim/ext/base_text_formatter-ext.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d76367e3e72459fcb48c7e7c2ac7644c91bfc2a8
|
4
|
+
data.tar.gz: 4fcd4b448eb952c926b96330d53a462de3e1daeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 344fa9f5496e7564195c040e9772091a6a9a608f57e6a1bc6bea44391cb295d32b67a17a9ba2067539b1c7e512b741be4124a5fd10cd4a2d7339b8c64187bebf
|
7
|
+
data.tar.gz: 9441923f6b77523ee48a530376438f3c35c7e28bc8b93e0500bc83f2188ebdb9e761916f4cd867eb3da2da2c92acdcc23f2faf6a7dc5f53f21ae39134d329f5d
|
data/README.md
CHANGED
@@ -4,7 +4,15 @@ Kelbim is a tool to manage ELB.
|
|
4
4
|
|
5
5
|
It defines the state of ELB using DSL, and updates ELB according to DSL.
|
6
6
|
|
7
|
-
|
7
|
+
[](https://drone.io/bitbucket.org/winebarrel/kelbim/latest)
|
8
|
+
|
9
|
+
**Notice**
|
10
|
+
|
11
|
+
It does not yet support the following load balancer policies:
|
12
|
+
|
13
|
+
* ProxyProtocolPolicyType
|
14
|
+
* BackendServerAuthenticationPolicyType
|
15
|
+
* PublicKeyPolicyType
|
8
16
|
|
9
17
|
## Installation
|
10
18
|
|
data/bin/kelbim
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
|
3
3
|
require 'rubygems'
|
4
|
+
require 'fileutils'
|
4
5
|
require 'json'
|
5
6
|
require 'kelbim'
|
6
7
|
require 'optparse'
|
7
8
|
require 'rspec'
|
9
|
+
require 'kelbim/rspec_formatter'
|
8
10
|
|
9
11
|
DEFAULT_FILENAME = 'ELBfile'
|
10
12
|
|
@@ -35,6 +37,7 @@ ARGV.options do |opt|
|
|
35
37
|
opt.on('-e', '--export') {|v| mode = :export }
|
36
38
|
opt.on('-o', '--output FILE') {|v| output_file = v }
|
37
39
|
opt.on('', '--split') {|v| split = true }
|
40
|
+
opt.on('', '--split-more') {|v| split = :more }
|
38
41
|
opt.on('-t', '--test') {|v| mode = :test }
|
39
42
|
opt.on('', '--show-load-balancers') {|v| mode = :show_load_balancers }
|
40
43
|
opt.on('', '--show-policies') {|v| mode = :show_policies }
|
@@ -83,13 +86,29 @@ begin
|
|
83
86
|
|
84
87
|
client.export do |exported, converter|
|
85
88
|
exported.each do |vpc, elbs|
|
86
|
-
|
87
|
-
|
89
|
+
if split == :more
|
90
|
+
elb_dir = File.join(File.dirname(output_file), "#{vpc || :classic}")
|
91
|
+
FileUtils.mkdir_p(elb_dir)
|
88
92
|
|
89
|
-
|
93
|
+
elbs.each do |name, attrs|
|
94
|
+
elb_file = File.join(elb_dir, "#{name}.elb")
|
95
|
+
requires << elb_file
|
90
96
|
|
91
|
-
|
92
|
-
|
97
|
+
logger.info(" write `#{elb_file}`")
|
98
|
+
|
99
|
+
open(elb_file, 'wb') do |f|
|
100
|
+
f.puts converter.call(vpc => {name => attrs})
|
101
|
+
end
|
102
|
+
end
|
103
|
+
else
|
104
|
+
elb_file = File.join(File.dirname(output_file), "#{vpc || :classic}.elb")
|
105
|
+
requires << elb_file
|
106
|
+
|
107
|
+
logger.info(" write `#{elb_file}`")
|
108
|
+
|
109
|
+
open(elb_file, 'wb') do |f|
|
110
|
+
f.puts converter.call(vpc => elbs)
|
111
|
+
end
|
93
112
|
end
|
94
113
|
end
|
95
114
|
end
|
@@ -127,8 +146,13 @@ begin
|
|
127
146
|
raise "No ELBfile found (looking for: #{file})"
|
128
147
|
end
|
129
148
|
|
149
|
+
RSpec.configure do |config|
|
150
|
+
config.color_enabled = options[:color]
|
151
|
+
config.output_stream = $stdout # formatterをセットする前に設定…
|
152
|
+
config.formatter = Kelbim::RSpecFormatter
|
153
|
+
end
|
154
|
+
|
130
155
|
logger.info("Test `#{file}`")
|
131
|
-
RSpec.configuration.color_enabled = options[:color]
|
132
156
|
client.test(file)
|
133
157
|
when :show_load_balancers
|
134
158
|
puts JSON.pretty_generate(client.load_balancers)
|
data/lib/kelbim/client.rb
CHANGED
@@ -123,7 +123,7 @@ module Kelbim
|
|
123
123
|
if ec2_aws
|
124
124
|
walk_ec2(vpc, ec2_dsl, ec2_aws, elb.load_balancers)
|
125
125
|
else
|
126
|
-
|
126
|
+
walk_ec2(vpc, ec2_dsl, [], elb.load_balancers)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -145,6 +145,9 @@ module Kelbim
|
|
145
145
|
end
|
146
146
|
|
147
147
|
lb_list_dsl.each do |key, lb_dsl|
|
148
|
+
name = key[0]
|
149
|
+
log(:info, "Comparing #{vpc || :classic} > #{name}", :intense_black)
|
150
|
+
|
148
151
|
lb_aws = lb_list_aws.delete(key)
|
149
152
|
walk_load_balancer(lb_dsl, lb_aws)
|
150
153
|
end
|
@@ -233,13 +236,13 @@ module Kelbim
|
|
233
236
|
old_policies << plcy_aws
|
234
237
|
end
|
235
238
|
|
236
|
-
if
|
239
|
+
if orig_policy_names.sort != new_policies.map {|i| i.name }.sort
|
237
240
|
listener.policies = new_policies
|
241
|
+
end
|
238
242
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
end
|
243
|
+
if not old_policies.empty? and not @options.without_deleting_policy
|
244
|
+
old_policies.each do |plcy_aws|
|
245
|
+
plcy_aws.delete
|
243
246
|
end
|
244
247
|
end
|
245
248
|
end
|
data/lib/kelbim/dsl/converter.rb
CHANGED
data/lib/kelbim/dsl/ec2.rb
CHANGED
@@ -8,7 +8,6 @@ module Kelbim
|
|
8
8
|
attr_reader :result
|
9
9
|
|
10
10
|
def initialize(vpc, load_balancers, &block)
|
11
|
-
@names = []
|
12
11
|
@error_identifier = "EC2 `#{vpc || :classic}`"
|
13
12
|
|
14
13
|
@result = OpenStruct.new({
|
@@ -16,6 +15,7 @@ module Kelbim
|
|
16
15
|
:load_balancers => load_balancers,
|
17
16
|
})
|
18
17
|
|
18
|
+
@names = load_balancers.map {|i| i.name }
|
19
19
|
instance_eval(&block)
|
20
20
|
end
|
21
21
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rspec/core/formatters/progress_formatter'
|
3
|
+
|
4
|
+
module Kelbim
|
5
|
+
class RSpecFormatter < RSpec::Core::Formatters::ProgressFormatter
|
6
|
+
def dump_failure_info(example)
|
7
|
+
exception = example.execution_result[:exception]
|
8
|
+
|
9
|
+
if exception.message
|
10
|
+
line = exception.message.to_s.split("\n").first
|
11
|
+
line.sub!(/\s*with backtrace:\s*/, '')
|
12
|
+
output.puts "#{long_padding}#{failure_color(line)}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def dump_backtrace(example)
|
17
|
+
end
|
18
|
+
|
19
|
+
def dump_commands_to_rerun_failed_examples
|
20
|
+
end
|
21
|
+
end # RSpecFormatter
|
22
|
+
end # Kelbim
|
data/lib/kelbim/tester.rb
CHANGED
data/lib/kelbim/version.rb
CHANGED
@@ -33,7 +33,7 @@ module Kelbim
|
|
33
33
|
log(:info, 'Update Listener', :green, log_id)
|
34
34
|
|
35
35
|
compare_server_certificate(dsl) do
|
36
|
-
log(:info, " set server_certificate=#{dsl.server_certificate
|
36
|
+
log(:info, " set server_certificate=#{dsl.server_certificate}", :green)
|
37
37
|
|
38
38
|
unless @options.dry_run
|
39
39
|
ss = @options.iam.server_certificates[dsl.server_certificate]
|
@@ -29,7 +29,7 @@ module Kelbim
|
|
29
29
|
:id => "<new load balancer name=#{dsl.name}>",
|
30
30
|
:name => dsl.name,
|
31
31
|
:vpc_id => vpc,
|
32
|
-
:instances =>
|
32
|
+
:instances => [], # instancesはLoadBalancerの処理で更新
|
33
33
|
:scheme => dsl.scheme,
|
34
34
|
:listeners => dsl.listeners.map {|i| LoadBalancer::ListenerCollection.create_mock_listener(i, @load_balancer) },
|
35
35
|
:health_check => {}, # health_checkはLoadBalancerの処理で更新
|
@@ -48,7 +48,7 @@ module Kelbim
|
|
48
48
|
:listeners => [],
|
49
49
|
}
|
50
50
|
|
51
|
-
|
51
|
+
# instancesはLoadBalancerの処理で更新
|
52
52
|
|
53
53
|
dsl.listeners.each do |lstnr|
|
54
54
|
lstnr_opts = LoadBalancer::ListenerCollection.create_listener_options(lstnr, @options.iam)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelbim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: term-ansicolor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,13 +143,13 @@ files:
|
|
129
143
|
- lib/kelbim/dsl/load-balancer.rb
|
130
144
|
- lib/kelbim/dsl.rb
|
131
145
|
- lib/kelbim/exporter.rb
|
132
|
-
- lib/kelbim/ext/base_text_formatter-ext.rb
|
133
146
|
- lib/kelbim/ext/ec2-ext.rb
|
134
147
|
- lib/kelbim/ext/elb-listener-ext.rb
|
135
148
|
- lib/kelbim/ext/elb-load-balancer-ext.rb
|
136
149
|
- lib/kelbim/ext/string-ext.rb
|
137
150
|
- lib/kelbim/logger.rb
|
138
151
|
- lib/kelbim/policy-types.rb
|
152
|
+
- lib/kelbim/rspec_formatter.rb
|
139
153
|
- lib/kelbim/tester.rb
|
140
154
|
- lib/kelbim/version.rb
|
141
155
|
- lib/kelbim/wrapper/elb-wrapper.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'rspec/core/formatters/base_text_formatter'
|
3
|
-
|
4
|
-
module RSpec
|
5
|
-
module Core
|
6
|
-
module Formatters
|
7
|
-
class BaseTextFormatter < BaseFormatter
|
8
|
-
def dump_failure_info(example)
|
9
|
-
exception = example.execution_result[:exception]
|
10
|
-
|
11
|
-
if exception.message
|
12
|
-
line = exception.message.to_s.split("\n").first
|
13
|
-
line.sub!(/\s*with backtrace:\s*/, '')
|
14
|
-
output.puts "#{long_padding}#{failure_color(line)}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def dump_backtrace(example)
|
19
|
-
end
|
20
|
-
|
21
|
-
def dump_commands_to_rerun_failed_examples
|
22
|
-
end
|
23
|
-
end # BaseTextFormatter
|
24
|
-
end # Formatters
|
25
|
-
end # Core
|
26
|
-
end # RSpec
|