carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package hostguard
2
3import "context"
4
5func (a *RootAuthority) HostRetired(ctx context.Context, host string) (bool, error) {
6 if err := ctx.Err(); err != nil {
7 return false, err
8 }
9 if a == nil || a.store == nil || validateFileHost(host) != nil {
10 return false, ErrInvalidInput
11 }
12 unlock, err := a.store.Lock(ctx, host+".lock")
13 if err != nil {
14 return false, err
15 }
16 defer unlock()
17 r, err := a.read(host)
18 if err != nil {
19 return false, err
20 }
21 if r.quarantined || r.pendingInstallation != nil || r.barrier != nil {
22 return false, ErrFenced
23 }
24 if r.ActiveStamp != 0 {
25 return false, nil
26 }
27 for _, old := range r.rootRetired {
28 if old.Incarnation == r.installation.Incarnation && old.Stamp == r.installation.Stamp && old.Stamp != 0 {
29 return true, nil
30 }
31 }
32 return false, nil
33}
34