cfdef 0.1.6 → 0.1.7

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: 0f7569ecd16aca5421994ce854733c6593d79cae
4
- data.tar.gz: 7f70f529230958a3113e232f140a95ef29c2ea53
3
+ metadata.gz: 0d55a0bdee6a2bbaf9db699f83615a3d328bd8b8
4
+ data.tar.gz: 559139e452bf7b33c00ed77eb7064104eaf64aec
5
5
  SHA512:
6
- metadata.gz: f4110663867762259c075df419a806b491e1b821bd3692ba06a0f4e5a59d4d91e236ff90ddbb5486de098a723aeb0f12b3cec168e5cc50890acf81683416a1d5
7
- data.tar.gz: bc7917e4e368cbc06804eb2b75967830272807e54f666b96ea657fd00e616bd23e8890108ec3323c077ba4eb62c05b3f56961267a52ca0f3600e9e16b172be38
6
+ metadata.gz: 1b036a409ca0ea2b99aa613b72c12437217d8718c6559353d583a54dc67e90db3950c6e1b4d39ee0ecb0f4dc735ebfcc0709cf99e61b701ecafc18d0090f18a9
7
+ data.tar.gz: 0e90921ba73ce3d379f7a11bd84bf16ace05c9dc3ce1b58fc7dba16348cad07c68941d22a485c308bb8d694d76f6a19d8d36a9ff840feddb80b9a589d340b228
data/README.md CHANGED
@@ -181,6 +181,89 @@ $ cat CFfile
181
181
  $ cfdef -a
182
182
  ```
183
183
 
184
+ ## Use braces
185
+
186
+ Export with `--use-braces` option.
187
+
188
+ ```ruby
189
+ distribution("EXAMPLEID") {
190
+ aliases {
191
+ quantity 0
192
+ }
193
+ origins {
194
+ quantity 1
195
+ items {|*|
196
+ id "Custom-example.com"
197
+ domain_name "example.com"
198
+ origin_path ""
199
+ custom_headers {
200
+ quantity 0
201
+ }
202
+ custom_origin_config {
203
+ http_port 80
204
+ https_port 443
205
+ origin_protocol_policy "http-only"
206
+ origin_ssl_protocols {
207
+ quantity 3
208
+ items ["TLSv1", "TLSv1.1", "TLSv1.2"]
209
+ }
210
+ }
211
+ }
212
+ }
213
+ default_cache_behavior {
214
+ target_origin_id "Custom-example.com"
215
+ forwarded_values {
216
+ query_string false
217
+ cookies {
218
+ forward "none"
219
+ }
220
+ headers {
221
+ quantity 0
222
+ }
223
+ }
224
+ trusted_signers {
225
+ enabled false
226
+ quantity 0
227
+ }
228
+ viewer_protocol_policy "allow-all"
229
+ min_ttl 0
230
+ allowed_methods {
231
+ quantity 2
232
+ items ["GET", "HEAD"]
233
+ cached_methods {
234
+ quantity 2
235
+ items ["GET", "HEAD"]
236
+ }
237
+ }
238
+ smooth_streaming false
239
+ default_ttl 86400
240
+ max_ttl 31536000
241
+ compress false
242
+ }
243
+ cache_behaviors {
244
+ quantity 0
245
+ }
246
+ custom_error_responses {
247
+ quantity 0
248
+ }
249
+ comment ""
250
+ price_class "PriceClass_All"
251
+ enabled true
252
+ viewer_certificate {
253
+ cloud_front_default_certificate true
254
+ minimum_protocol_version "SSLv3"
255
+ certificate_source "cloudfront"
256
+ }
257
+ restrictions {
258
+ geo_restriction {
259
+ restriction_type "none"
260
+ quantity 0
261
+ }
262
+ }
263
+ web_acl_id ""
264
+ }
265
+ ```
266
+
184
267
  ## ToDo
185
268
 
186
269
  * Support Streaming Distribution
data/cfdef.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'diffy'
24
24
  spec.add_dependency 'dslh', '>= 0.3.6'
25
25
  spec.add_dependency 'term-ansicolor'
26
+ spec.add_dependency 'parallel'
26
27
 
27
28
  spec.add_development_dependency 'bundler'
28
29
  spec.add_development_dependency 'rake'
data/lib/cfdef.rb CHANGED
@@ -3,6 +3,7 @@ require 'diffy'
3
3
  require 'dslh'
4
4
  require 'json'
5
5
  require 'logger'
6
+ require 'parallel'
6
7
  require 'pp'
7
8
  require 'securerandom'
8
9
  require 'singleton'
@@ -1,6 +1,8 @@
1
1
  class Cfdef::Exporter
2
2
  include Cfdef::Utils::Helper
3
3
 
4
+ CONCURRENCY = 8
5
+
4
6
  def initialize(client, options = {})
5
7
  @client = client
6
8
  @options = options
@@ -19,10 +21,12 @@ class Cfdef::Exporter
19
21
  def export_distributions
20
22
  result = {}
21
23
 
22
- distributions = @client.list_distributions.flat_map(&:distribution_list).flat_map(&:items).map(&:to_h)
24
+ distribution_ids = @client.list_distributions.flat_map(&:distribution_list).flat_map(&:items).map(&:id)
23
25
 
24
- distributions.each do |distribution|
25
- distribution_id = distribution.fetch(:id)
26
+ Parallel.each(distribution_ids, in_threads: CONCURRENCY) do |distribution_id|
27
+ resp = @client.get_distribution_config(id: distribution_id)
28
+ distribution = resp.distribution_config.to_h
29
+ distribution.delete(:caller_reference)
26
30
  origin_ids = distribution.fetch(:origins).fetch(:items).map {|i| i[:id] }.sort
27
31
  next unless origin_ids.any?{|i| matched?(i) }
28
32
  result[distribution_id] = remove_status!(distribution)
data/lib/cfdef/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cfdef
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfdef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-07-01 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: parallel
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