package main import ( "fmt" "regexp" ) // planID is every id the mesh gives a plan: a merge's walk or batch (plan-) or a release // (release-). var planID = regexp.MustCompile(`^(plan|release)-[0-9]+$`) // planIDArguments are the arguments of plans that name a plan. wait is among them for when it is declared // (novox/hq issue 229); an argument not declared is refused before this is asked. var planIDArguments = []string{"id", "wait", "stop", "close", "retry", "go"} // plainPlanIDs refuses a plans call naming a plan by anything but a plan's id (novox/hq issue 561): checked // once, where the call becomes a command line, so nothing else a caller sent reaches a command or the store. func plainPlanIDs(given map[string]string) error { for _, arg := range planIDArguments { if id, named := given[arg]; named && !planID.MatchString(id) { return fmt.Errorf("plans %s: %q is not a plan's id (plan- or release-, as `plans` "+ "lists them); nothing was done", arg, id) } } return nil }