carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package hostops
2
3import (
4 "github.com/carlosframework/platform/internal/hostactors"
5 "github.com/carlosframework/platform/internal/park"
6)
7
8// ClaimMoveRosterPlaces is shared by the console preflight and the start CAS.
9func ClaimMoveRosterPlaces(r hostactors.Roster, source, target, recRegion, to string, homeNames ...string) bool {
10 if len(homeNames) > 1 {
11 return false
12 }
13 home := ""
14 if len(homeNames) == 1 {
15 home = homeNames[0]
16 }
17 if home != "" && park.PlacementRegion(home) != home {
18 return false
19 }
20 src, sourceOK := r.Boxes[source]
21 dst, targetOK := r.Boxes[target]
22 if !sourceOK || !targetOK || source == target || src.State != "active" || dst.State != "active" || src.Enrollment == "" || dst.Enrollment == "" || src.Region == "" || dst.Region == "" {
23 return false
24 }
25 from, into := park.PlacementRegion(park.HomePlacementCode(home, src.Region)), park.PlacementRegion(park.HomePlacementCode(home, dst.Region))
26 return from != "" && into != "" && from != into && from == park.PlacementRegion(recRegion) && into == park.PlacementRegion(to)
27}
28