From 2c44846336ac6cdb8454679a01cf5fa329588d9a Mon Sep 17 00:00:00 2001 From: Muhammad Salman Date: Sun, 4 Aug 2024 10:54:19 +0000 Subject: [PATCH 1/2] Add setlabel to the recipe --- core/recipe.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/recipe.go b/core/recipe.go index ebddcb2..6196f09 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 labnel + */ + 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. From b52c2ac22fb38a65621e129f634b47ebd53a7c01 Mon Sep 17 00:00:00 2001 From: Mateus Melchiades Date: Sat, 10 Aug 2024 12:30:58 +0000 Subject: [PATCH 2/2] Fix typo + update recipe doc --- RECIPE.md | 8 ++++++++ core/recipe.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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 6196f09..05281ae 100644 --- a/core/recipe.go +++ b/core/recipe.go @@ -245,7 +245,7 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { * * **Accepts**: * - *PartNum* ('int'): The partition number on disk (e.g. '/dev/sda3' is partition 3). - * - *Label* ('string'): The filesystem labnel + * - *Label* ('string'): The filesystem label */ case "setlabel": partNum, err := jsonFieldToInt(args[0])