ecs_helper 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ecs_helper/command/deploy.rb +18 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abb3dcfdd4e42b2bf86e57422c59ceda2458f359e557cd0f782385c3e673ecf1
|
4
|
+
data.tar.gz: d036e9dbfac6b04133e2667f13e897b1e43cbad438d586904e53bb26b9536eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d4df5b95e14fce83d28822904a4822bc6f8074cd7895b950a18ac68675790e8d998b0c9fa22b985430b1a5684b026b63c1caa771263025517d5272d7e54837c
|
7
|
+
data.tar.gz: 26dd182dcb2b0bc3d437acb41d3c89f2513b6ec4944c28a971244fcce3bece4efb63261591aadd31a5c4088557cc440e5ccc699cc1e014598e3424db427fa7ef
|
@@ -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,20 +12,23 @@ 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
|
21
22
|
|
23
|
+
def timeout
|
24
|
+
|
22
25
|
def run
|
23
26
|
log("Command", type)
|
24
27
|
log("Options", options)
|
25
28
|
log("Environment", environment)
|
26
29
|
log("Cluster", cluster_arn)
|
27
30
|
log("Service", service_arn)
|
28
|
-
log("
|
31
|
+
log("Version", version)
|
29
32
|
log("Service task definition", task_definition_arn)
|
30
33
|
log("Containers", pretty_container_definitions)
|
31
34
|
log("New task definition", new_task_definition.task_definition_arn)
|
@@ -37,7 +40,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
37
40
|
def wait_for_deployment(time = 0)
|
38
41
|
service = helper.client.describe_service(cluster_arn, service_arn)
|
39
42
|
return true if service.deployments.count == 1
|
40
|
-
error("Deployment timeout (#{
|
43
|
+
error("Deployment timeout (#{timeout})") if time > timeout
|
41
44
|
sleep STEP
|
42
45
|
wait_for_deployment(time + STEP)
|
43
46
|
end
|
@@ -56,8 +59,12 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
56
59
|
helper.current_service
|
57
60
|
end
|
58
61
|
|
59
|
-
def
|
60
|
-
options[:
|
62
|
+
def version
|
63
|
+
options[:version] || helper.version
|
64
|
+
end
|
65
|
+
|
66
|
+
def timeout
|
67
|
+
options[:timeout] || DEFAULT_TIMEOUT
|
61
68
|
end
|
62
69
|
|
63
70
|
def service
|
@@ -80,8 +87,8 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
80
87
|
@repositories ||= client.private_repositories
|
81
88
|
end
|
82
89
|
|
83
|
-
def
|
84
|
-
client.describe_images({repository_name: repo.repository_name, image_ids: [image_tag:
|
90
|
+
def version_image(repo)
|
91
|
+
client.describe_images({repository_name: repo.repository_name, image_ids: [image_tag: version]})
|
85
92
|
rescue
|
86
93
|
nil
|
87
94
|
end
|
@@ -99,7 +106,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
99
106
|
def container_definition_to_ecr(cd)
|
100
107
|
repo = repo_for(cd.name)
|
101
108
|
is_ecr = cd.image.include?(ecr_base)
|
102
|
-
image = repo &&
|
109
|
+
image = repo && version_image(repo)
|
103
110
|
should_update = is_ecr && repo && image
|
104
111
|
[repo, is_ecr, image, should_update]
|
105
112
|
end
|
@@ -107,7 +114,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
107
114
|
def new_container_definitions
|
108
115
|
container_definitions.map do |cd|
|
109
116
|
repo, is_ecr, image, should_be_updated = container_definition_to_ecr(cd)
|
110
|
-
cd.image = "#{repo.repository_uri}:#{
|
117
|
+
cd.image = "#{repo.repository_uri}:#{version}" if should_be_updated
|
111
118
|
cd.to_hash
|
112
119
|
end
|
113
120
|
end
|
@@ -120,7 +127,7 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
|
|
120
127
|
cd.image,
|
121
128
|
is_ecr ? "ECR image" : "Not a ECR image",
|
122
129
|
repo ? "Repo #{repo.repository_name}" : "Repo not found",
|
123
|
-
image ? "Image
|
130
|
+
image ? "Image version #{version}" : "Image version #{version} not found",
|
124
131
|
should_be_updated ? "Will be updated" : "Not applicable"
|
125
132
|
].join(' | ')
|
126
133
|
end.join("\n")
|