Skip to content

Commit

Permalink
feat: Add setlabel to the recipe
Browse files Browse the repository at this point in the history
* Add setlabel to the recipe

* Fix typo + update recipe doc

---------

Co-authored-by: Mateus Melchiades <matbme@duck.com>
  • Loading branch information
muhdsalm and matbme committed Aug 10, 2024
1 parent cee36c6 commit f7a1c81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions RECIPE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions core/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f7a1c81

Please sign in to comment.