@@ -19,6 +19,19 @@ import (
19
19
const (
20
20
partitionSize = 20000000000
21
21
defaultMountpoint = "/data"
22
+ md0 = "/dev/md0"
23
+ md1 = "/dev/md1"
24
+ md2 = "/dev/md2"
25
+ ext4 = "ext4"
26
+ raidLevel1 = "raid_level_1"
27
+ nvme0p2 = "/dev/nvme0n1p2"
28
+ nvme0p3 = "/dev/nvme0n1p3"
29
+ nvme1p1 = "/dev/nvme1n1p1"
30
+ nvme1p2 = "/dev/nvme1n1p2"
31
+ uefi = "uefi"
32
+ swap = "swap"
33
+ root = "root"
34
+ boot = "boot"
22
35
)
23
36
24
37
func DataEasyPartitioning () * schema.Resource {
@@ -152,19 +165,19 @@ func dataEasyPartitioningRead(ctx context.Context, d *schema.ResourceData, m int
152
165
func updateRaidRemoveSwap (partitionSchema * baremetal.Schema ) {
153
166
raidSchema := []* baremetal.SchemaRAID {
154
167
{
155
- Name : "/dev/ md0" ,
156
- Level : "raid_level_1" ,
168
+ Name : md0 ,
169
+ Level : raidLevel1 ,
157
170
Devices : []string {
158
- "/dev/nvme0n1p2" ,
159
- "/dev/nvme1n1p1" ,
171
+ nvme0p2 ,
172
+ nvme1p1 ,
160
173
},
161
174
},
162
175
{
163
- Name : "/dev/ md1" ,
164
- Level : "raid_level_1" ,
176
+ Name : md1 ,
177
+ Level : raidLevel1 ,
165
178
Devices : []string {
166
- "/dev/nvme0n1p3" ,
167
- "/dev/nvme1n1p2" ,
179
+ nvme0p3 ,
180
+ nvme1p2 ,
168
181
},
169
182
},
170
183
}
@@ -175,8 +188,8 @@ func updateRaidNewPartition(partitionSchema *baremetal.Schema) {
175
188
lenDisk0Partition := len (partitionSchema .Disks [0 ].Partitions )
176
189
lenDisk1Partition := len (partitionSchema .Disks [1 ].Partitions )
177
190
raid := & baremetal.SchemaRAID {
178
- Name : "/dev/ md2" ,
179
- Level : "raid_level_1" ,
191
+ Name : md2 ,
192
+ Level : raidLevel1 ,
180
193
Devices : []string {
181
194
fmt .Sprintf ("%sp%d" , partitionSchema .Disks [0 ].Device , lenDisk0Partition ),
182
195
fmt .Sprintf ("%sp%d" , partitionSchema .Disks [1 ].Device , lenDisk1Partition ),
@@ -200,8 +213,8 @@ func addExtraExt4Partition(mountpoint string, defaultPartitionSchema *baremetal.
200
213
}
201
214
202
215
filesystem := & baremetal.SchemaFilesystem {
203
- Device : "/dev/ md2" ,
204
- Format : " ext4" ,
216
+ Device : md2 ,
217
+ Format : ext4 ,
205
218
Mountpoint : mountpoint ,
206
219
}
207
220
defaultPartitionSchema .Filesystems = append (defaultPartitionSchema .Filesystems , filesystem )
@@ -210,13 +223,12 @@ func addExtraExt4Partition(mountpoint string, defaultPartitionSchema *baremetal.
210
223
func updateSizeRoot (originalDisks []* baremetal.SchemaDisk , hasExtraPartition bool ) {
211
224
for _ , disk := range originalDisks {
212
225
for _ , partition := range disk .Partitions {
213
- if partition .Label == "root" {
226
+ if partition .Label == root {
227
+ partition .Size = 0
228
+ partition .UseAllAvailableSpace = true
214
229
if hasExtraPartition {
215
230
partition .Size = partitionSize
216
231
partition .UseAllAvailableSpace = false
217
- } else {
218
- partition .Size = 0
219
- partition .UseAllAvailableSpace = true
220
232
}
221
233
}
222
234
}
@@ -228,11 +240,11 @@ func removeSwap(originalDisks []*baremetal.SchemaDisk) {
228
240
newPartitions := make ([]* baremetal.SchemaPartition , 0 , len (disk .Partitions ))
229
241
230
242
for _ , partition := range disk .Partitions {
231
- if partition .Label == " swap" {
243
+ if partition .Label == swap {
232
244
continue
233
245
}
234
246
235
- if partition .Label != " uefi" {
247
+ if partition .Label != uefi {
236
248
partition .Number --
237
249
}
238
250
0 commit comments