Download this file
| 1 | package host |
| 2 | |
| 3 | import ( |
| 4 | "github.com/carlosframework/platform/internal/hostbox" |
| 5 | "github.com/carlosframework/platform/internal/park" |
| 6 | ) |
| 7 | |
| 8 | // The signed roster supplies both the engine name and the fleet home. |
| 9 | // An empty local placement binds an alias only when those names agree. |
| 10 | func claimRegionBinding(roster, code, fleetHome string) (engine, home string, err error) { |
| 11 | engine = park.PlacementRegion(roster) |
| 12 | placement := park.PlacementRegion(code) |
| 13 | if roster == "" || engine == "" || placement == "" || (code != "" && engine != placement) { |
| 14 | return "", "", hostbox.ErrChanged |
| 15 | } |
| 16 | if code == "" && fleetHome != "" { |
| 17 | if roster != fleetHome { |
| 18 | return "", "", hostbox.ErrChanged |
| 19 | } |
| 20 | home = engine |
| 21 | } |
| 22 | return engine, home, nil |
| 23 | } |
| 24 | |