Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit c4aa4c0

Browse files
committed
Add separate file for replace_properties
Also, created a script called process_html.sh which reads the amazon docs about resource properties and finds the ones that require replacement. This output can be pasted into the new replace_properties.rb file. Unfortunately, there's a lot of them (some which we may not need now but will later) so I had to disable rubocop whining about the class length. Also fixed some other rubocop issues.
1 parent d381448 commit c4aa4c0

File tree

4 files changed

+476
-23
lines changed

4 files changed

+476
-23
lines changed

lib/convection/model/diff.rb

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require_relative './mixin/colorize'
2+
require_relative './replace_properties'
23

34
module Convection
45
module Model
@@ -14,29 +15,23 @@ class Diff
1415
attr_reader :theirs
1516
colorize :action, :green => [:create], :yellow => [:update], :red => [:delete, :replace]
1617

17-
# Properties for which a change requires a replacement
18-
# (as opposed to an in-place update)
19-
REPLACE_PROPERTIES = [
20-
"AWS::Route53::HostedZone.Name",
21-
# TODO: Add more
22-
]
23-
2418
def initialize(key, ours, theirs)
2519
@key = key
2620
@ours = ours
2721
@theirs = theirs
2822

29-
@action = :delete
30-
if ours && theirs
31-
property_name = key[/AWS::[A-Za-z0-9:]+\.[A-Za-z0-9]+/]
32-
if REPLACE_PROPERTIES.include? property_name
33-
@action = :replace
34-
else
35-
@action = :update
36-
end
37-
elsif ours
38-
@action = :create
39-
end
23+
@action = if ours && theirs
24+
property_name = key[/AWS::[A-Za-z0-9:]+\.[A-Za-z0-9]+/]
25+
if REPLACE_PROPERTIES.include?(property_name)
26+
:replace
27+
else
28+
:update
29+
end
30+
elsif ours
31+
:create
32+
else
33+
:delete
34+
end
4035
end
4136

4237
def to_thor

0 commit comments

Comments
 (0)