bukelatta 0.1.0 → 0.1.1

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: 1e84a56a80a6728268e54b8444aa8347704eb09e
4
- data.tar.gz: bf37f6b46f7625cdaaf3ef9d9fff91772bbeef48
3
+ metadata.gz: c40b0ab6b5d26689801b483afa0d4c081c3b5f10
4
+ data.tar.gz: 5142c2e26e330691b9fb993df048cb3aac57b03d
5
5
  SHA512:
6
- metadata.gz: 531351c5b30f532e73a84349efc0df6e9d5eba85c2aeefaba5d91c9d995207e20eaf57676255ea64200c7a645a11ab6a215f8299aeb9c38ff43fc0204da5686f
7
- data.tar.gz: e1cbfbfb8dedd711b25308c1bc61cc79ce88496d288353b892032a72a9a8cc71b501e5dc3046ebcd892e3a68ef3a2af20964d4251ac7097709315b0e31d206c6
6
+ metadata.gz: dc1214d98450bd85b67c84a787f4c39ae5741a5e264a3b30ae7e0085f551804fff9c6e2c8e373577e6b944a6a93a8deb9e163e464d9e18dcb3c5a18c0cd74bfe
7
+ data.tar.gz: 5c9fd3cbce80be309c4ab8656d17a061f5d445caae57e0dbf83f925546fe13607614460315857cb87c657046ae09e43dd2ce946e5f8c5c77f5dea7a76a4be65b
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  test.rb
11
11
  PolicyFile
12
+ *.policy
data/README.md CHANGED
@@ -45,6 +45,7 @@ Usage: bukelatta [options]
45
45
  --dry-run
46
46
  -e, --export
47
47
  -o, --output FILE
48
+ --split
48
49
  --target REGEXP
49
50
  --no-color
50
51
  --debug
data/exe/bukelatta CHANGED
@@ -43,6 +43,7 @@ def parse_options(argv)
43
43
  opt.on('' , '--dry-run') { options[:dry_run] = true }
44
44
  opt.on('-e', '--export') { options[:mode] = :export }
45
45
  opt.on('-o', '--output FILE') {|v| options[:output] = v }
46
+ opt.on('' , '--split') { options[:split] = :true }
46
47
  opt.on('' , '--target REGEXP') {|v| options[:target] = Regexp.new(v) }
47
48
  opt.on('' , '--no-color') { options[:color] = false }
48
49
  opt.on('' , '--debug') { options[:debug] = true }
@@ -90,14 +91,52 @@ def main(argv)
90
91
  exported = client.export
91
92
  output = options[:output]
92
93
 
93
- if output == '-'
94
- logger.info('# Export Bucket Policy')
95
- puts exported
96
- else
97
- logger.info("Export Bucket Policy to `#{output}`")
94
+ if options[:split]
95
+ logger.info('Export Bucket Policy')
96
+
97
+ output = DEFAULT_FILENAME if output == '-'
98
+ dir = File.dirname(output)
99
+ FileUtils.mkdir_p(dir)
100
+ requires = []
101
+
102
+ exported.each do |bucket_name, policy|
103
+ next unless policy
104
+
105
+ filename = "#{bucket_name}.policy"
106
+ requires << filename
107
+ policy_file = File.join(dir, filename)
108
+
109
+ logger.info(" write `#{policy_file}`")
110
+
111
+ dsl = Bukelatta::DSL.convert({bucket_name => policy}, options)
112
+
113
+ open(policy_file, 'wb') do |f|
114
+ f.puts MAGIC_COMMENT
115
+ f.puts dsl
116
+ end
117
+ end
118
+
119
+ logger.info(" write `#{output}`")
120
+
98
121
  open(output, 'wb') do |f|
99
122
  f.puts MAGIC_COMMENT
100
- f.puts exported
123
+
124
+ requires.each do |policy_file|
125
+ f.puts "require '#{policy_file}'"
126
+ end
127
+ end
128
+ else
129
+ dsl = Bukelatta::DSL.convert(exported, options)
130
+
131
+ if output == '-'
132
+ logger.info('# Export Bucket Policy')
133
+ puts dsl
134
+ else
135
+ logger.info("Export Bucket Policy to `#{output}`")
136
+ open(output, 'wb') do |f|
137
+ f.puts MAGIC_COMMENT
138
+ f.puts dsl
139
+ end
101
140
  end
102
141
  end
103
142
  when :apply
@@ -10,8 +10,7 @@ class Bukelatta::Client
10
10
  end
11
11
 
12
12
  def export
13
- exported = Bukelatta::Exporter.export(@client, @options)
14
- Bukelatta::DSL.convert(exported, @options)
13
+ Bukelatta::Exporter.export(@client, @options)
15
14
  end
16
15
 
17
16
  def apply(file)
@@ -1,3 +1,3 @@
1
1
  module Bukelatta
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bukelatta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel