disk: new interface UniqueEntity for Entities with UUID
This is for all entities that have a uniquely identifiable via a UUID. Currently the interface only contains a single function, GenUUID(), that should generate a new UUID via a random source (`rand.Rand`). NB: Partitions are uniquely identifiable if and only if the layout is GPT. Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
126c23cb13
commit
b0899c5c59
5 changed files with 55 additions and 5 deletions
|
|
@ -1,6 +1,11 @@
|
|||
package disk
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Argon2id struct {
|
||||
Iterations uint
|
||||
|
|
@ -59,3 +64,9 @@ func (lc *LUKSContainer) Clone() Entity {
|
|||
Payload: lc.Payload,
|
||||
}
|
||||
}
|
||||
|
||||
func (lc *LUKSContainer) GenUUID(rng *rand.Rand) {
|
||||
if lc.UUID == "" {
|
||||
lc.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue