Download this file
| 1 | package hostops |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "github.com/carlosframework/platform/internal/hostclaim" |
| 6 | "github.com/carlosframework/platform/internal/park" |
| 7 | "github.com/carlosframework/platform/internal/termfence" |
| 8 | ) |
| 9 | |
| 10 | // MoveFenceRegions preserves the verifier's roster/enrollment checks, then |
| 11 | // projects only its region binding into the move's engine vocabulary. |
| 12 | // Signed fence bytes and the cloud region are never edited. |
| 13 | type MoveFenceRegions struct { |
| 14 | Authority hostclaim.FenceAuthority |
| 15 | HomeRegion string |
| 16 | } |
| 17 | |
| 18 | func (a MoveFenceRegions) ValidateFence(ctx context.Context, f termfence.Record) (hostclaim.FenceBinding, error) { |
| 19 | if a.Authority == nil { |
| 20 | return hostclaim.FenceBinding{}, hostclaim.ErrFence |
| 21 | } |
| 22 | binding, err := a.Authority.ValidateFence(ctx, f) |
| 23 | if err != nil { |
| 24 | return hostclaim.FenceBinding{}, err |
| 25 | } |
| 26 | if binding.Region == "" || (a.HomeRegion != "" && (a.HomeRegion != binding.FleetHomeRegion || park.PlacementRegion(a.HomeRegion) != a.HomeRegion)) { |
| 27 | return hostclaim.FenceBinding{}, hostclaim.ErrFence |
| 28 | } |
| 29 | binding.Region = park.PlacementRegion(park.HomePlacementCode(a.HomeRegion, binding.Region)) |
| 30 | if binding.Region == "" { |
| 31 | return hostclaim.FenceBinding{}, hostclaim.ErrFence |
| 32 | } |
| 33 | return binding, nil |
| 34 | } |
| 35 | |