herdst_worker 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2da174a99ab5adb9ead51ce658fe766168a67f192c2b29c4dece4bb053497182
4
- data.tar.gz: 0623b5535cafcd7fa59b2de19ee8571d119e472940d692b9aa8dcfbb145aeaa8
3
+ metadata.gz: f923f35476bb893010b8dfe3fd0ecd8d60cfe599d21b187d1ef2c615e721a8c0
4
+ data.tar.gz: db24d82e075659d3cdb955e184f0504d44769f615341c53e33a8140ea022ed3d
5
5
  SHA512:
6
- metadata.gz: 873c462a26fc7dcec6c02b59e6a5bb3a4b08c52ccf7b06aa093d6db677fb858ef6ba0985cd4a3c07e3e3dc48a083d42732def672adde350db6e53f15638e637a
7
- data.tar.gz: 6bf8ff1584c6d7a2936d249b54f22ae85fe791cd4f196e3693f6d02e4ecd8ab21f6c18e3e5bf60c4ecf4b04ca5fb902e1b10dd23761ae398f9618adb3276a889
6
+ metadata.gz: 94aaf2d09122cdb0eb8b386cb91f3207d7cbb1a98dfc7ad3bbfecbcdedbded460162c73fd4d83daae306d885de83be76c517eb2efc27b0109c0c04302cf7cf12
7
+ data.tar.gz: 4c1a7e468c82f9467eb6a57d020d5e64057185b15399ab8c8debae202eca047d2fd7fcae5ebed9da67a4a277ffb513ce6de8d6cd0eb9581c76040b9f40fd6a07
@@ -60,6 +60,24 @@ module HerdstWorker
60
60
  def get_aws_credentials
61
61
  self.get_aws_credentials! rescue nil
62
62
  end
63
+
64
+
65
+ def get_tasks_info
66
+ metadata = make_request!(get_metadata_uri)
67
+
68
+ ecs_client = Aws::ECS::Client.new(
69
+ :region => self.secrets["AWS_REGION"],
70
+ :credentials => self.aws_credentials
71
+ )
72
+
73
+ ecs_client.describe_tasks(
74
+ :cluster => metadata["Cluster"],
75
+ :tasks => [
76
+ metadata["TaskARN"]
77
+ ],
78
+ :include => ["TAGS"]
79
+ )
80
+ end
63
81
 
64
82
 
65
83
  def get_aws_credentials!
@@ -103,28 +121,14 @@ module HerdstWorker
103
121
  return self.secrets["DEPLOYMENT_ENV"] if self.secrets["DEPLOYMENT_ENV"]
104
122
 
105
123
  if self.is_prod?
106
- metadata = make_request!(get_metadata_uri)
107
-
108
- ecs_client = Aws::ECS::Client.new(
109
- :region => self.secrets["AWS_REGION"],
110
- :credentials => self.aws_credentials
111
- )
112
-
113
- ecs_response = ecs_client.describe_tasks(
114
- :cluster => metadata["Cluster"],
115
- :tasks => [
116
- metadata["TaskARN"]
117
- ],
118
- :include => ["TAGS"]
119
- )
120
-
121
- ecs_response["tasks"][0]["tags"].each do |i|
124
+ info = self.get_tasks_info
125
+ info["tasks"][0]["tags"].each do |i|
122
126
  self[i["key"]] = i["value"]
123
127
  end
124
128
 
125
129
  report_error("Deployment env not found") unless self.secrets["DEPLOYMENT_ENV"]
126
130
 
127
- self["RELEASE_VERSION"] = ecs_response["tasks"][0]["containers"][0]["containerArn"] rescue nil
131
+ self["RELEASE_VERSION"] = info["tasks"][0]["containers"][0]["containerArn"] rescue nil
128
132
  else
129
133
  self["DEPLOYMENT_ENV"] = "development"
130
134
  end
@@ -92,6 +92,8 @@ module HerdstWorker
92
92
 
93
93
 
94
94
  def create_email_queue_message(template, company, message_data, attributes = nil, delay = 2)
95
+ company_key = company.class.name.downcase.to_sym
96
+
95
97
  # Convert instances of ApplicationRecord to attributes instead of json representation
96
98
  message_data.each do |key, value|
97
99
  message_data[key] = value.attributes if value.is_a?(ActiveRecord::Base)
@@ -108,8 +110,8 @@ module HerdstWorker
108
110
  data[:type] = "email"
109
111
  data[:template] = template
110
112
  data[:data] = message_data || {}
111
- data[:data][:company] = company unless data[:data][:company].present?
112
-
113
+ data[:data][company_key] = company unless data[:data][company_key].present?
114
+
113
115
  # Add message structure
114
116
  message = Hash.new
115
117
  message[:id] = SecureRandom.hex(32)
@@ -1,3 +1,3 @@
1
1
  module HerdstWorker
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herdst_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herd.St
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-18 00:00:00.000000000 Z
11
+ date: 2023-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport