ecs_helper 0.0.5 → 0.0.10
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4e40c9c0050075171080514f957eeef76fce51e292c5305d2003005326ad1bb
|
4
|
+
data.tar.gz: f48a33a223c127b561f7e639834fa59c0b7c0ad96f42fc661af062e50ef6f439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 849243dae8979adaf2ee254edbe49142af2a96e32143472653f124030c8f5389d278ae55b26c063b6b05793f544e7d2183424d0630b0680761371e3dfb7b10d6
|
7
|
+
data.tar.gz: e4cc9793f2962554bfa56ccad5d0c4f7045eb098ff5d98be470be58dc97a03fec07966d23601085971baa94594c73698c603796dffdd85e28988717562aec322
|
@@ -32,7 +32,6 @@ class ECSHelper::Command::BuildAndPush < ECSHelper::Command::Base
|
|
32
32
|
def auth_public
|
33
33
|
auth_cmd = Terrapin::CommandLine.new("aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws")
|
34
34
|
auth_cmd.run
|
35
|
-
|
36
35
|
end
|
37
36
|
|
38
37
|
def auth_private
|
@@ -2,7 +2,7 @@ require 'terrapin'
|
|
2
2
|
|
3
3
|
class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
4
4
|
attr_accessor :repositories, :task_definition, :new_task_definition, :service
|
5
|
-
|
5
|
+
DEFAULT_TIMEOUT = 300
|
6
6
|
STEP = 5
|
7
7
|
|
8
8
|
def cmd_option_parser
|
@@ -12,9 +12,10 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
12
12
|
opts.on("-p VALUE", "--project VALUE", "Set project name, if not specified will look at ENV['PROJECT'], will be used to detect cluster") { |p| options[:project] = processEqual(p) }
|
13
13
|
opts.on("-a VALUE", "--application VALUE", "Set application name, if not specified will look at ENV['APPLICATION'], will be used to detect service and task definition") { |a| options[:application] = processEqual(a) }
|
14
14
|
opts.on("-e VALUE", "--environment VALUE", "Set environment, if not specified will look at ENV['ENVIRONMENT'], it there is empty will try to detect based on the branch") { |e| options[:environment] = processEqual(e) }
|
15
|
-
opts.on("-
|
15
|
+
opts.on("-v VALUE", "--version VALUE", "Set version which will be applied to all containers in the task if tag is present in the repo") { |t| options[:version] = processEqual(t) }
|
16
16
|
opts.on("-c VALUE", "--cluster VALUE", "Set cluster name, could be autodetected if project and environment are specified") { |c| options[:cluster] = processEqual(c) }
|
17
17
|
opts.on("-s VALUE", "--service VALUE", "Set service, could be autodetected if application and environment are specified") { |s| options[:service] = processEqual(s) }
|
18
|
+
opts.on("-t VALUE", "--timeout VALUE", "Set timeout how long to wait until deployment finished") { |t| options[:timeout] = processEqual(t) }
|
18
19
|
end
|
19
20
|
[parser, options]
|
20
21
|
end
|
@@ -25,7 +26,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
25
26
|
log("Environment", environment)
|
26
27
|
log("Cluster", cluster_arn)
|
27
28
|
log("Service", service_arn)
|
28
|
-
log("
|
29
|
+
log("Version", version)
|
29
30
|
log("Service task definition", task_definition_arn)
|
30
31
|
log("Containers", pretty_container_definitions)
|
31
32
|
log("New task definition", new_task_definition.task_definition_arn)
|
@@ -37,7 +38,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
37
38
|
def wait_for_deployment(time = 0)
|
38
39
|
service = helper.client.describe_service(cluster_arn, service_arn)
|
39
40
|
return true if service.deployments.count == 1
|
40
|
-
error("Deployment timeout (#{
|
41
|
+
error("Deployment timeout (#{timeout})") if time > timeout
|
41
42
|
sleep STEP
|
42
43
|
wait_for_deployment(time + STEP)
|
43
44
|
end
|
@@ -56,8 +57,12 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
56
57
|
helper.current_service
|
57
58
|
end
|
58
59
|
|
59
|
-
def
|
60
|
-
options[:
|
60
|
+
def version
|
61
|
+
options[:version] || helper.version
|
62
|
+
end
|
63
|
+
|
64
|
+
def timeout
|
65
|
+
options[:timeout] || DEFAULT_TIMEOUT
|
61
66
|
end
|
62
67
|
|
63
68
|
def service
|
@@ -77,11 +82,11 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
77
82
|
end
|
78
83
|
|
79
84
|
def repositories
|
80
|
-
@repositories ||= client.
|
85
|
+
@repositories ||= client.private_repositories
|
81
86
|
end
|
82
87
|
|
83
|
-
def
|
84
|
-
client.describe_images({repository_name: repo.repository_name, image_ids: [image_tag:
|
88
|
+
def version_image(repo)
|
89
|
+
client.describe_images({repository_name: repo.repository_name, image_ids: [image_tag: version]})
|
85
90
|
rescue
|
86
91
|
nil
|
87
92
|
end
|
@@ -99,7 +104,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
99
104
|
def container_definition_to_ecr(cd)
|
100
105
|
repo = repo_for(cd.name)
|
101
106
|
is_ecr = cd.image.include?(ecr_base)
|
102
|
-
image = repo &&
|
107
|
+
image = repo && version_image(repo)
|
103
108
|
should_update = is_ecr && repo && image
|
104
109
|
[repo, is_ecr, image, should_update]
|
105
110
|
end
|
@@ -107,7 +112,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
107
112
|
def new_container_definitions
|
108
113
|
container_definitions.map do |cd|
|
109
114
|
repo, is_ecr, image, should_be_updated = container_definition_to_ecr(cd)
|
110
|
-
cd.image = "#{repo.repository_uri}:#{
|
115
|
+
cd.image = "#{repo.repository_uri}:#{version}" if should_be_updated
|
111
116
|
cd.to_hash
|
112
117
|
end
|
113
118
|
end
|
@@ -120,7 +125,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
120
125
|
cd.image,
|
121
126
|
is_ecr ? "ECR image" : "Not a ECR image",
|
122
127
|
repo ? "Repo #{repo.repository_name}" : "Repo not found",
|
123
|
-
image ? "Image
|
128
|
+
image ? "Image version #{version}" : "Image version #{version} not found",
|
124
129
|
should_be_updated ? "Will be updated" : "Not applicable"
|
125
130
|
].join(' | ')
|
126
131
|
end.join("\n")
|
@@ -16,10 +16,16 @@ class ECSHelper::Command::ECRLogin < ECSHelper::Command::Base
|
|
16
16
|
|
17
17
|
def run
|
18
18
|
log("Command", type)
|
19
|
-
log("Auth",
|
19
|
+
log("Auth Private", auth_private)
|
20
|
+
log("Auth Public", auth_public)
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
+
def auth_public
|
24
|
+
auth_cmd = Terrapin::CommandLine.new("aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws")
|
25
|
+
auth_cmd.run
|
26
|
+
end
|
27
|
+
|
28
|
+
def auth_private
|
23
29
|
auth_cmd = Terrapin::CommandLine.new("aws ecr get-login --no-include-email | sh")
|
24
30
|
auth_cmd.run
|
25
31
|
end
|
@@ -18,12 +18,6 @@ class ECSHelper::Command::ExportImages < ECSHelper::Command::Base
|
|
18
18
|
puts export_images
|
19
19
|
end
|
20
20
|
|
21
|
-
def auth
|
22
|
-
auth_cmd = Terrapin::CommandLine.new("aws ecr get-login --no-include-email | sh")
|
23
|
-
auth_cmd.run
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
21
|
private
|
28
22
|
|
29
23
|
def project
|
@@ -35,7 +29,7 @@ class ECSHelper::Command::ExportImages < ECSHelper::Command::Base
|
|
35
29
|
end
|
36
30
|
|
37
31
|
def export_images
|
38
|
-
variables = (['export'] + client.
|
32
|
+
variables = (['export'] + client.private_repositories.map do |repo|
|
39
33
|
container_name = repo.repository_name.scan(/#{project}-#{application}-(.*)/).flatten.first
|
40
34
|
key = container_name.upcase.gsub("-", "_") + "_IMAGE"
|
41
35
|
value = "#{repo.repository_uri}:#{helper.version}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecs_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Petrov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-ecs
|