-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧹 Add bytes reporter to support the packer plugin
This adds a reporter which allows to access the rendered report as bytes.Buffer. This is needed, so we can output it inside the packer plugin. For reference: mondoohq/packer-plugin-cnspec#170 Signed-off-by: Christian Zunker <[email protected]>
- Loading branch information
Showing
5 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package reporter | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
|
||
"go.mondoo.com/cnspec/v9/policy" | ||
_ "gocloud.dev/pubsub/awssnssqs" | ||
) | ||
|
||
type byteWriterHandler struct { | ||
data *bytes.Buffer | ||
format Format | ||
} | ||
|
||
func (h *byteWriterHandler) WriteReport(ctx context.Context, report *policy.ReportCollection) error { | ||
reporter := NewReporter(h.format, false) | ||
h.data = &bytes.Buffer{} | ||
reporter.out = h.data | ||
err := reporter.WriteReport(ctx, report) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (h *byteWriterHandler) OutputReport(ctx context.Context) *bytes.Buffer { | ||
return h.data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters