Download this file
| 1 | package hostops |
| 2 | |
| 3 | import ( |
| 4 | "github.com/carlosframework/platform/internal/hostclaim" |
| 5 | "github.com/carlosframework/platform/internal/regionname" |
| 6 | ) |
| 7 | |
| 8 | func consoleHomeRegion(names []string) (string, error) { |
| 9 | if len(names) > 1 { |
| 10 | return "", ErrContract |
| 11 | } |
| 12 | home := "" |
| 13 | if len(names) == 1 { |
| 14 | home = names[0] |
| 15 | } |
| 16 | if home != "" && regionname.PlacementRegion(home) != home { |
| 17 | return "", ErrContract |
| 18 | } |
| 19 | return home, nil |
| 20 | } |
| 21 | |
| 22 | // Check the configured designation before interpreting an operation's alias. |
| 23 | // An operation that recorded no home name started alias-free (before any |
| 24 | // designation was published) and stays alias-free, so a later first |
| 25 | // publication does not strand it: its comparisons stay exact. |
| 26 | func operationHomeMatches(home string, c *hostclaim.Claim) bool { |
| 27 | if c == nil || c.Op.Intent["home_region"] == "" { |
| 28 | return true |
| 29 | } |
| 30 | return c.Op.Intent["home_region"] == home |
| 31 | } |
| 32 | |