Skip to content

Commit edeeac7

Browse files
committed
refactor for loop updateRootSize and use const
1 parent d5f087f commit edeeac7

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

internal/services/baremetal/easy_partitioning_data_source.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ import (
1919
const (
2020
partitionSize = 20000000000
2121
defaultMountpoint = "/data"
22+
md0 = "/dev/md0"
23+
md1 = "/dev/md1"
24+
raidLevel1 = "raid_level_1"
25+
nvme0p2 = "/dev/nvme0n1p2"
26+
nvme0p3 = "/dev/nvme0n1p3"
27+
nvme1p1 = "/dev/nvme1n1p1"
28+
nvme1p2 = "/dev/nvme1n1p2"
2229
)
2330

2431
func DataEasyPartitioning() *schema.Resource {
@@ -152,19 +159,19 @@ func dataEasyPartitioningRead(ctx context.Context, d *schema.ResourceData, m int
152159
func updateRaidRemoveSwap(partitionSchema *baremetal.Schema) {
153160
raidSchema := []*baremetal.SchemaRAID{
154161
{
155-
Name: "/dev/md0",
156-
Level: "raid_level_1",
162+
Name: md0,
163+
Level: raidLevel1,
157164
Devices: []string{
158-
"/dev/nvme0n1p2",
159-
"/dev/nvme1n1p1",
165+
nvme0p2,
166+
nvme1p1,
160167
},
161168
},
162169
{
163-
Name: "/dev/md1",
164-
Level: "raid_level_1",
170+
Name: md1,
171+
Level: raidLevel1,
165172
Devices: []string{
166-
"/dev/nvme0n1p3",
167-
"/dev/nvme1n1p2",
173+
nvme0p3,
174+
nvme1p2,
168175
},
169176
},
170177
}
@@ -211,12 +218,11 @@ func updateSizeRoot(originalDisks []*baremetal.SchemaDisk, hasExtraPartition boo
211218
for _, disk := range originalDisks {
212219
for _, partition := range disk.Partitions {
213220
if partition.Label == "root" {
221+
partition.Size = 0
222+
partition.UseAllAvailableSpace = true
214223
if hasExtraPartition {
215224
partition.Size = partitionSize
216225
partition.UseAllAvailableSpace = false
217-
} else {
218-
partition.Size = 0
219-
partition.UseAllAvailableSpace = true
220226
}
221227
}
222228
}

0 commit comments

Comments
 (0)