Skip to content

Commit

Permalink
refactor: expose InsertAt method via interface
Browse files Browse the repository at this point in the history
External code is using generic interface, not GPT code directly.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira authored and talos-bot committed Oct 23, 2020
1 parent c40dcd8 commit cebe43d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion blockdevice/table/gpt/gpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (gpt *GPT) Add(size uint64, setters ...interface{}) (table.Partition, error
return gpt.InsertAt(len(gpt.partitions), size, setters...)
}

// InsertAt inserts partition after the partition at the position idx.
// InsertAt inserts partition before the partition at the position idx.
//
// If idx == 0, it inserts new partition as the first partition, etc., idx == 1 as the second, etc.
func (gpt *GPT) InsertAt(idx int, size uint64, setters ...interface{}) (table.Partition, error) {
Expand Down
6 changes: 5 additions & 1 deletion blockdevice/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package table

import "github.com/talos-systems/go-blockdevice/blockdevice/serde"
import (
"github.com/talos-systems/go-blockdevice/blockdevice/serde"
)

// Table represents a partition table.
type Table = []byte
Expand Down Expand Up @@ -67,6 +69,8 @@ type Partition interface {
type Partitioner interface {
// Add adds a partition to the partition table.
Add(uint64, ...interface{}) (Partition, error)
// InsertAt inserts partition before the partition at the position idx.
InsertAt(idx int, size uint64, setters ...interface{}) (Partition, error)
// Resize resizes a partition table.
Resize(Partition) error
// Delete deletes a partition table.
Expand Down

0 comments on commit cebe43d

Please sign in to comment.