refactor: return an int32 for scale count

This commit is contained in:
Jose Diaz-Gonzalez
2024-01-18 19:23:57 -05:00
parent 3f96a250a2
commit 6bcb4a016d
2 changed files with 6 additions and 6 deletions

View File

@@ -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

View File

@@ -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)