kelbim 0.3.1.beta3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kelbim/version.rb +1 -1
- metadata +5 -7
- data/bin/kelbim~ +0 -187
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87ad9862b45f3588d99bf590615d0e9a895296a8
|
4
|
+
data.tar.gz: 9f56929ac11c8a23759cca04d1e2495090bedf97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2215cd23731bcf31cb93783fda79e7fe2e364fa4c66c978393f39b93242e23f32f6115b799d055be5726260ab96b256216a71d13afec0f985ccae04b2c47ccff
|
7
|
+
data.tar.gz: 0a8e3584bccb95d8546b0eadc02e31029f33fdb294aee006ce4bf2515c2201f2da42b379fadd3213f8728c0326e0bce7291883fa16a00883213833260ba2ecbe
|
data/lib/kelbim/version.rb
CHANGED
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.3.1
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|
@@ -156,13 +156,11 @@ email:
|
|
156
156
|
- sgwr_dts@yahoo.co.jp
|
157
157
|
executables:
|
158
158
|
- kelbim
|
159
|
-
- kelbim~
|
160
159
|
extensions: []
|
161
160
|
extra_rdoc_files: []
|
162
161
|
files:
|
163
162
|
- README.md
|
164
163
|
- bin/kelbim
|
165
|
-
- bin/kelbim~
|
166
164
|
- lib/kelbim.rb
|
167
165
|
- lib/kelbim/client.rb
|
168
166
|
- lib/kelbim/dsl.rb
|
@@ -208,12 +206,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
206
|
version: '0'
|
209
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
208
|
requirements:
|
211
|
-
- - "
|
209
|
+
- - ">="
|
212
210
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
211
|
+
version: '0'
|
214
212
|
requirements: []
|
215
213
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.6.12
|
217
215
|
signing_key:
|
218
216
|
specification_version: 4
|
219
217
|
summary: Kelbim is a tool to manage ELB.
|
data/bin/kelbim~
DELETED
@@ -1,187 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
3
|
-
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
|
4
|
-
require 'rubygems'
|
5
|
-
require 'fileutils'
|
6
|
-
require 'json'
|
7
|
-
require 'kelbim'
|
8
|
-
require 'optparse'
|
9
|
-
require 'rspec'
|
10
|
-
require 'kelbim/rspec-formatter'
|
11
|
-
|
12
|
-
DEFAULT_FILENAME = 'ELBfile'
|
13
|
-
|
14
|
-
mode = nil
|
15
|
-
file = DEFAULT_FILENAME
|
16
|
-
output_file = '-'
|
17
|
-
split = false
|
18
|
-
|
19
|
-
options = {
|
20
|
-
:dry_run => false,
|
21
|
-
:color => true,
|
22
|
-
:debug => false,
|
23
|
-
}
|
24
|
-
|
25
|
-
ARGV.options do |opt|
|
26
|
-
begin
|
27
|
-
access_key = nil
|
28
|
-
secret_key = nil
|
29
|
-
region = nil
|
30
|
-
profile_name = nil
|
31
|
-
credentials_path = nil
|
32
|
-
|
33
|
-
opt.on('-p', '--profile PROFILE_NAME') {|v| profile_name = v }
|
34
|
-
opt.on('' , '--credentials-path PATH') {|v| credentials_path = v }
|
35
|
-
opt.on('-k', '--access-key ACCESS_KEY') {|v| access_key = v }
|
36
|
-
opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
|
37
|
-
opt.on('-r', '--region REGION') {|v| region = v }
|
38
|
-
opt.on('-a', '--apply') { mode = :apply }
|
39
|
-
opt.on('-f', '--file FILE') {|v| file = v }
|
40
|
-
opt.on('-n', '--elb-name REGEXP') {|v| options[:elb_name] = Regexp.new(v) }
|
41
|
-
opt.on('', '--exclude-elb-name REGEXP') {|v| options[:exclude_elb_name] = Regexp.new(v) }
|
42
|
-
opt.on('', '--dry-run') { options[:dry_run] = true }
|
43
|
-
opt.on('', '--ec2s VPC_IDS', Array) {|v| options[:ec2s] = v }
|
44
|
-
opt.on('', '--without-deleting-policy') { options[:without_deleting_policy] = true }
|
45
|
-
opt.on('-e', '--export') { mode = :export }
|
46
|
-
opt.on('-o', '--output FILE') {|v| output_file = v }
|
47
|
-
opt.on('', '--split') { split = true }
|
48
|
-
opt.on('', '--split-more') { split = :more }
|
49
|
-
opt.on('-t', '--test') { mode = :test }
|
50
|
-
opt.on('', '--show-load-balancers') { mode = :show_load_balancers }
|
51
|
-
opt.on('', '--show-policies') { mode = :show_policies }
|
52
|
-
opt.on('' , '--no-color') { options[:color] = false }
|
53
|
-
opt.on('' , '--debug') { options[:debug] = true }
|
54
|
-
opt.parse!
|
55
|
-
|
56
|
-
aws_opts = {}
|
57
|
-
if access_key and secret_key
|
58
|
-
aws_opts[:access_key_id] = access_key
|
59
|
-
aws_opts[:secret_access_key] = secret_key
|
60
|
-
elsif profile_name or credentials_path
|
61
|
-
credentials_opts = {}
|
62
|
-
credentials_opts[:profile_name] = profile_name if profile_name
|
63
|
-
credentials_opts[:path] = credentials_path if credentials_path
|
64
|
-
provider = AWS::Core::CredentialProviders::SharedCredentialFileProvider.new(credentials_opts)
|
65
|
-
aws_opts[:credential_provider] = provider
|
66
|
-
elsif (access_key and !secret_key) or (!access_key and secret_key) or mode.nil?
|
67
|
-
puts opt.help
|
68
|
-
exit 1
|
69
|
-
end
|
70
|
-
|
71
|
-
aws_opts[:region] = region if region
|
72
|
-
AWS.config(aws_opts)
|
73
|
-
rescue => e
|
74
|
-
$stderr.puts("[ERROR] #{e.message}")
|
75
|
-
exit 1
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
String.colorize = options[:color]
|
80
|
-
|
81
|
-
if options[:debug]
|
82
|
-
AWS.config({
|
83
|
-
:http_wire_trace => true,
|
84
|
-
:logger => Kelbim::Logger.instance,
|
85
|
-
})
|
86
|
-
end
|
87
|
-
|
88
|
-
begin
|
89
|
-
logger = Kelbim::Logger.instance
|
90
|
-
logger.set_debug(options[:debug])
|
91
|
-
client = Kelbim::Client.new(options)
|
92
|
-
|
93
|
-
case mode
|
94
|
-
when :export
|
95
|
-
if split
|
96
|
-
logger.info('Export ELB')
|
97
|
-
|
98
|
-
output_file = DEFAULT_FILENAME if output_file == '-'
|
99
|
-
requires = []
|
100
|
-
|
101
|
-
client.export(options) do |exported, converter|
|
102
|
-
exported.each do |vpc, elbs|
|
103
|
-
if split == :more
|
104
|
-
elb_dir = File.join(File.dirname(output_file), "#{vpc || :classic}")
|
105
|
-
FileUtils.mkdir_p(elb_dir)
|
106
|
-
|
107
|
-
elbs.each do |name, attrs|
|
108
|
-
elb_file = File.join(elb_dir, "#{name}.elb")
|
109
|
-
requires << elb_file
|
110
|
-
|
111
|
-
logger.info(" write `#{elb_file}`")
|
112
|
-
|
113
|
-
open(elb_file, 'wb') do |f|
|
114
|
-
f.puts converter.call(vpc => {name => attrs})
|
115
|
-
end
|
116
|
-
end
|
117
|
-
else
|
118
|
-
elb_file = File.join(File.dirname(output_file), "#{vpc || :classic}.elb")
|
119
|
-
requires << elb_file
|
120
|
-
|
121
|
-
logger.info(" write `#{elb_file}`")
|
122
|
-
|
123
|
-
open(elb_file, 'wb') do |f|
|
124
|
-
f.puts converter.call(vpc => elbs)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
logger.info(" write `#{output_file}`")
|
131
|
-
path_prefix = File.dirname(output_file)
|
132
|
-
|
133
|
-
open(output_file, 'wb') do |f|
|
134
|
-
requires.each do |elb_file|
|
135
|
-
elb_file.sub!(%r|\A#{Regexp.escape(path_prefix)}/|, '')
|
136
|
-
f.puts "require '#{elb_file}'"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
else
|
140
|
-
if output_file == '-'
|
141
|
-
logger.info('# Export ELB')
|
142
|
-
puts client.export(options)
|
143
|
-
else
|
144
|
-
logger.info("Export ELB to `#{output_file}`")
|
145
|
-
open(output_file, 'wb') {|f| f.puts client.export(options) }
|
146
|
-
end
|
147
|
-
end
|
148
|
-
when :apply
|
149
|
-
unless File.exist?(file)
|
150
|
-
raise "No ELBfile found (looking for: #{file})"
|
151
|
-
end
|
152
|
-
|
153
|
-
msg = "Apply `#{file}` to ELB"
|
154
|
-
msg << ' (dry-run)' if options[:dry_run]
|
155
|
-
logger.info(msg)
|
156
|
-
|
157
|
-
updated = client.apply(file)
|
158
|
-
|
159
|
-
logger.info('No change'.intense_blue) unless updated
|
160
|
-
when :test
|
161
|
-
unless File.exist?(file)
|
162
|
-
raise "No ELBfile found (looking for: #{file})"
|
163
|
-
end
|
164
|
-
|
165
|
-
RSpec.configure do |config|
|
166
|
-
config.color = options[:color]
|
167
|
-
config.output_stream = $stdout # formatterをセットする前に設定…
|
168
|
-
config.formatter = Kelbim::RSpecFormatter
|
169
|
-
end
|
170
|
-
|
171
|
-
logger.info("Test `#{file}`")
|
172
|
-
client.test(file)
|
173
|
-
when :show_load_balancers
|
174
|
-
puts JSON.pretty_generate(client.load_balancers)
|
175
|
-
when :show_policies
|
176
|
-
puts JSON.pretty_generate(client.policies)
|
177
|
-
else
|
178
|
-
raise 'must not happen'
|
179
|
-
end
|
180
|
-
rescue => e
|
181
|
-
if options[:debug]
|
182
|
-
raise e
|
183
|
-
else
|
184
|
-
$stderr.puts("[ERROR] #{e.message}".red)
|
185
|
-
exit 1
|
186
|
-
end
|
187
|
-
end
|