diff --git a/core/disk.go b/core/disk.go index f0eb3480..e5dccee6 100644 --- a/core/disk.go +++ b/core/disk.go @@ -146,7 +146,7 @@ func (disk *Disk) LabelDisk(label DiskLabel) error { // If fsType is an empty string, the function will skip creating the filesystem. // This can be useful when creating LUKS-encrypted partitions, where the format // operation needs to be executed first. -func (target *Disk) NewPartition(name string, fsType PartitionFs, start, end int64) (*Partition, error) { +func (target *Disk) NewPartition(name string, fsType PartitionFs, start, end int) (*Partition, error) { createPartCmd := "parted -s %s unit MiB mkpart%s%s %s %d %s" var partType string diff --git a/core/recipe.go b/core/recipe.go index 4bbba451..a59dc6e8 100644 --- a/core/recipe.go +++ b/core/recipe.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path/filepath" - "reflect" "regexp" "strconv" "strings" @@ -63,33 +62,11 @@ func ReadRecipe(path string) (*Recipe, error) { } var recipe Recipe - dec := json.NewDecoder(strings.NewReader(string(content))) - dec.DisallowUnknownFields() - dec.UseNumber() - err = dec.Decode(&recipe) + err = json.Unmarshal(content, &recipe) if err != nil { return nil, fmt.Errorf("failed to read recipe: %s", err) } - // Convert json.Number to int64 - for i := 0; i < len(recipe.Setup); i++ { - step := &recipe.Setup[i] - formattedParams := []interface{}{} - for _, param := range step.Params { - dummy := "1" - if reflect.TypeOf(param) == reflect.TypeOf(dummy) { - convertedParam, err := param.(json.Number).Int64() - if err != nil { - return nil, fmt.Errorf("failed to convert recipe parameter: %s", err) - } - formattedParams = append(formattedParams, convertedParam) - } else { - formattedParams = append(formattedParams, param) - } - } - step.Params = formattedParams - } - return &recipe, nil } @@ -134,8 +111,8 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { case "mkpart": name := args[0].(string) fsType := PartitionFs(args[1].(string)) - start := args[2].(int64) - end := args[3].(int64) + start := int(args[2].(float64)) + end := int(args[3].(float64)) if len(args) > 4 && strings.HasPrefix(string(fsType), "luks-") { luksPassword := args[4].(string) part, err := disk.NewPartition(name, "", start, end)