refactor: return an int32 for scale count
This commit is contained in:
@@ -390,8 +390,8 @@ func ParseReportArgs(pluginName string, arguments []string) ([]string, string, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseScaleOutput allows golang plugins to properly parse the output of ps-current-scale
|
// ParseScaleOutput allows golang plugins to properly parse the output of ps-current-scale
|
||||||
func ParseScaleOutput(b []byte) (map[string]int, error) {
|
func ParseScaleOutput(b []byte) (map[string]int32, error) {
|
||||||
scale := make(map[string]int)
|
scale := make(map[string]int32)
|
||||||
|
|
||||||
for _, line := range strings.Split(string(b), "\n") {
|
for _, line := range strings.Split(string(b), "\n") {
|
||||||
s := strings.SplitN(line, "=", 2)
|
s := strings.SplitN(line, "=", 2)
|
||||||
@@ -399,11 +399,11 @@ func ParseScaleOutput(b []byte) (map[string]int, error) {
|
|||||||
return scale, fmt.Errorf("invalid scale output stored by dokku: %v", line)
|
return scale, fmt.Errorf("invalid scale output stored by dokku: %v", line)
|
||||||
}
|
}
|
||||||
processType := s[0]
|
processType := s[0]
|
||||||
count, err := strconv.Atoi(s[1])
|
count, err := strconv.ParseInt(s[1], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scale, err
|
return scale, err
|
||||||
}
|
}
|
||||||
scale[processType] = count
|
scale[processType] = int32(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
return scale, nil
|
return scale, nil
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ func BuildConfig(appName string) error {
|
|||||||
common.LogInfo1(fmt.Sprintf("Ensuring network configuration is in sync for %s", appName))
|
common.LogInfo1(fmt.Sprintf("Ensuring network configuration is in sync for %s", appName))
|
||||||
|
|
||||||
for processType, procCount := range scale {
|
for processType, procCount := range scale {
|
||||||
containerIndex := 0
|
containerIndex := int32(0)
|
||||||
for containerIndex < procCount {
|
for containerIndex < procCount {
|
||||||
containerIndex++
|
containerIndex++
|
||||||
containerIndexString := strconv.Itoa(containerIndex)
|
containerIndexString := strconv.FormatInt(int64(containerIndex), 10)
|
||||||
containerIDFile := fmt.Sprintf("%v/CONTAINER.%v.%v", appRoot, processType, containerIndex)
|
containerIDFile := fmt.Sprintf("%v/CONTAINER.%v.%v", appRoot, processType, containerIndex)
|
||||||
|
|
||||||
containerID := common.ReadFirstLine(containerIDFile)
|
containerID := common.ReadFirstLine(containerIDFile)
|
||||||
|
|||||||
Reference in New Issue
Block a user