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
- #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 |
# 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) 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
#deploy_tag ⇒ Object
25 26 27 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 25 def deploy_tag production? ? 'production' : 'non-production' end |
#development? ⇒ Boolean
33 34 35 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 33 def development? !(%w(production staging).include?(env_name)) end |
#error_queue_url ⇒ Object
89 90 91 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 89 def error_queue_url @error_queue_url ||= AssetWala::SqsQueue.get_error_queue_url end |
#get_binding ⇒ Object
17 18 19 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 17 def get_binding binding end |
#image_name ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 42 def image_name if existing_image_name? existing_image_name else "redbubble/#{app_name}:master" end end |
#image_tag ⇒ Object
55 56 57 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 55 def image_tag image_name.split(':').last end |
#plain_text_secrets ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 67 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
29 30 31 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 29 def production? env_name == 'production' end |
#rails_env(name) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 59 def rails_env(name) if %w(development test cucumber demo staging production).include?(name) name else 'demo' end end |
#ruby_env ⇒ Object
37 38 39 40 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 37 def ruby_env return 'development' if development? env_name end |
#stack_name ⇒ Object
21 22 23 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 21 def stack_name "#{app_name}-#{env_name}" end |
#tagged_app_image(service_name) ⇒ Object
50 51 52 53 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 50 def tagged_app_image(service_name) service = docker_cloud_api.service_by_stack_and_service_name(stack_name, service_name) service ? service.image_name : "redbubble/#{app_name}:master" end |
#tags ⇒ Object
85 86 87 |
# File 'lib/kumo_dockercloud/environment_config.rb', line 85 def [deploy_tag] end |