-
Notifications
You must be signed in to change notification settings - Fork 51
/
puinfo.go
30 lines (26 loc) · 1.13 KB
/
puinfo.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
package policy
import "go.aporeto.io/trireme-lib/common"
// PUInfo captures all policy information related to a connection as well as runtime.
// It makes passing data around simpler.
type PUInfo struct {
// ContextID is the ID of the container that the policy applies to
ContextID string
// Policy is an instantiation of the container policy
Policy *PUPolicy
// RunTime captures all data that are captured from the container
Runtime *PURuntime
}
// NewPUInfo instantiates a new ContainerPolicy
func NewPUInfo(contextID string, puType common.PUType) *PUInfo {
policy := NewPUPolicy(contextID, AllowAll, nil, nil, nil, nil, nil, nil, nil, []string{}, []string{}, &ProxiedServicesInfo{}, nil, nil, []string{})
runtime := NewPURuntime("", 0, "", nil, nil, puType, nil)
return PUInfoFromPolicyAndRuntime(contextID, policy, runtime)
}
// PUInfoFromPolicyAndRuntime generates a ContainerInfo Struct from an existing RuntimeInfo and PolicyInfo
func PUInfoFromPolicyAndRuntime(contextID string, policyInfo *PUPolicy, runtimeInfo *PURuntime) *PUInfo {
return &PUInfo{
ContextID: contextID,
Policy: policyInfo,
Runtime: runtimeInfo,
}
}