Refactor ConstructVolumeSpec

Return a struct from ConstructVolumeSpec to be able to add more fields to
it later.
This commit is contained in:
Jan Safranek
2022-10-19 14:52:08 +02:00
parent 2dc8cc13a4
commit fc245b339b
35 changed files with 202 additions and 141 deletions

View File

@@ -166,7 +166,7 @@ type VolumePlugin interface {
// and volumePath. The spec may have incomplete information due to limited
// information from input. This function is used by volume manager to reconstruct
// volume spec by reading the volume directories from disk
ConstructVolumeSpec(volumeName, volumePath string) (*Spec, error)
ConstructVolumeSpec(volumeName, volumePath string) (ReconstructedVolume, error)
// SupportsMountOption returns true if volume plugins supports Mount options
// Specifying mount options in a volume plugin that doesn't support
@@ -570,6 +570,12 @@ type VolumeConfig struct {
ProvisioningEnabled bool
}
// ReconstructedVolume contains information about a volume reconstructed by
// ConstructVolumeSpec().
type ReconstructedVolume struct {
Spec *Spec
}
// NewSpecFromVolume creates an Spec from an v1.Volume
func NewSpecFromVolume(vs *v1.Volume) *Spec {
return &Spec{