check

package
v0.0.0-...-a161123 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Remediation string                 `json:"remediation"`
	Scope       *ObjectKindsDesc       `json:"scope"`
	Template    string                 `json:"template"`
	Params      map[string]interface{} `json:"params,omitempty"`
}

A Check represents a single check. It is serializable.

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"`
}

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 ObjectKindsDesc

type ObjectKindsDesc struct {
	ObjectKinds []string `json:"objectKinds"`
}

ObjectKindsDesc describes a list of supported object kinds for a check template.

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

	// 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"
)

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 ObjectKindsDesc

	Parameters             []ParameterDesc
	ParseAndValidateParams func(params map[string]interface{}) (interface{}, error)
	Instantiate            func(parsedParams interface{}) (Func, error)
}

A Template is a template for a check.

Jump to

Keyboard shortcuts

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