snapshot

package
v0.113.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PVCKind = "PersistentVolumeClaim"

	// Snapshot resource Kinds
	VolSnapClassKind                  = "VolumeSnapshotClass"
	VolSnapKind                       = "VolumeSnapshot"
	VolSnapContentKind                = "VolumeSnapshotContent"
	VolSnapClassAlphaDriverKey        = "snapshotter"
	VolSnapClassBetaDriverKey         = "driver"
	DeletionPolicyDelete              = "Delete"
	DeletionPolicyRetain              = "Retain"
	CloneVolumeSnapshotClassLabelName = "kanister-cloned-from"
)
View Source
const (
	// VolumeSnapshotContentResourcePlural is "volumesnapshotcontents"
	VolumeSnapshotContentResourcePlural = "volumesnapshotcontents"
	// VolumeSnapshotResourcePlural is "volumesnapshots"
	VolumeSnapshotResourcePlural = "volumesnapshots"
	// VolumeSnapshotClassResourcePlural is "volumesnapshotclasses"
	VolumeSnapshotClassResourcePlural = "volumesnapshotclasses"

	GroupName = "snapshot.storage.k8s.io"
	Version   = "v1"
)

Variables

View Source
var (
	// VolSnapGVR specifies GVR schema for VolumeSnapshots
	VolSnapGVR = schema.GroupVersionResource{Group: GroupName, Version: Version, Resource: VolumeSnapshotResourcePlural}
	// VolSnapClassGVR specifies GVR schema for VolumeSnapshotClasses
	VolSnapClassGVR = schema.GroupVersionResource{Group: GroupName, Version: Version, Resource: VolumeSnapshotClassResourcePlural}
	// VolSnapContentGVR specifies GVR schema for VolumeSnapshotContents
	VolSnapContentGVR = schema.GroupVersionResource{Group: GroupName, Version: Version, Resource: VolumeSnapshotContentResourcePlural}
)

Functions

func GetSnapshotClassbyAnnotation

func GetSnapshotClassbyAnnotation(ctx context.Context, dynCli dynamic.Interface, kubeCli kubernetes.Interface, gvr schema.GroupVersionResource, annotationKey, annotationValue, storageClass string) (string, error)

GetSnapshotClassbyAnnotation checks if the provided annotation is present in either the storageclass or volumesnapshotclass and returns the volumesnapshotclass.

func Mss2msi

func Mss2msi(in map[string]string) map[string]interface{}

Mss2msi takes a map of string:string and returns a string:inteface map. This is useful since the unstructured type take map[string]interface{} as values.

func TransformUnstructured

func TransformUnstructured(u *unstructured.Unstructured, obj metav1.Object) error

TransformUnstructured maps Unstructured object to object pointed by obj

func TransformUnstructuredSnaphotV1alphaToV1

func TransformUnstructuredSnaphotV1alphaToV1(u *unstructured.Unstructured) (*v1.VolumeSnapshot, error)

func UnstructuredVolumeSnapshot

func UnstructuredVolumeSnapshot(gvr schema.GroupVersionResource, pvcName, snapClassName string, snapshotMeta, snapshotContentMeta ObjectMeta) *unstructured.Unstructured

UnstructuredVolumeSnapshot returns Unstructured object for the VolumeSnapshot resource. If snapshotContentMeta has name value set, UnstructuredVolumeSnapshot will return VolumeSnapshot object with VolumeSnapshotContent information.

func UnstructuredVolumeSnapshotAlpha

func UnstructuredVolumeSnapshotAlpha(pvcName, snapClassName string, snapshotMeta, snapshotContentMeta ObjectMeta) *unstructured.Unstructured

UnstructuredVolumeSnapshotAlpha returns Unstructured object for the VolumeSnapshot resource. If snapshotContentMeta has name value set, UnstructuredVolumeSnapshotAlpha will return VolumeSnapshot object with VolumeSnapshotContent information.

func UnstructuredVolumeSnapshotClass

func UnstructuredVolumeSnapshotClass(gvr schema.GroupVersionResource, name, driver, deletionPolicy string, params map[string]string) *unstructured.Unstructured

func UnstructuredVolumeSnapshotClassAlpha

func UnstructuredVolumeSnapshotClassAlpha(name, driver, deletionPolicy string, params map[string]string) *unstructured.Unstructured

func UnstructuredVolumeSnapshotContent

func UnstructuredVolumeSnapshotContent(gvr schema.GroupVersionResource, snapshotName, snapshotNS, deletionPolicy, driver, handle, snapClassName string, snapshotContentMeta ObjectMeta) *unstructured.Unstructured

UnstructuredVolumeSnapshotContent returns Unstructured object for the VolumeSnapshotContent resource.

func UnstructuredVolumeSnapshotContentAlpha

func UnstructuredVolumeSnapshotContentAlpha(snapshotName, snapshotNS, deletionPolicy, driver, handle, snapClassName string, snapshotContentMeta ObjectMeta) *unstructured.Unstructured

UnstructuredVolumeSnapshotContentAlpha returns Unstructured object for the VolumeSnapshotContent resource.

Types

type ObjectMeta

type ObjectMeta struct {
	Name        string            `json:"name,omitempty"`
	Namespace   string            `json:"namespace,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

ObjectMeta has common metadata fields that can be used to pass meta data of a resource around.

type SnapshotAlpha

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

func (*SnapshotAlpha) Clone

func (sna *SnapshotAlpha) Clone(ctx context.Context, name, namespace string, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error

Clone will clone the VolumeSnapshot to namespace 'cloneNamespace'. Underlying VolumeSnapshotContent will be cloned with a different name.

func (*SnapshotAlpha) CloneVolumeSnapshotClass

func (sna *SnapshotAlpha) CloneVolumeSnapshotClass(ctx context.Context, sourceClassName, targetClassName, newDeletionPolicy string, excludeAnnotations []string) error

CloneVolumeSnapshotClass creates a copy of the source volume snapshot class

func (*SnapshotAlpha) Create

func (sna *SnapshotAlpha) Create(ctx context.Context, pvcName string, snapshotClass *string, waitForReady bool, snapshotMeta ObjectMeta) error

Create creates a VolumeSnapshot and returns it or any error that happened meanwhile.

func (*SnapshotAlpha) CreateContentFromSource

func (sna *SnapshotAlpha) CreateContentFromSource(ctx context.Context, source *Source, snapshotName, namespace, deletionPolicy string, snapshotContentMeta ObjectMeta) error

CreateContentFromSource will create a 'VolumesnaphotContent' for the underlying snapshot source.

func (*SnapshotAlpha) CreateFromSource

func (sna *SnapshotAlpha) CreateFromSource(ctx context.Context, source *Source, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error

CreateFromSource will create a 'Volumesnapshot' and 'VolumesnaphotContent' pair for the underlying snapshot source.

func (*SnapshotAlpha) Delete

func (sna *SnapshotAlpha) Delete(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)

Delete will delete the VolumeSnapshot and returns any error as a result.

func (*SnapshotAlpha) DeleteContent

func (sna *SnapshotAlpha) DeleteContent(ctx context.Context, name string) error

DeleteContent will delete the specified VolumeSnapshotContent

func (*SnapshotAlpha) Get

func (sna *SnapshotAlpha) Get(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)

Get will return the VolumeSnapshot in the 'namespace' with given 'name'.

func (*SnapshotAlpha) GetSource

func (sna *SnapshotAlpha) GetSource(ctx context.Context, snapshotName, namespace string) (*Source, error)

GetSource will return the CSI source that backs the volume snapshot.

func (*SnapshotAlpha) GetVolumeSnapshotClass

func (sna *SnapshotAlpha) GetVolumeSnapshotClass(ctx context.Context, annotationKey, annotationValue, storageClassName string) (string, error)

GetVolumeSnapshotClass returns VolumeSnapshotClass name which is annotated with given key.

func (*SnapshotAlpha) GroupVersion

func (sna *SnapshotAlpha) GroupVersion(ctx context.Context) schema.GroupVersion

func (*SnapshotAlpha) List

func (sna *SnapshotAlpha) List(ctx context.Context, namespace string, labels map[string]string) (*v1.VolumeSnapshotList, error)

func (*SnapshotAlpha) UpdateVolumeSnapshotStatusAlpha

func (sna *SnapshotAlpha) UpdateVolumeSnapshotStatusAlpha(ctx context.Context, namespace string, snapshotName string, readyToUse bool) error

UpdateVolumeSnapshotStatusAlpha sets the readyToUse valuse of a VolumeSnapshot.

func (*SnapshotAlpha) WaitOnReadyToUse

func (sna *SnapshotAlpha) WaitOnReadyToUse(ctx context.Context, snapshotName, namespace string) error

WaitOnReadyToUse will block until the Volumesnapshot in namespace 'namespace' with name 'snapshotName' has status 'ReadyToUse' or 'ctx.Done()' is signalled.

type SnapshotBeta

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

func (*SnapshotBeta) Clone

func (sna *SnapshotBeta) Clone(ctx context.Context, name, namespace string, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error

Clone will clone the VolumeSnapshot to namespace 'snapshotMeta.Namespace'. Underlying VolumeSnapshotContent will be cloned with a different name.

func (*SnapshotBeta) CloneVolumeSnapshotClass

func (sna *SnapshotBeta) CloneVolumeSnapshotClass(ctx context.Context, sourceClassName, targetClassName, newDeletionPolicy string, excludeAnnotations []string) error

CloneVolumeSnapshotClass creates a copy of the source volume snapshot class

func (*SnapshotBeta) Create

func (sna *SnapshotBeta) Create(ctx context.Context, volumeName string, snapshotClass *string, waitForReady bool, snapshotMeta ObjectMeta) error

Create creates a VolumeSnapshot and returns it or any error happened meanwhile.

func (*SnapshotBeta) CreateContentFromSource

func (sna *SnapshotBeta) CreateContentFromSource(ctx context.Context, source *Source, snapshotName, namespace, deletionPolicy string, snapshotContentMeta ObjectMeta) error

CreateContentFromSource will create a 'VolumesnaphotContent' for the underlying snapshot source.

func (*SnapshotBeta) CreateFromSource

func (sna *SnapshotBeta) CreateFromSource(ctx context.Context, source *Source, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error

CreateFromSource will create a 'Volumesnapshot' and 'VolumesnaphotContent' pair for the underlying snapshot source.

func (*SnapshotBeta) Delete

func (sna *SnapshotBeta) Delete(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)

Delete will delete the VolumeSnapshot and returns any error as a result.

func (*SnapshotBeta) DeleteContent

func (sna *SnapshotBeta) DeleteContent(ctx context.Context, name string) error

DeleteContent will delete the specified VolumeSnapshotContent

func (*SnapshotBeta) Get

func (sna *SnapshotBeta) Get(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)

Get will return the VolumeSnapshot in the 'namespace' with given 'name'.

func (*SnapshotBeta) GetSource

func (sna *SnapshotBeta) GetSource(ctx context.Context, snapshotName, namespace string) (*Source, error)

GetSource will return the CSI source that backs the volume snapshot.

func (*SnapshotBeta) GetVolumeSnapshotClass

func (sna *SnapshotBeta) GetVolumeSnapshotClass(ctx context.Context, annotationKey, annotationValue, storageClassName string) (string, error)

GetVolumeSnapshotClass returns VolumeSnapshotClass name which is annotated with given key.

func (*SnapshotBeta) GroupVersion

func (sna *SnapshotBeta) GroupVersion(ctx context.Context) schema.GroupVersion

func (*SnapshotBeta) List

func (sna *SnapshotBeta) List(ctx context.Context, namespace string, labels map[string]string) (*v1.VolumeSnapshotList, error)

func (*SnapshotBeta) UpdateVolumeSnapshotStatusBeta

func (sna *SnapshotBeta) UpdateVolumeSnapshotStatusBeta(ctx context.Context, namespace string, snapshotName string, readyToUse bool) error

UpdateVolumeSnapshotStatusBeta sets the readyToUse valuse of a VolumeSnapshot.

func (*SnapshotBeta) WaitOnReadyToUse

func (sna *SnapshotBeta) WaitOnReadyToUse(ctx context.Context, snapshotName, namespace string) error

WaitOnReadyToUse will block until the Volumesnapshot in 'namespace' with name 'snapshotName' has status 'ReadyToUse' or 'ctx.Done()' is signalled.

type SnapshotStable

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

func (*SnapshotStable) Clone

func (sna *SnapshotStable) Clone(ctx context.Context, name, namespace string, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error

Clone will clone the VolumeSnapshot to namespace 'cloneNamespace'. Underlying VolumeSnapshotContent will be cloned with a different name.

func (*SnapshotStable) CloneVolumeSnapshotClass

func (sna *SnapshotStable) CloneVolumeSnapshotClass(ctx context.Context, sourceClassName, targetClassName, newDeletionPolicy string, excludeAnnotations []string) error

CloneVolumeSnapshotClass creates a copy of the source volume snapshot class

func (*SnapshotStable) Create

func (sna *SnapshotStable) Create(ctx context.Context, volumeName string, snapshotClass *string, waitForReady bool, snapshotMeta ObjectMeta) error

Create creates a VolumeSnapshot and returns it or any error happened meanwhile.

func (*SnapshotStable) CreateContentFromSource

func (sna *SnapshotStable) CreateContentFromSource(ctx context.Context, source *Source, snapshotName, snapshotNS, deletionPolicy string, snapshotContentMeta ObjectMeta) error

CreateContentFromSource will create a 'VolumesnaphotContent' for the underlying snapshot source.

func (*SnapshotStable) CreateFromSource

func (sna *SnapshotStable) CreateFromSource(ctx context.Context, source *Source, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error

CreateFromSource will create a 'Volumesnapshot' and 'VolumesnaphotContent' pair for the underlying snapshot source.

func (*SnapshotStable) Delete

func (sna *SnapshotStable) Delete(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)

Delete will delete the VolumeSnapshot and returns any error as a result.

func (*SnapshotStable) DeleteContent

func (sna *SnapshotStable) DeleteContent(ctx context.Context, name string) error

DeleteContent will delete the specified VolumeSnapshotContent

func (*SnapshotStable) Get

func (sna *SnapshotStable) Get(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)

Get will return the VolumeSnapshot in the 'namespace' with given 'name'.

func (*SnapshotStable) GetSource

func (sna *SnapshotStable) GetSource(ctx context.Context, snapshotName, namespace string) (*Source, error)

GetSource will return the CSI source that backs the volume snapshot.

func (*SnapshotStable) GetVolumeSnapshotClass

func (sna *SnapshotStable) GetVolumeSnapshotClass(ctx context.Context, annotationKey, annotationValue, storageClassName string) (string, error)

GetVolumeSnapshotClass returns VolumeSnapshotClass name which is annotated with given key.

func (*SnapshotStable) GroupVersion

func (sna *SnapshotStable) GroupVersion(ctx context.Context) schema.GroupVersion

func (*SnapshotStable) List

func (sna *SnapshotStable) List(ctx context.Context, namespace string, labels map[string]string) (*v1.VolumeSnapshotList, error)

func (*SnapshotStable) UpdateVolumeSnapshotStatusStable

func (sna *SnapshotStable) UpdateVolumeSnapshotStatusStable(ctx context.Context, namespace string, snapshotName string, readyToUse bool) error

UpdateVolumeSnapshotStatusStable sets the readyToUse valuse of a VolumeSnapshot.

func (*SnapshotStable) WaitOnReadyToUse

func (sna *SnapshotStable) WaitOnReadyToUse(ctx context.Context, snapshotName, namespace string) error

WaitOnReadyToUse will block until the Volumesnapshot in 'namespace' with name 'snapshotName' has status 'ReadyToUse' or 'ctx.Done()' is signalled.

type Snapshotter

type Snapshotter interface {
	// GetVolumeSnapshotClass returns VolumeSnapshotClass name which is annotated with given key
	//
	// 'annotationKey' is the annotation key which has to be present on VolumeSnapshotClass.
	// 'annotationValue' is the value for annotationKey in VolumeSnapshotClass spec.
	// 'storageClassName' is the name of the storageClass that shares the same driver as the VolumeSnapshotClass.
	// This returns error if no VolumeSnapshotClass found.
	GetVolumeSnapshotClass(ctx context.Context, annotationKey, annotationValue, storageClassName string) (string, error)

	// CloneVolumeSnapshotClass creates a copy of the source volume snapshot
	// class with the specified deletion policy and name. If the target
	// already exists, it returns no error.
	//
	// 'sourceClassName' is the name of the source VolumeSnapshotClass.
	// 'targetClassName' is the name of the target VolumeSnapshotClass
	// 'newDeletionPolicy' is the deletion policy to set on the target.
	// 'excludeAnnotations' are the annotations that should not be set on the
	// target
	CloneVolumeSnapshotClass(ctx context.Context, sourceClassName, targetClassName, newDeletionPolicy string, excludeAnnotations []string) error
	// Create creates a VolumeSnapshot and returns it or any error happened meanwhile.
	//
	// 'pvcName' is the name of the PVC of which we will take snapshot. It must be in the same namespace 'ns'.
	// 'waitForReady' will block the caller until the snapshot status is 'ReadyToUse'.
	// or 'ctx.Done()' is signalled. Otherwise it will return immediately after the snapshot is cut.
	// 'snapshotMeta' has metadata of the VolumeSnapshot resource that is going to get created.
	Create(ctx context.Context, pvcName string, snapshotClass *string, waitForReady bool, snapshotMeta ObjectMeta) error
	// Get will return the VolumeSnapshot in the namespace 'namespace' with given 'name'.
	//
	// 'name' is the name of the VolumeSnapshot that will be returned.
	// 'namespace' is the namespace of the VolumeSnapshot that will be returned.
	Get(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)
	// Delete will delete the VolumeSnapshot.
	// Returns the `VolumeSnapshot` deleted and any error as a result.
	//
	// 'name' is the name of the VolumeSnapshot that will be deleted.
	// 'namespace' is the namespace of the VolumeSnapshot that will be deleted.
	Delete(ctx context.Context, name, namespace string) (*v1.VolumeSnapshot, error)
	// DeleteContent will delete the VolumeSnapshot and returns any error as a
	// result.
	//
	// 'name' is the name of the VolumeSnapshotContent that will be deleted.
	DeleteContent(ctx context.Context, name string) error
	// Clone will clone the VolumeSnapshot to namespace 'cloneNamespace'.
	// Underlying VolumeSnapshotContent will be cloned with a different name.
	//
	// 'name' is the name of the VolumeSnapshot that will be cloned.
	// 'namespace' is the namespace of the VolumeSnapshot that will be cloned.
	// 'waitForReady' will make the function blocks until the clone's status is ready to use.
	// 'snapshotMeta' has metadata of the VolumeSnapshot resource that is going to get created.
	// 'snapshotContentMeta' has metadata of the VolumeSnapshotContent content resource that is going to get created.
	Clone(ctx context.Context, name, namespace string, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error
	// GetSource will return the CSI source that backs the volume snapshot.
	//
	// 'snapshotName' is the name of the VolumeSnapshot.
	// 'namespace' is the namespace of the VolumeSnapshot.
	GetSource(ctx context.Context, snapshotName, namespace string) (*Source, error)
	// CreateFromSource will create a 'VolumeSnapshot' and 'VolumeSnapshotContent' pair for the underlying snapshot source.
	//
	// 'source' contains information about CSI snapshot.
	// 'waitForReady' blocks the caller until snapshot is ready to use or context is cancelled.
	// 'snapshotMeta' has metadata of the VolumeSnapshot resource that is going to get created.
	// 'snapshotContentMeta' has metadata of the VolumeSnapshotContent resource that is going to get created.
	CreateFromSource(ctx context.Context, source *Source, waitForReady bool, snapshotMeta, snapshotContentMeta ObjectMeta) error
	// CreateContentFromSource will create a 'VolumeSnapshotContent' for the underlying snapshot source.
	//
	// 'source' contains information about CSI snapshot.
	// 'snapshotName' is the name of the snapshot that will be reference the VSC.
	// 'namespace' is the namespace of the snapshot.
	// 'deletionPolicy' is the deletion policy to set on the created VSC
	// 'snapshotContentMeta' has metadata of the VolumeSnapshotContent resource that is going to get created.
	CreateContentFromSource(ctx context.Context, source *Source, snapshotName, namespace, deletionPolicy string, snapshotContentMeta ObjectMeta) error
	// WaitOnReadyToUse will block until the VolumeSnapshot in namespace 'namespace' with name 'snapshotName'
	// has status 'ReadyToUse' or 'ctx.Done()' is signalled.
	WaitOnReadyToUse(ctx context.Context, snapshotName, namespace string) error
	// List will list the VolumeSnapshot in a namespace that match search. If labels aren't provided,
	// it will list all the snapshots in the namespace
	List(ctx context.Context, namespace string, labels map[string]string) (*v1.VolumeSnapshotList, error)
	// GroupVersion returns the group and version according to snapshotter version
	GroupVersion(ctx context.Context) schema.GroupVersion
}

Snapshotter is an interface that describes snapshot operations

func NewSnapshotAlpha

func NewSnapshotAlpha(kubeCli kubernetes.Interface, dynCli dynamic.Interface) Snapshotter

func NewSnapshotBeta

func NewSnapshotBeta(kubeCli kubernetes.Interface, dynCli dynamic.Interface) Snapshotter

func NewSnapshotStable

func NewSnapshotStable(kubeCli kubernetes.Interface, dynCli dynamic.Interface) Snapshotter

func NewSnapshotter

func NewSnapshotter(kubeCli kubernetes.Interface, dynCli dynamic.Interface) (Snapshotter, error)

NewSnapshotter creates and return new Snapshotter object

type Source

type Source struct {
	Handle                  string
	Driver                  string
	RestoreSize             *int64
	VolumeSnapshotClassName string
}

Source represents the CSI source of the Volumesnapshot.

Directories

Path Synopsis
apis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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