fix: deploy menu numbers only undeployed nodes
This commit is contained in:
parent
c49ee64b0b
commit
216b24b9ac
1 changed files with 6 additions and 8 deletions
|
|
@ -221,20 +221,18 @@ func deployMenu() {
|
||||||
fmt.Println("\n─── Deploy Node ───")
|
fmt.Println("\n─── Deploy Node ───")
|
||||||
available := []int{}
|
available := []int{}
|
||||||
for i, nc := range nodes {
|
for i, nc := range nodes {
|
||||||
marker := " "
|
|
||||||
if deployed[nc.Name] {
|
if deployed[nc.Name] {
|
||||||
marker = "✓ "
|
fmt.Printf(" ✓ %s (port %s) [deployed]\n", nc.Name, nc.Port)
|
||||||
}
|
} else {
|
||||||
fmt.Printf(" %s[%d] %s (port %s)\n", marker, i+1, nc.Name, nc.Port)
|
|
||||||
if !deployed[nc.Name] {
|
|
||||||
available = append(available, i)
|
available = append(available, i)
|
||||||
|
fmt.Printf(" [%d] %s (port %s)\n", len(available), nc.Name, nc.Port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(available) == 0 {
|
if len(available) == 0 {
|
||||||
fmt.Println("All nodes deployed.")
|
fmt.Println("All nodes deployed.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print("\nSelect node number (or Enter for all undeployed): ")
|
fmt.Print("\nSelect node number (or Enter for all): ")
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
choice, _ := reader.ReadString('\n')
|
choice, _ := reader.ReadString('\n')
|
||||||
choice = strings.TrimSpace(choice)
|
choice = strings.TrimSpace(choice)
|
||||||
|
|
@ -244,11 +242,11 @@ func deployMenu() {
|
||||||
for _, i := range available { selected = append(selected, nodes[i]) }
|
for _, i := range available { selected = append(selected, nodes[i]) }
|
||||||
} else {
|
} else {
|
||||||
idx, err := strconv.Atoi(choice)
|
idx, err := strconv.Atoi(choice)
|
||||||
if err != nil || idx < 1 || idx > len(nodes) {
|
if err != nil || idx < 1 || idx > len(available) {
|
||||||
fmt.Println("Invalid choice")
|
fmt.Println("Invalid choice")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
selected = append(selected, nodes[idx-1])
|
selected = append(selected, nodes[available[idx-1]])
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, nc := range selected {
|
for _, nc := range selected {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue