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 "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.
13type MoveFenceRegions struct {
14 Authority hostclaim.FenceAuthority
15 HomeRegion string
16}
17
18func (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