Class: Cumulus::S3::BucketDiff
- Inherits:
-
Common::Diff
- Object
- Common::Diff
- Cumulus::S3::BucketDiff
- Includes:
- Common::TagsDiff, BucketChange
- Defined in:
- lib/s3/models/BucketDiff.rb
Overview
Public: Represents a single difference between local configuration and AWS S3 bucket configuration
Constant Summary
Constants included from BucketChange
Cumulus::S3::BucketChange::CORS, Cumulus::S3::BucketChange::ENCRYPTION, Cumulus::S3::BucketChange::GRANTS, Cumulus::S3::BucketChange::LIFECYCLE, Cumulus::S3::BucketChange::LOGGING, Cumulus::S3::BucketChange::NOTIFICATIONS, Cumulus::S3::BucketChange::POLICY, Cumulus::S3::BucketChange::REPLICATION, Cumulus::S3::BucketChange::TAGS, Cumulus::S3::BucketChange::VERSIONING, Cumulus::S3::BucketChange::WEBSITE
Constants included from Common::DiffChange
Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED
Instance Attribute Summary collapse
-
#default_encryption ⇒ Object
Returns the value of attribute default_encryption.
-
#grants ⇒ Object
Returns the value of attribute grants.
-
#lifecycle ⇒ Object
Returns the value of attribute lifecycle.
-
#notifications ⇒ Object
Returns the value of attribute notifications.
-
#replication ⇒ Object
Returns the value of attribute replication.
Attributes inherited from Common::Diff
#aws, #changes, #info_only, #local, #type
Class Method Summary collapse
- .default_encryption_changes(default_encryption, local) ⇒ Object
-
.grant_changes(grants, local) ⇒ Object
Public: Static method that will create a diff representing changes in grants.
-
.lifecycle_changes(lifecycle, local) ⇒ Object
Public: Static method that will create a diff representing changes in lifecycle rules.
-
.notification_changes(notifications, local) ⇒ Object
Public: Static method that will create a diff representing changes in notifications.
-
.replication_changes(replication, local) ⇒ Object
Public: Static method that will create a diff representing changes in replication configuration.
Instance Method Summary collapse
-
#added_cors ⇒ Object
Public: Get the CORS rules to add.
- #asset_type ⇒ Object
- #aws_name ⇒ Object
- #diff_string ⇒ Object
-
#removed_cors ⇒ Object
Public: Get the CORS rules to remove.
Methods included from Common::TagsDiff
#tags_diff_string, #tags_to_add, #tags_to_remove
Methods included from Common::DiffChange
Methods inherited from Common::Diff
#add_string, added, #initialize, #local_name, modified, #to_s, unmanaged, #unmanaged_string
Constructor Details
This class inherits a constructor from Cumulus::Common::Diff
Instance Attribute Details
#default_encryption ⇒ Object
Returns the value of attribute default_encryption.
34 35 36 |
# File 'lib/s3/models/BucketDiff.rb', line 34 def default_encryption @default_encryption end |
#grants ⇒ Object
Returns the value of attribute grants.
30 31 32 |
# File 'lib/s3/models/BucketDiff.rb', line 30 def grants @grants end |
#lifecycle ⇒ Object
Returns the value of attribute lifecycle.
31 32 33 |
# File 'lib/s3/models/BucketDiff.rb', line 31 def lifecycle @lifecycle end |
#notifications ⇒ Object
Returns the value of attribute notifications.
32 33 34 |
# File 'lib/s3/models/BucketDiff.rb', line 32 def notifications @notifications end |
#replication ⇒ Object
Returns the value of attribute replication.
33 34 35 |
# File 'lib/s3/models/BucketDiff.rb', line 33 def replication @replication end |
Class Method Details
.default_encryption_changes(default_encryption, local) ⇒ Object
87 88 89 90 91 |
# File 'lib/s3/models/BucketDiff.rb', line 87 def self.default_encryption_changes(default_encryption, local) diff = BucketDiff.new(ENCRYPTION, nil, local) diff.default_encryption = default_encryption diff end |
.grant_changes(grants, local) ⇒ Object
Public: Static method that will create a diff representing changes in grants
grants - the grant changes local - the local configuration
Returns the diff
42 43 44 45 46 |
# File 'lib/s3/models/BucketDiff.rb', line 42 def self.grant_changes(grants, local) diff = BucketDiff.new(GRANTS, nil, local) diff.grants = grants diff end |
.lifecycle_changes(lifecycle, local) ⇒ Object
Public: Static method that will create a diff representing changes in lifecycle rules.
lifecycle - the lifecycle changes local - the local configuration
Returns the diff
68 69 70 71 72 |
# File 'lib/s3/models/BucketDiff.rb', line 68 def self.lifecycle_changes(lifecycle, local) diff = BucketDiff.new(LIFECYCLE, nil, local) diff.lifecycle = lifecycle diff end |
.notification_changes(notifications, local) ⇒ Object
Public: Static method that will create a diff representing changes in notifications.
notifications - the notification changes local - the local configuration
Returns the diff
55 56 57 58 59 |
# File 'lib/s3/models/BucketDiff.rb', line 55 def self.notification_changes(notifications, local) diff = BucketDiff.new(NOTIFICATIONS, nil, local) diff.notifications = notifications diff end |
.replication_changes(replication, local) ⇒ Object
Public: Static method that will create a diff representing changes in replication configuration.
replication - the replication configuration local - the local configuration
Returns the diff
81 82 83 84 85 |
# File 'lib/s3/models/BucketDiff.rb', line 81 def self.replication_changes(replication, local) diff = BucketDiff.new(REPLICATION, nil, local) diff.replication = replication diff end |
Instance Method Details
#added_cors ⇒ Object
Public: Get the CORS rules to add.
Returns an array of CORSRules.
169 170 171 |
# File 'lib/s3/models/BucketDiff.rb', line 169 def added_cors (@local.cors || []) - @aws.cors.rules end |
#asset_type ⇒ Object
151 152 153 |
# File 'lib/s3/models/BucketDiff.rb', line 151 def asset_type "Bucket" end |
#aws_name ⇒ Object
155 156 157 |
# File 'lib/s3/models/BucketDiff.rb', line 155 def aws_name @aws.name end |
#diff_string ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/s3/models/BucketDiff.rb', line 93 def diff_string case @type when CORS [ "CORS Rules:", removed_cors.map { |cors| Colors.removed("\t#{cors}") }, added_cors.map { |cors| Colors.added("\t#{cors}") } ].flatten.join("\n") when GRANTS [ "Grants:", grants.flat_map { |g| g.to_s.lines.map { |s| "\t#{s}" }.join }, ].flatten.join("\n") when LIFECYCLE [ "Lifecycle Rules:", lifecycle.flat_map { |n| n.to_s.lines.map { |s| "\t#{s}" }.join }, ].flatten.join("\n") when LOGGING [ "Logging Settings:", Colors.aws_changes("\tAWS\t- #{if @aws.logging.to_cumulus then @aws.logging.to_cumulus else "Not enabled" end}"), Colors.local_changes("\tLocal\t- #{if @local.logging then @local.logging else "Not enabled" end}") ].join("\n") when NOTIFICATIONS [ "Notifications:", notifications.flat_map { |n| n.to_s.lines.map { |s| "\t#{s}" }.join }, ].flatten.join("\n") when POLICY [ "Bucket Policy:", Colors.aws_changes("\tAWS\t- #{@aws.policy.policy_string}"), Colors.local_changes("\tLocal\t- #{@local.policy}") ].join("\n") when REPLICATION [ "Replication:", replication.flat_map { |r| r.to_s.lines.map { |s| "\t#{s}" }.join }, ].flatten.join("\n") when TAGS when VERSIONING "Versioning: AWS - #{Colors.aws_changes(@aws.versioning.enabled)}, Local - #{Colors.local_changes(@local.versioning)}" when WEBSITE [ "S3 Website Settings:", Colors.aws_changes("\tAWS\t- #{if @aws.website.to_cumulus then @aws.website.to_cumulus else "Not enabled" end}"), Colors.local_changes("\tLocal\t- #{if @local.website then @local.website else "Not enabled" end}"), ].join("\n") when ENCRYPTION [ "Default Encryption:", default_encryption.flat_map { |r| r.to_s.lines.map { |s| "\t#{s}" }.join }, ].flatten.join("\n") end end |
#removed_cors ⇒ Object
Public: Get the CORS rules to remove.
Returns an array of CORSRules
162 163 164 |
# File 'lib/s3/models/BucketDiff.rb', line 162 def removed_cors @aws.cors.rules - (@local.cors || []) end |