fake

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fake provides stubs for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculate

type Calculate struct {
	GetUsageRatioReplicaCountReactor  func(currentReplicas int32, usageRatio float64, readyPodCount int64) int32
	GetPlainMetricReplicaCountReactor func(metrics podmetrics.MetricsInfo,
		currentReplicas int32,
		targetUtilization int64,
		readyPodCount int64,
		missingPods,
		ignoredPods sets.String) int32
}

Calculate (fake) provides a way to insert functionality into a Calculater

func (*Calculate) GetPlainMetricReplicaCount

func (f *Calculate) GetPlainMetricReplicaCount(metrics podmetrics.MetricsInfo,
	currentReplicas int32,
	targetUtilization int64,
	readyPodCount int64,
	missingPods,
	ignoredPods sets.String) int32

GetPlainMetricReplicaCount calls the fake Calculater function

func (*Calculate) GetUsageRatioReplicaCount

func (f *Calculate) GetUsageRatioReplicaCount(currentReplicas int32, usageRatio float64, readyPodCount int64) int32

GetUsageRatioReplicaCount calls the fake Calculater function

type MetricsClient

type MetricsClient struct {
	GetResourceMetricReactor func(resource corev1.ResourceName, namespace string, selector labels.Selector) (podmetrics.MetricsInfo, time.Time, error)
	GetRawMetricReactor      func(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (podmetrics.MetricsInfo, time.Time, error)
	GetObjectMetricReactor   func(metricName string, namespace string, objectRef *autoscalingv2.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error)
	GetExternalMetricReactor func(metricName string, namespace string, selector labels.Selector) ([]int64, time.Time, error)
}

MetricsClient (fake) provides a way to insert functionality into a metricsclient

func (*MetricsClient) GetExternalMetric

func (f *MetricsClient) GetExternalMetric(metricName string, namespace string, selector labels.Selector) ([]int64, time.Time, error)

GetExternalMetric calls the fake metricsclient function

func (*MetricsClient) GetObjectMetric

func (f *MetricsClient) GetObjectMetric(metricName string, namespace string, objectRef *autoscalingv2.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error)

GetObjectMetric calls the fake metricsclient function

func (*MetricsClient) GetRawMetric

func (f *MetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (podmetrics.MetricsInfo, time.Time, error)

GetRawMetric calls the fake metricsclient function

func (*MetricsClient) GetResourceMetric

func (f *MetricsClient) GetResourceMetric(resource corev1.ResourceName, namespace string, selector labels.Selector) (podmetrics.MetricsInfo, time.Time, error)

GetResourceMetric calls the fake metricsclient function

type PodLister

type PodLister struct {
	ListReactor func(selector labels.Selector) (ret []*corev1.Pod, err error)
	PodsReactor func(namespace string) corelisters.PodNamespaceLister
}

PodLister (fake) provides a way to insert functionality into a PodLister

func (*PodLister) List

func (f *PodLister) List(selector labels.Selector) (ret []*corev1.Pod, err error)

List calls the fake PodLister function

func (*PodLister) Pods

func (f *PodLister) Pods(namespace string) corelisters.PodNamespaceLister

Pods calls the fake PodLister function

type PodNamespaceLister

type PodNamespaceLister struct {
	ListReactor func(selector labels.Selector) (ret []*corev1.Pod, err error)
	GetReactor  func(name string) (*corev1.Pod, error)
}

PodNamespaceLister (fake) provides a way to insert functionality into a PodNamespaceLister

func (*PodNamespaceLister) Get

func (f *PodNamespaceLister) Get(name string) (*corev1.Pod, error)

Get calls the fake PodNamespaceLister function

func (*PodNamespaceLister) List

func (f *PodNamespaceLister) List(selector labels.Selector) (ret []*corev1.Pod, err error)

List calls the fake PodNamespaceLister function

type PodReadyCounter

type PodReadyCounter struct {
	GetReadyPodsCountReactor func(namespace string, selector labels.Selector) (int64, error)
}

PodReadyCounter (fake) provides a way to insert functionality into a PodReadyCounter

func (*PodReadyCounter) GetReadyPodsCount

func (f *PodReadyCounter) GetReadyPodsCount(namespace string, selector labels.Selector) (int64, error)

GetReadyPodsCount calls the fake PodReadyCounter function

type ResourceClient

type ResourceClient struct {
	GetReactor func(apiVersion string, kind string, name string, namespace string) (*unstructured.Unstructured, error)
}

ResourceClient (fake) allows inserting logic into a resource client for testing

func (*ResourceClient) Get

func (u *ResourceClient) Get(apiVersion string, kind string, name string, namespace string) (*unstructured.Unstructured, error)

Get calls the fake ResourceClient reactor method provided

Jump to

Keyboard shortcuts

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