Class: Cumulus::CloudFront::OriginDiff
- Inherits:
-
Cumulus::Common::Diff
- Object
- Cumulus::Common::Diff
- Cumulus::CloudFront::OriginDiff
- Includes:
- OriginChange
- Defined in:
- lib/cloudfront/models/OriginDiff.rb
Overview
Public: Represents a single difference between local configuration and AWS configuration of zones.
Constant Summary
Constants included from OriginChange
Cumulus::CloudFront::OriginChange::CUSTOM, Cumulus::CloudFront::OriginChange::DOMAIN, Cumulus::CloudFront::OriginChange::HEADERS, Cumulus::CloudFront::OriginChange::PATH, Cumulus::CloudFront::OriginChange::S3
Constants included from Cumulus::Common::DiffChange
Cumulus::Common::DiffChange::ADD, Cumulus::Common::DiffChange::MODIFIED, Cumulus::Common::DiffChange::UNMANAGED
Instance Attribute Summary collapse
-
#changed_headers ⇒ Object
Returns the value of attribute changed_headers.
-
#custom_changes ⇒ Object
Returns the value of attribute custom_changes.
Attributes inherited from Cumulus::Common::Diff
#aws, #changes, #info_only, #local, #type
Class Method Summary collapse
-
.custom(changes, aws, local) ⇒ Object
Public: Static method that produces a diff representing changes in custom origin.
- .headers(changes, local) ⇒ Object
Instance Method Summary collapse
Methods included from Cumulus::Common::DiffChange
Methods inherited from Cumulus::Common::Diff
#add_string, added, #initialize, modified, #to_s, unmanaged, #unmanaged_string
Constructor Details
This class inherits a constructor from Cumulus::Common::Diff
Instance Attribute Details
#changed_headers ⇒ Object
Returns the value of attribute changed_headers.
24 25 26 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 24 def changed_headers @changed_headers end |
#custom_changes ⇒ Object
Returns the value of attribute custom_changes.
23 24 25 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 23 def custom_changes @custom_changes end |
Class Method Details
.custom(changes, aws, local) ⇒ Object
Public: Static method that produces a diff representing changes in custom origin
changed_origins - the CustomOriginDiffs local - the local configuration for the zone
Returns the diff
32 33 34 35 36 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 32 def self.custom(changes, aws, local) diff = OriginDiff.new(CUSTOM, aws, local) diff.custom_changes = changes diff end |
.headers(changes, local) ⇒ Object
38 39 40 41 42 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 38 def self.headers(changes, local) diff = OriginDiff.new(HEADERS, nil, local) diff.changed_headers = changes diff end |
Instance Method Details
#asset_type ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 89 def asset_type if (!@local.nil? and @local.s3_access_origin_identity.nil?) or (!@aws.nil? and @aws.s3_origin_config.nil?) "Custom Origin" else "S3 Origin" end end |
#aws_name ⇒ Object
101 102 103 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 101 def aws_name @aws.id end |
#diff_string ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 44 def diff_string case @type when DOMAIN [ "domain:", Colors.aws_changes("\tAWS - #{@aws.domain_name}"), Colors.local_changes("\tLocal - #{@local.domain_name}"), ].join("\n") when PATH [ "path:", Colors.aws_changes("\tAWS - #{@aws.origin_path}"), Colors.local_changes("\tLocal - #{@local.origin_path}"), ].join("\n") when S3 aws_value = (@aws.s3_origin_config.origin_access_identity rescue nil) [ "s3 origin access identity:", Colors.aws_changes("\tAWS - #{aws_value}"), Colors.local_changes("\tLocal - #{@local.s3_access_origin_identity}"), ].join("\n") when CUSTOM [ "custom origin config:", (@custom_changes.flat_map do |c| c.to_s.lines.map { |l| "\t#{l.chomp}"} end).join("\n"), ].join("\n") when HEADERS [ "custom headers:", @changed_headers.map do |h| if h.type == ADD or h.type == UNMANAGED h.to_s.lines.map{ |l| "\t#{l}".chomp("\n") } else [ "\t#{h.local_name}", h.to_s.lines.map { |l| "\t\t#{l}".chomp("\n")} ] end end ].flatten.join("\n") end end |
#local_name ⇒ Object
97 98 99 |
# File 'lib/cloudfront/models/OriginDiff.rb', line 97 def local_name @local.id end |