From b7e36c3cf2567ec4f1917e49972d84d48268b740 Mon Sep 17 00:00:00 2001 From: Ross Dickey Date: Tue, 1 Nov 2016 21:28:39 -0500 Subject: [PATCH 1/3] Maintain backwards compatability with route53 Previously, users needed to specify the json for alias_target and geo_location for a route53_recordset. In the add-alb branch, merged in PR 214, this was changed in a backwards-incompatible way, requiring anyone who had previously specified json to now specify a block for the resource_property. Now, either way is acceptable. This is potentially a paradigm that can be used elsewhere, as there are many places where a resource_property would be appropriate, but has not existed and users have implemented the functionality directly with a json (or ruby hash) object. This will allow us to deprecate that method in favor of the more clean resource_property approach, without breaking everything in a 1.0 upgrade. --- .../model/template/resource/aws_route53_recordset.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/convection/model/template/resource/aws_route53_recordset.rb b/lib/convection/model/template/resource/aws_route53_recordset.rb index 4c291db..6e3ca9c 100644 --- a/lib/convection/model/template/resource/aws_route53_recordset.rb +++ b/lib/convection/model/template/resource/aws_route53_recordset.rb @@ -26,17 +26,29 @@ class Route53RecordSet < Resource property :record_type, 'Type' property :weight, 'Weight' + # Add new resource_property functionality def alias_target(&block) a = ResourceProperty::Route53AliasTarget.new(self) a.instance_exec(&block) if block properties['AliasTarget'].set(a) end + # Maintain backwards compatability + def alias_target(obj) + alias_tgt obj + end + + # Add new resource_property functionality def geo_location(&block) g = ResourceProperty::Route53GeoLocation.new(self) g.instance_exec(&block) if block properties['GeoLocation'].set(g) end + + # Maintain backwards compatability + def geo_location(obj) + geo_loc obj + end end end end From be50666b2c7a8f1f1a9fd36a5c14b83e526bdaab Mon Sep 17 00:00:00 2001 From: Ross Dickey Date: Wed, 2 Nov 2016 09:27:49 -0500 Subject: [PATCH 2/3] Use a single function def for blocks and sets --- .../resource/aws_route53_recordset.rb | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/convection/model/template/resource/aws_route53_recordset.rb b/lib/convection/model/template/resource/aws_route53_recordset.rb index 6e3ca9c..54331de 100644 --- a/lib/convection/model/template/resource/aws_route53_recordset.rb +++ b/lib/convection/model/template/resource/aws_route53_recordset.rb @@ -26,29 +26,30 @@ class Route53RecordSet < Resource property :record_type, 'Type' property :weight, 'Weight' - # Add new resource_property functionality - def alias_target(&block) - a = ResourceProperty::Route53AliasTarget.new(self) - a.instance_exec(&block) if block - properties['AliasTarget'].set(a) + def alias_target(tgt = nil, &block) + if tgt + # Maintain backwards compatability + alias_tgt tgt + else + # Add new resource_property functionality + a = ResourceProperty::Route53AliasTarget.new(self) + a.instance_exec(&block) if block + properties['AliasTarget'].set(a) + end end - # Maintain backwards compatability - def alias_target(obj) - alias_tgt obj + def geo_location(geo = nil, &block) + if geo + # Maintain backwards compatability + geo_loc geo + else + # Add new resource_property functionality + g = ResourceProperty::Route53GeoLocation.new(self) + g.instance_exec(&block) if block + properties['GeoLocation'].set(g) + end end - # Add new resource_property functionality - def geo_location(&block) - g = ResourceProperty::Route53GeoLocation.new(self) - g.instance_exec(&block) if block - properties['GeoLocation'].set(g) - end - - # Maintain backwards compatability - def geo_location(obj) - geo_loc obj - end end end end From b76cfcca28bdefd9e9b48c266877d2ff8153ba32 Mon Sep 17 00:00:00 2001 From: Ross Dickey Date: Wed, 2 Nov 2016 09:42:57 -0500 Subject: [PATCH 3/3] Delete a line to make Travis happy --- lib/convection/model/template/resource/aws_route53_recordset.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/convection/model/template/resource/aws_route53_recordset.rb b/lib/convection/model/template/resource/aws_route53_recordset.rb index 54331de..75b1bf5 100644 --- a/lib/convection/model/template/resource/aws_route53_recordset.rb +++ b/lib/convection/model/template/resource/aws_route53_recordset.rb @@ -49,7 +49,6 @@ def geo_location(geo = nil, &block) properties['GeoLocation'].set(g) end end - end end end