check

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(lintCtx lintcontext.LintContext, object lintcontext.Object) []diagnostic.Diagnostic

A Func is a specific lint-check, which runs on a specific objects, and emits diagnostics if problems are found. Checks have access to the entire LintContext, with all the objects in it, but must only report problems for the object passed in the second argument.

type HumanReadableParamDesc

type HumanReadableParamDesc struct {
	Name            string                   `json:"name"`
	Type            ParameterType            `json:"type"`
	Description     string                   `json:"description"`
	Required        bool                     `json:"required"`
	Examples        []string                 `json:"examples,omitempty"`
	RegexAllowed    *bool                    `json:"regexAllowed,omitempty"`
	NegationAllowed *bool                    `json:"negationAllowed,omitempty"`
	SubParameters   []HumanReadableParamDesc `json:"subParameters,omitempty"`
	ArrayElemType   ParameterType            `json:"arrayElemType,omitempty"`
	NestingLevel    int                      `json:"-"` // NestingLevel controls output indentation for sub-params.
}

HumanReadableParamDesc is a human-friendly representation of a ParameterDesc. It is intended only for API documentation/JSON marshaling, and must NOT be used for any business logic.

type ParameterDesc

type ParameterDesc struct {
	Name        string
	Type        ParameterType
	Description string

	Examples []string

	// Enum is set if the object is always going to be one of a specified set of values.
	// Only relevant if Type is "string"
	Enum []string

	// SubParameters are the child parameters of the given parameter.
	// Only relevant if Type is "object".
	SubParameters []ParameterDesc

	// ArrayElemType is only set when the object is of type array, and it describes the type
	// of the element of the array.
	ArrayElemType ParameterType

	// Required denotes whether the parameter is required.
	Required bool

	// NoRegex is set if the parameter does not support regexes.
	// Only relevant if Type is "string".
	NoRegex bool

	// NotNegatable is set if the parameter does not support negation via a leading !.
	// OnlyRelevant if Type is "string".
	NotNegatable bool

	XXXStructFieldName string
	XXXIsPointer       bool
}

ParameterDesc describes a parameter.

func (*ParameterDesc) HumanReadableFields

func (p *ParameterDesc) HumanReadableFields() HumanReadableParamDesc

HumanReadableFields returns a human-friendly representation of this ParameterDesc.

type ParameterType

type ParameterType string

ParameterType represents the expected type of a particular parameter.

const (
	StringType  ParameterType = "string"
	IntegerType ParameterType = "integer"
	BooleanType ParameterType = "boolean"
	NumberType  ParameterType = "number"
	ObjectType  ParameterType = "object"
	ArrayType   ParameterType = "array"
)

This block enumerates all known type names. These type names are chosen to be aligned with OpenAPI/JSON schema.

type Template

type Template struct {
	// HumanName is a human-friendly name for the template.
	// It is to be used ONLY for documentation, and has no
	// semantic relevance.
	HumanName            string
	Key                  string
	Description          string
	SupportedObjectKinds config.ObjectKindsDesc

	Parameters             []ParameterDesc                                          // TODO: use HumanReadableParamDesc for json output instead
	ParseAndValidateParams func(params map[string]interface{}) (interface{}, error) `json:"-"`
	Instantiate            func(parsedParams interface{}) (Func, error)             `json:"-"`
}

A Template is a template for a check.

func (*Template) HumanReadableParameters

func (t *Template) HumanReadableParameters() []HumanReadableParamDesc

HumanReadableParameters helper transforms each of Template.Parameters to HumanReadableParamDesc.

Jump to

Keyboard shortcuts

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