jackal-cfn 0.2.18 → 0.2.20

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
  SHA1:
3
- metadata.gz: d68462a480bb426c377656d7bc2ba63725dd1e61
4
- data.tar.gz: 35b702d77313eaead8aac1d61e66ddbdbfb55f5c
3
+ metadata.gz: bda5713d227f3483f95292f4c1d5637d2108e487
4
+ data.tar.gz: 64a6507a873182488b9a749b31158cb893441fd1
5
5
  SHA512:
6
- metadata.gz: a49947efa919dc54ded09b699239054a7648747b474d2317ae7bef30f82a980c2a06ec6274462956abbbb4824c56d62502365f3368bc9984230a01b789a857fd
7
- data.tar.gz: 0012138672f9a8c7eaccadba908166d0a053b441c292f11c6fa4de86b9caf1189efa8fa2af68ef72956f93208a2900718d5365114ee091570f10da4f06b61533
6
+ metadata.gz: 66d968cd6e691ec841d2cbdd45bbfc9631db91250ef1b26e93d6f280f58b01c63adbdbd3899762b8b3e11a8998c2b9aab0b2bfd2cf489b103be5194ebb2c4165
7
+ data.tar.gz: f3695b27166715d0cb32da79f4c13e1ae1b5ee7c474c211c123bb791aed6d1f39625fb45f1187fbd9c1906ac6b9062937575f5b5aec157e4dad07a602cfaf9ba
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v0.2.20
2
+ * [enhancement] Allow raw result removal from OrchestrationUnit resource
3
+
1
4
  # v0.2.18
2
5
  * [feature] Add OrchestrationUnit resource
3
6
 
data/README.md CHANGED
@@ -336,28 +336,31 @@ Resource Usage:
336
336
  "Env": {
337
337
  "CUSTOM_ENV_VARS": "FOR_COMMAND"
338
338
  },
339
+ "RawResult": true,
339
340
  "OnCreate": {
340
341
  "Exec": "STRING_COMMAND",
341
342
  "ExecZip": "REMOTE_URL_TO_ZIP",
342
343
  "Env": {
343
344
  "CUSTOM_ENV_VARS": "FOR_COMMAND"
344
- }
345
+ },
346
+ "RawResult": true
345
347
  },
346
348
  "OnUpdate": {
347
349
  "Exec": "STRING_COMMAND",
348
350
  "ExecZip": "REMOTE_URL_TO_ZIP",
349
351
  "Env": {
350
352
  "CUSTOM_ENV_VARS": "FOR_COMMAND"
351
- }
353
+ },
354
+ "RawResult": true
352
355
  },
353
356
  "OnDelete": {
354
357
  "Exec": "STRING_COMMAND",
355
358
  "ExecZip": "REMOTE_URL_TO_ZIP",
356
359
  "Env": {
357
360
  "CUSTOM_ENV_VARS": "FOR_COMMAND"
358
- }
359
- },
360
-
361
+ },
362
+ "RawResult": true
363
+ }
361
364
  }
362
365
  }
363
366
  ```
@@ -374,7 +377,7 @@ If command result is a non-JSON value:
374
377
 
375
378
  ```json
376
379
  {
377
- "OrchestrationUnitValue": "RESULT_OF_COMMAND"
380
+ "OrchestrationUnitResult": "RESULT_OF_COMMAND"
378
381
  }
379
382
  ```
380
383
 
@@ -383,7 +386,7 @@ If the result of the command is a JSON value (for example `{"MyKey": "MyValue"}`
383
386
  ```json
384
387
  {
385
388
  "MyKey": "MyValue",
386
- "OrchestrationUnitValue": "{\"MyKey\": \"MyValue\"}"
389
+ "OrchestrationUnitResult": "{\"MyKey\": \"MyValue\"}"
387
390
  }
388
391
  ```
389
392
 
@@ -12,31 +12,38 @@ module Jackal
12
12
  # "OnCreate": {
13
13
  # "Exec": "SHELL_COMMAND",
14
14
  # "ExecZip": "DOWNLOAD_URI",
15
+ # "RawResult": true,
15
16
  # "Env": {
16
17
  # }
17
18
  # },
18
19
  # "OnUpdate": {
19
20
  # "Exec": "SHELL_COMMAND",
20
21
  # "ExecZip": "DOWNLOAD_URI",
22
+ # "RawResult": true,
21
23
  # "Env": {
22
24
  # }
23
25
  # },
24
26
  # "OnDelete": {
25
27
  # "Exec": "SHELL_COMMAND",
26
28
  # "ExecZip": "DOWNLOAD_URI",
29
+ # "RawResult": true,
27
30
  # "Env": {
28
31
  # }
29
32
  # },
30
33
  # "Exec": "SHELL_COMMAND",
31
34
  # "ExecZip": "DOWNLOAD_URI",
32
35
  # "Env": {
33
- # }
36
+ # },
37
+ # "RawResult": true
34
38
  # }
35
39
  # }
36
40
  # }
37
41
  #
38
42
  class OrchestrationUnit < Jackal::Cfn::Resource
39
43
 
44
+ # Max result size
45
+ MAX_RESULT_SIZE = 4096
46
+
40
47
  # Execute orchestration unit
41
48
  #
42
49
  # @param message [Carnivore::Message]
@@ -124,11 +131,13 @@ module Jackal
124
131
  result[:stop_time] = Time.now.to_i
125
132
  result[:exit_code] = process.exit_code
126
133
  stdout.rewind
127
- # TODO: size check
128
- result[:content] = stdout.read
134
+ if(stdout.size > MAX_RESULT_SIZE)
135
+ warn "Command result greater than allowed size: #{stdout.size} > #{MAX_RESULT_SIZE}"
136
+ end
137
+ result[:content] = stdout.readpartial(0, MAX_RESULT_SIZE)
129
138
  if(process.exit_code != 0)
130
139
  stderr.rewind
131
- result[:error_message] = stderr.read
140
+ result[:error_message] = stderr.readpartial(0, MAX_RESULT_SIZE)
132
141
  end
133
142
  end
134
143
  if(result[:exit_code] == 0)
@@ -136,6 +145,9 @@ module Jackal
136
145
  begin
137
146
  j_result = MultiJson.load(result[:content])
138
147
  response['Data'] = j_result.merge(response['Data'])
148
+ unless(unit[:raw_result])
149
+ response['Data'].delete('OrchestrationUnitResult')
150
+ end
139
151
  rescue MultiJson::ParseError => e
140
152
  debug 'Command result not JSON data'
141
153
  end
@@ -158,7 +170,7 @@ module Jackal
158
170
  base_key = "on_#{request_type.to_s.downcase}"
159
171
  result = Smash.new
160
172
  if(direct_unit = parameters[base_key])
161
- [:exec, :exec_zip, :env].each do |p_key|
173
+ [:exec, :exec_zip, :env, :raw_result].each do |p_key|
162
174
  if(direct_unit[p_key])
163
175
  result[p_key] = direct[p_key]
164
176
  end
@@ -178,6 +190,9 @@ module Jackal
178
190
  result[:env] = parameters[:env]
179
191
  end
180
192
  end
193
+ unless(result.key?('raw_result'))
194
+ result[:raw_result] = parameters.fetch('raw_result', true)
195
+ end
181
196
  result[:env] ||= Smash.new
182
197
  result[:env]['CFN_REQUEST_TYPE'] = request_type.to_s.upcase
183
198
  result
@@ -1,6 +1,6 @@
1
1
  module Jackal
2
2
  module Cfn
3
3
  # Current version
4
- VERSION = Gem::Version.new('0.2.18')
4
+ VERSION = Gem::Version.new('0.2.20')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jackal-cfn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jackal