disk: rename Create{Volume → Mountpoint}

The function is indeed creating a mounpoint not a Volume; the
latter is not even well defined in our "ontology".
This commit is contained in:
Christian Kellner 2022-02-26 20:12:12 +01:00
parent 45f898c05c
commit 7bfd0bb49f
5 changed files with 14 additions and 14 deletions

View file

@ -50,7 +50,7 @@ func (b *Btrfs) GetItemCount() uint {
func (b *Btrfs) GetChild(n uint) Entity {
return &b.Subvolumes[n]
}
func (b *Btrfs) CreateVolume(mountpoint string, size uint64) (Entity, error) {
func (b *Btrfs) CreateMountpoint(mountpoint string, size uint64) (Entity, error) {
name := mountpoint
if name == "/" {
name = "root"

View file

@ -98,10 +98,10 @@ type Mountable interface {
// A VolumeContainer is a container that is able to create new volumes.
//
// CreateVolume creates a new volume with the given mount point and
// size and returns it.
// CreateMountpoint creates a new mountpoint with the given size and
// returns the entity that represents the new mountpoint.
type VolumeContainer interface {
CreateVolume(mountpoint string, size uint64) (Entity, error)
CreateMountpoint(mountpoint string, size uint64) (Entity, error)
}
// A UniqueEntity is an entity that can be uniquely identified via a UUID.

View file

@ -57,9 +57,9 @@ func (vg *LVMVolumeGroup) GetChild(n uint) Entity {
return &vg.LogicalVolumes[n]
}
func (vg *LVMVolumeGroup) CreateVolume(mountpoint string, size uint64) (Entity, error) {
func (vg *LVMVolumeGroup) CreateMountpoint(mountpoint string, size uint64) (Entity, error) {
if vg == nil {
panic("LVMVolumeGroup.CreateVolume: nil entity")
panic("LVMVolumeGroup.CreateMountpoint: nil entity")
}
filesystem := Filesystem{
Type: "xfs",

View file

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestLVMVGCreateVolume(t *testing.T) {
func TestLVMVCreateMountpoint(t *testing.T) {
assert := assert.New(t)
@ -15,15 +15,15 @@ func TestLVMVGCreateVolume(t *testing.T) {
Description: "root volume group",
}
entity, err := vg.CreateVolume("/", 0)
entity, err := vg.CreateMountpoint("/", 0)
assert.NoError(err)
rootlv := entity.(*LVMLogicalVolume)
assert.Equal("rootlv", rootlv.Name)
_, err = vg.CreateVolume("/home_test", 0)
_, err = vg.CreateMountpoint("/home_test", 0)
assert.NoError(err)
entity, err = vg.CreateVolume("/home/test", 0)
entity, err = vg.CreateMountpoint("/home/test", 0)
assert.NoError(err)
dedup := entity.(*LVMLogicalVolume)
@ -31,10 +31,10 @@ func TestLVMVGCreateVolume(t *testing.T) {
// Lets collide it
for i := 0; i < 98; i++ {
_, err = vg.CreateVolume("/home/test", 0)
_, err = vg.CreateMountpoint("/home/test", 0)
assert.NoError(err)
}
_, err = vg.CreateVolume("/home/test", 0)
_, err = vg.CreateMountpoint("/home/test", 0)
assert.Error(err)
}

View file

@ -158,7 +158,7 @@ func (pt *PartitionTable) EnsureSize(s uint64) bool {
return false
}
func (pt *PartitionTable) CreateVolume(mountpoint string, size uint64) (Entity, error) {
func (pt *PartitionTable) CreateMountpoint(mountpoint string, size uint64) (Entity, error) {
filesystem := Filesystem{
Type: "xfs",
Mountpoint: mountpoint,
@ -330,7 +330,7 @@ func (pt *PartitionTable) createFilesystem(mountpoint string, size uint64) error
panic("could not find root volume container")
}
newVol, err := vc.CreateVolume(mountpoint, 0)
newVol, err := vc.CreateMountpoint(mountpoint, 0)
if err != nil {
return fmt.Errorf("failed creating volume: " + err.Error())
}