Sha256: 3f9f7eee8802a119b51ed00f13193a107dd768f21f1b05a1b868fb022a5e71e0

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

module Heirloom
  module CLI
    class Authorize

      include Heirloom::CLI::Shared

      def initialize
        @opts = read_options
        @logger = HeirloomLogger.new :log_level => @opts[:level]
        @config = load_config :logger => @logger,
                              :opts   => @opts

        ensure_valid_options :provided => @opts,
                             :required => [:accounts, :name, :id],
                             :config   => @config

        ensure_domain_exists :name => @opts[:name], :config => @config

        @archive = Archive.new :name   => @opts[:name],
                               :id     => @opts[:id],
                               :config => @config
      end

      def authorize
        @archive.authorize @opts[:accounts]
      end

      private

      def read_options
        Trollop::options do
          version Heirloom::VERSION
          banner <<-EOS

Authorize access from another AWS account to an archive.

Usage:

heirloom authorize -n NAME -i ID -a AWS_ACCOUNT1 -a AWS_ACCOUNT2

Note: This will replace all current authorizations with those specified and make the archive private.

EOS
          opt :accounts, "AWS Account(s) email to authorize. Can be specified multiple times.", :type  => :string,
                                                                                                :multi => true
          opt :help, "Display Help"
          opt :id, "ID of the archive to authorize.", :type => :string
          opt :key, "AWS Access Key", :type => :string
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :secret, "AWS Secret Access Key", :type => :string
          opt :name, "Name of archive.", :type => :string
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heirloom-0.5.0rc2 lib/heirloom/cli/authorize.rb
heirloom-0.5.0rc1 lib/heirloom/cli/authorize.rb