error

package
v0.6.29 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(componentInfo *component.Info, infoAll *InfoAll, outputDir string) error

func SummarizeAnalysis

func SummarizeAnalysis(componentInfo *component.Info, infoAll *InfoAll, outputDir string) error

SummarizeAnalysis summarizes the analysis and writes it to the specified output directory.

Types

type Error

type Error struct {
	Name                 string `yaml:"name" json:"name"`                                   // the name of the error code variable, e.g. "ErrInstallMesh", not guaranteed to be unique as it is package scoped
	Code                 string `yaml:"code" json:"code"`                                   // the code, an int, but exported as string, e.g. "1001", guaranteed to be unique per component-type:component-name
	Severity             string `yaml:"severity" json:"severity"`                           // a textual representation of the type Severity (errors/types.go), i.e. "none", "alert", etc
	LongDescription      string `yaml:"long_description" json:"long_description"`           // might contain newlines (JSON encoded)
	ShortDescription     string `yaml:"short_description" json:"short_description"`         // might contain newlines (JSON encoded)
	ProbableCause        string `yaml:"probable_cause" json:"probable_cause"`               // might contain newlines (JSON encoded)
	SuggestedRemediation string `yaml:"suggested_remediation" json:"suggested_remediation"` // might contain newlines (JSON encoded)
}

Error is used to export Error for e.g. documentation purposes.

Type Error (errors/types.go) is not reused in order to avoid tight coupling between code and documentation of errors, e.g. on Meshery website. It is good practice not to use internal data types in integrations; one should in general transform between internal and external models. DDD calls this anti-corruption layer. One reason is that one might like to have a different representation externally, e.g. severity 'info' instead of '1'. Another one is that it is often desirable to be able to change the internal representation without the need for the consumer (in this case, the meshery doc) to have to adjust quickly in order to be able to handle updated content. The lifecycles of producers and consumers should not be tightly coupled.

type Info

type Info struct {
	Name          string `yaml:"name" json:"name"`
	OldCode       string `yaml:"old_code" json:"old_code"`
	Code          string `yaml:"code" json:"code"`
	CodeIsLiteral bool   `yaml:"code_is_literal" json:"code_is_literal"`
	CodeIsInt     bool   `yaml:"code_is_int" json:"code_is_int"`
	Path          string `yaml:"path" json:"path"`
}

type InfoAll

type InfoAll struct {
	Entries              []Info             `yaml:"entries" json:"entries"`                                // raw entries
	LiteralCodes         map[string][]Info  `yaml:"literal_codes" json:"literal_codes"`                    // entries with literal codes
	CallExprCodes        []Info             `yaml:"call_expr_codes" json:"call_expr_codes"`                // entries with call expressions
	DeprecatedNewDefault []string           `yaml:"deprecated_new_default" json:"deprecated_new_default" ` // list of files with usage of deprecated NewDefault func
	Errors               map[string][]Error `yaml:"errors_raw" json:"errors_raw"`                          // map of detected errors created using errors.New(...). The key is the error name, more than 1 entry in the list is a duplication error.
}

func NewInfoAll

func NewInfoAll() *InfoAll

Jump to

Keyboard shortcuts

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