Sha256: 2252117980741de1f5b40418d5046275e5e34e542d7814b0f2b6946bd00583aa
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
require 'optparse' require_relative 'options_parser/options' class RdsRotateDbSnapshots class OptionsParser class NotImplementedError < StandardError; end class InvalidArgument < StandardError; end include RdsRotateDbSnapshots::OptionsParser::Options attr_reader :options, :script_name, :time_periods def initialize(script_name: nil, cli: false) @script_name = script_name @options = { aws_access_key: ENV.fetch("AWS_ACCESS_KEY_ID", nil), aws_secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY", nil), aws_session_token: ENV.fetch("AWS_SESSION_TOKEN", nil), aws_region: ENV.fetch("AWS_REGION", nil), pattern: nil, by_tags: nil, dry_run: false, backoff_limit: 15, create_snapshot: nil } @time_periods = { hourly: { seconds: 60 * 60, format: '%Y-%m-%d-%H', keep: 0, keeping: {} }, daily: { seconds: 24 * 60 * 60, format: '%Y-%m-%d', keep: 0, keeping: {} }, weekly: { seconds: 7 * 24 * 60 * 60, format: '%Y-%W', keep: 0, keeping: {} }, monthly: { seconds: 30 * 24 * 60 * 60, format: '%Y-%m', keep: 0, keeping: {} }, yearly: { seconds: 12 * 30 * 24 * 60 * 60, format: '%Y', keep: 0, keeping: {} } } @cli = cli init_cli_parser if cli? end def parse! @parser.parse! @options.merge(time_periods: @time_periods) end private def cli? !!@cli end def init_cli_parser @parser ||= OptionParser.new do |o| banner_opts o aws_opts o snapshot_create_opts o time_period_opts o extra_opts o not_supported_opts o end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rds-rotate-db-snapshots-0.5.2 | lib/rds_rotate_db_snapshots/options_parser.rb |