ecs_cmd 0.1.7 → 0.2.0

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: 0da13ec777258351bd19f2fd99c529ce5a65097e83206877cb908d7c863726a8
4
- data.tar.gz: 91472ab09eaba8f9d5aa434ab682ffb4dc12e4e8f06cbf420b40007fafd06ad3
3
+ metadata.gz: bbd91546f11022a99e9f90e2c24d9d4629e7cc2912ac367b4900a7931938b415
4
+ data.tar.gz: 4537970250ec0419bb6053df0bba185ac2ddb5bafd735caf5b7ff4cd090da2aa
5
5
  SHA512:
6
- metadata.gz: 9d33f77b41c7a40e01246312b4e4fc20477585bd0defe59f2f41305ef06d62a4e8c7ce25cb7a3f00e8ab0a2686eeceaf046ac5eb9051e2e38b4d6dcd7ed2d162
7
- data.tar.gz: 91233d643d6cdbe4455a9b77d3defc4c35d7ef9e97d278c8cb70fcb7e41b200b018948c401285b92103b811d96119261fbe5653941c0b34acda3993161a50240
6
+ metadata.gz: 330770b30f40ece1405ad8e5d4ca1e7197ceeb71bf6ea57c44823c89e1cb26b1b3871c7c404ed8a1b0cf379f9e7f586d2f56c28e8e7f0ef295f34210d1a7acf3
7
+ data.tar.gz: 469f151f365cd20cbaa15c6cc016f1fd49a888df8e09d025d783b5423b34f2cbb264dff8c3357ffe1814ed64c0b8f08295d5f9c2453bbc8bcbd561a720caaeed
@@ -1,4 +1,8 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  Metrics/LineLength:
2
4
  Max: 120
5
+ Metrics/MethodLength:
6
+ Max: 20
3
7
  Style/FrozenStringLiteralComment:
4
8
  Enabled: false
@@ -0,0 +1,299 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-03-16 16:50:28 -0700 using RuboCop version 0.80.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/OrderedDependencies:
14
+ Exclude:
15
+ - 'ecs_cmd.gemspec'
16
+
17
+ # Offense count: 1
18
+ # Cop supports --auto-correct.
19
+ Layout/CommentIndentation:
20
+ Exclude:
21
+ - 'lib/ecs_cmd/service.rb'
22
+
23
+ # Offense count: 3
24
+ # Cop supports --auto-correct.
25
+ # Configuration parameters: EnforcedStyle.
26
+ # SupportedStyles: leading, trailing
27
+ Layout/DotPosition:
28
+ Exclude:
29
+ - 'lib/ecs_cmd/utils.rb'
30
+
31
+ # Offense count: 1
32
+ # Cop supports --auto-correct.
33
+ Layout/EmptyLineAfterGuardClause:
34
+ Exclude:
35
+ - 'lib/ecs_cmd/utils.rb'
36
+
37
+ # Offense count: 4
38
+ # Cop supports --auto-correct.
39
+ # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
40
+ Layout/EmptyLineBetweenDefs:
41
+ Exclude:
42
+ - 'lib/ecs_cmd/service.rb'
43
+ - 'lib/ecs_cmd/task_definition.rb'
44
+
45
+ # Offense count: 1
46
+ # Cop supports --auto-correct.
47
+ Layout/EmptyLines:
48
+ Exclude:
49
+ - 'lib/ecs_cmd/task_definition.rb'
50
+
51
+ # Offense count: 1
52
+ # Cop supports --auto-correct.
53
+ # Configuration parameters: EnforcedStyle.
54
+ # SupportedStyles: empty_lines, no_empty_lines
55
+ Layout/EmptyLinesAroundBlockBody:
56
+ Exclude:
57
+ - 'spec/ecs_cmd/services_spec.rb'
58
+
59
+ # Offense count: 1
60
+ # Cop supports --auto-correct.
61
+ # Configuration parameters: EnforcedStyle.
62
+ # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
63
+ Layout/EmptyLinesAroundClassBody:
64
+ Exclude:
65
+ - 'lib/ecs_cmd/task_definition.rb'
66
+
67
+ # Offense count: 2
68
+ # Cop supports --auto-correct.
69
+ # Configuration parameters: IndentationWidth.
70
+ # SupportedStyles: special_inside_parentheses, consistent, align_brackets
71
+ Layout/FirstArrayElementIndentation:
72
+ EnforcedStyle: consistent
73
+
74
+ # Offense count: 2
75
+ # Cop supports --auto-correct.
76
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
77
+ # SupportedStyles: special_inside_parentheses, consistent, align_braces
78
+ Layout/FirstHashElementIndentation:
79
+ Exclude:
80
+ - 'spec/ecs_cmd/services_spec.rb'
81
+
82
+ # Offense count: 2
83
+ # Cop supports --auto-correct.
84
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
85
+ # SupportedHashRocketStyles: key, separator, table
86
+ # SupportedColonStyles: key, separator, table
87
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
88
+ Layout/HashAlignment:
89
+ Exclude:
90
+ - 'spec/ecs_cmd_spec.rb'
91
+
92
+ # Offense count: 1
93
+ # Cop supports --auto-correct.
94
+ # Configuration parameters: EnforcedStyle.
95
+ # SupportedStyles: normal, indented_internal_methods
96
+ Layout/IndentationConsistency:
97
+ Exclude:
98
+ - 'spec/ecs_cmd/services_spec.rb'
99
+
100
+ # Offense count: 2
101
+ # Cop supports --auto-correct.
102
+ # Configuration parameters: Width, IgnoredPatterns.
103
+ Layout/IndentationWidth:
104
+ Exclude:
105
+ - 'lib/ecs_cmd/service.rb'
106
+ - 'spec/ecs_cmd/services_spec.rb'
107
+
108
+ # Offense count: 1
109
+ # Cop supports --auto-correct.
110
+ Layout/LeadingEmptyLines:
111
+ Exclude:
112
+ - 'ecs_cmd.gemspec'
113
+
114
+ # Offense count: 11
115
+ # Cop supports --auto-correct.
116
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
117
+ # URISchemes: http, https
118
+ Layout/LineLength:
119
+ Max: 188
120
+
121
+ # Offense count: 2
122
+ # Cop supports --auto-correct.
123
+ Layout/SpaceAfterComma:
124
+ Exclude:
125
+ - 'bin/ecs-cmd'
126
+ - 'lib/ecs_cmd/utils.rb'
127
+
128
+ # Offense count: 1
129
+ # Cop supports --auto-correct.
130
+ # Configuration parameters: EnforcedStyle.
131
+ # SupportedStyles: space, no_space
132
+ Layout/SpaceAroundEqualsInParameterDefault:
133
+ Exclude:
134
+ - 'lib/ecs_cmd/task_definition.rb'
135
+
136
+ # Offense count: 4
137
+ # Cop supports --auto-correct.
138
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
139
+ # SupportedStyles: space, no_space
140
+ # SupportedStylesForEmptyBraces: space, no_space
141
+ Layout/SpaceInsideBlockBraces:
142
+ Exclude:
143
+ - 'Gemfile'
144
+ - 'lib/ecs_cmd/utils.rb'
145
+
146
+ # Offense count: 5
147
+ # Cop supports --auto-correct.
148
+ # Configuration parameters: EnforcedStyle.
149
+ # SupportedStyles: final_newline, final_blank_line
150
+ Layout/TrailingEmptyLines:
151
+ Exclude:
152
+ - 'lib/ecs_cmd/clusters.rb'
153
+ - 'lib/ecs_cmd/task_definition.rb'
154
+ - 'lib/ecs_cmd/utils.rb'
155
+ - 'spec/ecs_cmd/clusters_spec.rb'
156
+ - 'spec/ecs_cmd/services_spec.rb'
157
+
158
+ # Offense count: 5
159
+ # Cop supports --auto-correct.
160
+ # Configuration parameters: AllowInHeredoc.
161
+ Layout/TrailingWhitespace:
162
+ Exclude:
163
+ - 'lib/ecs_cmd.rb'
164
+ - 'lib/ecs_cmd/task_definition.rb'
165
+ - 'spec/spec_helper.rb'
166
+
167
+ # Offense count: 1
168
+ # Configuration parameters: MaximumRangeSize.
169
+ Lint/MissingCopEnableDirective:
170
+ Exclude:
171
+ - 'lib/ecs_cmd/service.rb'
172
+
173
+ # Offense count: 1
174
+ # Cop supports --auto-correct.
175
+ # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
176
+ Lint/UnusedBlockArgument:
177
+ Exclude:
178
+ - 'bin/ecs-cmd'
179
+
180
+ # Offense count: 1
181
+ # Configuration parameters: CheckForMethodsWithNoSideEffects.
182
+ Lint/Void:
183
+ Exclude:
184
+ - 'lib/ecs_cmd/task_definition.rb'
185
+
186
+ # Offense count: 4
187
+ Metrics/AbcSize:
188
+ Max: 23
189
+
190
+ # Offense count: 2
191
+ # Configuration parameters: CountComments, ExcludedMethods.
192
+ # ExcludedMethods: refine
193
+ Metrics/BlockLength:
194
+ Max: 71
195
+
196
+ # Offense count: 4
197
+ # Configuration parameters: CountComments, ExcludedMethods.
198
+ Metrics/MethodLength:
199
+ Max: 20
200
+
201
+ # Offense count: 2
202
+ Naming/AccessorMethodName:
203
+ Exclude:
204
+ - 'lib/ecs_cmd/clusters.rb'
205
+ - 'lib/ecs_cmd/services.rb'
206
+
207
+ # Offense count: 1
208
+ # Cop supports --auto-correct.
209
+ # Configuration parameters: PreferredName.
210
+ Naming/RescuedExceptionsVariableName:
211
+ Exclude:
212
+ - 'lib/ecs_cmd/run_task.rb'
213
+
214
+ # Offense count: 8
215
+ Style/Documentation:
216
+ Exclude:
217
+ - 'spec/**/*'
218
+ - 'test/**/*'
219
+ - 'lib/ecs_cmd/clusters.rb'
220
+ - 'lib/ecs_cmd/exec.rb'
221
+ - 'lib/ecs_cmd/run_task.rb'
222
+ - 'lib/ecs_cmd/service.rb'
223
+ - 'lib/ecs_cmd/services.rb'
224
+ - 'lib/ecs_cmd/task_definition.rb'
225
+ - 'lib/ecs_cmd/utils.rb'
226
+
227
+ # Offense count: 1
228
+ # Cop supports --auto-correct.
229
+ # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
230
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
231
+ Style/HashSyntax:
232
+ Exclude:
233
+ - 'Rakefile'
234
+
235
+ # Offense count: 1
236
+ # Cop supports --auto-correct.
237
+ Style/IfUnlessModifier:
238
+ Exclude:
239
+ - 'lib/ecs_cmd/task_definition.rb'
240
+
241
+ # Offense count: 1
242
+ # Cop supports --auto-correct.
243
+ # Configuration parameters: InverseMethods, InverseBlocks.
244
+ Style/InverseMethods:
245
+ Exclude:
246
+ - 'lib/ecs_cmd/utils.rb'
247
+
248
+ # Offense count: 2
249
+ Style/MixinUsage:
250
+ Exclude:
251
+ - 'bin/ecs-cmd'
252
+
253
+ # Offense count: 1
254
+ # Cop supports --auto-correct.
255
+ # Configuration parameters: EnforcedStyle.
256
+ # SupportedStyles: literals, strict
257
+ Style/MutableConstant:
258
+ Exclude:
259
+ - 'lib/ecs_cmd/version.rb'
260
+
261
+ # Offense count: 1
262
+ # Cop supports --auto-correct.
263
+ Style/Not:
264
+ Exclude:
265
+ - 'lib/ecs_cmd/utils.rb'
266
+
267
+ # Offense count: 2
268
+ # Cop supports --auto-correct.
269
+ Style/RedundantSelf:
270
+ Exclude:
271
+ - 'lib/ecs_cmd/task_definition.rb'
272
+ - 'lib/ecs_cmd/utils.rb'
273
+
274
+ # Offense count: 2
275
+ # Cop supports --auto-correct.
276
+ # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
277
+ # SupportedStyles: slashes, percent_r, mixed
278
+ Style/RegexpLiteral:
279
+ Exclude:
280
+ - 'lib/ecs_cmd/utils.rb'
281
+
282
+ # Offense count: 10
283
+ # Cop supports --auto-correct.
284
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
285
+ # SupportedStyles: single_quotes, double_quotes
286
+ Style/StringLiterals:
287
+ Exclude:
288
+ - 'Gemfile'
289
+ - 'Rakefile'
290
+ - 'bin/console'
291
+ - 'lib/ecs_cmd/version.rb'
292
+ - 'spec/spec_helper.rb'
293
+
294
+ # Offense count: 1
295
+ # Cop supports --auto-correct.
296
+ # Configuration parameters: MinSize, WordRegex.
297
+ # SupportedStyles: percent, brackets
298
+ Style/WordArray:
299
+ EnforcedStyle: brackets
@@ -5,4 +5,4 @@ env:
5
5
  rvm:
6
6
  - 2.4.3
7
7
  - 2.5.1
8
- before_install: gem install bundler -v 1.16.1
8
+ before_install: gem install bundler -v 2.1.4
@@ -1,3 +1,10 @@
1
+ # Next
2
+
3
+ # 0.2.0
4
+
5
+ - add --sudo flag to enable running docker commands with sudo, defaults to true
6
+ - Combine shell and exec commands. Pass a shell like `sh` or `bash` to interactively login to a container.
7
+
1
8
  # 0.1.7
2
9
 
3
10
  - bugfix: Run task did not work when task definition contained secrets.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ecs_cmd (0.1.7)
4
+ ecs_cmd (0.2.0)
5
5
  aws-sdk-ec2
6
6
  aws-sdk-ecs
7
7
  gli (= 2.18.0)
@@ -10,31 +10,47 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- aws-eventstream (1.0.1)
14
- aws-partitions (1.133.0)
15
- aws-sdk-core (3.46.0)
16
- aws-eventstream (~> 1.0)
17
- aws-partitions (~> 1.0)
18
- aws-sigv4 (~> 1.0)
13
+ ast (2.4.0)
14
+ aws-eventstream (1.0.3)
15
+ aws-partitions (1.286.0)
16
+ aws-sdk-core (3.92.0)
17
+ aws-eventstream (~> 1.0, >= 1.0.2)
18
+ aws-partitions (~> 1, >= 1.239.0)
19
+ aws-sigv4 (~> 1.1)
19
20
  jmespath (~> 1.0)
20
- aws-sdk-ec2 (1.67.0)
21
- aws-sdk-core (~> 3, >= 3.39.0)
22
- aws-sigv4 (~> 1.0)
23
- aws-sdk-ecs (1.28.0)
24
- aws-sdk-core (~> 3, >= 3.39.0)
25
- aws-sigv4 (~> 1.0)
26
- aws-sigv4 (1.0.3)
21
+ aws-sdk-ec2 (1.151.0)
22
+ aws-sdk-core (~> 3, >= 3.71.0)
23
+ aws-sigv4 (~> 1.1)
24
+ aws-sdk-ecs (1.59.0)
25
+ aws-sdk-core (~> 3, >= 3.71.0)
26
+ aws-sigv4 (~> 1.1)
27
+ aws-sigv4 (1.1.1)
28
+ aws-eventstream (~> 1.0, >= 1.0.2)
29
+ backport (0.3.0)
27
30
  coderay (1.1.2)
28
31
  diff-lcs (1.3)
29
32
  docile (1.3.1)
30
33
  gli (2.18.0)
34
+ htmlentities (4.3.4)
35
+ jaro_winkler (1.5.4)
31
36
  jmespath (1.4.0)
32
37
  json (2.1.0)
38
+ kramdown (1.17.0)
33
39
  method_source (0.9.0)
40
+ mini_portile2 (2.4.0)
41
+ nokogiri (1.10.9)
42
+ mini_portile2 (~> 2.4.0)
43
+ parallel (1.19.1)
44
+ parser (2.7.0.4)
45
+ ast (~> 2.4.0)
34
46
  pry (0.11.3)
35
47
  coderay (~> 1.1.0)
36
48
  method_source (~> 0.9.0)
37
- rake (10.5.0)
49
+ rainbow (3.0.0)
50
+ rake (12.3.3)
51
+ reverse_markdown (1.4.0)
52
+ nokogiri
53
+ rexml (3.2.4)
38
54
  rspec (3.7.0)
39
55
  rspec-core (~> 3.7.0)
40
56
  rspec-expectations (~> 3.7.0)
@@ -48,26 +64,50 @@ GEM
48
64
  diff-lcs (>= 1.2.0, < 2.0)
49
65
  rspec-support (~> 3.7.0)
50
66
  rspec-support (3.7.1)
67
+ rubocop (0.80.1)
68
+ jaro_winkler (~> 1.5.1)
69
+ parallel (~> 1.10)
70
+ parser (>= 2.7.0.1)
71
+ rainbow (>= 2.2.2, < 4.0)
72
+ rexml
73
+ ruby-progressbar (~> 1.7)
74
+ unicode-display_width (>= 1.4.0, < 1.7)
75
+ ruby-progressbar (1.10.1)
51
76
  simplecov (0.16.1)
52
77
  docile (~> 1.1)
53
78
  json (>= 1.8, < 3)
54
79
  simplecov-html (~> 0.10.0)
55
80
  simplecov-html (0.10.2)
81
+ solargraph (0.31.3)
82
+ backport (~> 0.3)
83
+ htmlentities (~> 4.3, >= 4.3.4)
84
+ jaro_winkler (~> 1.5)
85
+ kramdown (~> 1.16)
86
+ parser (~> 2.3)
87
+ reverse_markdown (~> 1.0, >= 1.0.5)
88
+ rubocop (~> 0.52)
89
+ thor (~> 0.19, >= 0.19.4)
90
+ tilt (~> 2.0)
91
+ yard (~> 0.9)
56
92
  terminal-table (1.8.0)
57
93
  unicode-display_width (~> 1.1, >= 1.1.1)
94
+ thor (0.20.3)
95
+ tilt (2.0.10)
58
96
  unicode-display_width (1.4.1)
97
+ yard (0.9.24)
59
98
 
60
99
  PLATFORMS
61
100
  ruby
62
101
  x86_64-darwin-17
63
102
 
64
103
  DEPENDENCIES
65
- bundler (~> 1.16)
104
+ bundler (~> 2.1)
66
105
  ecs_cmd!
67
106
  pry
68
- rake (~> 10.0)
107
+ rake (~> 12.3.3)
69
108
  rspec (~> 3.0)
70
109
  simplecov
110
+ solargraph
71
111
 
72
112
  BUNDLED WITH
73
- 1.16.3
113
+ 2.1.4
data/README.md CHANGED
@@ -15,8 +15,8 @@ The gem uses the standard aws crendential chain for authentication actions. See
15
15
 
16
16
  ## Usage
17
17
 
18
- ```
19
- ecs-cmd
18
+ ```text
19
+ $ ecs-cmd
20
20
  NAME
21
21
  ecs-cmd - Command utility for interacting with AWS ECS
22
22
 
@@ -47,8 +47,8 @@ These allow you to query information from ECS.
47
47
 
48
48
  #### Get Clusters
49
49
 
50
- ```
51
- ecs-cmd get clusters
50
+ ```text
51
+ $ ecs-cmd get clusters
52
52
  +--------------------+--------------------------+----------+---------------+---------------+
53
53
  | CLUSTER NAME | CONTAINER_INSTANCE_COUNT | SERVICES | RUNNING_TASKS | PENDING_TASKS |
54
54
  +--------------------+--------------------------+----------+---------------+---------------+
@@ -61,8 +61,8 @@ These allow you to query information from ECS.
61
61
 
62
62
  Prints an overview of the services in a given cluster.
63
63
 
64
- ```shella
65
- ecs-cmd get services --help
64
+ ```text
65
+ $ ecs-cmd get services --help
66
66
  NAME
67
67
  services -
68
68
 
@@ -73,8 +73,8 @@ COMMAND OPTIONS
73
73
  -c, --cluster=cluster - cluster name (required, default: none)
74
74
  ```
75
75
 
76
- ```shell
77
- ecs-cmd get services -c testing
76
+ ```text
77
+ $ ecs-cmd get services -c testing
78
78
  +--------------------+---------------+---------------+---------------+
79
79
  | SERVICE NAME | DESIRED_COUNT | RUNNING_COUNT | PENDING_COUNT |
80
80
  +--------------------+---------------+---------------+---------------+
@@ -87,8 +87,8 @@ ecs-cmd get services -c testing
87
87
 
88
88
  Get information on a specific service in a cluster.
89
89
 
90
- ```shell
91
- cs-cmd get service --help
90
+ ```text
91
+ $ ecs-cmd get service --help
92
92
  NAME
93
93
  service -
94
94
 
@@ -102,8 +102,8 @@ COMMAND OPTIONS
102
102
  -t, --[no-]task_definition - get current task definition for service
103
103
  ```
104
104
 
105
- ```shell
106
- ecs-cmd get service -c production -s foo
105
+ ```text
106
+ $ ecs-cmd get service -c production -s foo
107
107
  +------+--------+---------------+---------------+---------------+-------------+-------------+
108
108
  | NAME | STATUS | RUNNING COUNT | DESIRED COUNT | PENDING COUNT | MAX HEALTHY | MIN HEALTHY |
109
109
  +------+--------+---------------+---------------+---------------+-------------+-------------+
@@ -131,20 +131,24 @@ ecs-cmd get service -c production -s foo
131
131
  | running count | 2 |
132
132
  | created at | 2018-12-07 09:44:59 -0800 |
133
133
  | updated at | 2018-12-07 09:45:58 -0800 |
134
-
135
134
  +-----------------+----------------------------------------------------------------------+
135
+ +------------------------------------------------------------------------------+---------------------+---------------+
136
+ | TASK_ID | INSTANCE_ID | IP |
137
+ +------------------------------------------------------------------------------+---------------------+---------------+
138
+ | arn:aws:ecs:us-east-1:xxxxxxxxxxxx:task/50a84065-4bcf-4450-9a3b-3ee411bb3fb0 | i-xxxxxxxxxxxxxxxxx | 10.20.205.150 |
139
+ +------------------------------------------------------------------------------+---------------------+---------------+
136
140
  ```
137
141
 
138
142
  ### Logs
139
143
 
140
144
  **_works for ec2 type services only_**
141
145
 
142
- **_requires ssh access to instance_**
146
+ **_requires ssh access to instance and sudo or docker group membership_**
143
147
 
144
148
  Streams logs from 1 of a services running tasks using the docker logs command
145
149
 
146
- ```shell
147
- ecs-cmd logs --help
150
+ ```text
151
+ $ ecs-cmd logs --help
148
152
  NAME
149
153
  logs - Tail Logs From a Service's Container
150
154
 
@@ -155,6 +159,7 @@ COMMAND OPTIONS
155
159
  -c, --cluster=cluster - cluster name (required, default: none)
156
160
  -l, --lines=lines - number of historical lines to tail (default: 30)
157
161
  -s, --service=service - service name (required, default: none)
162
+ --[no-]sudo - use sudo for docker commands, necessary if not in docker group (default: enabled)
158
163
  ```
159
164
 
160
165
  ### Run Task
@@ -163,8 +168,8 @@ Run a one off task in ECS. This will poll for the task to exit and report its ex
163
168
  handy for tasks like rails migrations in ci/cd pipelines. If a docker image is passed it will create a new revision of
164
169
  the task definition prior to running the task.
165
170
 
166
- ```shell
167
- ecs-cmd run-task --help
171
+ ```text
172
+ $ ecs-cmd run-task --help
168
173
  NAME
169
174
  run-task - Run a One Off Task On an ECS Cluster
170
175
 
@@ -179,27 +184,28 @@ COMMAND OPTIONS
179
184
  -t, --task-definition=arg - the task definition to use for task (required, default: none)
180
185
  ```
181
186
 
182
- ### Shell
187
+ ### Exec
183
188
 
184
- **_works for ec2 type services only_**
189
+ **_works for ec2 type services only and requires sudo or docker group membership_**
185
190
 
186
191
  **_requires ssh access to instance_**
187
192
 
188
- Open a shell inside of a container for a given service.
193
+ Run a command inside a container for a given service. If a shell is given as a command (e.g. `sh`)
194
+ an interactive login terminal will be opened.
189
195
 
190
- ```shell
191
- ecs-cmd shell --help
196
+ ```text
197
+ $ ecs-cmd shell --help
192
198
  NAME
193
- shell - Open a Shell Inside a Service's Container
199
+ exec - Open a Shell Inside a Service's Container
194
200
 
195
201
  SYNOPSIS
196
- ecs-cmd [global options] shell [command options]
202
+ ecs-cmd [global options] exec [command options] command
197
203
 
198
204
  COMMAND OPTIONS
199
205
  -c, --cluster=cluster - cluster name (required, default: none)
200
206
  -s, --service=service - service name (required, default: none)
201
- --[no-]sh - use sh instead of bash
202
- -u, --user=user - user name or uid (default: root)
207
+ --[no-]sudo - use sudo for docker commands, necessary if not in docker group (default: enabled)
208
+ -u, --user=user - user name or uid of container user (default: root)
203
209
  ```
204
210
 
205
211
  ### SSH
@@ -210,8 +216,8 @@ COMMAND OPTIONS
210
216
 
211
217
  SSH onto a host where a container for a given service is running.
212
218
 
213
- ```shell
214
- ecs-cmd ssh --help
219
+ ```text
220
+ $ ecs-cmd ssh --help
215
221
  NAME
216
222
  ssh - SSH into Host Task is Running On
217
223
 
@@ -84,33 +84,20 @@ command :ssh do |c|
84
84
  end
85
85
  end
86
86
 
87
- desc 'Execute a Command Within a Service\'s Container'
87
+ desc "Open a Shell Inside a Service's Container"
88
88
  arg_name 'command', :required
89
- command :exec do |c|
89
+ command 'exec' do |c|
90
90
  c.flag %i[c cluster], desc: 'cluster name', arg_name: 'cluster', required: true
91
91
  c.flag %i[s service], desc: 'service name', arg_name: 'service', required: true
92
- c.flag %i[u user], desc: 'user name or uid', arg_name: 'user', default_value: 'root', required: false
92
+ c.flag %i[u user], desc: 'user name or uid of container user',
93
+ arg_name: 'user', default_value: 'root', required: false
94
+ c.switch %i[sudo], desc: 'use sudo for docker commands, necessary if not in docker group', default_value: true
93
95
  c.action do |global_options, options, args|
94
96
  service = EcsCmd::Service.new(options[:c], options[:s], global_options[:region])
95
97
  ip = service.container_instance_ips[0]
96
98
  task_family = service.task_family
97
99
  command = args.join(' ')
98
- EcsCmd::Exec.execute(task_family, ip, command, options[:u])
99
- end
100
- end
101
-
102
- desc "Open a Shell Inside a Service's Container"
103
- command 'shell' do |c|
104
- c.flag %i[c cluster], desc: 'cluster name', arg_name: 'cluster', required: true
105
- c.flag %i[s service], desc: 'service name', arg_name: 'service', required: true
106
- c.flag %i[u user], desc: 'user name or uid', arg_name: 'user', default_value: 'root', required: false
107
- c.switch %i[sh], desc: 'use sh instead of bash', default_value: false
108
- c.action do |global_options, options, args|
109
- service = EcsCmd::Service.new(options[:c], options[:s], global_options[:region])
110
- ip = service.container_instance_ips[0]
111
- task_family = service.task_family
112
- shell = options[:sh] ? 'sh' : 'bash'
113
- EcsCmd::Exec.shell(task_family, ip, shell, options[:u])
100
+ EcsCmd::Exec.execute(task_family, ip, command, options[:u], options[:sudo])
114
101
  end
115
102
  end
116
103
 
@@ -119,11 +106,12 @@ command 'logs' do |c|
119
106
  c.flag %i[c cluster], desc: 'cluster name', arg_name: 'cluster', required: true
120
107
  c.flag %i[s service], desc: 'service name', arg_name: 'service', required: true
121
108
  c.flag %i[l lines], desc: 'number of historical lines to tail', arg_name: 'lines', default_value: 30, required: false
122
- c.action do |global_options, options, args|
109
+ c.switch %i[sudo], desc: 'use sudo for docker commands, necessary if not in docker group', default_value: true
110
+ c.action do |global_options, options|
123
111
  service = EcsCmd::Service.new(options[:c], options[:s], global_options[:region])
124
112
  ip = service.container_instance_ips[0]
125
113
  task_family = service.task_family
126
- EcsCmd::Exec.logs(task_family, ip, options[:lines])
114
+ EcsCmd::Exec.logs(task_family, ip, options[:lines], options[:sudo])
127
115
  end
128
116
  end
129
117
  # desc 'Describe complete here'
@@ -36,8 +36,9 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency 'gli', '2.18.0'
37
37
  spec.add_runtime_dependency 'terminal-table'
38
38
 
39
- spec.add_development_dependency 'bundler', '~> 1.16'
40
- spec.add_development_dependency 'rake', '~> 10.0'
39
+ spec.add_development_dependency 'bundler', '~> 2.1'
40
+ spec.add_development_dependency 'rake', '~> 12.3.3'
41
+ spec.add_development_dependency 'solargraph'
41
42
  spec.add_development_dependency 'rspec', '~> 3.0'
42
43
  spec.add_development_dependency 'pry'
43
44
  spec.add_development_dependency 'simplecov'
@@ -16,30 +16,31 @@ module EcsCmd
16
16
  exec(ssh_cmd(ip))
17
17
  end
18
18
 
19
- # used to run arbitrary command inside a container
20
- def execute(task_family, ip, command, user = 'root')
21
- cmd = "docker exec -i -t -u #{user} `#{docker_ps_task(task_family)}` #{command}"
22
- Open3.popen2e(ssh_cmd(ip) + " '#{cmd}' ") do |stdin, stdout, stderr, status_thread|
23
- stdout.each_line do |line|
24
- puts line
25
- end
26
- end
27
- end
28
-
29
- # used to open a shell within a container?
30
- def shell(task_family, ip, shell = 'bash', user = 'root')
31
- cmd = "docker exec -i -t -u #{user} `#{docker_ps_task(task_family)}` #{shell}"
19
+ def execute(task_family, ip, command, user = 'root', sudo = true)
20
+ cmd = if sudo == true
21
+ "sudo docker exec -i -t -u #{user} `#{docker_ps_task(task_family)}` #{command}"
22
+ else
23
+ "docker exec -i -t -u #{user} `#{docker_ps_task(task_family)}` #{command}"
24
+ end
32
25
  exec(ssh_cmd(ip) + " '#{cmd}' ")
33
26
  end
34
27
 
35
- def logs(task_family, ip, lines)
36
- cmd = "docker logs -f --tail=#{lines} `#{docker_ps_task(task_family)}`"
28
+ def logs(task_family, ip, lines, sudo)
29
+ cmd = if sudo == true
30
+ "sudo docker logs -f --tail=#{lines} `#{docker_ps_task(task_family)}`"
31
+ else
32
+ "docker logs -f --tail=#{lines} `#{docker_ps_task(task_family)}`"
33
+ end
37
34
  exec(ssh_cmd(ip) + " '#{cmd}' ")
38
35
  end
39
36
 
40
37
  # docker ps command to get container id
41
- def docker_ps_task(task_family)
42
- "docker ps -n 1 -q --filter name=#{Shellwords.shellescape(task_family)}"
38
+ def docker_ps_task(task_family, sudo = true)
39
+ if sudo == true
40
+ "sudo docker ps -n 1 -q --filter name=#{Shellwords.shellescape(task_family)}"
41
+ else
42
+ "docker ps -n 1 -q --filter name=#{Shellwords.shellescape(task_family)}"
43
+ end
43
44
  end
44
45
  end
45
46
  end
@@ -3,6 +3,7 @@ require 'aws-sdk-ec2'
3
3
  require 'terminal-table'
4
4
 
5
5
  module EcsCmd
6
+ # rubocop:disable Metrics/ClassLength
6
7
  class Service
7
8
  def initialize(cluster, name, region)
8
9
  @client = Aws::ECS::Client.new(region: region)
@@ -63,11 +64,11 @@ module EcsCmd
63
64
  # TODO: improve this later
64
65
  @service_stats[0]['task_definition'].split('/')[1].split(':')[0]
65
66
  end
66
-
67
+ # list task arns for a service
67
68
  def tasks
68
69
  @client.list_tasks(cluster: @cluster, service_name: @name)[0]
69
70
  end
70
-
71
+ # list all container instance arns for given service's tasks
71
72
  def container_instances
72
73
  instances = []
73
74
  @client.describe_tasks(cluster: @cluster, tasks: tasks)[0].each do |e|
@@ -75,6 +76,14 @@ module EcsCmd
75
76
  end
76
77
  instances
77
78
  end
79
+ # return container instance arn for given task id
80
+ def container_instance(task_arn)
81
+ instance = []
82
+ @client.describe_tasks(cluster: @cluster, tasks: [task_arn])[0].each do |e|
83
+ instance << e[:container_instance_arn]
84
+ end
85
+ instance[0]
86
+ end
78
87
 
79
88
  def container_instance_id(arn)
80
89
  instance = [arn.to_s]
@@ -120,29 +129,45 @@ module EcsCmd
120
129
  @service_stats[0]['deployments'][0]['launch_type']
121
130
  end
122
131
 
123
- def list_container_instances
132
+ def tasks_table
124
133
  t = []
125
- container_instances.each do |e|
126
- t << [container_instance_id(e), container_instance_ip(container_instance_id(e))]
134
+ if launch_type == 'FARGATE'
135
+ tasks.each do |e|
136
+ t << [e]
137
+ end
138
+ table = Terminal::Table.new headings: ['TASK_ID'], rows: t
139
+ else
140
+ tasks.each do |e|
141
+ t << [e, container_instance_id(container_instance(e)),
142
+ container_instance_ip(container_instance_id(container_instance(e)))]
143
+ end
144
+ table = Terminal::Table.new headings: ['TASK_ID', 'INSTANCE_ID', 'IP'], rows: t
127
145
  end
128
- table = Terminal::Table.new headings: ['INSTANCE ID', 'IP'], rows: t
129
146
  table
130
147
  end
131
148
 
132
- def list_service
149
+ def overview_table
133
150
  row1 = []
134
151
  row1 << [name, status, running_count, desired_count, pending_count,
135
152
  deployment_configuration['maximum_percent'], deployment_configuration['minimum_healthy_percent']]
136
153
  table1 = Terminal::Table.new headings: ['NAME', 'STATUS', 'RUNNING COUNT',
137
154
  'DESIRED COUNT', 'PENDING COUNT',
138
155
  'MAX HEALTHY', 'MIN HEALTHY'], rows: row1
156
+ table1
157
+ end
158
+
159
+ def task_def_table
139
160
  row2 = []
140
161
  row2 << [task_definition]
141
162
  table2 = Terminal::Table.new headings: ['TASK DEFINITION'], rows: row2
142
- puts table1
143
- puts table2
144
- puts list_container_instances unless launch_type == 'FARGATE'
163
+ table2
164
+ end
165
+
166
+ def list_service
167
+ puts overview_table
168
+ puts task_def_table
145
169
  puts deployments
170
+ puts tasks_table
146
171
  end
147
172
  end
148
173
  end
@@ -45,7 +45,7 @@ module EcsCmd
45
45
  end
46
46
 
47
47
  def execution_role_arn
48
- @task_def['execution_role_arn']
48
+ @task_def['execution_role_arn'] || ''
49
49
  end
50
50
 
51
51
  def update_image(image)
@@ -56,12 +56,14 @@ module EcsCmd
56
56
  end
57
57
  end
58
58
  @new_task_def
59
- resp = register_task_definition(@new_task_def[:family], @new_task_def[:container_definitions], @new_task_def[:volumes], @new_task_def[:task_role_arn])
59
+ resp = register_task_definition(@new_task_def[:family], @new_task_def[:container_definitions],
60
+ @new_task_def[:volumes], @new_task_def[:task_role_arn])
60
61
  resp.task_definition.task_definition_arn
61
62
  end
62
63
 
63
64
  def register_task_definition(family, container_definitions, volumes, task_role_arn)
64
- @client.register_task_definition(family: family, container_definitions: container_definitions, volumes: volumes, task_role_arn: task_role_arn, execution_role_arn: execution_role_arn)
65
+ @client.register_task_definition(family: family, container_definitions: container_definitions, volumes: volumes,
66
+ task_role_arn: task_role_arn, execution_role_arn: execution_role_arn)
65
67
  end
66
68
 
67
69
  def print_json
@@ -1,3 +1,3 @@
1
1
  module EcsCmd
2
- VERSION = "0.1.7"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_cmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schaaff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2020-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ec2
@@ -72,28 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.16'
75
+ version: '2.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.16'
82
+ version: '2.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: 12.3.3
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: 12.3.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: solargraph
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rspec
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +161,7 @@ files:
147
161
  - ".gitignore"
148
162
  - ".rspec"
149
163
  - ".rubocop.yml"
164
+ - ".rubocop_todo.yml"
150
165
  - ".travis.yml"
151
166
  - CHANGELOG.md
152
167
  - CODE_OF_CONDUCT.md