class DockerRailsProxy::DataBags

Constants

EXCLUDE

Attributes

local_summary[RW]
options[RW]

Private Instance Methods

bucket_summary() click to toggle source
# File lib/docker_rails_proxy/commands/data_bags.rb, line 43
def bucket_summary
  summary = %x(
    aws s3 ls '#{options[:bucket]}' --summarize --recursive \
      --profile '#{options[:profile]}' | grep -v '^$' | sort -n
  ).strip.split("\n")

  # 0 => Total Size
  # 1 => Total Objects
  # last => last updated file
  (summary[ 0..1 ] << summary.last).map{|s| s.gsub(/\D/, ''.freeze) }.join('-')
end
exclude_args() click to toggle source
# File lib/docker_rails_proxy/commands/data_bags.rb, line 55
def exclude_args
  EXCLUDE.map{|s| "--exclude '#{s}'" }.join(' ')
end
opt_parser() click to toggle source
# File lib/docker_rails_proxy/commands/data_bags.rb, line 72
def opt_parser
  @opt_parser ||= OptionParser.new do |opts|
    opts.banner = "Usage: bin/#{APP_NAME} data-bags <pull|push> [options]"

    opts.on(
      '--profile [PROFILE]',
      "Aws profile (Default: #{APP_NAME})"
    ) { |profile| options[:profile] = profile }

    opts.on(
      '--bucket [BUCKET]',
      "AWS S3 Data bags bucket (Default: #{APP_NAME}-data-bags)"
    ) { |bucket| options[:bucket] = bucket }

    opts.on('-h', '--help', 'Display this screen') do
      puts opts
      exit
    end
  end
end
parse_options!() click to toggle source
# File lib/docker_rails_proxy/commands/data_bags.rb, line 68
def parse_options!
  opt_parser.parse!(arguments)
end
set_defaults() click to toggle source
# File lib/docker_rails_proxy/commands/data_bags.rb, line 59
def set_defaults
  options[:profile] ||= APP_NAME
  options[:bucket]  ||= "#{APP_NAME}-data-bags"

  options[:bucket_path]  = "s3://#{options[:bucket]}"
  options[:folder]       = build_path(".data-bags/#{options[:bucket]}")
  options[:summary_path] = "#{options[:folder]}/.summary"
end