Class: HerdstWorker::Configuration::Metadata
- Inherits:
-
Object
- Object
- HerdstWorker::Configuration::Metadata
- Defined in:
- lib/herdst_worker/configuration/metadata.rb
Instance Attribute Summary collapse
-
#aws_credentials ⇒ Object
Returns the value of attribute aws_credentials.
-
#config ⇒ Object
Returns the value of attribute config.
-
#config_suffix ⇒ Object
Returns the value of attribute config_suffix.
-
#secrets ⇒ Object
Returns the value of attribute secrets.
-
#secrets_suffix ⇒ Object
Returns the value of attribute secrets_suffix.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #get_aws_credentials ⇒ Object
- #get_aws_credentials! ⇒ Object
- #get_aws_region ⇒ Object
- #get_secrets ⇒ Object
-
#initialize(env, name, config) ⇒ Metadata
constructor
A new instance of Metadata.
- #reload! ⇒ Object
Constructor Details
#initialize(env, name, config) ⇒ Metadata
Returns a new instance of Metadata.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 16 def initialize(env, name, config) self.config = config self.config_suffix = "-#{name}-service-config" self.secrets_suffix = "-#{name}-service-secrets" self.secrets = {}.with_indifferent_access self.secrets["ENV"] = env begin self.reload! rescue Exception => ex raise ex unless self.is_prod? end end |
Instance Attribute Details
#aws_credentials ⇒ Object
Returns the value of attribute aws_credentials.
12 13 14 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 12 def aws_credentials @aws_credentials end |
#config ⇒ Object
Returns the value of attribute config.
12 13 14 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 12 def config @config end |
#config_suffix ⇒ Object
Returns the value of attribute config_suffix.
13 14 15 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 13 def config_suffix @config_suffix end |
#secrets ⇒ Object
Returns the value of attribute secrets.
12 13 14 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 12 def secrets @secrets end |
#secrets_suffix ⇒ Object
Returns the value of attribute secrets_suffix.
13 14 15 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 13 def secrets_suffix @secrets_suffix end |
Instance Method Details
#[](key) ⇒ Object
46 47 48 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 46 def [](key) self.secrets[key.to_s.upcase] end |
#[]=(key, value) ⇒ Object
51 52 53 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 51 def []=(key, value) self.secrets[key.to_s.upcase] = value end |
#get_aws_credentials ⇒ Object
56 57 58 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 56 def get_aws_credentials self.get_aws_credentials! rescue nil end |
#get_aws_credentials! ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 61 def get_aws_credentials! credentials = self.is_prod? ? make_request!(get_credentials_uri) : self.config.config_for(:aws) self.aws_credentials = Aws::Credentials.new( credentials["AccessKeyId"], credentials["SecretAccessKey"], credentials["Token"] ) Aws.config.update( region: self.get_aws_region, credentials: self.aws_credentials ) self.aws_credentials end |
#get_aws_region ⇒ Object
81 82 83 84 85 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 81 def get_aws_region # "ap-southeast-2" self["AWS_REGION"] = (ENV["AWS_REGION"] || "us-east-1") end |
#get_secrets ⇒ Object
41 42 43 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 41 def get_secrets self.secrets end |
#reload! ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/herdst_worker/configuration/metadata.rb', line 32 def reload! self.get_aws_credentials! self.set_task_info! self.get_config_and_secrets! self end |