Download this file
| 1 | package park |
| 2 | |
| 3 | import "github.com/carlosframework/platform/internal/hostclaim" |
| 4 | |
| 5 | // HolderRegionView is for read-only generation selection. Never persist it |
| 6 | // or use it to validate signed stop/loss evidence; those keep exact tuples. |
| 7 | func HolderRegionView(h hostclaim.Holder, home, region string) hostclaim.Holder { |
| 8 | if home == "" || !SameRegion(home, region, HomeRegion) { |
| 9 | return h |
| 10 | } |
| 11 | h.Admissions = append([]hostclaim.AdmissionRecord(nil), h.Admissions...) |
| 12 | for i := range h.Admissions { |
| 13 | a := &h.Admissions[i] |
| 14 | if SameRegion(home, a.Region, region) { |
| 15 | a.Region = region |
| 16 | } |
| 17 | if SameRegion(home, a.PredecessorRegion, region) { |
| 18 | a.PredecessorRegion = region |
| 19 | } |
| 20 | } |
| 21 | return h |
| 22 | } |
| 23 | |
| 24 | func HomeView(o hostclaim.Observed, home string) hostclaim.Observed { |
| 25 | if home == "" || o.Claim == nil || o.Claim.Holder == nil { |
| 26 | return o |
| 27 | } |
| 28 | c := *o.Claim |
| 29 | h := HolderRegionView(*c.Holder, home, HomeRegion) |
| 30 | c.Holder = &h |
| 31 | o.Claim = &c |
| 32 | return o |
| 33 | } |
| 34 | |