lintcontext

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: 32 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvalidObject

type InvalidObject struct {
	Metadata ObjectMetadata
	LoadErr  error
}

An InvalidObject represents something that couldn't be loaded from a YAML file.

type K8sObjectInfo

type K8sObjectInfo struct {
	Namespace, Name  string
	GroupVersionKind schema.GroupVersionKind
}

K8sObjectInfo contains identifying information about k8s object.

func (K8sObjectInfo) String

func (n K8sObjectInfo) String() string

String provides plain-text representation of k8s object name.

type LintContext

type LintContext interface {
	Objects() []Object
	InvalidObjects() []InvalidObject
}

A LintContext represents the context for a lint run.

func CreateContexts

func CreateContexts(ignorePaths []string, filesOrDirs ...string) ([]LintContext, error)

CreateContexts creates a context. Each context contains a set of files that should be linted as a group. Currently, each directory of Kube YAML files (or Helm charts) are treated as a separate context. TODO: Figure out if it's useful to allow people to specify that files spanning different directories should be treated as being in the same context.

func CreateContextsFromHelmArchive

func CreateContextsFromHelmArchive(ignorePaths []string, fileName string, tgzReader io.Reader) ([]LintContext, error)

CreateContextsFromHelmArchive creates a context from TGZ reader of Helm Chart. Note: although this function is not used in CLI, it is exposed from kube-linter library and therefore should stay. See https://github.com/stackrox/kube-linter/pull/173

func CreateContextsWithOptions

func CreateContextsWithOptions(options Options, ignorePaths []string, filesOrDirs ...string) ([]LintContext, error)

CreateContextsWithOptions creates a context with additional Options

type Object

type Object struct {
	Metadata  ObjectMetadata
	K8sObject k8sutil.Object `json:"-"`
}

An Object references an object that is loaded from a YAML file.

func (*Object) GetK8sObjectName

func (o *Object) GetK8sObjectName() K8sObjectInfo

GetK8sObjectName extracts K8sObjectInfo from Object.K8sObject.

func (*Object) MarshalJSON

func (o *Object) MarshalJSON() ([]byte, error)

MarshalJSON provides custom serialization for Object. Object.K8sObject is not serialized directly because that would be too much data. This function limits output to only K8sObjectInfo returned for K8sObject.

type ObjectMetadata

type ObjectMetadata struct {
	FilePath string
	Raw      []byte `json:"-"`
}

ObjectMetadata is metadata about an object.

type Options

type Options struct {
	// CustomDecoder allows users to supply a non-default decoder to parse k8s objects. This can be used
	// to allow the linter to create contexts for k8s custom resources
	CustomDecoder runtime.Decoder
}

Options represent values that can be provided to modify how objects are parsed to create lint contexts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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