k8s

package
v0.0.0-...-9db51f9 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 7 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 struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(clientset *kubernetes.Clientset) *Client

func (*Client) NodeMetrics

func (c *Client) NodeMetrics(ctx context.Context, nodeName string) (NodeMetrics, error)

type ClientInterface

type ClientInterface interface {
	NodeMetrics(ctx context.Context, nodeName string) (NodeMetrics, error)
}

type ClientMock

type ClientMock struct {
	// NodeMetricsFunc mocks the NodeMetrics method.
	NodeMetricsFunc func(ctx context.Context, nodeName string) (NodeMetrics, error)
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of ClientInterface.

func TestSomethingThatUsesClientInterface(t *testing.T) {

	// make and configure a mocked ClientInterface
	mockedClientInterface := &ClientMock{
		NodeMetricsFunc: func(ctx context.Context, nodeName string) (NodeMetrics, error) {
			panic("mock out the NodeMetrics method")
		},
	}

	// use mockedClientInterface in code that requires ClientInterface
	// and then make assertions.

}

func (*ClientMock) NodeMetrics

func (mock *ClientMock) NodeMetrics(ctx context.Context, nodeName string) (NodeMetrics, error)

NodeMetrics calls NodeMetricsFunc.

func (*ClientMock) NodeMetricsCalls

func (mock *ClientMock) NodeMetricsCalls() []struct {
	Ctx      context.Context
	NodeName string
}

NodeMetricsCalls gets all the calls that were made to NodeMetrics. Check the length with:

len(mockedClientInterface.NodeMetricsCalls())

type MetricValue

type MetricValue struct {
	Value       float64
	TimestampMs int64
}

type NodeMetrics

type NodeMetrics struct {
	PodCPUUsageSecondsTotal  PodMetric
	PodMemoryWorkingSetBytes PodMetric
}

type PodKey

type PodKey struct {
	Name      string
	Namespace string
}

type PodMetric

type PodMetric map[PodKey]MetricValue

Jump to

Keyboard shortcuts

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