apiserver

package
v2.13.15 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetNodeInfo(nodeName string) (*NodeInfo, error)
	GetServerVersion() (*version.Info, error)
}

Client an interface for querying the k8s API server

func NewClient

func NewClient(client client.Kubernetes) Client

NewClient creates a new API Server client

func NewFileCacheClientWrapper

func NewFileCacheClientWrapper(client Client, config client.DiscoveryCacherConfig, options ...Option) Client

NewFileCacheClientWrapper wraps the given Client and caches the responses for the given TTL.

type NodeInfo

type NodeInfo struct {
	NodeName       string
	Labels         map[string]string
	Allocatable    v1.ResourceList
	Capacity       v1.ResourceList
	Conditions     []v1.NodeCondition
	Unschedulable  bool
	KubeletVersion string
}

NodeInfo contains information about a specific node

func (*NodeInfo) IsMasterNode

func (i *NodeInfo) IsMasterNode() bool

IsMasterNode returns true if the NodeInfo contains the labels that identify a node as master.

type Option

type Option func(*fileCacheClient)

Option is a func that configures the fileCacheClient

func WithTimeProvider

func WithTimeProvider(timeProvider TimeProvider) Option

WithTimeProvider overrides the default TimeProvider (which returns the current time). This is useful for testing cache durations/evictions

type TestAPIServer

type TestAPIServer struct {
	Mem map[string]*NodeInfo
}

TestAPIServer is for testing purposes. It implements the apiserver.Client interface with an in-memory list of objects

func (TestAPIServer) GetNodeInfo

func (t TestAPIServer) GetNodeInfo(nodeName string) (*NodeInfo, error)

func (TestAPIServer) GetServerVersion

func (t TestAPIServer) GetServerVersion() (*version.Info, error)

type TimeProvider

type TimeProvider interface {
	Time() time.Time
}

TimeProvider defines an interface that returns the current time. It's used for testing.

Jump to

Keyboard shortcuts

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