report

package
v2.17.4 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DetailTypeInfo indicates a detail of type info.
	DetailTypeInfo = "INFO"

	// DetailTypeWarn indicates a detail of type warning.
	DetailTypeWarn = "WARN"

	// DetailTypeError indicates a detail of type error.
	DetailTypeError = "ERROR"
)
View Source
const (
	// StateDeploySuccess indicates a config was successfully deployed.
	StateDeploySuccess = "SUCCESS"

	// StateDeployError indicates a config could not be deployed due to an error.
	StateDeployError = "ERROR"

	// StateDeployExcluded indicates no attempt was made to deploy a config because it was marked by the user to skip.
	StateDeployExcluded = "EXCLUDED"

	// StateDeploySkipped indicates no attempt was made to deploy a config because one or mored dependencies were skipped or excluded.
	StateDeploySkipped = "SKIPPED"
)
View Source
const (
	TypeDeploy = "DEPLOY"
)

Variables

This section is empty.

Functions

func NewContextWithDetailer

func NewContextWithDetailer(ctx context.Context, d Detailer) context.Context

NewContextWithDetailer returns a copy of the specified Context associated with the specified Detailer.

func NewContextWithReporter

func NewContextWithReporter(ctx context.Context, r Reporter) context.Context

NewContextWithReporter returns a new Context associated with the specified Reporter.

Types

type Detail

type Detail struct {
	// Type is the type of detail: info, warning or error.
	Type string `json:"type"`

	// Message is the message of the detail.
	Message string `json:"msg"`
}

Detail represents additional information produced during the deployment of an configuration.

type Detailer

type Detailer interface {

	// Add adds a Detail to the Detailer.
	Add(d Detail)

	// GetAll gets all Details stored by the Detailer.
	GetAll() []Detail
}

// Reporter is a minimal interface for recording and retrieving details.

func GetDetailerFromContextOrDiscard

func GetDetailerFromContextOrDiscard(ctx context.Context) Detailer

GetDetailerFromContextOrDiscard gets the Detailer associated with the Context or returns a discarding Detailer if none is available.

func NewDefaultDetailer

func NewDefaultDetailer() Detailer

NewDefaultDetailer creates a Detailer that simply stores Details in a slice.

type JSONTime

type JSONTime time.Time

JSONTime represents a time.Time value that is serialized as a string in RFC3339 format.

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals a JSONTime value into a RFC3339 string.

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a JSONTime value from a RFC3339 string.

type Record

type Record struct {
	// Type is the type of record, currently TypeDeploy.
	Type string `json:"type"`

	// Time is the time associated with the Record.
	Time JSONTime `json:"time"`

	// Config provides the config ID, project and type of the config associated with the Record.
	Config coordinate.Coordinate `json:"config"`

	// State is the result of the deployment of the config, currently StateDeploySuccess, StateDeployError, StateDeployExcluded, StateDeploySkipped.
	State string `json:"state"`

	// Details optionally provides Detail log entries associated with the record.
	Details []Detail `json:"details,omitempty"`

	// Error optionally provides the string representation of any error associated with the Record.
	Error *string `json:"error,omitempty"`
}

Record is a single entry in a report.

func ReadReportFile

func ReadReportFile(fs afero.Fs, filename string) ([]Record, error)

ReadReportFile reads a report file and returns a slice of records or an error. It is intended for use in testing.

type Reporter

type Reporter interface {
	// ReportDeployment reports the result of deploying a config.
	ReportDeployment(config coordinate.Coordinate, state string, details []Detail, err error)

	// GetSummary returns a summary of all seen events as a string.
	GetSummary() string

	// Stop shuts down the Reporter, writing out all records.
	Stop()
}

Reporter is a minimal interface for reporting events and retrieving summaries.

func GetReporterFromContextOrDiscard

func GetReporterFromContextOrDiscard(ctx context.Context) Reporter

GetReporterFromContextOrDiscard gets the Reporter associated with the Context or returns a discarding Reporter if none is available.

func NewDefaultReporter

func NewDefaultReporter(fs afero.Fs, reportFilePath string) Reporter

NewDefaultReporter creates a new Reporter that writes events as records as objects in a JSON lines file specified by reportFilePath.

Jump to

Keyboard shortcuts

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