Class: ElasticBeans::Command::GetEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_beans/command/get_env.rb

Overview

:nodoc: all

Constant Summary collapse

USAGE =
"getenv [KEY]..."
DESC =
"Fetch environment variables from the Elastic Beanstalk application"
LONG_DESC =
<<-LONG_DESC
Fetch environment variables from the Elastic Beanstalk application.
These are stored in S3 to avoid the 4096-byte limit on environment variables in Elastic Beanstalk.

Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
LONG_DESC

Instance Method Summary collapse

Constructor Details

#initialize(application:, ui:) ⇒ GetEnv

Returns a new instance of GetEnv.



14
15
16
17
# File 'lib/elastic_beans/command/get_env.rb', line 14

def initialize(application:, ui:)
  @application = application
  @ui = ui
end

Instance Method Details

#run(*env_vars) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/elastic_beans/command/get_env.rb', line 19

def run(*env_vars)
  outputs = application.env_vars.to_h.each_with_object([]) do |(key, value), acc|
    if env_vars.empty? || env_vars.include?(key)
      acc << "#{key}=#{value}"
    end
  end
  outputs.sort.each do |output|
    ui.info(output)
  end
end