volumes

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package volumes is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWaitError

func IsWaitError(err error) bool

IsWaitError checks if an error is a WaitError.

func LegacySyncPVCs

func LegacySyncPVCs(ctx context.Context, cli client.Client,
	expectPVCs []*corev1.PersistentVolumeClaim, vm Modifier, logger logr.Logger,
) (wait bool, err error)

LegacySyncPVCs gets the actual PVCs and compares them with the expected PVCs. If the actual PVCs are different from the expected PVCs, it will update the PVCs.

func SyncPVCs

func SyncPVCs(ctx context.Context, c client.Client, pvcs []*corev1.PersistentVolumeClaim) error

Types

type ActualVolume

type ActualVolume struct {
	Desired *DesiredVolume
	PVC     *corev1.PersistentVolumeClaim
	Phase   VolumePhase
	// PV may be nil if there is no permission to get pvc
	PV *corev1.PersistentVolume
	// StorageClass may be nil if there is no permission to get storage class
	StorageClass *storagev1.StorageClass

	VACName *string
	VAC     *storagev1beta1.VolumeAttributesClass
}

func (*ActualVolume) GetStorageClassName

func (v *ActualVolume) GetStorageClassName() string

func (*ActualVolume) GetStorageSize

func (v *ActualVolume) GetStorageSize() resource.Quantity

func (*ActualVolume) String

func (v *ActualVolume) String() string

type DesiredVolume

type DesiredVolume struct {
	Size resource.Quantity
	// it may be nil if there is no permission to get storage class
	StorageClass *storagev1.StorageClass
	// it is sc name specified by user
	// the sc may not exist
	StorageClassName *string
	// VACName is the name of VolumeAttributesClass specified by user.
	// The VAC may not exist.
	VACName *string
	VAC     *storagev1beta1.VolumeAttributesClass
}

func (*DesiredVolume) GetStorageClassName

func (v *DesiredVolume) GetStorageClassName() string

GetStorageClassName may return empty because SC is unset or no permission to verify the existence of SC.

func (*DesiredVolume) GetStorageSize

func (v *DesiredVolume) GetStorageSize() resource.Quantity

func (*DesiredVolume) String

func (v *DesiredVolume) String() string

type MockModifier

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

MockModifier is a mock of Modifier interface.

func NewMockModifier

func NewMockModifier(ctrl *gomock.Controller) *MockModifier

NewMockModifier creates a new mock instance.

func (*MockModifier) EXPECT

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

func (*MockModifier) GetActualVolume

func (m *MockModifier) GetActualVolume(ctx context.Context, expect, current *v1.PersistentVolumeClaim) (*ActualVolume, error)

GetActualVolume mocks base method.

func (*MockModifier) Modify

func (m *MockModifier) Modify(ctx context.Context, vol *ActualVolume) error

Modify mocks base method.

func (*MockModifier) ShouldModify

func (m *MockModifier) ShouldModify(ctx context.Context, actual *ActualVolume) bool

ShouldModify mocks base method.

type MockModifierFactory

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

MockModifierFactory is a mock of ModifierFactory interface.

func NewMockModifierFactory

func NewMockModifierFactory(ctrl *gomock.Controller) *MockModifierFactory

NewMockModifierFactory creates a new mock instance.

func (*MockModifierFactory) EXPECT

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

func (*MockModifierFactory) New

func (m *MockModifierFactory) New() Modifier

New mocks base method.

type MockModifierFactoryMockRecorder

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

MockModifierFactoryMockRecorder is the mock recorder for MockModifierFactory.

func (*MockModifierFactoryMockRecorder) New

New indicates an expected call of New.

type MockModifierMockRecorder

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

MockModifierMockRecorder is the mock recorder for MockModifier.

func (*MockModifierMockRecorder) GetActualVolume

func (mr *MockModifierMockRecorder) GetActualVolume(ctx, expect, current any) *gomock.Call

GetActualVolume indicates an expected call of GetActualVolume.

func (*MockModifierMockRecorder) Modify

func (mr *MockModifierMockRecorder) Modify(ctx, vol any) *gomock.Call

Modify indicates an expected call of Modify.

func (*MockModifierMockRecorder) ShouldModify

func (mr *MockModifierMockRecorder) ShouldModify(ctx, actual any) *gomock.Call

ShouldModify indicates an expected call of ShouldModify.

type Modifier

type Modifier interface {
	GetActualVolume(ctx context.Context, expect, current *corev1.PersistentVolumeClaim) (*ActualVolume, error)

	ShouldModify(ctx context.Context, actual *ActualVolume) bool

	Modify(ctx context.Context, vol *ActualVolume) error
}

func NewRawModifier

func NewRawModifier(k8sClient client.Client, logger logr.Logger) Modifier

type ModifierFactory

type ModifierFactory interface {
	// new modifier for cluster
	New() Modifier
}

func NewModifierFactory

func NewModifierFactory(logger logr.Logger, cli client.Client) ModifierFactory

NewModifierFactory creates a volume modifier factory.

type VolumePhase

type VolumePhase int
const (
	VolumePhaseUnknown VolumePhase = iota
	// VolumePhasePending will be set when:
	//   1. isPVCRevisionChanged: false
	//   2. needModify: true
	//   3. waitForNextTime: true
	VolumePhasePending
	// VolumePhasePreparing will be set when:
	//   1. isPVCRevisionChanged: false
	//   2. needModify: true
	//   3. waitForNextTime: false
	VolumePhasePreparing
	// VolumePhaseModifying will be set when:
	//   1. isPVCRevisionChanged: true
	//   2. needModify: true/false
	//   3. waitForNextTime: true/false
	VolumePhaseModifying
	// VolumePhaseModified will be set when:
	//   1. isPVCRevisionChanged: false
	//   2. needModify: false
	//   3. waitForNextTime: true/false
	VolumePhaseModified

	VolumePhaseCannotModify
)

func (VolumePhase) String

func (p VolumePhase) String() string

type WaitError

type WaitError struct {
	Message string
}

WaitError is a special error type that indicates the operation is not failed but needs to wait.

func (*WaitError) Error

func (e *WaitError) Error() string

Error implements the error interface.

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

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