-
Notifications
You must be signed in to change notification settings - Fork 25
/
policy.go
40 lines (32 loc) · 1.13 KB
/
policy.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
36
37
38
39
40
package iface
import (
"fmt"
"time"
"google.golang.org/protobuf/types/known/durationpb"
policylangv1 "github.com/fluxninja/aperture/v2/api/gen/proto/go/aperture/policy/language/v1"
"github.com/fluxninja/aperture/v2/pkg/config"
"github.com/fluxninja/aperture/v2/pkg/status"
)
const (
// PoliciesRoot - path in config and status registry for policies results.
PoliciesRoot = "policies"
)
// FxOptionsFuncTag allows sub-modules to provide their options to per policy apps independently.
var FxOptionsFuncTag = config.GroupTag("policy-fx-funcs")
// PolicyBase is for read only access to base policy info.
type PolicyBase interface {
GetPolicyName() string
GetPolicyHash() string
}
// Policy is for read only access to full policy state.
type Policy interface {
PolicyBase
GetEvaluationInterval() time.Duration
GetStatusRegistry() status.Registry
TicksInDurationPb(*durationpb.Duration) int
TicksInDuration(time.Duration) int
}
// GetSelectorsShortDescription returns a short description of the selectors.
func GetSelectorsShortDescription(selectors []*policylangv1.Selector) string {
return fmt.Sprintf("%d selectors", len(selectors))
}