forked from dorzheh/deployer
/
config.go
29 lines (25 loc) · 807 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package config
import (
"fmt"
"github.com/dorzheh/deployer/builder/image"
)
func StorageConfig(pathToMainImage string, configIndex image.ConfigIndex, sconf *image.Storage, diskSizeMbSlice []int) (*image.Config, error) {
conf, err := sconf.IndexToConfig(configIndex)
if err != nil {
return nil, err
}
deviceIndex := 0
amountOfDisks := len(conf.Disks)
for ; amountOfDisks != 0; amountOfDisks-- {
if deviceIndex == 0 {
conf.Disks[deviceIndex].Path = fmt.Sprintf("%s.%s", pathToMainImage, conf.Disks[deviceIndex].Type)
} else {
conf.Disks[deviceIndex].Path = fmt.Sprintf("%s_%d.%s", pathToMainImage, deviceIndex, conf.Disks[deviceIndex].Type)
}
if len(diskSizeMbSlice) > 0 {
conf.Disks[deviceIndex].SizeMb = diskSizeMbSlice[deviceIndex]
}
deviceIndex++
}
return conf, nil
}