| 1 | package console |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "sort" |
| 6 | ) |
| 7 | |
| 8 | // instanceChoices lists, under their names, the regions an EXPLICIT |
| 9 | // request for this same socket-backed instance would pass right now (codex |
| 10 | // plan-R4 2): the manifest's allow-list as the door reads it (each code |
| 11 | // normalized through homeRegionIn first), the armed gate's reachable and |
| 12 | // hosting bars, and R9's refusal. These are the explicit door's rules, not |
| 13 | // automatic eligibility. except, the region just refused, is left out. |
| 14 | // |
| 15 | // The home joins the list only when CONSOLE_HOME_REGION names it: an |
| 16 | // unnamed home has no name a caller could pass. The bars are |
| 17 | // explicitGate.refusal, the same predicate the app-region doors use, so no |
| 18 | // door lists a region another would refuse. |
| 19 | func (s *Server) instanceChoices(ctx context.Context, allowed []string, cands []regionCandidate, except string) []string { |
| 20 | g := explicitGate{cands: cands} |
| 21 | g.caps, g.published = placements(ctx, s.cfg.Releases) |
| 22 | codes := map[string]bool{} |
| 23 | if s.cfg.HomeRegion != "" { |
| 24 | codes[""] = true |
| 25 | } |
| 26 | for c := range g.caps { |
| 27 | if code := s.homeRegionIn(c); code != "" { |
| 28 | codes[code] = true |
| 29 | } |
| 30 | } |
| 31 | for _, c := range allowed { |
| 32 | if code := s.homeRegionIn(c); code != "" { |
| 33 | codes[code] = true |
| 34 | } |
| 35 | } |
| 36 | var out []string |
| 37 | for code := range codes { |
| 38 | if code == except || !instanceRegionAllowed(allowed, code) || g.refusal(code) != "" { |
| 39 | continue |
| 40 | } |
| 41 | out = append(out, s.homeRegionOut(code)) |
| 42 | } |
| 43 | sort.Strings(out) |
| 44 | return out |
| 45 | } |
| 46 | |