backends

package
v0.0.0-...-d5bad45 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package backends is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBackendRegistered returned when try to register a backend twice
	ErrBackendRegistered = errors.New("backend already registered")
	// ErrNoBackendRegistered returned when no backend found for given type
	ErrNoBackendRegistered = errors.New("no backend registered for current loadtest type")
)

Functions

func BuildResourceRequirements

func BuildResourceRequirements(resources Resources) coreV1.ResourceRequirements

BuildResourceRequirements creates ResourceRequirements that allows not all values to be specified This is necessary because setting a resource requirement with value 0 produces a different behavior

func Register

func Register(b Backend)

Register should be called to register your backend

Types

type Backend

type Backend interface {
	// Type must return backend unique type string, called by both Proxy and Controller
	Type() loadTestV1.LoadTestType

	// TransformLoadTestSpec should validate and transform LoadTestSpec, called by Proxy
	TransformLoadTestSpec(spec *loadTestV1.LoadTestSpec) error

	// Sync should create resources if not exists, called by Controller
	Sync(ctx context.Context, loadTest loadTestV1.LoadTest, reportURL string) error
	// Sync should update status with current resource state, called by Controller
	SyncStatus(ctx context.Context, loadTest loadTestV1.LoadTest, loadTestStatus *loadTestV1.LoadTestStatus) error
}

Backend is basic methods a backend must implement

type BackendGetEnvConfig

type BackendGetEnvConfig interface {
	// GetEnvConfig get from backend a envConfig struct pointer
	GetEnvConfig() interface{}
}

BackendGetEnvConfig backend must implement this if it has Environment Variables This method is called by both commands, Proxy and Controller

type BackendSetDefaults

type BackendSetDefaults interface {
	// SetDefaultValues gives a chance to backend initialize itself
	SetDefaults()
}

BackendSetDefaults backend must implement this if wants to set default values This method is called by both commands, Proxy and Controller

type BackendSetKangalClientSet

type BackendSetKangalClientSet interface {
	// SetKangalClientSet gives backend a kangalClientSet instance
	SetKangalClientSet(clientSetV.Interface)
}

BackendSetKangalClientSet interface can be implemented by backend to receive an kangalClientSet This method is called only by command Controller

type BackendSetKubeClientSet

type BackendSetKubeClientSet interface {
	// SetKubeClientSet gives backend a kubeClientSet instance
	SetKubeClientSet(kubernetes.Interface)
}

BackendSetKubeClientSet interface can be implemented by backend to receive an kubeClientSet This method is called only by command Controller

type BackendSetLogger

type BackendSetLogger interface {
	// SetLogger gives backend a logger instance
	SetLogger(*zap.Logger)
}

BackendSetLogger interface can be implemented by backend to receive an logger This method is called by both commands, Proxy and Controller

type BackendSetNamespaceLister

type BackendSetNamespaceLister interface {
	// SetNamespaceLister gives backend a namespaceLister instance
	SetNamespaceLister(coreListersV1.NamespaceLister)
}

BackendSetNamespaceLister interface can be implemented by backend to receive an namespaceLister This method is called only by command Controller

type BackendSetPodAnnotations

type BackendSetPodAnnotations interface {
	// SetPodAnnotations gives backend annotations to be attached in loadtest pods
	SetPodAnnotations(map[string]string)
}

BackendSetPodAnnotations interface can be implemented by backend to receive pod annotations This method is called only by command Controller

type BackendSetPodNodeSelector

type BackendSetPodNodeSelector interface {
	// SetPodNodeSelector gives backend node selector to be attached in loadtest pods
	SetPodNodeSelector(map[string]string)
}

BackendSetPodNodeSelector interface can be implemented by backend to receive pod node selectors This method is called only by command Controller

type BackendSetPodTolerations

type BackendSetPodTolerations interface {
	// SetPodNodeSelector gives backend node selector to be attached in loadtest pods
	SetPodTolerations([]kubeCoreV1.Toleration)
}

BackendSetPodTolerations interface can be implemented by backend to receive pod tolerations This method is called only by command Controller

type MockBackend

type MockBackend struct {
	// contains filtered or unexported fields
}

MockBackend is a mock of Backend interface.

func NewMockBackend

func NewMockBackend(ctrl *gomock.Controller) *MockBackend

NewMockBackend creates a new mock instance.

func (*MockBackend) EXPECT

func (m *MockBackend) EXPECT() *MockBackendMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBackend) GetEnvConfig

func (m *MockBackend) GetEnvConfig() interface{}

GetEnvConfig mocks base method.

func (*MockBackend) SetDefaults

func (m *MockBackend) SetDefaults()

SetDefaults mocks base method.

func (*MockBackend) SetKangalClientSet

func (m *MockBackend) SetKangalClientSet(arg0 versioned.Interface)

SetKangalClientSet mocks base method.

func (*MockBackend) SetKubeClientSet

func (m *MockBackend) SetKubeClientSet(arg0 kubernetes.Interface)

SetKubeClientSet mocks base method.

func (*MockBackend) SetLogger

func (m *MockBackend) SetLogger(arg0 *zap.Logger)

SetLogger mocks base method.

func (*MockBackend) SetNamespaceLister

func (m *MockBackend) SetNamespaceLister(arg0 v10.NamespaceLister)

SetNamespaceLister mocks base method.

func (*MockBackend) SetPodAnnotations

func (m *MockBackend) SetPodAnnotations(arg0 map[string]string)

SetPodAnnotations mocks base method.

func (*MockBackend) SetPodNodeSelector

func (m *MockBackend) SetPodNodeSelector(arg0 map[string]string)

SetPodNodeSelector mocks base method.

func (*MockBackend) Sync

func (m *MockBackend) Sync(ctx context.Context, loadTest v1.LoadTest, reportURL string) error

Sync mocks base method.

func (*MockBackend) SyncStatus

func (m *MockBackend) SyncStatus(ctx context.Context, loadTest v1.LoadTest, loadTestStatus *v1.LoadTestStatus) error

SyncStatus mocks base method.

func (*MockBackend) TransformLoadTestSpec

func (m *MockBackend) TransformLoadTestSpec(spec *v1.LoadTestSpec) error

TransformLoadTestSpec mocks base method.

func (*MockBackend) Type

func (m *MockBackend) Type() v1.LoadTestType

Type mocks base method.

type MockBackendMockRecorder

type MockBackendMockRecorder struct {
	// contains filtered or unexported fields
}

MockBackendMockRecorder is the mock recorder for MockBackend.

func (*MockBackendMockRecorder) GetEnvConfig

func (mr *MockBackendMockRecorder) GetEnvConfig() *gomock.Call

GetEnvConfig indicates an expected call of GetEnvConfig.

func (*MockBackendMockRecorder) SetDefaults

func (mr *MockBackendMockRecorder) SetDefaults() *gomock.Call

SetDefaults indicates an expected call of SetDefaults.

func (*MockBackendMockRecorder) SetKangalClientSet

func (mr *MockBackendMockRecorder) SetKangalClientSet(arg0 interface{}) *gomock.Call

SetKangalClientSet indicates an expected call of SetKangalClientSet.

func (*MockBackendMockRecorder) SetKubeClientSet

func (mr *MockBackendMockRecorder) SetKubeClientSet(arg0 interface{}) *gomock.Call

SetKubeClientSet indicates an expected call of SetKubeClientSet.

func (*MockBackendMockRecorder) SetLogger

func (mr *MockBackendMockRecorder) SetLogger(arg0 interface{}) *gomock.Call

SetLogger indicates an expected call of SetLogger.

func (*MockBackendMockRecorder) SetNamespaceLister

func (mr *MockBackendMockRecorder) SetNamespaceLister(arg0 interface{}) *gomock.Call

SetNamespaceLister indicates an expected call of SetNamespaceLister.

func (*MockBackendMockRecorder) SetPodAnnotations

func (mr *MockBackendMockRecorder) SetPodAnnotations(arg0 interface{}) *gomock.Call

SetPodAnnotations indicates an expected call of SetPodAnnotations.

func (*MockBackendMockRecorder) SetPodNodeSelector

func (mr *MockBackendMockRecorder) SetPodNodeSelector(arg0 interface{}) *gomock.Call

SetPodNodeSelector indicates an expected call of SetPodNodeSelector.

func (*MockBackendMockRecorder) Sync

func (mr *MockBackendMockRecorder) Sync(ctx, loadTest, reportURL interface{}) *gomock.Call

Sync indicates an expected call of Sync.

func (*MockBackendMockRecorder) SyncStatus

func (mr *MockBackendMockRecorder) SyncStatus(ctx, loadTest, loadTestStatus interface{}) *gomock.Call

SyncStatus indicates an expected call of SyncStatus.

func (*MockBackendMockRecorder) TransformLoadTestSpec

func (mr *MockBackendMockRecorder) TransformLoadTestSpec(spec interface{}) *gomock.Call

TransformLoadTestSpec indicates an expected call of TransformLoadTestSpec.

func (*MockBackendMockRecorder) Type

func (mr *MockBackendMockRecorder) Type() *gomock.Call

Type indicates an expected call of Type.

type Option

type Option func(*registry)

Option allows to configure backends

func WithKangalClientSet

func WithKangalClientSet(kangalClientSet clientSetV.Interface) Option

WithKangalClientSet adds given kangalClientSet to each registered backend that implements BackendKangalClientSet

func WithKubeClientSet

func WithKubeClientSet(kubeClientSet kubernetes.Interface) Option

WithKubeClientSet adds given kubeClientSet to each registered backend that implements BackendKubeClientSet

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger adds given logger to each registered backend that implements BackendSetLogger

func WithNamespaceLister

func WithNamespaceLister(namespaceLister coreListersV1.NamespaceLister) Option

WithNamespaceLister adds given namespaceLister to each registered backend that implements BackendNamespaceLister

func WithNodeSelector

func WithNodeSelector(nodeSelector map[string]string) Option

WithNodeSelector adds given pod node selectors to each registered backend that implements BackendSetPodNodeSelector

func WithPodAnnotations

func WithPodAnnotations(podAnnotations map[string]string) Option

WithPodAnnotations adds given pod annotations to each registered backend that implements BackendSetPodAnnotations

func WithTolerations

func WithTolerations(tolerations []kubeCoreV1.Toleration) Option

WithTolerations adds given pod tolerations to each registered backend that implements BackendSetPodTolerations

type Registry

type Registry interface {
	GetBackend(loadTestType loadTestV1.LoadTestType) (Backend, error)
}

Registry is the interface for backends registering/retrieving

func New

func New(opts ...Option) Registry

New creates a new backend registry instance

type Resources

type Resources struct {
	CPULimits      string
	CPURequests    string
	MemoryLimits   string
	MemoryRequests string
}

Resources contains resources limits/requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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