...
1
2
3 package fleet
4
5 import (
6 "fmt"
7
8 "edge-infra.dev/pkg/edge/constants"
9 )
10
11
12 const Label = "fleet." + constants.Domain
13
14
15 const LabelType = "edge-fleet"
16
17
18 type Type string
19
20
21 const (
22 TopLevel = "top-level"
23 Enterprise = "enterprise"
24 Store = "store"
25 BasicStore = "basic-store"
26 Banner = "banner-infra"
27 Cluster = "cluster-infra"
28 CouchDB = "couchdb-masters"
29 )
30
31 func IsValid(ft string) error {
32 return Type(ft).IsValid()
33 }
34
35 var Types = []Type{TopLevel, Enterprise, Store, BasicStore, Banner, Cluster, CouchDB}
36
37 var ErrInvalidType = fmt.Errorf("invalid fleet type, expected %v", Types)
38
39
40 func (ft Type) IsValid() error {
41 found := false
42 for _, fType := range Types {
43 if ft == fType {
44 found = true
45 }
46 }
47 if found {
48 return nil
49 }
50 return fmt.Errorf("%v: %w", ft, ErrInvalidType)
51 }
52
53
54 func (ft Type) String() string {
55 return string(ft)
56 }
57
58 type AnnotationsGetter interface {
59 GetAnnotations() map[string]string
60 }
61
62 func IsClusterInfraCluster(val Type) bool {
63 return val == Cluster
64 }
65
66 func IsStoreCluster(val Type) bool {
67 if val == Store {
68 return true
69 }
70 if val == BasicStore {
71 return true
72 }
73 return false
74 }
75
View as plain text