2019-12-16 13:19:59 +00:00
|
|
|
package structs
|
|
|
|
|
2020-01-08 19:52:06 +00:00
|
|
|
import (
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
"github.com/hashicorp/nomad/plugins/csi"
|
2019-12-17 11:09:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CSIVolumeMountOptions contains the mount options that should be provided when
|
|
|
|
// attaching and mounting a volume with the CSIVolumeAttachmentModeFilesystem
|
|
|
|
// attachment mode.
|
|
|
|
type CSIVolumeMountOptions struct {
|
|
|
|
// Filesystem is the desired filesystem type that should be used by the volume
|
|
|
|
// (e.g ext4, aufs, zfs). This field is optional.
|
|
|
|
Filesystem string
|
|
|
|
|
|
|
|
// MountFlags contain the mount options that should be used for the volume.
|
|
|
|
// These may contain _sensitive_ data and should not be leaked to logs or
|
|
|
|
// returned in debugging data.
|
|
|
|
// The total size of this field must be under 4KiB.
|
|
|
|
MountFlags []string
|
|
|
|
}
|
|
|
|
|
2019-12-17 11:37:33 +00:00
|
|
|
type ClientCSIControllerAttachVolumeRequest struct {
|
2019-12-16 13:19:59 +00:00
|
|
|
PluginName string
|
|
|
|
|
|
|
|
// The ID of the volume to be used on a node.
|
|
|
|
// This field is REQUIRED.
|
|
|
|
VolumeID string
|
|
|
|
|
|
|
|
// The ID of the node. This field is REQUIRED. This must match the NodeID that
|
|
|
|
// is fingerprinted by the target node for this plugin name.
|
|
|
|
NodeID string
|
|
|
|
|
2019-12-17 11:09:57 +00:00
|
|
|
// AttachmentMode indicates how the volume should be attached and mounted into
|
|
|
|
// a task.
|
2020-01-08 19:52:06 +00:00
|
|
|
AttachmentMode structs.CSIVolumeAttachmentMode
|
2019-12-17 11:09:57 +00:00
|
|
|
|
|
|
|
// AccessMode indicates the desired concurrent access model for the volume
|
2020-01-08 19:52:06 +00:00
|
|
|
AccessMode structs.CSIVolumeAccessMode
|
2019-12-16 13:19:59 +00:00
|
|
|
|
2019-12-17 11:09:57 +00:00
|
|
|
// MountOptions is an optional field that contains additional configuration
|
|
|
|
// when providing an AttachmentMode of CSIVolumeAttachmentModeFilesystem
|
|
|
|
MountOptions *CSIVolumeMountOptions
|
2019-12-16 13:19:59 +00:00
|
|
|
|
2019-12-17 11:09:57 +00:00
|
|
|
// ReadOnly indicates that the volume will be used in a readonly fashion. This
|
|
|
|
// only works when the Controller has the PublishReadonly capability.
|
2019-12-16 13:19:59 +00:00
|
|
|
ReadOnly bool
|
|
|
|
}
|
|
|
|
|
2019-12-17 11:37:33 +00:00
|
|
|
func (c *ClientCSIControllerAttachVolumeRequest) ToCSIRequest() *csi.ControllerPublishVolumeRequest {
|
2019-12-16 13:19:59 +00:00
|
|
|
if c == nil {
|
|
|
|
return &csi.ControllerPublishVolumeRequest{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &csi.ControllerPublishVolumeRequest{
|
|
|
|
VolumeID: c.VolumeID,
|
|
|
|
NodeID: c.NodeID,
|
|
|
|
ReadOnly: c.ReadOnly,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-17 11:37:33 +00:00
|
|
|
type ClientCSIControllerAttachVolumeResponse struct {
|
2019-12-16 13:19:59 +00:00
|
|
|
// Opaque static publish properties of the volume. SP MAY use this
|
|
|
|
// field to ensure subsequent `NodeStageVolume` or `NodePublishVolume`
|
|
|
|
// calls calls have contextual information.
|
|
|
|
// The contents of this field SHALL be opaque to nomad.
|
|
|
|
// The contents of this field SHALL NOT be mutable.
|
|
|
|
// The contents of this field SHALL be safe for the nomad to cache.
|
|
|
|
// The contents of this field SHOULD NOT contain sensitive
|
|
|
|
// information.
|
|
|
|
// The contents of this field SHOULD NOT be used for uniquely
|
|
|
|
// identifying a volume. The `volume_id` alone SHOULD be sufficient to
|
|
|
|
// identify the volume.
|
|
|
|
// This field is OPTIONAL and when present MUST be passed to
|
|
|
|
// subsequent `NodeStageVolume` or `NodePublishVolume` calls
|
|
|
|
PublishContext map[string]string
|
|
|
|
}
|
2020-02-10 16:45:06 +00:00
|
|
|
|
|
|
|
type ClientCSIControllerDetachVolumeRequest struct {
|
|
|
|
PluginName string
|
|
|
|
|
|
|
|
// The ID of the volume to be unpublished for the node
|
|
|
|
// This field is REQUIRED.
|
|
|
|
VolumeID string
|
|
|
|
|
|
|
|
// The ID of the node. This field is REQUIRED. This must match the NodeID that
|
|
|
|
// is fingerprinted by the target node for this plugin name.
|
|
|
|
NodeID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ClientCSIControllerDetachVolumeRequest) ToCSIRequest() *csi.ControllerUnpublishVolumeRequest {
|
|
|
|
if c == nil {
|
|
|
|
return &csi.ControllerUnpublishVolumeRequest{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &csi.ControllerUnpublishVolumeRequest{
|
|
|
|
VolumeID: c.VolumeID,
|
|
|
|
NodeID: c.NodeID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ClientCSIControllerDetachVolumeResponse struct{}
|