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

Commit

Permalink
Add separate file for replace_properties
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdickey committed Nov 7, 2016
1 parent d381448 commit c4aa4c0
Show file tree
Hide file tree
Showing 4 changed files with 476 additions and 23 deletions.
31 changes: 13 additions & 18 deletions lib/convection/model/diff.rb
@@ -1,4 +1,5 @@
require_relative './mixin/colorize'
require_relative './replace_properties'

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

# Properties for which a change requires a replacement
# (as opposed to an in-place update)
REPLACE_PROPERTIES = [
"AWS::Route53::HostedZone.Name",
# TODO: Add more
]

def initialize(key, ours, theirs)
@key = key
@ours = ours
@theirs = theirs

@action = :delete
if ours && theirs
property_name = key[/AWS::[A-Za-z0-9:]+\.[A-Za-z0-9]+/]
if REPLACE_PROPERTIES.include? property_name
@action = :replace
else
@action = :update
end
elsif ours
@action = :create
end
@action = if ours && theirs
property_name = key[/AWS::[A-Za-z0-9:]+\.[A-Za-z0-9]+/]
if REPLACE_PROPERTIES.include?(property_name)
:replace
else
:update
end
elsif ours
:create
else
:delete
end
end

def to_thor
Expand Down

0 comments on commit c4aa4c0

Please sign in to comment.