sonic-screwdriver 2.2.1 → 2.2.6

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: ca0ee2f6b882f119c6e607c3de2c38391c8c17236f9ef892211cb55e887c7c95
4
- data.tar.gz: a4592ac7afc7d3c875be3f02b26f5a884d2bd09423f518cf53fc5b027c963436
3
+ metadata.gz: 29aac04bb7f8d0a6b49d6a30813edbcb2aeaab5616fc33e641f80343a0e6e821
4
+ data.tar.gz: 00d10d65f3e2ba80fb946ea67ef4c8ece025bfcd1f4283979e25634c0b0a0599
5
5
  SHA512:
6
- metadata.gz: e4c02076435af8641128a6487769362b4a3cb4f428a88fe07f14cb0455f8a5ab3bf80ea1950748b9ea0690307e7c38f4f779165e01a3e5279801ad798e4b279f
7
- data.tar.gz: f0a7a5cea95e05190b5cf2fe767cc212d49e4063b9cfd4e04c18fb95ed20f2ae4b59b7bfe5a245b1616750aba6eb562ab53cddc196034af98977f8c25af56845
6
+ metadata.gz: 5623fd72b4faa65edcb42e63b7210a5254752e6c909a2c3343cd23e68adfb954d623ddc4d4bd9915e5d578a492ec8d2772e7f96a69b351d1d2e61ab69adc9c5a
7
+ data.tar.gz: ff9854b28d81f8f094fbe1d087624797fd00c9d6cba4fe59acbaf86fa70f7483f41d0c7edb48e704c80c8aff97e03ceb619a6e371b226f507970f59e3225745c
data/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely* adheres to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [2.2.6] - 2021-04-30
7
+ - [#15](https://github.com/boltops-tools/sonic/pull/15) execution-timeout and delivery-timeout options and timeout sets both …
8
+
9
+ ## [2.2.5] - 2021-04-24
10
+ - [#14](https://github.com/boltops-tools/sonic/pull/14) execute --timeout option: executionTimeout
11
+
12
+ ## [2.2.4] - 2021-04-13
13
+ - [#13](https://github.com/boltops-tools/sonic/pull/13) execute --comment option
14
+
15
+ ## [2.2.3] - 2021-04-12
16
+ - [#12](https://github.com/boltops-tools/sonic/pull/12) fix cli check
17
+
18
+ ## [2.2.2] - 2021-04-12
19
+ - [#11](https://github.com/boltops-tools/sonic/pull/11) cli check
20
+
6
21
  ## [2.2.1] - 2021-04-12
7
22
  - [#9](https://github.com/boltops-tools/sonic/pull/9) improve command array handling
8
23
 
data/lib/sonic/cli.rb CHANGED
@@ -29,6 +29,10 @@ module Sonic
29
29
  # filter - Filter ec2 instances by tag name or instance_ids separated by commas
30
30
  option :instance_ids, desc: %Q|Instance ids to execute command on. Format: --instance-ids "i-111,i-222"|
31
31
  option :tags, desc: %Q|Tags used to determine what instances to execute command on. Format: --tags "Key1=v1,v2;Key2=v3"|
32
+ option :comment, desc: "comment. defaults to the sonic command used"
33
+ option :timeout, aliases: %w[t], desc: "timeout in seconds. defaults to nil which uses AWS-RunShellScript default of 3600"
34
+ option :execution_timeout, desc: "execution timeout in seconds. defaults to general timeout option"
35
+ option :delivery_timeout, desc: "delivery timeout in seconds. defaults to general timeout option"
32
36
  def execute(*command)
33
37
  Execute.new(command, options).execute
34
38
  end
data/lib/sonic/execute.rb CHANGED
@@ -53,18 +53,32 @@ module Sonic
53
53
  puts
54
54
  return if @options[:noop]
55
55
  status = wait(command_id)
56
- instances_found = display_ssm_output(command_id)
56
+ display_ssm_output(command_id)
57
57
  display_console_url(command_id)
58
58
 
59
59
  if status == "Success"
60
60
  puts "Command successful: #{status}".color(:green)
61
- exit(0)
61
+ exit_status(0)
62
62
  else
63
63
  puts "Command unsuccessful: #{status}".color(:red)
64
- exit(1)
64
+ exit_status(1)
65
65
  end
66
66
  end
67
67
 
68
+ def exit_status(code)
69
+ exit(code) if cli?
70
+
71
+ if code == 0
72
+ true
73
+ else
74
+ raise "Error running command"
75
+ end
76
+ end
77
+
78
+ def cli?
79
+ $0.include?('sonic')
80
+ end
81
+
68
82
  def wait(command_id)
69
83
  ongoing_states = ["Pending", "InProgress", "Delayed"]
70
84
 
@@ -183,10 +197,17 @@ module Sonic
183
197
  def build_ssm_options
184
198
  criteria = transform_filter_option
185
199
  command = build_command(@command)
200
+ comment = @options[:comment] || "sonic #{ARGV.join(' ')}"
201
+ comment = comment[0..99] # comment has a max of 100 chars
202
+
203
+ parameters = { "commands" => command }
204
+ t = @options[:execution_timeout] || @options[:timeout]
205
+ parameters[:executionTimeout] = [t] if t # weird but executionTimeout expects an Array
206
+
186
207
  options = criteria.merge(
187
208
  document_name: "AWS-RunShellScript", # default
188
- comment: "sonic #{ARGV.join(' ')}"[0..99], # comment has a max of 100 chars
189
- parameters: { "commands" => command },
209
+ comment: comment,
210
+ parameters: parameters,
190
211
  # Default CloudWatchLog settings. Can be overwritten with settings.yml send_command
191
212
  # IMPORTANT: make sure the EC2 instance the command runs on has access to write to CloudWatch Logs.
192
213
  cloud_watch_output_config: {
@@ -194,6 +215,10 @@ module Sonic
194
215
  cloud_watch_output_enabled: true,
195
216
  },
196
217
  )
218
+
219
+ t = @options[:execution_timeout] || @options[:timeout]
220
+ options[:timeout_seconds] = t if t
221
+
197
222
  settings_options = settings["send_command"] || {}
198
223
  options.merge(settings_options.deep_symbolize_keys)
199
224
  end
data/lib/sonic/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sonic
2
- VERSION = "2.2.1"
2
+ VERSION = "2.2.6"
3
3
  end
data/sonic.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = "http://sonic-screwdriver.cloud/"
13
13
  spec.license = "MIT"
14
14
 
15
- spec.files = `git ls-files`.split($/)
15
+ spec.files = File.directory?('.git') ? `git ls-files`.split($/) : Dir.glob("**/*")
16
16
  spec.bindir = "exe"
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sonic-screwdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport