volumeoptions

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessMode

type AccessMode string

AccessMode represents volume access modes

const (
	// SingleNode indicates the volume can only be accessed from a single node
	SingleNode AccessMode = "single"
	// MultiNode indicates the volume can be accessed from multiple nodes
	MultiNode AccessMode = "multi"
)

type SetVolumeOptFn

type SetVolumeOptFn func(options *volume.CreateOptions)

SetVolumeOptFn is a function type that configures options for creating a Docker volume.

func AddDriverOpt

func AddDriverOpt(key, value string) SetVolumeOptFn

AddDriverOpt adds a driver-specific option. Each driver has its own set of options. Common ones include:

Local driver: - size: Size of the volume - type: Filesystem type

NFS driver: - server: NFS server address - share: Export path from NFS server - security: NFS security options

Usage example:

volume.SetOptions(
	volumeoptions.SetDriver(volumeoptions.NFSDriver),
	volumeoptions.AddDriverOpt("server", "10.0.0.1"),
	volumeoptions.AddDriverOpt("share", "/exports"),
)

func AddLabel

func AddLabel(key, value string) SetVolumeOptFn

AddLabel adds a label to the Docker volume. Labels provide a way to attach metadata to volumes for categorization or organization.

Usage example:

volume.SetOptions(
	volumeoptions.AddLabel("environment", "production"),
	volumeoptions.AddLabel("project", "web-app"),
)

func AddSecret

func AddSecret(key, secretID string) SetVolumeOptFn

AddSecret adds a secret that will be passed to the CSI storage plugin. This is only applicable for cluster volumes.

Usage example:

volume.SetOptions(
	volumeoptions.AddSecret("encryption-key", "my-secret-id"),
)

func SetAvailability

func SetAvailability(availability VolumeAvailability) SetVolumeOptFn

SetAvailability sets the availability state of a cluster volume.

Usage example:

volume.SetOptions(
	volumeoptions.SetAvailability(volumeoptions.AvailabilityActive),
)

func SetCapacityRange

func SetCapacityRange(requiredBytes, limitBytes int64) SetVolumeOptFn

SetCapacityRange sets the desired capacity range for the volume. This is only applicable for cluster volumes.

Usage example:

volume.SetOptions(
	volumeoptions.SetCapacityRange(100*1024*1024, 1024*1024*1024), // 100MB to 1GB
)

func SetClusterSpec

func SetClusterSpec(group string, access AccessMode, sharing SharingMode) SetVolumeOptFn

SetClusterSpec sets the cluster volume specification for swarm mode volumes.

Usage example:

volume.SetOptions(
	volumeoptions.SetClusterSpec(
		"backend-group",
		volumeoptions.SingleNode,
		volumeoptions.ReadWrite,
	),
)

func SetDriver

func SetDriver(driver VolumeDriver) SetVolumeOptFn

SetDriver sets the driver to use for creating the Docker volume.

Usage example:

volume.SetOptions(
	volumeoptions.SetDriver(volumeoptions.NFSDriver),
)

func SetDriverOpts

func SetDriverOpts(opts map[string]string) SetVolumeOptFn

SetDriverOpts sets multiple driver-specific options at once.

Usage example:

volume.SetOptions(
	volumeoptions.SetDriver(volumeoptions.NFSDriver),
	volumeoptions.SetDriverOpts(map[string]string{
		"server": "10.0.0.1",
		"share": "/exports",
		"security": "sys",
	}),
)

func SetLabels

func SetLabels(labels map[string]string) SetVolumeOptFn

SetLabels sets multiple labels at once.

Usage example:

volume.SetOptions(
	volumeoptions.SetLabels(map[string]string{
		"environment": "production",
		"project": "web-app",
		"team": "backend",
	}),
)

func SetName

func SetName(name string) SetVolumeOptFn

SetName sets the name of the Docker volume.

Usage example:

volume.SetOptions(
	volumeoptions.SetName("my-data-volume"),
)

func SetTopologyRequirement

func SetTopologyRequirement(req TopologyRequirement) SetVolumeOptFn

SetTopologyRequirement sets the topology requirements for a cluster volume. This specifies which nodes in the cluster the volume must be accessible from.

Usage example:

volume.SetOptions(
	volumeoptions.SetTopologyRequirement(volumeoptions.TopologyRequirement{
		Requisite: []map[string]string{
			{"region": "us-east", "zone": "us-east-1a"},
			{"region": "us-east", "zone": "us-east-1b"},
		},
		Preferred: []map[string]string{
			{"region": "us-east", "zone": "us-east-1a"},
		},
	}),
)

type SharingMode

type SharingMode string

SharingMode represents volume sharing modes

const (
	// None indicates no sharing
	None SharingMode = "none"
	// ReadOnly indicates read-only sharing
	ReadOnly SharingMode = "read-only"
	// ReadWrite indicates read-write sharing
	ReadWrite SharingMode = "read-write"
)

type TopologyRequirement

type TopologyRequirement struct {
	Requisite []map[string]string
	Preferred []map[string]string
}

TopologyRequirement specifies where in the cluster a volume must be accessible from

type VolumeAvailability

type VolumeAvailability = volume.Availability

VolumeAvailability represents the availability state of a cluster volume

const (
	// AvailabilityActive indicates that the volume is active and fully schedulable
	AvailabilityActive VolumeAvailability = volume.AvailabilityActive
	// AvailabilityPause indicates that no new workloads should use the volume
	AvailabilityPause VolumeAvailability = volume.AvailabilityPause
	// AvailabilityDrain indicates that all workloads using this volume should be rescheduled
	AvailabilityDrain VolumeAvailability = volume.AvailabilityDrain
)

type VolumeDriver

type VolumeDriver string

VolumeDriver represents supported volume drivers

const (
	// LocalDriver is the default local volume driver
	LocalDriver VolumeDriver = "local"
	// NFSDriver is for NFS volumes
	NFSDriver VolumeDriver = "nfs"
	// CephDriver is for Ceph RBD volumes
	CephDriver VolumeDriver = "rbd"
	// GlusterFSDriver is for GlusterFS volumes
	GlusterFSDriver VolumeDriver = "glusterfs"
)

Jump to

Keyboard shortcuts

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