lint

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Phase added in v0.21.0

func Phase(po *v1.Pod) string

func SpecFor added in v0.21.0

func SpecFor(fqn string, o metav1.ObjectMetaAccessor) rules.Spec

SpecFor construct a new run spec for a given resource.

func ToPerc

func ToPerc(v1, v2 int64) int64

ToPerc computes the percentage from one number over another.

Types

type Cluster

type Cluster struct {
	*issues.Collector
	ClusterLister
}

Cluster tracks cluster sanitization.

func NewCluster

func NewCluster(co *issues.Collector, lister ClusterLister) *Cluster

NewCluster returns a new instance.

func (*Cluster) Lint

func (c *Cluster) Lint(ctx context.Context) error

Lint cleanse the resource.

type ClusterLister

type ClusterLister interface {
	ListVersion() (*semver.Version, error)
	HasMetrics() bool
}

ClusterLister list available Clusters on a cluster.

type ClusterRole

type ClusterRole struct {
	*issues.Collector
	// contains filtered or unexported fields
}

ClusterRole tracks ClusterRole sanitization.

func NewClusterRole

func NewClusterRole(c *issues.Collector, db *db.DB) *ClusterRole

NewClusterRole returns a new instance.

func (*ClusterRole) Lint

func (s *ClusterRole) Lint(ctx context.Context) error

Lint sanitizes the resource.

type ClusterRoleBinding

type ClusterRoleBinding struct {
	*issues.Collector
	// contains filtered or unexported fields
}

ClusterRoleBinding tracks ClusterRoleBinding sanitization.

func NewClusterRoleBinding

func NewClusterRoleBinding(c *issues.Collector, db *db.DB) *ClusterRoleBinding

NewClusterRoleBinding returns a new instance.

func (*ClusterRoleBinding) Lint

func (c *ClusterRoleBinding) Lint(ctx context.Context) error

Lint sanitizes the resource.

type Collector

type Collector interface {
	// Outcome collects issues.
	Outcome() issues.Outcome

	// AddSubCode records a sub issue.
	AddSubCode(context.Context, rules.ID, ...interface{})

	// AddCode records a new issue.
	AddCode(context.Context, rules.ID, ...interface{})

	// AddErr records errors.
	AddErr(context.Context, ...error)
}

Collector collects sub issues.

type CollectorLimiter

type CollectorLimiter interface {
	// Collector an issue collector.
	Collector

	// ConfigLister track config options.
	ConfigLister
}

CollectorLimiter represents a collector with resource allocation limits.

type ConfigLister

type ConfigLister interface {
	// CPUResourceLimits returns the CPU utilization threshold.
	CPUResourceLimits() config.Allocations

	// MEMResourceLimits returns the MEM utilization threshold.
	MEMResourceLimits() config.Allocations
}

ConfigLister tracks configuration parameters.

type ConfigMap

type ConfigMap struct {
	*issues.Collector
	// contains filtered or unexported fields
}

ConfigMap tracks ConfigMap sanitization.

func NewConfigMap

func NewConfigMap(c *issues.Collector, db *db.DB) *ConfigMap

NewConfigMap returns a new instance.

func (*ConfigMap) Lint

func (s *ConfigMap) Lint(ctx context.Context) error

Lint lints the resource.

type ConsumptionMetrics

type ConsumptionMetrics struct {
	QOS                    v1.PodQOSClass
	CurrentCPU, CurrentMEM resource.Quantity
	RequestCPU, RequestMEM resource.Quantity
	LimitCPU, LimitMEM     resource.Quantity
	RequestedStorage       resource.Quantity
}

ConsumptionMetrics tracks managed pods resource utilization.

func (*ConsumptionMetrics) LimitCPURatio

func (d *ConsumptionMetrics) LimitCPURatio() float64

LimitCPURatio returns current cpu usage over requested percentage.

func (*ConsumptionMetrics) LimitMEMRatio

func (d *ConsumptionMetrics) LimitMEMRatio() float64

LimitMEMRatio returns current memory usage over requested percentage.

func (*ConsumptionMetrics) ReqAbsCPURatio

func (d *ConsumptionMetrics) ReqAbsCPURatio() float64

ReqAbsCPURatio returns absolute cpu ratio.

func (*ConsumptionMetrics) ReqAbsMEMRatio

func (d *ConsumptionMetrics) ReqAbsMEMRatio() float64

ReqAbsMEMRatio returns absolute mem ratio.

func (*ConsumptionMetrics) ReqCPURatio

func (d *ConsumptionMetrics) ReqCPURatio() float64

ReqCPURatio returns current cpu usage over requested percentage.

func (*ConsumptionMetrics) ReqMEMRatio

func (d *ConsumptionMetrics) ReqMEMRatio() float64

ReqMEMRatio returns current memory usage over requested percentage.

type Container

type Container struct {
	LimitCollector
	// contains filtered or unexported fields
}

Container represents a Container linter.

func NewContainer

func NewContainer(fqn string, c LimitCollector) *Container

NewContainer returns a new instance.

type ContainerRestrictor

type ContainerRestrictor interface {
	AllowedRegistries() []string
}

type CronJob

type CronJob struct {
	*issues.Collector
	// contains filtered or unexported fields
}

CronJob tracks CronJob linting.

func NewCronJob

func NewCronJob(co *issues.Collector, db *db.DB) *CronJob

NewCronJob returns a new instance.

func (*CronJob) Lint

func (s *CronJob) Lint(ctx context.Context) error

Lint cleanse the resource.

type DaemonSet

type DaemonSet struct {
	*issues.Collector
	// contains filtered or unexported fields
}

DaemonSet tracks DaemonSet sanitization.

func NewDaemonSet

func NewDaemonSet(co *issues.Collector, db *db.DB) *DaemonSet

NewDaemonSet returns a new instance.

func (*DaemonSet) Lint

func (s *DaemonSet) Lint(ctx context.Context) error

Lint cleanse the resource.

type Deployment

type Deployment struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Deployment tracks Deployment sanitization.

func NewDeployment

func NewDeployment(co *issues.Collector, db *db.DB) *Deployment

NewDeployment returns a new instance.

func (*Deployment) Lint

func (s *Deployment) Lint(ctx context.Context) error

Lint cleanse the resource.

type Gateway

type Gateway struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Gateway tracks Gateway sanitization.

func NewGateway

func NewGateway(co *issues.Collector, db *db.DB) *Gateway

NewGateway returns a new instance.

func (*Gateway) Lint

func (s *Gateway) Lint(ctx context.Context) error

Lint cleanse the resource.

type GatewayClass

type GatewayClass struct {
	*issues.Collector
	// contains filtered or unexported fields
}

GatewayClass tracks GatewayClass sanitization.

func NewGatewayClass

func NewGatewayClass(co *issues.Collector, db *db.DB) *GatewayClass

NewGatewayClass returns a new instance.

func (*GatewayClass) Lint

func (s *GatewayClass) Lint(ctx context.Context) error

Lint cleanse the resource.

type HTTPRoute

type HTTPRoute struct {
	*issues.Collector
	// contains filtered or unexported fields
}

HTTPRoute tracks HTTPRoute sanitization.

func NewHTTPRoute

func NewHTTPRoute(co *issues.Collector, db *db.DB) *HTTPRoute

NewHTTPRoute returns a new instance.

func (*HTTPRoute) Lint

func (s *HTTPRoute) Lint(ctx context.Context) error

Lint cleanse the resource.

type HorizontalPodAutoscaler

type HorizontalPodAutoscaler struct {
	*issues.Collector
	// contains filtered or unexported fields
}

HorizontalPodAutoscaler represents a HorizontalPodAutoscaler linter.

func NewHorizontalPodAutoscaler

func NewHorizontalPodAutoscaler(co *issues.Collector, db *db.DB) *HorizontalPodAutoscaler

NewHorizontalPodAutoscaler returns a new instance.

func (*HorizontalPodAutoscaler) Lint

Lint sanitizes an hpa.

type Ingress

type Ingress struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Ingress tracks Ingress sanitization.

func NewIngress

func NewIngress(co *issues.Collector, db *db.DB) *Ingress

NewIngress returns a new instance.

func (*Ingress) Lint

func (s *Ingress) Lint(ctx context.Context) error

Lint cleanse the resource.

type Job

type Job struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Job tracks Job linting.

func NewJob

func NewJob(co *issues.Collector, db *db.DB) *Job

NewJob returns a new instance.

func (*Job) Lint

func (s *Job) Lint(ctx context.Context) error

Lint cleanse the resource.

type Labels

type Labels map[string]string

type LimitCollector

type LimitCollector interface {
	Collector
	PodLimiter
	ContainerRestrictor
}

LimitCollector represents a collector with resource limits.

type Namespace

type Namespace struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Namespace represents a Namespace linter.

func NewNamespace

func NewNamespace(co *issues.Collector, db *db.DB) *Namespace

NewNamespace returns a new instance.

func (*Namespace) Lint

func (s *Namespace) Lint(ctx context.Context) error

Lint cleanse the resource.

func (*Namespace) ReferencedNamespaces

func (s *Namespace) ReferencedNamespaces(res map[string]struct{}) error

ReferencedNamespaces fetch all namespaces referenced by pods and service accounts.

type NetworkPolicy

type NetworkPolicy struct {
	*issues.Collector
	// contains filtered or unexported fields
}

NetworkPolicy tracks NetworkPolicy sanitizatios.

func NewNetworkPolicy

func NewNetworkPolicy(co *issues.Collector, db *db.DB) *NetworkPolicy

NewNetworkPolicy returns a new instance.

func (*NetworkPolicy) Lint

func (s *NetworkPolicy) Lint(ctx context.Context) error

Lint cleanse the resource.

type Node

type Node struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Node represents a Node linter.

func NewNode

func NewNode(co *issues.Collector, db *db.DB) *Node

NewNode returns a new instance.

func (*Node) Lint

func (n *Node) Lint(ctx context.Context) error

Lint cleanse the resource.

type PersistentVolume

type PersistentVolume struct {
	*issues.Collector
	// contains filtered or unexported fields
}

PersistentVolume represents a PersistentVolume linter.

func NewPersistentVolume

func NewPersistentVolume(co *issues.Collector, db *db.DB) *PersistentVolume

NewPersistentVolume returns a new instance.

func (*PersistentVolume) Lint

func (s *PersistentVolume) Lint(ctx context.Context) error

Lint cleanse the resource.

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	*issues.Collector
	// contains filtered or unexported fields
}

PersistentVolumeClaim represents a PersistentVolumeClaim linter.

func NewPersistentVolumeClaim

func NewPersistentVolumeClaim(co *issues.Collector, db *db.DB) *PersistentVolumeClaim

NewPersistentVolumeClaim returns a new instance.

func (*PersistentVolumeClaim) Lint

Lint cleanse the resource.

type Pod

type Pod struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Pod represents a Pod linter.

func NewPod

func NewPod(co *issues.Collector, db *db.DB) *Pod

NewPod returns a new instance.

func (*Pod) ForLabels

func (s *Pod) ForLabels(labels map[string]string) *policyv1.PodDisruptionBudget

ForLabels returns a pdb whose selector match the given labels. Returns nil if no match.

func (*Pod) Lint

func (s *Pod) Lint(ctx context.Context) error

Lint cleanse the resource..

type PodDisruptionBudget

type PodDisruptionBudget struct {
	*issues.Collector
	// contains filtered or unexported fields
}

PodDisruptionBudget tracks PodDisruptionBudget sanitization.

func NewPodDisruptionBudget

func NewPodDisruptionBudget(c *issues.Collector, db *db.DB) *PodDisruptionBudget

NewPodDisruptionBudget returns a new PodDisruptionBudget linter.

func (*PodDisruptionBudget) Lint

Lint cleanse the resource.

type PodLimiter

type PodLimiter interface {
	PodCPULimit() float64
	PodMEMLimit() float64
	RestartsLimit() int
}

PodLimiter tracks metrics limit range.

type PodMetric

type PodMetric interface {
	CurrentCPU() int64
	CurrentMEM() int64
	Empty() bool
}

PodMetric tracks pod metrics available and current range.

type PodSelectorLister

type PodSelectorLister interface {
	ListPodsBySelector(ns string, sel *metav1.LabelSelector) map[string]*v1.Pod
}

PodSelectorLister list a collection of pod matching a selector.

type PodsMetricsLister

type PodsMetricsLister interface {
	ListPodsMetrics() map[string]*mv1beta1.PodMetrics
}

PodsMetricsLister handles pods metrics.

type ReplicaSet

type ReplicaSet struct {
	*issues.Collector
	// contains filtered or unexported fields
}

ReplicaSet tracks ReplicaSet sanitization.

func NewReplicaSet

func NewReplicaSet(co *issues.Collector, db *db.DB) *ReplicaSet

NewReplicaSet returns a new instance.

func (*ReplicaSet) Lint

func (s *ReplicaSet) Lint(ctx context.Context) error

Lint cleanse the resource.

type Role

type Role struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Role tracks Role sanitization.

func NewRole

func NewRole(c *issues.Collector, db *db.DB) *Role

NewRole returns a new instance.

func (*Role) Lint

func (s *Role) Lint(ctx context.Context) error

Lint cleanse the resource.

type RoleBinding

type RoleBinding struct {
	*issues.Collector
	// contains filtered or unexported fields
}

RoleBinding tracks RoleBinding sanitization.

func NewRoleBinding

func NewRoleBinding(c *issues.Collector, db *db.DB) *RoleBinding

NewRoleBinding returns a new instance.

func (*RoleBinding) Lint

func (r *RoleBinding) Lint(ctx context.Context) error

Lint cleanse the resource..

type Secret

type Secret struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Secret tracks Secret sanitization.

func NewSecret

func NewSecret(co *issues.Collector, db *db.DB) *Secret

NewSecret returns a new instance.

func (*Secret) Lint

func (s *Secret) Lint(ctx context.Context) error

Lint cleanse the resource.

type Service

type Service struct {
	*issues.Collector
	// contains filtered or unexported fields
}

Service represents a service linter.

func NewService

func NewService(co *issues.Collector, db *db.DB) *Service

NewService returns a new instance.

func (*Service) Lint

func (s *Service) Lint(ctx context.Context) error

Lint cleanse the resource.

type ServiceAccount

type ServiceAccount struct {
	*issues.Collector
	// contains filtered or unexported fields
}

ServiceAccount tracks ServiceAccount linter.

func NewServiceAccount

func NewServiceAccount(co *issues.Collector, db *db.DB) *ServiceAccount

NewServiceAccount returns a new instance.

func (*ServiceAccount) Lint

func (s *ServiceAccount) Lint(ctx context.Context) error

Lint cleanse the resource.

type StatefulSet

type StatefulSet struct {
	*issues.Collector
	// contains filtered or unexported fields
}

StatefulSet represents a StatefulSet linter.

func NewStatefulSet

func NewStatefulSet(co *issues.Collector, db *db.DB) *StatefulSet

NewStatefulSet returns a new instance.

func (*StatefulSet) Lint

func (s *StatefulSet) Lint(ctx context.Context) error

Lint cleanse the resource.

Jump to

Keyboard shortcuts

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