Class: KumoDockerCloud::EnvironmentConfig
- Inherits:
-
Object
- Object
- KumoDockerCloud::EnvironmentConfig
- Defined in:
- lib/kumo_dockercloud/environment_config.rb
Constant Summary collapse
- LOGGER =
Logger.new(STDOUT)
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#env_name ⇒ Object
readonly
Returns the value of attribute env_name.
Instance Method Summary collapse
- #config ⇒ Object
- #deploy_tag ⇒ Object
- #development? ⇒ Boolean
- #error_queue_url ⇒ Object
- #get_binding ⇒ Object
- #image_name ⇒ Object
- #image_tag ⇒ Object
-
#initialize(options, logger = LOGGER) ⇒ EnvironmentConfig
constructor
A new instance of EnvironmentConfig.
- #plain_text_secrets ⇒ Object
- #production? ⇒ Boolean
- #rails_env(name) ⇒ Object
- #ruby_env ⇒ Object
- #stack_name ⇒ Object
- #tagged_app_image(service_name) ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(options, logger = LOGGER) ⇒ EnvironmentConfig
Returns a new instance of EnvironmentConfig.
10 11 12 13 14 15 16 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 10 def initialize(, logger = LOGGER) @env_name = .fetch(:env_name) @config_path = .fetch(:config_path) @log = logger @app_name = .fetch(:app_name) @app_image = .fetch(:app_image) end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
8 9 10 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 8 def app_name @app_name end |
#env_name ⇒ Object (readonly)
Returns the value of attribute env_name.
8 9 10 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 8 def env_name @env_name end |
Instance Method Details
#config ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 68 def config return @config if @config file = File.read(config_file_path) erb_result = ERB.new(file).result(get_binding) @config = YAML.load(erb_result) end |
#deploy_tag ⇒ Object
26 27 28 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 26 def deploy_tag production? ? 'production' : 'non-production' end |
#development? ⇒ Boolean
34 35 36 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 34 def development? !(%w(production staging).include?(env_name)) end |
#error_queue_url ⇒ Object
98 99 100 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 98 def error_queue_url @error_queue_url ||= AssetWala::SqsQueue.get_error_queue_url end |
#get_binding ⇒ Object
18 19 20 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 18 def get_binding binding end |
#image_name ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 43 def image_name if existing_image_name? existing_image_name else @app_image end end |
#image_tag ⇒ Object
56 57 58 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 56 def image_tag image_name.split(':').last end |
#plain_text_secrets ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 76 def plain_text_secrets @plain_text_secrets ||= Hash[ encrypted_secrets.map do |name, cipher_text| @log.info "Decrypting '#{name}'" if cipher_text.start_with? '[ENC,' begin [name, "#{kms.decrypt cipher_text[5, cipher_text.size]}"] rescue @log.error "Error decrypting secret '#{name}' from '#{encrypted_secrets_filename}'" raise end else [name, cipher_text] end end ] end |
#production? ⇒ Boolean
30 31 32 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 30 def production? env_name == 'production' end |
#rails_env(name) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 60 def rails_env(name) if %w(development test cucumber demo staging production).include?(name) name else 'demo' end end |
#ruby_env ⇒ Object
38 39 40 41 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 38 def ruby_env return 'development' if development? env_name end |
#stack_name ⇒ Object
22 23 24 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 22 def stack_name "#{app_name}-#{env_name}" end |
#tagged_app_image(service_name) ⇒ Object
51 52 53 54 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 51 def tagged_app_image(service_name) service = docker_cloud_api.service_by_stack_and_service_name(stack_name, service_name) service ? service.image_name : @app_image end |
#tags ⇒ Object
94 95 96 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 94 def [deploy_tag] end |