diff --git a/RECIPE.md b/RECIPE.md index 3f53fe2..636e6fb 100644 --- a/RECIPE.md +++ b/RECIPE.md @@ -49,6 +49,14 @@ Rename the specified partition. - *PartNum* (`int`): The partition number on disk (e.g. `/dev/sda3` is partition 3). - *PartNewName* (`string`): The new name for the partition. +### setlabel + +Set the filesystem label of the specified partition. + +**Accepts**: +- *PartNum* ('int'): The partition number on disk (e.g. '/dev/sda3' is partition 3). +- *Label* ('string'): The filesystem label + ### setflag Set the value of a partition flag, from the flags supported by parted. diff --git a/core/recipe.go b/core/recipe.go index ebddcb2..05281ae 100644 --- a/core/recipe.go +++ b/core/recipe.go @@ -239,6 +239,27 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { if err != nil { return operationError(operation, err) } + /* !! ### setlabel + * + * Set the filesystem label of the specified partition. + * + * **Accepts**: + * - *PartNum* ('int'): The partition number on disk (e.g. '/dev/sda3' is partition 3). + * - *Label* ('string'): The filesystem label + */ + case "setlabel": + partNum, err := jsonFieldToInt(args[0]) + if err != nil { + return operationError(operation, err) + } + partNewName, ok := args[1].(string) + if !ok { + return operationError(operation, "%v is not a string", partNewName) + } + err = target.GetPartition(partNum).SetLabel(partNewName) + if err != nil { + return operationError(operation, err) + } /* !! ### setflag * * Set the value of a partition flag, from the flags supported by parted.