lucid-cumulus 0.11.6 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2FhNDkzYjc3ZDQzOTgwYjhhYzMxZTI0Y2U5NGM0MzRmYjYyM2JjNg==
4
+ ZTllODkxZjdiMWFjYTg1N2Y2ODE0NTdjZDBjZGFiMjgwYjg0MDMzZA==
5
5
  data.tar.gz: !binary |-
6
- NGQzNjUzZGIyYjhkZWI1ZGNjZDJkNjk5OTg4NTI2MjhjMGIxMmE3MA==
6
+ YzljZmYwNDE0MDAzNzBmNzgxNDY0NDkzYjgxOGM1NjdiNTMzZTc2ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGQzNGFiODQ5ZWJhYTg1YWM2NGE2YTUxZDFkMGExYTVhZTYzNjJkYzQ2OTFh
10
- Zjg1YmYzMWZkZWE3NDNiNGQ0NjRkZjc4OTU3OTUxMzNmNWQyMjU5ZGRkZDFl
11
- NGY1NTBkZjU5YjQxZDIzZTg4MDg0MmFlNDBjZTIzMWQ4ZTc4ZjQ=
9
+ YTczZTEwYzlhYWI2M2RmNzUzNmZkNzNmNjEzYjFjNjVjYjNlMzY1MzA4YjUw
10
+ ZjM4ZTAwNmIwMjg3MzkzNDAxYTY0MTM2NGViMGFmOWUxOTMzYzFlYzkzMWMw
11
+ MDkwZWMzZDliNzA1ZmY3Y2JhZDFiOWE2NjkwZGQ3NTYwYjQyYzc=
12
12
  data.tar.gz: !binary |-
13
- MjgyZjhmZTBmODRjMzc5NjZmZDM2MjA1ZTkyYmIxNzY5MmNmMzM5OTdkMzc3
14
- ZWZjMWYwM2M2MWRhN2E1NzEwNzRiODMzODVjZWNlNDMwOWE3ZjU2ODRmYzg5
15
- NjU4MThhMThlNTE3MmJmMjg3NGNjMDdhMjMzNjcyOTRmOTU4MjA=
13
+ OTNhYjA2ZTI2OWRlNzBlYjNhNzc3NjA5ZTVkMjBmZDI1MDFhOGQ4N2Y5MGEz
14
+ YWI2MDUwMThkOTJmMzlmZTFjNzM0MWUyYTY1ZGRlZDE4NGFhYmJkZGMzYjgx
15
+ NjZlY2FjNDk1ZDhlNDE0Y2Y0Y2UxZDgzYjJkNDUyYjZhNmMxYjk=
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lucid-cumulus (0.11.6)
5
- aws-sdk (= 2.2.30)
4
+ lucid-cumulus (0.11.7)
5
+ aws-sdk (~> 2.6.3)
6
6
  deepsort (~> 0.1)
7
7
  parse-cron (~> 0.1.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- aws-sdk (2.2.30)
13
- aws-sdk-resources (= 2.2.30)
14
- aws-sdk-core (2.2.30)
12
+ aws-sdk (2.6.3)
13
+ aws-sdk-resources (= 2.6.3)
14
+ aws-sdk-core (2.6.3)
15
15
  jmespath (~> 1.0)
16
- aws-sdk-resources (2.2.30)
17
- aws-sdk-core (= 2.2.30)
18
- deepsort (0.3.1)
16
+ aws-sdk-resources (2.6.3)
17
+ aws-sdk-core (= 2.6.3)
18
+ deepsort (0.4.0)
19
19
  diff-lcs (1.2.5)
20
20
  jmespath (1.3.1)
21
21
  parse-cron (0.1.4)
@@ -43,4 +43,4 @@ DEPENDENCIES
43
43
  rspec
44
44
 
45
45
  BUNDLED WITH
46
- 1.12.5
46
+ 1.13.1
@@ -105,6 +105,8 @@ module Cumulus
105
105
  if e.message =~ /OriginSslProtocols is required/
106
106
  puts Colors.red("Distribution #{local.name} must specify $.custom-origin-config.origin-ssl-protocols when \"protocol-policy\" is \"https-only\". Distribution not updated")
107
107
  StatusCodes.set_status(StatusCodes::EXCEPTION)
108
+ else
109
+ throw e
108
110
  end
109
111
  end
110
112
  end
@@ -1,5 +1,6 @@
1
1
  require "conf/Configuration"
2
2
  require "cloudfront/models/CacheBehaviorDiff"
3
+ require "util/AwsUtil"
3
4
 
4
5
  require "json"
5
6
 
@@ -37,6 +38,7 @@ module Cumulus
37
38
  @path_pattern = json["path-pattern"] if !default
38
39
  @target_origin_id = json["target-origin-id"]
39
40
  @forward_query_strings = json["forward-query-strings"]
41
+ @forward_query_string_cache_keys = json["forward-query-strings-cache-keys"] || []
40
42
  @forwarded_cookies = json["forwarded-cookies"]
41
43
  @forwarded_cookies_whitelist = json["forwarded-cookies-whitelist"] || []
42
44
  @forward_headers = json["forward-headers"] || []
@@ -57,6 +59,7 @@ module Cumulus
57
59
  @path_pattern = aws.path_pattern if !default
58
60
  @target_origin_id = aws.target_origin_id
59
61
  @forward_query_strings = aws.forwarded_values.query_string
62
+ @forward_query_string_cache_keys = aws.forwarded_valued.query_string_cache_keys.items || []
60
63
  @forwarded_cookies = aws.forwarded_values.cookies.forward
61
64
  @forwarded_cookies_whitelist = if aws.forwarded_values.cookies.whitelisted_names.nil? then [] else aws.forwarded_values.cookies.whitelisted_names.items end
62
65
  @forward_headers = if aws.forwarded_values.headers.nil? then [] else aws.forwarded_values.headers.items end
@@ -79,6 +82,7 @@ module Cumulus
79
82
  "path-pattern" => @path_pattern,
80
83
  "target-origin-id" => @target_origin_id,
81
84
  "forward-query-strings" => @forward_query_strings,
85
+ "forward-query-string-cache-keys" => @forward_query_string_cache_keys,
82
86
  "forwarded-cookies" => @forwarded_cookies,
83
87
  "forwarded-cookies-whitelist" => @forwarded_cookies_whitelist,
84
88
  "forward-headers" => @forward_headers,
@@ -103,22 +107,17 @@ module Cumulus
103
107
  target_origin_id: @target_origin_id,
104
108
  forwarded_values: {
105
109
  query_string: @forward_query_strings,
110
+ query_string_cache_keys: AwsUtil.aws_array(@forward_query_string_cache_keys),
106
111
  cookies: {
107
112
  forward: @forwarded_cookies,
108
- whitelisted_names: {
109
- quantity: @forwarded_cookies_whitelist.size,
110
- items: if @forwarded_cookies_whitelist.empty? then nil else @forwarded_cookies_whitelist end
111
- }
113
+ whitelisted_names: AwsUtil.aws_array(@forwarded_cookies_whitelist),
112
114
  },
113
- headers: {
114
- quantity: @forward_headers.size,
115
- items: if @forward_headers.empty? then nil else @forward_headers end
116
- }
115
+ headers: AwsUtil.aws_array(@forward_headers)
117
116
  },
118
117
  trusted_signers: {
119
118
  enabled: !@trusted_signers.empty?,
120
119
  quantity: @trusted_signers.size,
121
- items: if @trusted_signers.empty? then nil else @trusted_signers end
120
+ items: AwsUtil.array_or_nil(@trusted_signers)
122
121
  },
123
122
  viewer_protocol_policy: @viewer_protocol_policy,
124
123
  min_ttl: @min_ttl,
@@ -127,11 +126,8 @@ module Cumulus
127
126
  smooth_streaming: @smooth_streaming,
128
127
  allowed_methods: {
129
128
  quantity: @allowed_methods.size,
130
- items: if @allowed_methods.empty? then nil else @allowed_methods end,
131
- cached_methods: {
132
- quantity: @cached_methods.size,
133
- items: if @cached_methods.empty? then nil else @cached_methods end
134
- }
129
+ items: AwsUtil.array_or_nil(@allowed_methods),
130
+ cached_methods: AwsUtil.aws_array(@cached_methods)
135
131
  },
136
132
  compress: @compress
137
133
  }
@@ -177,6 +173,13 @@ module Cumulus
177
173
  diffs << CacheBehaviorDiff.cookies_whitelist(added_cookies, removed_cookies, self)
178
174
  end
179
175
 
176
+ aws_query_string_cache_keys = aws.forwarded_values.query_string_cache_keys.items || []
177
+ added_keys = (@forward_query_string_cache_keys - aws_query_string_cache_keys)
178
+ removed_keys = (aws_query_string_cache_keys - @forward_query_string_cache_keys)
179
+ if !(added_keys.empty? && removed_keys.empty?)
180
+ diffs << CacheBehaviorDiff.query_string_cache_keys(added_keys, removed_keys, self)
181
+ end
182
+
180
183
  aws_headers = if aws.forwarded_values.headers.nil? then [] else aws.forwarded_values.headers.items end
181
184
  added_headers = (@forward_headers - aws_headers)
182
185
  removed_headers = (aws_headers - @forward_headers)
@@ -14,6 +14,7 @@ module Cumulus
14
14
  QUERY = Common::DiffChange::next_change_id
15
15
  COOKIES = Common::DiffChange::next_change_id
16
16
  COOKIES_WHITELIST = Common::DiffChange::next_change_id
17
+ QUERY_STRING_CACHE_KEYS = Common::DiffChange::next_change_id
17
18
  HEADERS = Common::DiffChange::next_change_id
18
19
  SIGNERS = Common::DiffChange::next_change_id
19
20
  VIEWER_PROTOCOL = Common::DiffChange::next_change_id
@@ -32,6 +33,7 @@ module Cumulus
32
33
  include CacheBehaviorChange
33
34
 
34
35
  attr_accessor :cookies
36
+ attr_accessor :query_string_cache_keys
35
37
  attr_accessor :headers
36
38
  attr_accessor :signers
37
39
  attr_accessor :allowed_methods
@@ -50,6 +52,20 @@ module Cumulus
50
52
  diff
51
53
  end
52
54
 
55
+ # Public: Static method that produces a diff representing changes in CacheBehavior query string
56
+ # cache keys
57
+ #
58
+ # added_keys - the keys that were added
59
+ # removed_keys - the keys that were removed
60
+ # local - the local configuration for the zone
61
+ #
62
+ # Returns the diff
63
+ def self.query_string_cache_keys(added_keys, removed_keys, local)
64
+ diff = CacheBehaviorDiff.new(QUERY_STRING_CACHE_KEYS, nil, local)
65
+ diff.query_string_cache_keys = Common::ListChange.new(added_keys, removed_keys)
66
+ diff
67
+ end
68
+
53
69
  # Public: Static method that produces a diff representing changes in CacheBehavior headers
54
70
  #
55
71
  # added_headers - the headers that were added
@@ -134,6 +150,12 @@ module Cumulus
134
150
  cookies.removed.map{ |removed| Colors.removed("\t#{removed}")},
135
151
  cookies.added.map{ |added| Colors.added("\t#{added}")},
136
152
  ].flatten.join("\n")
153
+ when QUERY_STRING_CACHE_KEYS
154
+ [
155
+ "Query String Cache Keys:",
156
+ query_string_cache_keys.removed.map{ |removed| Colors.removed("\t#{removed}") },
157
+ query_string_cache_keys.added.map{ |added| Colors.added("\t#{added}")}
158
+ ].flatten.join("\n")
137
159
  when HEADERS
138
160
  [
139
161
  "forwarded headers:",
@@ -0,0 +1,30 @@
1
+ require 'cloudfront/models/CustomHeaderDiff'
2
+
3
+ module Cumulus
4
+ module CloudFront
5
+ CustomHeaderConfig = Struct.new(:name, :value) do
6
+ def diff(aws)
7
+ diffs = []
8
+
9
+ aws_name = aws && aws.header_name
10
+ if self.name != aws_name
11
+ diffs << CustomHeaderDiff.new(CustomHeaderDiff::NAME, aws, self)
12
+ end
13
+
14
+ aws_value = aws && aws.header_value
15
+ if self.value != aws_value
16
+ diffs << CustomHeaderDiff.new(CustomHeaderDiff::VALUE, aws, self)
17
+ end
18
+
19
+ diffs
20
+ end
21
+
22
+ def to_aws
23
+ {
24
+ header_name: self.name,
25
+ header_value: self.value
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,46 @@
1
+ require "common/models/Diff"
2
+ require 'util/Colors'
3
+
4
+ module Cumulus
5
+ module CloudFront
6
+ module CustomHeaderChange
7
+ include Common::DiffChange
8
+
9
+ NAME = Common::DiffChange::next_change_id
10
+ VALUE = Common::DiffChange::next_change_id
11
+ end
12
+
13
+ class CustomHeaderDiff < Common::Diff
14
+ include CustomHeaderChange
15
+
16
+ def diff_string
17
+ case @type
18
+ when NAME
19
+ [
20
+ "name:",
21
+ Colors.aws_changes("\tAWS - #{@aws.header_name}"),
22
+ Colors.local_changes("\tLocal - #{@local.name}")
23
+ ].join("\n")
24
+ when VALUE
25
+ [
26
+ "value:",
27
+ Colors.aws_changes("\tAWS - #{@aws.header_value}"),
28
+ Colors.local_changes("\tLocal - #{@local.value}")
29
+ ].join("\n")
30
+ end
31
+ end
32
+
33
+ def asset_type
34
+ "Custom Origin Header"
35
+ end
36
+
37
+ def aws_name
38
+ @aws.header_name
39
+ end
40
+
41
+ def local_name
42
+ @local.name
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,7 +1,10 @@
1
1
  require "conf/Configuration"
2
+ require "cloudfront/models/CustomHeaderConfig"
3
+ require "cloudfront/models/CustomHeaderDiff"
2
4
  require "cloudfront/models/CustomOriginConfig"
3
5
  require "cloudfront/models/OriginDiff"
4
6
  require "cloudfront/models/OriginSslProtocols"
7
+ require "util/AwsUtil"
5
8
 
6
9
  require "json"
7
10
 
@@ -15,6 +18,7 @@ module Cumulus
15
18
  attr_reader :origin_path
16
19
  attr_reader :s3_access_origin_identity
17
20
  attr_reader :custom_origin_config
21
+ attr_reader :custom_origin_headers
18
22
 
19
23
  # Public: Constructor
20
24
  #
@@ -37,6 +41,13 @@ module Cumulus
37
41
  )
38
42
  )
39
43
  end
44
+ @custom_headers = if json["custom-headers"].nil?
45
+ []
46
+ else
47
+ json["custom-headers"].map do |name, value|
48
+ CustomHeaderConfig.new(name, value)
49
+ end
50
+ end
40
51
  @name = @id
41
52
  end
42
53
  end
@@ -56,6 +67,9 @@ module Cumulus
56
67
  )
57
68
  )
58
69
  end
70
+ @custom_headers = (aws.custom_headers.items || []).map do |header|
71
+ CustomHeaderConfig.new(header.header_name, header.header_value)
72
+ end
59
73
  @name = @id
60
74
  end
61
75
 
@@ -68,7 +82,10 @@ module Cumulus
68
82
  "domain-name" => @domain_name,
69
83
  "origin-path" => @origin_path,
70
84
  "s3-origin-access-identity" => @s3_access_origin_identity,
71
- "custom-origin-config" => if @custom_origin_config.nil? then nil else @custom_origin_config.to_local end
85
+ "custom-origin-config" => if @custom_origin_config.nil? then nil else @custom_origin_config.to_local end,
86
+ "custom-headers" => Hash[@custom_headers.map do |header|
87
+ [header.name, header.value]
88
+ end]
72
89
  }.reject { |k, v| v.nil? }
73
90
  end
74
91
 
@@ -94,7 +111,8 @@ module Cumulus
94
111
  }
95
112
  end
96
113
  }
97
- end
114
+ end,
115
+ custom_headers: AwsUtil.aws_array(@custom_headers.map(&:to_aws))
98
116
  }
99
117
  end
100
118
 
@@ -136,9 +154,44 @@ module Cumulus
136
154
  diffs << OriginDiff.custom(custom_diffs, aws, self) if !custom_diffs.empty?
137
155
  end
138
156
 
157
+ header_diffs = diff_custom_headers(aws.custom_headers.items)
158
+ if !header_diffs.empty?
159
+ diffs << OriginDiff.headers(header_diffs, self)
160
+ end
161
+
139
162
  diffs.flatten
140
163
  end
141
164
 
165
+ # Internal : Produce an array of difference between local and remove custom origin headers
166
+ #
167
+ # aws_headers - the custom origin headers
168
+ #
169
+ # Returns an array of CustomHeaderDiffs that were found
170
+ def diff_custom_headers(aws_headers)
171
+ diffs = []
172
+
173
+ #map headers to their names
174
+ aws = Hash[aws_headers.map { |o| [o.header_name, o] }]
175
+ local = Hash[@custom_headers.map { |o| [o.name, o] }]
176
+
177
+ # find headers not configured locally
178
+ aws.each do |header_name, header|
179
+ if !local.include?(header_name)
180
+ diffs << CustomHeaderDiff.unmanaged(header)
181
+ end
182
+ end
183
+
184
+ local.each do |header_name, header|
185
+ if !aws.include?(header_name)
186
+ diffs << CustomHeaderDiff.added(header)
187
+ else
188
+ diffs += header.diff(aws[header_name])
189
+ end
190
+ end
191
+
192
+ diffs
193
+ end
194
+
142
195
  end
143
196
  end
144
197
  end
@@ -12,6 +12,7 @@ module Cumulus
12
12
  PATH = Common::DiffChange::next_change_id
13
13
  S3 = Common::DiffChange::next_change_id
14
14
  CUSTOM = Common::DiffChange::next_change_id
15
+ HEADERS = Common::DiffChange::next_change_id
15
16
  end
16
17
 
17
18
  # Public: Represents a single difference between local configuration and AWS
@@ -20,6 +21,7 @@ module Cumulus
20
21
  include OriginChange
21
22
 
22
23
  attr_accessor :custom_changes
24
+ attr_accessor :changed_headers
23
25
 
24
26
  # Public: Static method that produces a diff representing changes in custom origin
25
27
  #
@@ -33,6 +35,12 @@ module Cumulus
33
35
  diff
34
36
  end
35
37
 
38
+ def self.headers(changes, local)
39
+ diff = OriginDiff.new(HEADERS, nil, local)
40
+ diff.changed_headers = changes
41
+ diff
42
+ end
43
+
36
44
  def diff_string
37
45
  case @type
38
46
  when DOMAIN
@@ -61,6 +69,20 @@ module Cumulus
61
69
  c.to_s.lines.map { |l| "\t#{l.chomp}"}
62
70
  end).join("\n"),
63
71
  ].join("\n")
72
+ when HEADERS
73
+ [
74
+ "custom headers:",
75
+ @changed_headers.map do |h|
76
+ if h.type == ADD or h.type == UNMANAGED
77
+ h.to_s.lines.map{ |l| "\t#{l}".chomp("\n") }
78
+ else
79
+ [
80
+ "\t#{h.local_name}",
81
+ h.to_s.lines.map { |l| "\t\t#{l}".chomp("\n")}
82
+ ]
83
+ end
84
+ end
85
+ ].flatten.join("\n")
64
86
  end
65
87
  end
66
88
 
@@ -0,0 +1,34 @@
1
+ module AwsUtil
2
+ # Public: Static method that converts an array to an object that can be used in the
3
+ # AWS API (with quantity and items)
4
+ #
5
+ # arr - the array to convert
6
+ #
7
+ # Returns an object with quantity and items
8
+ def self.aws_array(arr)
9
+ if arr.nil? || arr.empty?
10
+ {
11
+ quantity: 0,
12
+ items: nil
13
+ }
14
+ else
15
+ {
16
+ quantity: arr.size,
17
+ items: arr
18
+ }
19
+ end
20
+ end
21
+
22
+ # Public: Static method that returns nil if an array is empty
23
+ #
24
+ # arr - an array to conver
25
+ #
26
+ # Returns nil if the array is empty, or the original array otherwise
27
+ def self.array_or_nil(arr)
28
+ if arr.nil? || arr.empty?
29
+ nil
30
+ else
31
+ arr
32
+ end
33
+ end
34
+ end
@@ -4,7 +4,7 @@ require "bundler"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "lucid-cumulus"
7
- s.version = "0.11.6"
7
+ s.version = "0.11.7"
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Keilan Jackson", "Mark Siebert"]
10
10
  s.email = "cumulus@lucidchart.com"
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  s.license = "Apache-2.0"
17
17
 
18
- s.add_runtime_dependency "aws-sdk", "2.2.30"
18
+ s.add_runtime_dependency "aws-sdk", "~> 2.6.3"
19
19
  s.add_runtime_dependency "parse-cron", "~> 0.1.4"
20
20
  s.add_runtime_dependency "deepsort", "~> 0.1"
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid-cumulus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.6
4
+ version: 0.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keilan Jackson
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-17 00:00:00.000000000 Z
12
+ date: 2016-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '='
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 2.2.30
20
+ version: 2.6.3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '='
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: 2.2.30
27
+ version: 2.6.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: parse-cron
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +114,8 @@ files:
114
114
  - lib/cloudfront/manager/Manager.rb
115
115
  - lib/cloudfront/models/CacheBehaviorConfig.rb
116
116
  - lib/cloudfront/models/CacheBehaviorDiff.rb
117
+ - lib/cloudfront/models/CustomHeaderConfig.rb
118
+ - lib/cloudfront/models/CustomHeaderDiff.rb
117
119
  - lib/cloudfront/models/CustomOriginConfig.rb
118
120
  - lib/cloudfront/models/CustomOriginDiff.rb
119
121
  - lib/cloudfront/models/DistributionConfig.rb
@@ -221,6 +223,7 @@ files:
221
223
  - lib/sqs/models/DeadLetterDiff.rb
222
224
  - lib/sqs/models/QueueConfig.rb
223
225
  - lib/sqs/models/QueueDiff.rb
226
+ - lib/util/AwsUtil.rb
224
227
  - lib/util/Colors.rb
225
228
  - lib/util/StatusCodes.rb
226
229
  - lib/vpc/Commands.rb