ecs_helper 0.0.29 → 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9360d89edeb8333e9caf152cb45a4a1d6042c3f614ab0d6d5d45e8d6bcd6e61
4
- data.tar.gz: b3d2c66d829a1cf4b35e0d9dd476427287770fd14beb4e28729cc263d58ec878
3
+ metadata.gz: 871394ee1f21e808a91e123a5affccb713a0e7f44fcbb1d308bcc849eb97e992
4
+ data.tar.gz: bd42356f7c7984047d85e41810fd12a9aa5a0ef95e63fdab370c38ff20278117
5
5
  SHA512:
6
- metadata.gz: 20bc088dc9e4f3cbd8d04d83354faa39e3e319abcfe10335e0444fda5d755c32e883854f32a072c93f96129e98ba13b7d5dd53187a0b81dfc2cdcd3bc5bb8075
7
- data.tar.gz: b588b0c7003c7e08afd46ce196b04cae8756c0c7b2ba3aafabbbc20c9a9e99ef319fc952d14f23a4bd9b19291714d20843149d86bb50371f689218868d5de4f3
6
+ metadata.gz: 709ccc270f6143206e63d4f55b2ea68b556f8929407e0a44cf9bfd626595b39973a76ade7376072371bb17b965ee56e8340650fc44f22467c15fe4dbd28512c8
7
+ data.tar.gz: d7a5f1635642a612a3abe7c3c85887a91475c37fbe3f2bb2d15e8b793d39f7dff29018a55b85e12db43ca5a31ad36fcb3fdd539909bdc0ddce84a95c22eaa7d9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ecs_helper (0.0.29)
4
+ ecs_helper (0.0.33)
5
5
  aws-sdk-ecr (~> 1.42, >= 1.42)
6
6
  aws-sdk-ecrpublic (~> 1.3, >= 1.3)
7
7
  aws-sdk-ecs (~> 1.80, >= 1.80)
@@ -18,19 +18,19 @@ GEM
18
18
  ast (2.4.2)
19
19
  awesome_print (1.9.2)
20
20
  aws-eventstream (1.2.0)
21
- aws-partitions (1.503.0)
22
- aws-sdk-core (3.121.0)
21
+ aws-partitions (1.515.0)
22
+ aws-sdk-core (3.121.1)
23
23
  aws-eventstream (~> 1, >= 1.0.2)
24
24
  aws-partitions (~> 1, >= 1.239.0)
25
25
  aws-sigv4 (~> 1.1)
26
26
  jmespath (~> 1.0)
27
- aws-sdk-ecr (1.46.0)
27
+ aws-sdk-ecr (1.47.0)
28
28
  aws-sdk-core (~> 3, >= 3.120.0)
29
29
  aws-sigv4 (~> 1.1)
30
30
  aws-sdk-ecrpublic (1.6.0)
31
31
  aws-sdk-core (~> 3, >= 3.120.0)
32
32
  aws-sigv4 (~> 1.1)
33
- aws-sdk-ecs (1.85.0)
33
+ aws-sdk-ecs (1.86.0)
34
34
  aws-sdk-core (~> 3, >= 3.120.0)
35
35
  aws-sigv4 (~> 1.1)
36
36
  aws-sdk-ssm (1.0.0)
@@ -47,7 +47,7 @@ GEM
47
47
  rexml
48
48
  hashdiff (1.0.1)
49
49
  jmespath (1.4.0)
50
- json (2.5.1)
50
+ json (2.6.0)
51
51
  method_source (1.0.0)
52
52
  minitest (5.14.4)
53
53
  minitest-power_assert (0.3.1)
@@ -96,6 +96,7 @@ GEM
96
96
  hashdiff (>= 0.4.0, < 2.0.0)
97
97
 
98
98
  PLATFORMS
99
+ aarch64-linux
99
100
  x86_64-darwin-18
100
101
  x86_64-linux
101
102
 
data/ecs_helper.gemspec CHANGED
@@ -41,5 +41,4 @@ Gem::Specification.new do |s|
41
41
  s.add_runtime_dependency 'colorize', '~> 0.8', '>= 0.8'
42
42
  s.add_runtime_dependency 'json', '~> 2.5', '>= 2.5'
43
43
  s.add_runtime_dependency 'terrapin', '~> 0.6', '>= 0.6'
44
-
45
44
  end
@@ -24,6 +24,7 @@ class ECSHelper::Command::BuildAndPush < ECSHelper::Command::Base
24
24
  end
25
25
  opts.on('-c', '--cache', 'Cache image before build, default false') { options[:cache] = true }
26
26
  opts.on('--build-arg=VALUE', 'Pass --build-arg to the build command') { |o| options[:build_args] << o }
27
+ opts.on('-e', '--env-prefix', 'Add environment name as a prefix to the version tag, default false') { options[:env_prefix] = true }
27
28
  end
28
29
  [parser, options]
29
30
  end
@@ -90,7 +91,11 @@ class ECSHelper::Command::BuildAndPush < ECSHelper::Command::Base
90
91
  end
91
92
 
92
93
  def version_tag
93
- "#{repository}:#{helper.version}"
94
+ if options[:env_prefix]
95
+ "#{repository}:#{helper.environment}-#{helper.version}"
96
+ else
97
+ "#{repository}:#{helper.version}"
98
+ end
94
99
  end
95
100
 
96
101
  def project
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'terrapin'
4
+
5
+ class ECSHelper::Command::CheckExec < ECSHelper::Command::Base
6
+ def cmd_option_parser
7
+ options = { command: 'bash -c' }
8
+ parser = ::OptionParser.new do |opts|
9
+ opts.banner = 'Usage: ecs_helper check_exec'
10
+ opts.on('-p VALUE', '--project VALUE', "Set project name, if not specified will look at ENV['PROJECT'], will be used to detect cluster") do |p| options[:project] = processEqual(p) end
11
+ 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") do |a| options[:application] = processEqual(a) end
12
+ end
13
+ [parser, options]
14
+ end
15
+
16
+ def check_exec_bin
17
+ check_bin('check-ecs-exec')
18
+ end
19
+
20
+ def check_exec
21
+ exec_cmd = Terrapin::CommandLine.new("check-ecs-exec #{cluster_arn} #{task_arn}")
22
+ exec_cmd.run
23
+ end
24
+
25
+ def printable?
26
+ true
27
+ end
28
+
29
+ def run
30
+ log("Command", type)
31
+ log("Cluster", cluster_arn)
32
+ log("Service", service_arn)
33
+ log("Task", task_arn)
34
+ log("Options", options)
35
+ log("Check bin", check_exec_bin)
36
+ check_exec
37
+ end
38
+
39
+ private
40
+
41
+ def cluster_arn
42
+ helper.current_cluster
43
+ end
44
+
45
+ def service_arn
46
+ helper.current_service
47
+ end
48
+
49
+ def task_arn
50
+ @task_arn ||= helper.client.list_tasks({cluster: cluster_arn, service_name: service_arn, desired_status: "RUNNING"})[0]
51
+ end
52
+ end
@@ -4,7 +4,7 @@ require 'terrapin'
4
4
 
5
5
  class ECSHelper::Command::Exec < ECSHelper::Command::Base
6
6
  def cmd_option_parser
7
- options = { command: 'bash -c' }
7
+ options = { command: '/bin/bash' }
8
8
  parser = ::OptionParser.new do |opts|
9
9
  opts.banner = 'Usage: ecs_helper exec [options]. require session-manager-plugin and aws cli v2'
10
10
  opts.on('-p VALUE', '--project VALUE',
@@ -15,8 +15,8 @@ class ECSHelper::Command::Exec < ECSHelper::Command::Base
15
15
  "Set application name, if not specified will look at ENV['APPLICATION'], will be used to detect service and task definition") do |a|
16
16
  options[:application] = processEqual(a)
17
17
  end
18
- opts.on('-c', '--container VALUE', 'Cache image before build, default false') { |c| options[:container] = c }
19
- opts.on('--command VALUE', 'Command to execute') { |c| options[:command] = c }
18
+ opts.on('-c', '--container VALUE', 'Cache image before build, default false') { |c| options[:container] = processEqual(c) }
19
+ opts.on('--command VALUE', 'Command to execute') { |c| options[:command] = processEqual(c) }
20
20
  end
21
21
  [parser, options]
22
22
  end
@@ -45,38 +45,20 @@ class ECSHelper::Command::Exec < ECSHelper::Command::Base
45
45
  def check_aws_cli
46
46
  check_bin('aws')
47
47
  check_aws_cli_version
48
- "success"
49
48
  end
50
49
 
51
-
52
- def check_aws_cli_version
53
- check_cmd = Terrapin::CommandLine.new("aws --version")
54
- result = check_cmd.run
55
- version = parse_version(result)
56
- if version === "1"
57
- messages = [
58
- "Exec command requires aws cli v2".light_white,
59
- cmd_option_parser[0].help
60
- ]
61
- raise ECSHelper::Error::CommandValidationError.new(messages)
62
- end
50
+ def printable?
51
+ true
63
52
  end
64
53
 
65
54
  def run
66
- log("Command", type)
67
- log("Cluster", cluster_arn)
68
- log("Service", service_arn)
69
- log("Task", task_arn)
70
- log("Options", options)
71
- log("Check session-manager-plugin ", check_session_manager_plugin)
72
- log("Check aws cli version", check_aws_cli)
73
- exec
55
+ check_session_manager_plugin
56
+ check_aws_cli
57
+ exec_command
74
58
  end
75
59
 
76
- def exec
77
- exec_cmd = Terrapin::CommandLine.new("aws ecs execute-command --cluster #{cluster_arn} --task #{task_arn} --container=#{helper.options[:container]} --command=#{helper.options[:command]} --interactive")
78
- # --region us-east-1
79
- exec_cmd.run
60
+ def exec_command
61
+ "aws ecs execute-command --cluster #{cluster_arn} --task #{task_arn} --container #{helper.options[:container]} --command #{helper.options[:command]} --interactive"
80
62
  end
81
63
 
82
64
  private
@@ -6,6 +6,7 @@ class ECSHelper::Command
6
6
  autoload :ExportImages, 'ecs_helper/command/export_images'
7
7
  autoload :ECRLogin, 'ecs_helper/command/ecr_login'
8
8
  autoload :Exec, 'ecs_helper/command/exec'
9
+ autoload :CheckExec, 'ecs_helper/command/check_exec'
9
10
  autoload :RunCommand, 'ecs_helper/command/run_command'
10
11
  autoload :ExportEnvSecrets, 'ecs_helper/command/export_env_secrets'
11
12
 
@@ -17,6 +18,7 @@ class ECSHelper::Command
17
18
  "run_command" => RunCommand,
18
19
  "export_env_secrets" => ExportEnvSecrets,
19
20
  "exec" => Exec,
21
+ "check_exec" => CheckExec,
20
22
  }
21
23
  AVAILABLE_COMMANDS = CMD_MAPPING.keys
22
24
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ECSHelper
4
- VERSION = '0.0.29'
4
+ VERSION = '0.0.33'
5
5
  end
data/lib/ecs_helper.rb CHANGED
@@ -6,6 +6,8 @@ class ECSHelper
6
6
  extend Forwardable
7
7
  attr_accessor :options, :client, :command, :parser, :cluster_helper, :service_helper, :common_helper
8
8
 
9
+
10
+ autoload :VERSION, 'ecs_helper/version'
9
11
  autoload :Client, 'ecs_helper/client'
10
12
  autoload :CommonHelper, 'ecs_helper/common_helper'
11
13
  autoload :ClusterHelper, 'ecs_helper/cluster_helper'
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.29
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Petrov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -196,60 +196,60 @@ dependencies:
196
196
  name: aws-sdk-ecr
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - "~>"
200
200
  - !ruby/object:Gem::Version
201
201
  version: '1.42'
202
- - - "~>"
202
+ - - ">="
203
203
  - !ruby/object:Gem::Version
204
204
  version: '1.42'
205
205
  type: :runtime
206
206
  prerelease: false
207
207
  version_requirements: !ruby/object:Gem::Requirement
208
208
  requirements:
209
- - - ">="
209
+ - - "~>"
210
210
  - !ruby/object:Gem::Version
211
211
  version: '1.42'
212
- - - "~>"
212
+ - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: '1.42'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: aws-sdk-ecrpublic
217
217
  requirement: !ruby/object:Gem::Requirement
218
218
  requirements:
219
- - - ">="
219
+ - - "~>"
220
220
  - !ruby/object:Gem::Version
221
221
  version: '1.3'
222
- - - "~>"
222
+ - - ">="
223
223
  - !ruby/object:Gem::Version
224
224
  version: '1.3'
225
225
  type: :runtime
226
226
  prerelease: false
227
227
  version_requirements: !ruby/object:Gem::Requirement
228
228
  requirements:
229
- - - ">="
229
+ - - "~>"
230
230
  - !ruby/object:Gem::Version
231
231
  version: '1.3'
232
- - - "~>"
232
+ - - ">="
233
233
  - !ruby/object:Gem::Version
234
234
  version: '1.3'
235
235
  - !ruby/object:Gem::Dependency
236
236
  name: aws-sdk-ecs
237
237
  requirement: !ruby/object:Gem::Requirement
238
238
  requirements:
239
- - - ">="
239
+ - - "~>"
240
240
  - !ruby/object:Gem::Version
241
241
  version: '1.80'
242
- - - "~>"
242
+ - - ">="
243
243
  - !ruby/object:Gem::Version
244
244
  version: '1.80'
245
245
  type: :runtime
246
246
  prerelease: false
247
247
  version_requirements: !ruby/object:Gem::Requirement
248
248
  requirements:
249
- - - ">="
249
+ - - "~>"
250
250
  - !ruby/object:Gem::Version
251
251
  version: '1.80'
252
- - - "~>"
252
+ - - ">="
253
253
  - !ruby/object:Gem::Version
254
254
  version: '1.80'
255
255
  - !ruby/object:Gem::Dependency
@@ -270,60 +270,60 @@ dependencies:
270
270
  name: colorize
271
271
  requirement: !ruby/object:Gem::Requirement
272
272
  requirements:
273
- - - ">="
273
+ - - "~>"
274
274
  - !ruby/object:Gem::Version
275
275
  version: '0.8'
276
- - - "~>"
276
+ - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0.8'
279
279
  type: :runtime
280
280
  prerelease: false
281
281
  version_requirements: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - ">="
283
+ - - "~>"
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0.8'
286
- - - "~>"
286
+ - - ">="
287
287
  - !ruby/object:Gem::Version
288
288
  version: '0.8'
289
289
  - !ruby/object:Gem::Dependency
290
290
  name: json
291
291
  requirement: !ruby/object:Gem::Requirement
292
292
  requirements:
293
- - - ">="
293
+ - - "~>"
294
294
  - !ruby/object:Gem::Version
295
295
  version: '2.5'
296
- - - "~>"
296
+ - - ">="
297
297
  - !ruby/object:Gem::Version
298
298
  version: '2.5'
299
299
  type: :runtime
300
300
  prerelease: false
301
301
  version_requirements: !ruby/object:Gem::Requirement
302
302
  requirements:
303
- - - ">="
303
+ - - "~>"
304
304
  - !ruby/object:Gem::Version
305
305
  version: '2.5'
306
- - - "~>"
306
+ - - ">="
307
307
  - !ruby/object:Gem::Version
308
308
  version: '2.5'
309
309
  - !ruby/object:Gem::Dependency
310
310
  name: terrapin
311
311
  requirement: !ruby/object:Gem::Requirement
312
312
  requirements:
313
- - - ">="
313
+ - - "~>"
314
314
  - !ruby/object:Gem::Version
315
315
  version: '0.6'
316
- - - "~>"
316
+ - - ">="
317
317
  - !ruby/object:Gem::Version
318
318
  version: '0.6'
319
319
  type: :runtime
320
320
  prerelease: false
321
321
  version_requirements: !ruby/object:Gem::Requirement
322
322
  requirements:
323
- - - ">="
323
+ - - "~>"
324
324
  - !ruby/object:Gem::Version
325
325
  version: '0.6'
326
- - - "~>"
326
+ - - ">="
327
327
  - !ruby/object:Gem::Version
328
328
  version: '0.6'
329
329
  description: A simple gem which make CI CD process easier for AWS ECS service
@@ -349,6 +349,7 @@ files:
349
349
  - lib/ecs_helper/command.rb
350
350
  - lib/ecs_helper/command/base.rb
351
351
  - lib/ecs_helper/command/build_and_push.rb
352
+ - lib/ecs_helper/command/check_exec.rb
352
353
  - lib/ecs_helper/command/deploy.rb
353
354
  - lib/ecs_helper/command/ecr_login.rb
354
355
  - lib/ecs_helper/command/exec.rb
@@ -369,7 +370,7 @@ homepage: https://github.com/artempartos/ecs_helper
369
370
  licenses:
370
371
  - MIT
371
372
  metadata: {}
372
- post_install_message:
373
+ post_install_message:
373
374
  rdoc_options: []
374
375
  require_paths:
375
376
  - lib
@@ -384,8 +385,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
384
385
  - !ruby/object:Gem::Version
385
386
  version: '0'
386
387
  requirements: []
387
- rubygems_version: 3.0.3
388
- signing_key:
388
+ rubyforge_project:
389
+ rubygems_version: 2.7.6
390
+ signing_key:
389
391
  specification_version: 4
390
392
  summary: ECSHelper
391
393
  test_files: []