Download this file
| 1 | package hostclaim |
| 2 | |
| 3 | // QueueRelocationRelease records a stop-only obligation before requesting root |
| 4 | // evidence. The caller supplies a stable retirement identity for this release. |
| 5 | func QueueRelocationRelease(opID, box, region, retirement string) func(*Claim) error { |
| 6 | return func(c *Claim) error { |
| 7 | if c == nil || c.Holder == nil || c.Op.ID != opID || opID == "" || c.Op.Kind != KindRelocating || c.Op.Phase != "releasing" || c.Op.Exec != box || c.Op.Intent["source_box"] != box || c.Op.Intent["region"] != region || !validBoxReference(box) || box == "none" || region == "" || retirement == "" { |
| 8 | return ErrWrongState |
| 9 | } |
| 10 | for _, o := range c.Obligations { |
| 11 | if o.ID == "relocation-release" { |
| 12 | if o.Kind == "relocation-release" && o.Op == opID && o.Box == box && o.Region == region && o.Owner == "region:"+region && o.Park == nil && o.Retirement == retirement { |
| 13 | return nil |
| 14 | } |
| 15 | return ErrWrongState |
| 16 | } |
| 17 | } |
| 18 | if c.Op.Journal["release_stop_receipt"] != "" { |
| 19 | return ErrWrongState |
| 20 | } |
| 21 | c.Obligations = append(c.Obligations, Obligation{ID: "relocation-release", Kind: "relocation-release", Op: opID, Box: box, Region: region, Owner: "region:" + region, Retirement: retirement}) |
| 22 | return nil |
| 23 | } |
| 24 | } |
| 25 | |