util

package
v0.33.15 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PrepareDownloadFunc            = PrepareDownload
	CreateDataExporterIfNeededFunc = CreateDataExporterIfNeeded
	// ResolveClientFunc is stubbable because resolution is the first thing a command does and
	// the only step that contacts the API server before any of the work under test.
	ResolveClientFunc = ResolveClient
)

Function pointers for test stubbing

Functions

func CreateDataExport

func CreateDataExport(ctx context.Context, deName, namespace, ttl, group, kind, volumeName string, publish bool, rtClient ctrlrtclient.Client) error

CreateDataExport creates a DataExport CR targeting the object identified by group, kind, and volumeName. group is the API group ("" for core, e.g. "snapshot.storage.k8s.io" for VolumeSnapshot). kind is the target object kind (e.g. "VolumeSnapshot", "PersistentVolumeClaim").

func CreateDataExporterIfNeeded

func CreateDataExporterIfNeeded(ctx context.Context, log *slog.Logger, deName, namespace string, publish bool, ttl string, rtClient ctrlrtclient.Client) (string, error)

func DeleteDataExport

func DeleteDataExport(ctx context.Context, deName, namespace string, rtClient ctrlrtclient.Client) error

func EnsureDataExportPublish added in v0.29.8

func EnsureDataExportPublish(
	ctx context.Context,
	deObj *v1alpha1.DataExport,
	publish bool,
	rtClient ctrlrtclient.Client,
) error

EnsureDataExportPublish patches DataExport.Spec.Publish to match the resolved value. Only upgrades publish: false -> true is patched, true -> false is intentionally skipped to avoid downgrading already-published resources.

func GetDataExport

func GetDataExport(ctx context.Context, deName, namespace string, rtClient ctrlrtclient.Client) (*v1alpha1.DataExport, error)

func GetDataExportWithRestart

func GetDataExportWithRestart(ctx context.Context, deName, namespace string, rtClient ctrlrtclient.Client, log *slog.Logger) (*v1alpha1.DataExport, error)

func PrepareDownload

func PrepareDownload(ctx context.Context, log *slog.Logger, backend dataapi.Backend, deName, namespace string, publish bool, sClient *safeClient.SafeClient) (string, string, *safeClient.SafeClient, error)

PrepareDownload waits for the export to be usable and returns the data-plane URL, the volume mode and a client trusting the exporter's CA. backend is the group resolved for this run; it builds this function's own control-plane client, which would otherwise default to storage-foundation's group regardless of what the cluster serves.

func ResolveClient added in v0.33.14

func ResolveClient(
	ctx context.Context,
	sClient *safeClient.SafeClient,
	namespace string,
	log *slog.Logger,
) (dataapi.Backend, ctrlrtclient.Client, error)

ResolveClient resolves which of the two producers serves DataExport to this user in this namespace, and returns both the answer and a control-plane client bound to it.

Every `d8 data export` subcommand starts here rather than registering a fixed group, because the same binary ships to clusters that serve only storage-foundation's group, only storage-volume-data-manager's, or both with the user authorized for one of them. The resolved backend is returned alongside the client because callers that build their own client later (PrepareDownload) must bind it to the same group.

func SetupLogger

func SetupLogger() *slog.Logger

Types

This section is empty.

Jump to

Keyboard shortcuts

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