-
Notifications
You must be signed in to change notification settings - Fork 1
/
gate.go
35 lines (27 loc) · 927 Bytes
/
gate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package feature
import "flag"
var globalRegistry = NewRegistry()
func init() {
flag.Var(globalRegistry, "feature-gates", "A set of key=value pairs that describe feature gates for alpha/beta/stable features.")
}
// Register register a feature gate.
func Register(name string, enabled bool, opts ...Option) (*Feature, error) {
return globalRegistry.Register(name, enabled, opts...)
}
// MustRegister must register a feature gate.
func MustRegister(name string, enabled bool, opts ...Option) *Feature {
return globalRegistry.MustRegister(name, enabled, opts...)
}
// Set sets the feature arguments.
// eg: foo=true,bar=false
func Set(args string) error {
return globalRegistry.Set(args)
}
// SetEnabled set feature enabled.
func SetEnabled(name string, enabled bool) error {
return globalRegistry.SetEnabled(name, enabled)
}
// Visit visits all the features.
func Visit(f func(*Feature)) {
globalRegistry.Visit(f)
}