klint

package
v0.0.0-...-6aac043 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IS_YAEGI = false

IS_YAEGI controls whether Main runs. We don't want that in interpreted mode, but do what it in "native Go" mode

View Source
var Levels = map[Level]string{
	Info:    "INFO",
	Warning: "WARN",
	Error:   "ERROR",
}

Levels provides human readable values for the Level enu,

Functions

func Main

func Main(f func(manifest.Manifest) (Findings, error))

Main provides klint-single-rule, used for easy execution of single rules during development, without the need for an interpreter. It allows to `go run` a .klint.go file

Types

type Finding

type Finding struct {
	// Level of the finding
	Level Level

	// Field that is offending
	Field string

	// Message in human readable format what happened, and possibly how to fix it
	Message string
	// contains filtered or unexported fields
}

Finding describes a single thing the Rule found required to be mentioned

func (Finding) String

func (f Finding) String() string

type Findings

type Findings []Finding

func Found

func Found(f ...Finding) Findings

Found constructs Findings from a set of Finding. This is required because the Yaegi interpreter does not support the Findings{} slice literal

type Got

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

Got is the result of a manifest.Get call

func GetField

func GetField(m manifest.Manifest, fieldspec ...interface{}) (*Got, error)

Get returns any nested field of the manifest. It is invoked as m.Get("metadata", "name")

func (Got) Interface

func (g Got) Interface() interface{}

Interface returns the raw data

func (Got) Map

func (g Got) Map() map[string]interface{}

Map casts the underlying data to a map[string]interface{}. Panics if of wrong type

func (*Got) Slice

func (g *Got) Slice() []interface{}

Slice casts the underlying data to a []interface{}. Panics if of wrong type

type Klint

type Klint struct {
	Rules Rules
}

Klint lints Kubernetes manifests using runtime-loaded rules.

func (Klint) Lint

func (k Klint) Lint(list manifest.List) error

Lint all given manifests using the rules in the Klint instance

func (Klint) LintFiles

func (k Klint) LintFiles(files ...string) error

LintFiles lints all Manifests in the given files using the rules inside the Klint instance

type Level

type Level int

Level is the severity of a Finding

const (
	Info Level = iota
	Warning
	Error
)

func (Level) String

func (l Level) String() string

type Result

type Result map[string]Findings

Result is returned by Lint. It maps resource names to their respective findings.

func (Result) Error

func (r Result) Error() string

type Rule

type Rule func(manifest.Manifest) (Findings, error)

Rule is the function interface used by the individual rules

type Rules

type Rules map[string]Rule

Jump to

Keyboard shortcuts

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