Class: Belt::CLI::BackupConfig
- Inherits:
-
Object
- Object
- Belt::CLI::BackupConfig
- Defined in:
- lib/belt/cli/backup_config.rb
Defined Under Namespace
Classes: BackupDSL, ConfigDSL, ConfigEvaluator
Instance Attribute Summary collapse
-
#cognito_exports ⇒ Object
readonly
Returns the value of attribute cognito_exports.
-
#dynamodb_tables ⇒ Object
readonly
Returns the value of attribute dynamodb_tables.
-
#retention ⇒ Object
readonly
Returns the value of attribute retention.
-
#s3_buckets ⇒ Object
readonly
Returns the value of attribute s3_buckets.
Class Method Summary collapse
-
.load(env, infra_dir: nil) ⇒ Object
Load backup config from infrastructure/
/belt.rb Returns nil if no config file exists or backups aren't configured.
Instance Method Summary collapse
- #any? ⇒ Boolean
- #cognito? ⇒ Boolean
- #dynamodb? ⇒ Boolean
-
#initialize ⇒ BackupConfig
constructor
A new instance of BackupConfig.
Constructor Details
#initialize ⇒ BackupConfig
Returns a new instance of BackupConfig.
23 24 25 26 27 28 |
# File 'lib/belt/cli/backup_config.rb', line 23 def initialize @dynamodb_tables = nil # nil = not configured, :all = all tables, Array = specific tables @cognito_exports = [] # e.g. [:users, :pool_config] @s3_buckets = [] # e.g. [:legal_documents] @retention = { snapshots: 90, cognito: 10, s3: 10 } end |
Instance Attribute Details
#cognito_exports ⇒ Object (readonly)
Returns the value of attribute cognito_exports.
6 7 8 |
# File 'lib/belt/cli/backup_config.rb', line 6 def cognito_exports @cognito_exports end |
#dynamodb_tables ⇒ Object (readonly)
Returns the value of attribute dynamodb_tables.
6 7 8 |
# File 'lib/belt/cli/backup_config.rb', line 6 def dynamodb_tables @dynamodb_tables end |
#retention ⇒ Object (readonly)
Returns the value of attribute retention.
6 7 8 |
# File 'lib/belt/cli/backup_config.rb', line 6 def retention @retention end |
#s3_buckets ⇒ Object (readonly)
Returns the value of attribute s3_buckets.
6 7 8 |
# File 'lib/belt/cli/backup_config.rb', line 6 def s3_buckets @s3_buckets end |
Class Method Details
.load(env, infra_dir: nil) ⇒ Object
Load backup config from infrastructure/
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/belt/cli/backup_config.rb', line 10 def self.load(env, infra_dir: nil) infra_dir ||= 'infrastructure' config_file = File.join(infra_dir, env, 'belt.rb') return nil unless File.exist?(config_file) config = new evaluator = ConfigEvaluator.new(config) evaluator.evaluate(File.read(config_file), config_file) # Return nil if no backups were configured config.any? ? config : nil end |
Instance Method Details
#any? ⇒ Boolean
38 39 40 |
# File 'lib/belt/cli/backup_config.rb', line 38 def any? dynamodb? || cognito? || @s3_buckets.any? end |
#cognito? ⇒ Boolean
34 35 36 |
# File 'lib/belt/cli/backup_config.rb', line 34 def cognito? @cognito_exports.any? end |
#dynamodb? ⇒ Boolean
30 31 32 |
# File 'lib/belt/cli/backup_config.rb', line 30 def dynamodb? !@dynamodb_tables.nil? end |