cem_acpt 0.11.0 → 0.11.2

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -0
  3. data/.worktreeinclude +1 -0
  4. data/CLAUDE.md +64 -25
  5. data/Gemfile.lock +1 -1
  6. data/README.md +20 -7
  7. data/docs/ARCHITECTURE.md +1042 -0
  8. data/docs/rfcs/0000-template.md +54 -0
  9. data/docs/rfcs/0001-fix-bolt-missing-skip-path.md +105 -0
  10. data/docs/rfcs/0002-fix-default-character-substitutions.md +119 -0
  11. data/docs/rfcs/0003-windows-image-builder-template.md +110 -0
  12. data/docs/rfcs/0004-image-name-truncation-off-by-one.md +108 -0
  13. data/docs/rfcs/0005-os-dispatch-replace-windows-heuristic.md +117 -0
  14. data/docs/rfcs/0006-configurable-windows-bucket.md +96 -0
  15. data/docs/rfcs/0007-logging-quiet-and-typos.md +121 -0
  16. data/docs/rfcs/0008-namespace-platform-classes.md +110 -0
  17. data/docs/rfcs/0009-bolt-log-formatter-cleanup.md +111 -0
  18. data/docs/rfcs/0010-dead-code-cleanup.md +83 -0
  19. data/docs/rfcs/0011-provisioner-factory-consistency.md +89 -0
  20. data/docs/rfcs/README.md +34 -0
  21. data/lib/cem_acpt/cli.rb +10 -1
  22. data/lib/cem_acpt/config/cem_acpt.rb +4 -1
  23. data/lib/cem_acpt/image_builder/errors.rb +24 -0
  24. data/lib/cem_acpt/image_builder/provision_commands.rb +15 -3
  25. data/lib/cem_acpt/image_builder.rb +29 -2
  26. data/lib/cem_acpt/image_name_builder.rb +8 -1
  27. data/lib/cem_acpt/platform/gcp.rb +112 -106
  28. data/lib/cem_acpt/platform.rb +21 -19
  29. data/lib/cem_acpt/provision/terraform/linux.rb +1 -1
  30. data/lib/cem_acpt/provision/terraform/os_data.rb +23 -0
  31. data/lib/cem_acpt/provision/terraform/windows.rb +7 -1
  32. data/lib/cem_acpt/provision/terraform.rb +20 -16
  33. data/lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb +2 -1
  34. data/lib/cem_acpt/test_runner/log_formatter.rb +0 -1
  35. data/lib/cem_acpt/test_runner.rb +21 -8
  36. data/lib/cem_acpt/utils/winrm_runner.rb +4 -3
  37. data/lib/cem_acpt/utils.rb +0 -12
  38. data/lib/cem_acpt/version.rb +1 -1
  39. data/lib/cem_acpt.rb +19 -7
  40. data/lib/terraform/gcp/linux/main.tf +6 -1
  41. data/lib/terraform/image/gcp/linux/main.tf +8 -1
  42. data/specifications/CEM-6713.md +165 -0
  43. data/specifications/CEM-6714.md +271 -0
  44. data/specifications/CEM-6715.md +133 -0
  45. data/specifications/CEM-6716.md +160 -0
  46. data/specifications/CEM-6717.md +239 -0
  47. data/specifications/CEM-6718.md +120 -0
  48. data/specifications/CEM-6719.md +173 -0
  49. metadata +26 -11
  50. data/.claude/settings.local.json +0 -7
  51. data/lib/cem_acpt/action_result.rb +0 -91
  52. data/lib/cem_acpt/puppet_helpers.rb +0 -38
  53. data/lib/cem_acpt/test_runner/log_formatter/bolt_error_formatter.rb +0 -65
  54. data/lib/cem_acpt/test_runner/log_formatter/bolt_output_formatter.rb +0 -54
@@ -0,0 +1,173 @@
1
+ # CEM-6719: Remove unreferenced top-level helpers and Windows placeholder
2
+
3
+ Implements [RFC 0010](../docs/rfcs/0010-dead-code-cleanup.md).
4
+
5
+ ## Summary
6
+
7
+ Delete dead code surfaced by the architecture audit (`docs/ARCHITECTURE.md` §19,
8
+ items 1–3) and refresh the doc to drop the items being removed:
9
+
10
+ 1. `lib/cem_acpt/puppet_helpers.rb` — superseded by `Utils::Puppet::ModulePackageBuilder`.
11
+ 2. `lib/cem_acpt/action_result.rb` — superseded by `TestRunner::TestResults::TestActionResult` /
12
+ `TestErrorActionResult`. Defines top-level `CemAcpt::ActionResult` /
13
+ `CemAcpt::ErrorActionResult` constants that shadow more useful names.
14
+ 3. `Provision::Windows#provision_commands` returning `['placeholder']` — inert
15
+ on the Windows path, which has no Terraform `remote-exec`.
16
+ 4. `Utils.package_win_module` — unused; confirmed via `git grep` (no callers
17
+ outside its own definition + docs).
18
+
19
+ ## Audit results
20
+
21
+ `git grep` performed against `lib/`, `exe/`, and `spec/`:
22
+
23
+ | Symbol | Hits outside its own file / docs |
24
+ |----------------------------------------------------|----------------------------------|
25
+ | `PuppetHelpers` | none |
26
+ | `puppet_helpers` | none (no `require_relative`s) |
27
+ | `CemAcpt::ActionResult` / `CemAcpt::ErrorActionResult` | none — `TestErrorActionResult` is a different class under `TestRunner::TestResults` |
28
+ | `action_result` (require) | none |
29
+ | `package_win_module` | none |
30
+ | `Provision::Windows#provision_commands` | called from `lib/cem_acpt/provision/terraform.rb:276` (handled below) |
31
+
32
+ ## Functional behavior
33
+
34
+ ### 1. Delete `lib/cem_acpt/puppet_helpers.rb`
35
+
36
+ - Remove the file outright. Nothing requires it.
37
+ - No code-level changes elsewhere needed.
38
+
39
+ ### 2. Delete `lib/cem_acpt/action_result.rb`
40
+
41
+ - Remove the file outright. Nothing requires it.
42
+ - The runner uses the namespaced `CemAcpt::TestRunner::TestResults::TestActionResult`
43
+ / `TestErrorActionResult` — these stay.
44
+
45
+ ### 3. Remove `Provision::Windows#provision_commands` placeholder
46
+
47
+ The base class `OsData#provision_commands` already raises `NotImplementedError`
48
+ (`lib/cem_acpt/provision/terraform/os_data.rb:117`). The Windows subclass
49
+ override at `lib/cem_acpt/provision/terraform/windows.rb:26-28` exists only to
50
+ satisfy the call at `lib/cem_acpt/provision/terraform.rb:276`, where the
51
+ Windows path threads `provision_commands` into the JSON `node_data` even
52
+ though the Windows `main.tf` (`lib/terraform/gcp/windows/main.tf:51-58`) does
53
+ not declare a `provision_commands` field on the `node_data` object type.
54
+
55
+ Approach:
56
+
57
+ - Replace the override with a method that raises `NotImplementedError` with a
58
+ descriptive message pointing at `Utils::WinRMRunner` and `ARCHITECTURE.md` §13:
59
+ ```ruby
60
+ def provision_commands
61
+ raise NotImplementedError,
62
+ 'Windows provisioning is performed via Utils::WinRMRunner, not via ' \
63
+ 'Terraform remote-exec. See ARCHITECTURE.md §13.'
64
+ end
65
+ ```
66
+ - Update `lib/cem_acpt/provision/terraform.rb:268-283` so the Windows backend
67
+ no longer triggers the call. Use a `case` on backend class:
68
+ ```ruby
69
+ provision_commands: case @backend
70
+ when CemAcpt::Provision::Linux
71
+ @backend.provision_commands_wrapper(node.node_data[:image])
72
+ when CemAcpt::Provision::Windows
73
+ []
74
+ else
75
+ @backend.provision_commands
76
+ end
77
+ ```
78
+ Passing `[]` (instead of dropping the key) keeps the merged-hash shape
79
+ identical to today (where `['placeholder']` is currently passed) — Terraform
80
+ silently ignores unknown attributes on the Windows `node_data` type.
81
+ - Net effect: the override now raises with a clear message if a future
82
+ contributor calls it, and the call site stops invoking it for Windows.
83
+
84
+ ### 4. Delete `Utils.package_win_module`
85
+
86
+ - Remove `lib/cem_acpt/utils.rb:17-26`. The `class << self ... include
87
+ CemAcpt::Logging ... end` block stays — `reset_password_readiness_polling`
88
+ / `get_windows_login_info` still need the `logger` accessor.
89
+ - The `require 'fileutils'` was implicitly relied on by `package_win_module`'s
90
+ `FileUtils.rm_f`; the remaining methods don't use FileUtils, so no require
91
+ needs to be added.
92
+
93
+ ### 5. Update `docs/ARCHITECTURE.md`
94
+
95
+ - §19: delete items 1, 2, 3 (the items resolved by this ticket). Renumber the
96
+ remaining items (4 → 1, 5 → 2, 6 → 3, 7 → 4) and update internal references
97
+ accordingly.
98
+ - File-tree (lines 70, 79): remove the `action_result.rb` and
99
+ `puppet_helpers.rb` entries.
100
+ - §14 (line 871): drop "unused `package_win_module`" from the parenthetical
101
+ describing `lib/cem_acpt/utils.rb`.
102
+ - §7 (lines 491-493): rephrase the "`Provision::Windows#provision_commands`
103
+ returns `['placeholder']`" note to reflect that the Windows backend no
104
+ longer threads commands through Terraform at all (call site dispatches on
105
+ backend class; method now raises).
106
+
107
+ ## Inputs / outputs / contracts
108
+
109
+ - No public-API surface change (these symbols are internal helpers with no
110
+ external callers).
111
+ - `Provision::Terraform#provision_node_data` continues to produce the same
112
+ JSON shape — for Windows, `provision_commands` becomes `[]` instead of
113
+ `['placeholder']`.
114
+
115
+ ## Edge cases
116
+
117
+ - A future contributor invokes `Provision::Windows.new(...).provision_commands`
118
+ directly: now raises a descriptive `NotImplementedError` instead of returning
119
+ silently-misleading `['placeholder']`.
120
+ - Anything that `require`'d `cem_acpt/puppet_helpers` or `cem_acpt/action_result`
121
+ externally would break — but `git grep` confirms no such consumer exists in
122
+ the repo, and these are internal (the gem's lib root does not auto-require
123
+ them).
124
+
125
+ ## Constraints / invariants
126
+
127
+ - RuboCop must remain clean (200-char line limit, the existing permissive
128
+ `.rubocop.yml`).
129
+ - `bundle exec rake spec` must pass.
130
+ - The Windows test-node provisioning flow continues to work: Terraform
131
+ applies, then `Utils::WinRMRunner` does the real work.
132
+
133
+ ## Error handling
134
+
135
+ - Removing `puppet_helpers.rb` / `action_result.rb`: file deletions, nothing
136
+ to handle.
137
+ - The new `NotImplementedError` message in `Provision::Windows#provision_commands`
138
+ is descriptive and points at the relevant subsystem.
139
+
140
+ ## Non-goals
141
+
142
+ - Filling in `lib/terraform/image/gcp/windows/` (RFC 0003, §19 item 7).
143
+ - Wiring up `BoltOutputFormatter` / `BoltErrorFormatter` (§19 item 6).
144
+ - Making the `provisioner` static-option configurable (§19 item 4).
145
+ - Any other §19 item beyond 1, 2, 3.
146
+
147
+ ## Acceptance criteria
148
+
149
+ - [ ] `lib/cem_acpt/puppet_helpers.rb` deleted; `git grep PuppetHelpers
150
+ lib/ exe/ spec/` returns no matches.
151
+ - [ ] `lib/cem_acpt/action_result.rb` deleted; `git grep CemAcpt::ActionResult
152
+ lib/ exe/ spec/` returns no matches.
153
+ - [ ] `Provision::Windows#provision_commands` no longer returns
154
+ `['placeholder']`; raises `NotImplementedError` with a descriptive
155
+ message instead.
156
+ - [ ] `Provision::Terraform#provision_node_data` does not call
157
+ `provision_commands` on a Windows backend.
158
+ - [ ] `Utils.package_win_module` removed.
159
+ - [ ] `docs/ARCHITECTURE.md` §19 items 1, 2, 3 removed; remaining items
160
+ renumbered; file-tree and §14 references to deleted symbols cleaned up;
161
+ §7 Windows note updated.
162
+ - [ ] `bundle exec rake spec` passes.
163
+ - [ ] `rubocop` is clean against the changed files.
164
+
165
+ ## Test plan
166
+
167
+ - Existing specs cover `Utils::Puppet::ModulePackageBuilder` (the live
168
+ replacement for the deleted `PuppetHelpers::Module`) and
169
+ `TestRunner::TestResults` (the live replacement for the deleted top-level
170
+ `ActionResult`). No new unit tests are needed for deletions of unused code.
171
+ - Add a small spec for `Provision::Windows#provision_commands` confirming it
172
+ raises `NotImplementedError` with the expected message — locks in the new
173
+ behavior so a future contributor doesn't reintroduce a placeholder.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_acpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-03-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: async-http
@@ -223,11 +222,11 @@ executables:
223
222
  extensions: []
224
223
  extra_rdoc_files: []
225
224
  files:
226
- - ".claude/settings.local.json"
227
225
  - ".github/workflows/spec.yml"
228
226
  - ".gitignore"
229
227
  - ".rspec"
230
228
  - ".rubocop.yml"
229
+ - ".worktreeinclude"
231
230
  - CLAUDE.md
232
231
  - CODEOWNERS
233
232
  - Gemfile
@@ -237,10 +236,23 @@ files:
237
236
  - bin/console
238
237
  - bin/setup
239
238
  - cem_acpt.gemspec
239
+ - docs/ARCHITECTURE.md
240
+ - docs/rfcs/0000-template.md
241
+ - docs/rfcs/0001-fix-bolt-missing-skip-path.md
242
+ - docs/rfcs/0002-fix-default-character-substitutions.md
243
+ - docs/rfcs/0003-windows-image-builder-template.md
244
+ - docs/rfcs/0004-image-name-truncation-off-by-one.md
245
+ - docs/rfcs/0005-os-dispatch-replace-windows-heuristic.md
246
+ - docs/rfcs/0006-configurable-windows-bucket.md
247
+ - docs/rfcs/0007-logging-quiet-and-typos.md
248
+ - docs/rfcs/0008-namespace-platform-classes.md
249
+ - docs/rfcs/0009-bolt-log-formatter-cleanup.md
250
+ - docs/rfcs/0010-dead-code-cleanup.md
251
+ - docs/rfcs/0011-provisioner-factory-consistency.md
252
+ - docs/rfcs/README.md
240
253
  - exe/cem_acpt
241
254
  - exe/cem_acpt_image
242
255
  - lib/cem_acpt.rb
243
- - lib/cem_acpt/action_result.rb
244
256
  - lib/cem_acpt/actions.rb
245
257
  - lib/cem_acpt/bolt.rb
246
258
  - lib/cem_acpt/bolt/cmd.rb
@@ -265,6 +277,7 @@ files:
265
277
  - lib/cem_acpt/goss/api.rb
266
278
  - lib/cem_acpt/goss/api/action_response.rb
267
279
  - lib/cem_acpt/image_builder.rb
280
+ - lib/cem_acpt/image_builder/errors.rb
268
281
  - lib/cem_acpt/image_builder/exec.rb
269
282
  - lib/cem_acpt/image_builder/provision_commands.rb
270
283
  - lib/cem_acpt/image_name_builder.rb
@@ -279,13 +292,10 @@ files:
279
292
  - lib/cem_acpt/provision/terraform/os_data.rb
280
293
  - lib/cem_acpt/provision/terraform/terraform_cmd.rb
281
294
  - lib/cem_acpt/provision/terraform/windows.rb
282
- - lib/cem_acpt/puppet_helpers.rb
283
295
  - lib/cem_acpt/test_data.rb
284
296
  - lib/cem_acpt/test_runner.rb
285
297
  - lib/cem_acpt/test_runner/log_formatter.rb
286
298
  - lib/cem_acpt/test_runner/log_formatter/base.rb
287
- - lib/cem_acpt/test_runner/log_formatter/bolt_error_formatter.rb
288
- - lib/cem_acpt/test_runner/log_formatter/bolt_output_formatter.rb
289
299
  - lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb
290
300
  - lib/cem_acpt/test_runner/log_formatter/goss_action_response.rb
291
301
  - lib/cem_acpt/test_runner/log_formatter/goss_error_formatter.rb
@@ -314,6 +324,13 @@ files:
314
324
  - lib/terraform/image/gcp/linux/main.tf
315
325
  - lib/terraform/image/gcp/windows/.keep
316
326
  - sample_config.yaml
327
+ - specifications/CEM-6713.md
328
+ - specifications/CEM-6714.md
329
+ - specifications/CEM-6715.md
330
+ - specifications/CEM-6716.md
331
+ - specifications/CEM-6717.md
332
+ - specifications/CEM-6718.md
333
+ - specifications/CEM-6719.md
317
334
  homepage: https://github.com/puppetlabs/cem_acpt
318
335
  licenses:
319
336
  - proprietary
@@ -321,7 +338,6 @@ metadata:
321
338
  homepage_uri: https://github.com/puppetlabs/cem_acpt
322
339
  source_code_uri: https://github.com/puppetlabs/cem_acpt
323
340
  changelog_uri: https://github.com/puppetlabs/cem_acpt
324
- post_install_message:
325
341
  rdoc_options: []
326
342
  require_paths:
327
343
  - lib
@@ -336,8 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
352
  - !ruby/object:Gem::Version
337
353
  version: '0'
338
354
  requirements: []
339
- rubygems_version: 3.5.18
340
- signing_key:
355
+ rubygems_version: 3.6.9
341
356
  specification_version: 4
342
357
  summary: CEM Acceptance Tests
343
358
  test_files: []
@@ -1,7 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(xargs ls:*)"
5
- ]
6
- }
7
- }
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CemAcpt
4
- # Wrapper class for the result of an action. Provides a common interface for
5
- # getting reportable data from the result.
6
- class ActionResult
7
- attr_reader :result
8
-
9
- def initialize(result)
10
- @result = if result.instance_of?(CemAcpt::Goss::Api::ActionResponse)
11
- result
12
- elsif result.instance_of?(CemAcpt::Bolt::Cmd::Output)
13
- result
14
- elsif result.is_a?(StandardError)
15
- ErrorActionResult.new(result)
16
- else
17
- raise ArgumentError, "result must be a CemAcpt::Goss::Api::ActionResponse, CemAcpt::Bolt::Cmd::Output, or StandardError, got #{result.class}"
18
- end
19
- end
20
-
21
- def error?
22
- @result.is_a?(ErrorActionResult) || (@result.respond_to?(:error?) && @result.error?)
23
- end
24
-
25
- def method_missing(method_name, *args, **kwargs, &block)
26
- if @result.respond_to?(method_name)
27
- @result.send(method_name, *args, **kwargs, &block)
28
- else
29
- super
30
- end
31
- end
32
-
33
- def respond_to_missing?(method_name, include_private = false)
34
- @result.respond_to?(method_name, include_private) || super
35
- end
36
- end
37
-
38
- # Wrapper class for an error raised during an action.
39
- class ErrorActionResult
40
- attr_reader :error
41
-
42
- def initialize(error)
43
- @error = error
44
- end
45
-
46
- def error?
47
- true
48
- end
49
-
50
- def success?
51
- false
52
- end
53
-
54
- def to_s
55
- "#<#{@error.class.name}:0x#{@error.object_id.to_s(16)}>"
56
- end
57
-
58
- def inspect
59
- to_s
60
- end
61
-
62
- def to_h
63
- {
64
- class: @error.class.name,
65
- message: @error.message,
66
- backtrace: @error.backtrace,
67
- }
68
- end
69
-
70
- def status
71
- 1
72
- end
73
- alias http_status status
74
-
75
- def results
76
- @error.backtrace
77
- end
78
-
79
- def results?
80
- true
81
- end
82
-
83
- def summary
84
- @error.message
85
- end
86
-
87
- def summary?
88
- true
89
- end
90
- end
91
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'logging'
4
-
5
- module CemAcpt
6
- # Holds modules that provide helper methods for various Puppet-related
7
- # tasks.
8
- module PuppetHelpers
9
- # Provides helper methods for Puppet Modules.
10
- module Module
11
- class << self
12
- include CemAcpt::Logging
13
- end
14
-
15
- # Builds a Puppet module package.
16
- # @param module_dir [String] Path to the module directory. If target_dir
17
- # is specified as a relative path, it will be relative to the module dir.
18
- # @param target_dir [String] Path to the target directory where the package
19
- # will be built. This defaults to the relative path 'pkg/'.
20
- # @param should_log [Boolean] Whether or not to log the build process.
21
- # @return [String] Path to the built package.
22
- def self.build_module_package(module_dir, target_dir = nil, should_log: false)
23
- require 'puppet/modulebuilder'
24
- require 'fileutils'
25
-
26
- builder_logger = should_log ? logger : nil
27
- builder = Puppet::Modulebuilder::Builder.new(File.expand_path(module_dir), target_dir, builder_logger)
28
-
29
- # Validates module metadata by raising exception if invalid
30
- _metadata = builder.metadata
31
-
32
- # Builds the module package
33
- logger.info('CemAcpt::PuppetHelpers') { "Building module package for #{builder.release_name}" }
34
- builder.build
35
- end
36
- end
37
- end
38
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
-
5
- module CemAcpt
6
- module TestRunner
7
- module LogFormatter
8
- class BoltErrorFormatter < Base
9
- def initialize(subject: nil)
10
- super(subject)
11
- end
12
-
13
- def summary(response = nil)
14
- super(response)
15
- "Error: #{log_subject.summary}"
16
- end
17
-
18
- def results(response = nil)
19
- super(response)
20
- log_subject.results.map do |res|
21
- format_failed_result(res)
22
- end
23
- end
24
-
25
- def host_name(response = nil)
26
- super(response)
27
- "Error: #{log_subject.error.class.name}"
28
- end
29
-
30
- def test_name(response = nil)
31
- super(response)
32
- "Error: #{log_subject.error.class.name}"
33
- end
34
-
35
- private
36
-
37
- def format_failed_result(res)
38
- prefix = [
39
- 'Failed',
40
- "action #{res.action}",
41
- "object #{res.object}",
42
- "target #{res.target}",
43
- ].join(': ')
44
- return prefix unless res.error?
45
-
46
- error_parts = [
47
- "error type #{res.error.class.name}",
48
- normalize_whitespace(res.error.to_s),
49
- ]
50
- if res.error.respond_to?(:details) && res.error.details
51
- error_parts << "details #{res.error.details}"
52
- end
53
- if res.error.respond_to?(:original_error) && res.error.original_error
54
- error_parts << "original error #{res.error.original_error.class.name}"
55
- error_parts << "original message #{res.error.original_error.message}"
56
- end
57
- if res.error.respond_to?(:backtrace) && !res.error.backtrace.empty?
58
- error_parts << "backtrace:\n#{res.error.backtrace.join("\n#{INDENT}#{INDENT}")}"
59
- end
60
- "#{prefix}\n#{INDENT}#{error_parts.join("\n#{INDENT}")}"
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
-
5
- module CemAcpt
6
- module TestRunner
7
- module LogFormatter
8
- # Formats the results of a Bolt action
9
- class BoltOutputFormatter < Base
10
- def initialize(config, instance_names_ips, subject: nil)
11
- super(subject)
12
- @config = config
13
- @instance_names_ips = instance_names_ips
14
- end
15
-
16
- def summary(response = nil)
17
- super(response)
18
- [
19
- "SUMMARY: #{test_name(log_subject)}:",
20
- normalize_whitespace(log_subject.summary),
21
- ].join(' ')
22
- end
23
-
24
- def results(response = nil)
25
- super(response)
26
- log_subject.results.map do |res|
27
- prefix = success_str(res.success?).capitalize
28
- parts = [
29
- prefix,
30
- "action #{res.action}",
31
- "host(s) #{host_name(log_subject)}",
32
- "object #{res.object}",
33
- "status #{res.status}",
34
- ]
35
- parts << res.error if res.error?
36
- parts.join(': ')
37
- end
38
- end
39
-
40
- def host_name(response = nil)
41
- super(response)
42
- log_subject.items.map { |i| name_from_ip(i.target) }.compact.uniq.join(', ')
43
- end
44
-
45
- def test_name(response = nil)
46
- super(response)
47
- test_type = (log_subject.items.find { |i| i.action != 'unknown' }&.action || 'unknown')
48
- test_objects = log_subject.items.map(&:object).uniq.join(', ')
49
- "Bolt #{test_type} test for: #{test_objects}"
50
- end
51
- end
52
- end
53
- end
54
- end