reporter

package
v1.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package reporter is a generated GoMock package.

Index

Constants

View Source
const (
	// ErrorLevel is for unexpected problems that require attention.
	ErrorLevel = iota
	// WarnLevel is for indicating potential issues or something that should be brought to the attention of users.
	WarnLevel
	// InfoLevel is for general information about what datadog-sbom-generator is doing during its runtime.
	InfoLevel
	// VerboseLevel is for providing even more information compared to InfoLevel about the inner workings of datadog-sbom-generator.
	VerboseLevel
)

Variables

This section is empty.

Functions

func Format

func Format() []string

func VerbosityLevels

func VerbosityLevels() []string

Types

type CycloneDXReporter

type CycloneDXReporter struct {
	// contains filtered or unexported fields
}

func NewCycloneDXReporter

func NewCycloneDXReporter(stdout, stderr io.Writer, level VerbosityLevel) *CycloneDXReporter

func NewCycloneDXReporterWithPretty added in v1.2.2

func NewCycloneDXReporterWithPretty(stdout, stderr io.Writer, level VerbosityLevel, pretty bool) *CycloneDXReporter

func (*CycloneDXReporter) Errorf

func (r *CycloneDXReporter) Errorf(format string, a ...any)

func (*CycloneDXReporter) HasErrored

func (r *CycloneDXReporter) HasErrored() bool

func (*CycloneDXReporter) Infof

func (r *CycloneDXReporter) Infof(format string, a ...any)

func (*CycloneDXReporter) PrintResult

func (r *CycloneDXReporter) PrintResult(context *cli.Context, vulnerabilityResults *models.VulnerabilityResults) error

func (*CycloneDXReporter) Verbosef

func (r *CycloneDXReporter) Verbosef(format string, a ...any)

func (*CycloneDXReporter) Warnf

func (r *CycloneDXReporter) Warnf(format string, a ...any)

type JSONReporter

type JSONReporter struct {
	// contains filtered or unexported fields
}

JSONReporter prints vulnerability results in JSON format to stdout. Runtime information will be written to stderr.

func NewJSONReporter

func NewJSONReporter(stdout io.Writer, stderr io.Writer, level VerbosityLevel) *JSONReporter

func NewJSONReporterWithPretty added in v1.2.2

func NewJSONReporterWithPretty(stdout io.Writer, stderr io.Writer, level VerbosityLevel, pretty bool) *JSONReporter

func (*JSONReporter) Errorf

func (r *JSONReporter) Errorf(format string, a ...any)

func (*JSONReporter) HasErrored

func (r *JSONReporter) HasErrored() bool

func (*JSONReporter) Infof

func (r *JSONReporter) Infof(format string, a ...any)

func (*JSONReporter) PrintResult

func (r *JSONReporter) PrintResult(context *cli.Context, vulnResult *models.VulnerabilityResults) error

func (*JSONReporter) Verbosef

func (r *JSONReporter) Verbosef(format string, a ...any)

func (*JSONReporter) Warnf

func (r *JSONReporter) Warnf(format string, a ...any)

type MockReporter added in v0.0.3

type MockReporter struct {
	// contains filtered or unexported fields
}

MockReporter is a mock of Reporter interface.

func NewMockReporter added in v0.0.3

func NewMockReporter(ctrl *gomock.Controller) *MockReporter

NewMockReporter creates a new mock instance.

func (*MockReporter) EXPECT added in v0.0.3

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockReporter) Errorf added in v0.0.3

func (m *MockReporter) Errorf(format string, a ...any)

Errorf mocks base method.

func (*MockReporter) HasErrored added in v0.0.3

func (m *MockReporter) HasErrored() bool

HasErrored mocks base method.

func (*MockReporter) Infof added in v0.0.3

func (m *MockReporter) Infof(format string, a ...any)

Infof mocks base method.

func (*MockReporter) PrintResult added in v0.0.3

func (m *MockReporter) PrintResult(context *v2.Context, vulnResult *models.VulnerabilityResults) error

PrintResult mocks base method.

func (*MockReporter) Verbosef added in v0.0.3

func (m *MockReporter) Verbosef(format string, a ...any)

Verbosef mocks base method.

func (*MockReporter) Warnf added in v0.0.3

func (m *MockReporter) Warnf(format string, a ...any)

Warnf mocks base method.

type MockReporterMockRecorder added in v0.0.3

type MockReporterMockRecorder struct {
	// contains filtered or unexported fields
}

MockReporterMockRecorder is the mock recorder for MockReporter.

func (*MockReporterMockRecorder) Errorf added in v0.0.3

func (mr *MockReporterMockRecorder) Errorf(format interface{}, a ...interface{}) *gomock.Call

Errorf indicates an expected call of Errorf.

func (*MockReporterMockRecorder) HasErrored added in v0.0.3

func (mr *MockReporterMockRecorder) HasErrored() *gomock.Call

HasErrored indicates an expected call of HasErrored.

func (*MockReporterMockRecorder) Infof added in v0.0.3

func (mr *MockReporterMockRecorder) Infof(format interface{}, a ...interface{}) *gomock.Call

Infof indicates an expected call of Infof.

func (*MockReporterMockRecorder) PrintResult added in v0.0.3

func (mr *MockReporterMockRecorder) PrintResult(context, vulnResult interface{}) *gomock.Call

PrintResult indicates an expected call of PrintResult.

func (*MockReporterMockRecorder) Verbosef added in v0.0.3

func (mr *MockReporterMockRecorder) Verbosef(format interface{}, a ...interface{}) *gomock.Call

Verbosef indicates an expected call of Verbosef.

func (*MockReporterMockRecorder) Warnf added in v0.0.3

func (mr *MockReporterMockRecorder) Warnf(format interface{}, a ...interface{}) *gomock.Call

Warnf indicates an expected call of Warnf.

type Reporter

type Reporter interface {
	// Errorf prints errors in an appropriate manner to ensure that results
	// are printed in a way that is semantically valid for the intended consumer,
	// and tracking that an error has been printed.
	//
	// Where the error is actually printed (if at all) is entirely up to the actual
	// reporter, though generally it will be to stderr.
	Errorf(format string, a ...any)
	// HasErrored returns true if there have been any calls to Errorf.
	//
	// This does not actually represent if the error was actually printed anywhere
	// since what happens to the error message is up to the actual reporter.
	HasErrored() bool
	// Warnf prints text indicating potential issues or something that should be brought to the attention of users.
	Warnf(format string, a ...any)
	// Infof prints text providing general information about what datadog-sbom-generator is doing during its runtime.
	Infof(format string, a ...any)
	// Verbosef prints text providing additional information about the inner workings of datadog-sbom-generator to the user.
	Verbosef(format string, a ...any)
	// PrintResult prints the models.VulnerabilityResults per the logic of the
	// actual reporter
	PrintResult(context *cli.Context, vulnResult *models.VulnerabilityResults) error
}

Reporter provides printing operations for vulnerability results and for runtime information (depending on the verbosity level given to the Reporter implementation).

When printing non-error-related runtime information, it is entirely up to the Reporter implementation as to where the text is actually printed (if at all); in most cases for "human format" reporters this will be stdout whereas for "machine format" reporters this will be stderr.

func Effective added in v1.17.1

func Effective(r Reporter) Reporter

Effective returns r if non-nil, otherwise a VoidReporter that silently discards all output. Use this when constructing structs that hold a Reporter to guarantee the field is never nil.

func New

func New(format string, stdout, stderr io.Writer, level VerbosityLevel, pretty bool) (Reporter, error)

New returns an implementation of the reporter interface depending on the format passed in set terminalWidth as 0 to indicate the output is not a terminal and pretty formatting control

type VerbosityLevel

type VerbosityLevel uint8

VerbosityLevel is used to determine what amount of information should be given in datadog-sbom-generator's runtime.

func ParseVerbosityLevel

func ParseVerbosityLevel(text string) (VerbosityLevel, error)

type VoidReporter

type VoidReporter struct {
	// contains filtered or unexported fields
}

func (*VoidReporter) Errorf

func (r *VoidReporter) Errorf(msg string, a ...any)

func (*VoidReporter) HasErrored

func (r *VoidReporter) HasErrored() bool

func (*VoidReporter) Infof

func (r *VoidReporter) Infof(msg string, a ...any)

func (*VoidReporter) PrintResult

func (r *VoidReporter) PrintResult(context *cli.Context, vulnResult *models.VulnerabilityResults) error

func (*VoidReporter) Verbosef

func (r *VoidReporter) Verbosef(msg string, a ...any)

func (*VoidReporter) Warnf

func (r *VoidReporter) Warnf(msg string, a ...any)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL