move2kube icon indicating copy to clipboard operation
move2kube copied to clipboard

Reduce the chance of bugs and simplify the logic for certain QA by using indices instead of actual options.

Open HarikrishnanBalagopal opened this issue 4 years ago • 2 comments

Description

During Select and MultiSelect type QA we present some options to the user and they select one or more of them. To make it simple for the user we simplify the options (ex: make absolute paths into relative paths) However this can cause issues in certain corner cases where the options can become ambiguous.

It also limits us by not being able to show extra metadata that would be useful for the user. Ex: Display translation type next to the service name.

? 1. Select all services that are needed: 
Hints: 
 [The services unselected here will be ignored.]
  [Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
[✓] svc1 [Dockerfile2Kube]
[✓] svc2 [Compose2Kube]
[✓] svc3 [Any2Kube]

Proposed Fix

Use indices instead of strings. Ex:

package main
import (
	"fmt"
	"github.com/AlecAivazis/survey/v2"
)
func main() {
	days := []int{}
	prompt := &survey.MultiSelect{
		Message: "What days do you prefer:",
		Options: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
	}
	survey.AskOne(prompt, &days)
	fmt.Printf("days: %+v\n", days)
}

This allows us to display something nice to the user while using a different thing internally.

HarikrishnanBalagopal avatar Nov 25 '20 18:11 HarikrishnanBalagopal

Avoids chance for ambiguity here: https://github.com/konveyor/move2kube/blob/main/internal/move2kube/planner.go#L206-L216 once this is fixed.

HarikrishnanBalagopal avatar Jan 30 '21 19:01 HarikrishnanBalagopal

We should probably add another text named say, display text instead of changing the current behavior, so more robust display engines like cli and web can use them. For things like settings, we can retain current behavior.

Indices need to rely on orders which will be a challenge.

https://www.w3schools.com/tags/tag_select.asp

ashokponkumar avatar Jan 31 '21 06:01 ashokponkumar