core

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerPortToServicePort

func ContainerPortToServicePort(containerPort corev1.ContainerPort) corev1.ServicePort

func ConvertSingleContainerVolumes added in v0.0.6

func ConvertSingleContainerVolumes(scvs []SingleContainerVolume) ([]corev1.Volume, []corev1.VolumeMount)

TODO replace this with a new, more generic approach Converts SCVs into k8s volumes and volume mounts. If multiple SCVs have the same name, they are merged. This prevents issues with certain CSIs that don't support the same volume being listed multiple times under different names.

func PrivilegedContainerSecurityContext

func PrivilegedContainerSecurityContext() *corev1.SecurityContext

func PrivilegedPodSecurityContext

func PrivilegedPodSecurityContext() *corev1.PodSecurityContext

func RestrictedContainerSecurityContext

func RestrictedContainerSecurityContext(uid, gid int64) *corev1.SecurityContext

func RestrictedPodSecurityContext

func RestrictedPodSecurityContext(uid, gid int64) *corev1.PodSecurityContext

Types

type Client

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

func NewClient

func NewClient(config *rest.Config) (*Client, error)

func (*Client) CreatePVC

func (c *Client) CreatePVC(ctx *contexts.Context, namespace, pvcName string, size resource.Quantity, opts CreatePVCOptions) (*corev1.PersistentVolumeClaim, error)

func (*Client) CreatePod

func (c *Client) CreatePod(ctx *contexts.Context, namespace string, pod *corev1.Pod) (*corev1.Pod, error)

func (*Client) CreateService

func (c *Client) CreateService(ctx *contexts.Context, namespce string, service *corev1.Service) (*corev1.Service, error)

func (*Client) DeletePVC

func (c *Client) DeletePVC(ctx *contexts.Context, namespace, volumeName string) error

func (*Client) DeletePod

func (c *Client) DeletePod(ctx *contexts.Context, namespace, name string) error

func (*Client) DeleteService

func (c *Client) DeleteService(ctx *contexts.Context, namespace, name string) error

func (*Client) DoesPVCExist

func (c *Client) DoesPVCExist(ctx *contexts.Context, namespace, name string) (doesExist bool, err error)

func (*Client) EnsurePVCExists

func (c *Client) EnsurePVCExists(ctx *contexts.Context, namespace, pvcName string, size resource.Quantity, opts CreatePVCOptions) (*corev1.PersistentVolumeClaim, error)

func (*Client) GetEndpoint

func (c *Client) GetEndpoint(ctx *contexts.Context, namespace, name string) (*corev1.Endpoints, error)

func (*Client) GetPVC

func (kc *Client) GetPVC(ctx *contexts.Context, namespace, name string) (*corev1.PersistentVolumeClaim, error)

func (*Client) WaitForReadyEndpoint

func (c *Client) WaitForReadyEndpoint(ctx *contexts.Context, namespace, name string, opts WaitForReadyEndpointOpts) (endpoints *corev1.Endpoints, err error)

Wait for at least one ready endpoint to be available.

func (*Client) WaitForReadyPod

func (c *Client) WaitForReadyPod(ctx *contexts.Context, namespace, name string, opts WaitForReadyPodOpts) (pod *corev1.Pod, err error)

func (*Client) WaitForReadyService

func (c *Client) WaitForReadyService(ctx *contexts.Context, namespace, name string, opts WaitForReadyServiceOpts) (service *corev1.Service, err error)

type ClientInterface

type ClientInterface interface {
	// Pods
	CreatePod(ctx *contexts.Context, namespace string, pod *corev1.Pod) (*corev1.Pod, error) // TODO see if this can be refined further
	WaitForReadyPod(ctx *contexts.Context, namespace, name string, opts WaitForReadyPodOpts) (*corev1.Pod, error)
	DeletePod(ctx *contexts.Context, namespace, name string) error
	// PVCs
	CreatePVC(ctx *contexts.Context, namespace, pvcName string, size resource.Quantity, opts CreatePVCOptions) (*corev1.PersistentVolumeClaim, error)
	GetPVC(ctx *contexts.Context, namespace, name string) (*corev1.PersistentVolumeClaim, error)
	DoesPVCExist(ctx *contexts.Context, namespace, name string) (bool, error)
	EnsurePVCExists(ctx *contexts.Context, namespace, pvcName string, size resource.Quantity, opts CreatePVCOptions) (*corev1.PersistentVolumeClaim, error)
	DeletePVC(ctx *contexts.Context, namespace, volumeName string) error
	// Services
	CreateService(ctx *contexts.Context, namespce string, service *corev1.Service) (*corev1.Service, error)
	WaitForReadyService(ctx *contexts.Context, namespace, name string, opts WaitForReadyServiceOpts) (*corev1.Service, error)
	DeleteService(ctx *contexts.Context, namespace, name string) error
	// Endpoints
	GetEndpoint(ctx *contexts.Context, namespace, name string) (*corev1.Endpoints, error)
	WaitForReadyEndpoint(ctx *contexts.Context, namespace, name string, opts WaitForReadyEndpointOpts) (*corev1.Endpoints, error)
}

type CreatePVCOptions

type CreatePVCOptions struct {
	helpers.GenerateName
	StorageClassName string
	Source           *corev1.TypedObjectReference
}

type MockClientInterface

type MockClientInterface struct {
	mock.Mock
}

MockClientInterface is an autogenerated mock type for the ClientInterface type

func NewMockClientInterface

func NewMockClientInterface(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockClientInterface

NewMockClientInterface creates a new instance of MockClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockClientInterface) CreatePVC

func (_m *MockClientInterface) CreatePVC(ctx *contexts.Context, namespace string, pvcName string, size resource.Quantity, opts CreatePVCOptions) (*v1.PersistentVolumeClaim, error)

CreatePVC provides a mock function with given fields: ctx, namespace, pvcName, size, opts

func (*MockClientInterface) CreatePod

func (_m *MockClientInterface) CreatePod(ctx *contexts.Context, namespace string, pod *v1.Pod) (*v1.Pod, error)

CreatePod provides a mock function with given fields: ctx, namespace, pod

func (*MockClientInterface) CreateService

func (_m *MockClientInterface) CreateService(ctx *contexts.Context, namespce string, service *v1.Service) (*v1.Service, error)

CreateService provides a mock function with given fields: ctx, namespce, service

func (*MockClientInterface) DeletePVC

func (_m *MockClientInterface) DeletePVC(ctx *contexts.Context, namespace string, volumeName string) error

DeletePVC provides a mock function with given fields: ctx, namespace, volumeName

func (*MockClientInterface) DeletePod

func (_m *MockClientInterface) DeletePod(ctx *contexts.Context, namespace string, name string) error

DeletePod provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) DeleteService

func (_m *MockClientInterface) DeleteService(ctx *contexts.Context, namespace string, name string) error

DeleteService provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) DoesPVCExist

func (_m *MockClientInterface) DoesPVCExist(ctx *contexts.Context, namespace string, name string) (bool, error)

DoesPVCExist provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) EXPECT

func (*MockClientInterface) EnsurePVCExists

func (_m *MockClientInterface) EnsurePVCExists(ctx *contexts.Context, namespace string, pvcName string, size resource.Quantity, opts CreatePVCOptions) (*v1.PersistentVolumeClaim, error)

EnsurePVCExists provides a mock function with given fields: ctx, namespace, pvcName, size, opts

func (*MockClientInterface) GetEndpoint

func (_m *MockClientInterface) GetEndpoint(ctx *contexts.Context, namespace string, name string) (*v1.Endpoints, error)

GetEndpoint provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) GetPVC

func (_m *MockClientInterface) GetPVC(ctx *contexts.Context, namespace string, name string) (*v1.PersistentVolumeClaim, error)

GetPVC provides a mock function with given fields: ctx, namespace, name

func (*MockClientInterface) WaitForReadyEndpoint

func (_m *MockClientInterface) WaitForReadyEndpoint(ctx *contexts.Context, namespace string, name string, opts WaitForReadyEndpointOpts) (*v1.Endpoints, error)

WaitForReadyEndpoint provides a mock function with given fields: ctx, namespace, name, opts

func (*MockClientInterface) WaitForReadyPod

func (_m *MockClientInterface) WaitForReadyPod(ctx *contexts.Context, namespace string, name string, opts WaitForReadyPodOpts) (*v1.Pod, error)

WaitForReadyPod provides a mock function with given fields: ctx, namespace, name, opts

func (*MockClientInterface) WaitForReadyService

func (_m *MockClientInterface) WaitForReadyService(ctx *contexts.Context, namespace string, name string, opts WaitForReadyServiceOpts) (*v1.Service, error)

WaitForReadyService provides a mock function with given fields: ctx, namespace, name, opts

type MockClientInterface_CreatePVC_Call

type MockClientInterface_CreatePVC_Call struct {
	*mock.Call
}

MockClientInterface_CreatePVC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreatePVC'

func (*MockClientInterface_CreatePVC_Call) Return

func (*MockClientInterface_CreatePVC_Call) Run

type MockClientInterface_CreatePod_Call

type MockClientInterface_CreatePod_Call struct {
	*mock.Call
}

MockClientInterface_CreatePod_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreatePod'

func (*MockClientInterface_CreatePod_Call) Return

func (*MockClientInterface_CreatePod_Call) Run

func (*MockClientInterface_CreatePod_Call) RunAndReturn

type MockClientInterface_CreateService_Call

type MockClientInterface_CreateService_Call struct {
	*mock.Call
}

MockClientInterface_CreateService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateService'

func (*MockClientInterface_CreateService_Call) Return

func (*MockClientInterface_CreateService_Call) Run

func (*MockClientInterface_CreateService_Call) RunAndReturn

type MockClientInterface_DeletePVC_Call

type MockClientInterface_DeletePVC_Call struct {
	*mock.Call
}

MockClientInterface_DeletePVC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeletePVC'

func (*MockClientInterface_DeletePVC_Call) Return

func (*MockClientInterface_DeletePVC_Call) Run

func (*MockClientInterface_DeletePVC_Call) RunAndReturn

type MockClientInterface_DeletePod_Call

type MockClientInterface_DeletePod_Call struct {
	*mock.Call
}

MockClientInterface_DeletePod_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeletePod'

func (*MockClientInterface_DeletePod_Call) Return

func (*MockClientInterface_DeletePod_Call) Run

func (*MockClientInterface_DeletePod_Call) RunAndReturn

type MockClientInterface_DeleteService_Call

type MockClientInterface_DeleteService_Call struct {
	*mock.Call
}

MockClientInterface_DeleteService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteService'

func (*MockClientInterface_DeleteService_Call) Return

func (*MockClientInterface_DeleteService_Call) Run

func (*MockClientInterface_DeleteService_Call) RunAndReturn

type MockClientInterface_DoesPVCExist_Call

type MockClientInterface_DoesPVCExist_Call struct {
	*mock.Call
}

MockClientInterface_DoesPVCExist_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoesPVCExist'

func (*MockClientInterface_DoesPVCExist_Call) Return

func (*MockClientInterface_DoesPVCExist_Call) Run

func (*MockClientInterface_DoesPVCExist_Call) RunAndReturn

type MockClientInterface_EnsurePVCExists_Call

type MockClientInterface_EnsurePVCExists_Call struct {
	*mock.Call
}

MockClientInterface_EnsurePVCExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnsurePVCExists'

func (*MockClientInterface_EnsurePVCExists_Call) Return

func (*MockClientInterface_EnsurePVCExists_Call) Run

type MockClientInterface_Expecter

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

func (*MockClientInterface_Expecter) CreatePVC

func (_e *MockClientInterface_Expecter) CreatePVC(ctx interface{}, namespace interface{}, pvcName interface{}, size interface{}, opts interface{}) *MockClientInterface_CreatePVC_Call

CreatePVC is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • pvcName string
  • size resource.Quantity
  • opts CreatePVCOptions

func (*MockClientInterface_Expecter) CreatePod

func (_e *MockClientInterface_Expecter) CreatePod(ctx interface{}, namespace interface{}, pod interface{}) *MockClientInterface_CreatePod_Call

CreatePod is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • pod *v1.Pod

func (*MockClientInterface_Expecter) CreateService

func (_e *MockClientInterface_Expecter) CreateService(ctx interface{}, namespce interface{}, service interface{}) *MockClientInterface_CreateService_Call

CreateService is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespce string
  • service *v1.Service

func (*MockClientInterface_Expecter) DeletePVC

func (_e *MockClientInterface_Expecter) DeletePVC(ctx interface{}, namespace interface{}, volumeName interface{}) *MockClientInterface_DeletePVC_Call

DeletePVC is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • volumeName string

func (*MockClientInterface_Expecter) DeletePod

func (_e *MockClientInterface_Expecter) DeletePod(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_DeletePod_Call

DeletePod is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) DeleteService

func (_e *MockClientInterface_Expecter) DeleteService(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_DeleteService_Call

DeleteService is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) DoesPVCExist

func (_e *MockClientInterface_Expecter) DoesPVCExist(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_DoesPVCExist_Call

DoesPVCExist is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) EnsurePVCExists

func (_e *MockClientInterface_Expecter) EnsurePVCExists(ctx interface{}, namespace interface{}, pvcName interface{}, size interface{}, opts interface{}) *MockClientInterface_EnsurePVCExists_Call

EnsurePVCExists is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • pvcName string
  • size resource.Quantity
  • opts CreatePVCOptions

func (*MockClientInterface_Expecter) GetEndpoint

func (_e *MockClientInterface_Expecter) GetEndpoint(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_GetEndpoint_Call

GetEndpoint is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) GetPVC

func (_e *MockClientInterface_Expecter) GetPVC(ctx interface{}, namespace interface{}, name interface{}) *MockClientInterface_GetPVC_Call

GetPVC is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string

func (*MockClientInterface_Expecter) WaitForReadyEndpoint

func (_e *MockClientInterface_Expecter) WaitForReadyEndpoint(ctx interface{}, namespace interface{}, name interface{}, opts interface{}) *MockClientInterface_WaitForReadyEndpoint_Call

WaitForReadyEndpoint is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string
  • opts WaitForReadyEndpointOpts

func (*MockClientInterface_Expecter) WaitForReadyPod

func (_e *MockClientInterface_Expecter) WaitForReadyPod(ctx interface{}, namespace interface{}, name interface{}, opts interface{}) *MockClientInterface_WaitForReadyPod_Call

WaitForReadyPod is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string
  • opts WaitForReadyPodOpts

func (*MockClientInterface_Expecter) WaitForReadyService

func (_e *MockClientInterface_Expecter) WaitForReadyService(ctx interface{}, namespace interface{}, name interface{}, opts interface{}) *MockClientInterface_WaitForReadyService_Call

WaitForReadyService is a helper method to define mock.On call

  • ctx *contexts.Context
  • namespace string
  • name string
  • opts WaitForReadyServiceOpts

type MockClientInterface_GetEndpoint_Call

type MockClientInterface_GetEndpoint_Call struct {
	*mock.Call
}

MockClientInterface_GetEndpoint_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetEndpoint'

func (*MockClientInterface_GetEndpoint_Call) Return

func (*MockClientInterface_GetEndpoint_Call) Run

func (*MockClientInterface_GetEndpoint_Call) RunAndReturn

type MockClientInterface_GetPVC_Call

type MockClientInterface_GetPVC_Call struct {
	*mock.Call
}

MockClientInterface_GetPVC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPVC'

func (*MockClientInterface_GetPVC_Call) Return

func (*MockClientInterface_GetPVC_Call) Run

func (*MockClientInterface_GetPVC_Call) RunAndReturn

type MockClientInterface_WaitForReadyEndpoint_Call

type MockClientInterface_WaitForReadyEndpoint_Call struct {
	*mock.Call
}

MockClientInterface_WaitForReadyEndpoint_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForReadyEndpoint'

func (*MockClientInterface_WaitForReadyEndpoint_Call) Return

func (*MockClientInterface_WaitForReadyEndpoint_Call) Run

type MockClientInterface_WaitForReadyPod_Call

type MockClientInterface_WaitForReadyPod_Call struct {
	*mock.Call
}

MockClientInterface_WaitForReadyPod_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForReadyPod'

func (*MockClientInterface_WaitForReadyPod_Call) Return

func (*MockClientInterface_WaitForReadyPod_Call) Run

func (*MockClientInterface_WaitForReadyPod_Call) RunAndReturn

type MockClientInterface_WaitForReadyService_Call

type MockClientInterface_WaitForReadyService_Call struct {
	*mock.Call
}

MockClientInterface_WaitForReadyService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForReadyService'

func (*MockClientInterface_WaitForReadyService_Call) Return

func (*MockClientInterface_WaitForReadyService_Call) Run

type SingleContainerVolume

type SingleContainerVolume struct {
	Name         string              `yaml:"name" jsonschema:"required"`
	MountPaths   []string            `yaml:"mountPaths" jsonschema:"required"`
	VolumeSource corev1.VolumeSource `yaml:"volumeSource" jsonschema:"required"`
}

Helpers Represents a volume that is mounted in a single container.

func NewSingleContainerPVC

func NewSingleContainerPVC(pvcName, mountPath string) SingleContainerVolume

func NewSingleContainerSecret

func NewSingleContainerSecret(secretName, mountPath string, items ...corev1.KeyToPath) SingleContainerVolume

func (*SingleContainerVolume) ToVolume

func (scv *SingleContainerVolume) ToVolume() corev1.Volume

func (*SingleContainerVolume) ToVolumeMounts added in v0.0.6

func (svc *SingleContainerVolume) ToVolumeMounts() []corev1.VolumeMount

func (*SingleContainerVolume) WithMountPath added in v0.0.6

func (scv *SingleContainerVolume) WithMountPath(mountPath string) *SingleContainerVolume

type WaitForReadyEndpointOpts

type WaitForReadyEndpointOpts struct {
	helpers.MaxWaitTime
}

type WaitForReadyPodOpts

type WaitForReadyPodOpts struct {
	helpers.MaxWaitTime
}

type WaitForReadyServiceOpts

type WaitForReadyServiceOpts struct {
	helpers.MaxWaitTime
}

Jump to

Keyboard shortcuts

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