Sha256: 7a554d76a145f1c78cfb713473c5d98e5c1f7986768492ca54ed3923ea44bc0d

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents


module Meroku
  module CLI
    class Session
      include Meroku::CLI
      include Meroku::Infrastructure

      attr_accessor :ec2_client, :token

      def initialize(*args)
        case args.join(" ")
        when "signup"
          signup
        when "create"
          Meroku::CLI::User.load_secrets(self) || exit
          create
        when "keys:add"
          Meroku::CLI::User.load_secrets(self) || exit
          keys_add(self)
        when "infrastructure spawn"
          Meroku::CLI::AdminUser.load_secrets(self) || exit
          spawn(self)
        when "infrastructure despawn"
          Meroku::CLI::AdminUser.load_secrets(self) || exit
          despawn
        else
          puts "Unknown command #{args.join(" ")}\n\n"
          puts help
        end


        #case args.join(" ")
        #  when "infrastructure spawn"
        #    load_secrets || exit
        #    node = Meroku::Infrastructure::Node.new.associate_address.install_packages.install_frontend_app
        #    puts "spawned #{node.instance.try(:instance_id)}"
        #  when "infrastructure despawn"
        #    load_secrets || exit
        #    Meroku::Infrastructure.despawn
        #  when "signup"
        #    signup
        #  when "keys:add"
        #    token_check || exit
        #    keys_add
        #  when "create"
        #    token_check || exit
        #    create
        #  else
        #    puts HELP
        #end      
      end

      def ec2_client
        @ec2_client ||= ::Aws::EC2::Client.new(
          region: 'us-east-1',
          credentials: ::Aws::Credentials.new(ENV['AWS_ACCESS_KEY'], ENV['AWS_SECRET'])
        )
        @ec2_client
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
meroku-2.0.8 lib/meroku/cli/session.rb
meroku-2.0.7 lib/meroku/cli/session.rb
meroku-2.0.6 lib/meroku/cli/session.rb
meroku-2.0.5 lib/meroku/cli/session.rb
meroku-2.0.4 lib/meroku/cli/session.rb