carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package hostbox
2
3import (
4 "context"
5
6 "github.com/carlosframework/platform/internal/hostwrite"
7 "github.com/carlosframework/platform/internal/registry"
8)
9
10func RegistryHoldPolicy(reg *registry.Registry) func(context.Context, string) (string, error) {
11 return func(ctx context.Context, host string) (string, error) {
12 if ctx == nil || reg == nil {
13 return "", ErrUnsupported
14 }
15 if err := ctx.Err(); err != nil {
16 return "", err
17 }
18 rt, err := reg.Get(host)
19 if err != nil {
20 return "", err
21 }
22 if rt == nil {
23 return "", nil
24 }
25 return rt.HoldOp, nil
26 }
27}
28
29func Selected(work hostwrite.Work) (Selection, error) {
30 w, ok := work.(selectedWork)
31 if !ok {
32 return Selection{}, ErrUnsupported
33 }
34 return w.selection, nil
35}
36