-
Notifications
You must be signed in to change notification settings - Fork 25
/
nested-circuit-helpers.go
39 lines (36 loc) · 1.22 KB
/
nested-circuit-helpers.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
package components
import (
policylangv1 "github.com/fluxninja/aperture/v2/api/gen/proto/go/aperture/policy/language/v1"
)
// AddNestedIngress adds a nested ingress to the nested circuit.
func AddNestedIngress(nestedCircuit *policylangv1.NestedCircuit, portName, signalName string) {
nestedCircuit.Components = append(nestedCircuit.Components, &policylangv1.Component{
Component: &policylangv1.Component_NestedSignalIngress{
NestedSignalIngress: &policylangv1.NestedSignalIngress{
PortName: portName,
OutPorts: &policylangv1.NestedSignalIngress_Outs{
Signal: &policylangv1.OutPort{
SignalName: signalName,
},
},
},
},
})
}
// AddNestedEgress adds a nested egress to the nested circuit.
func AddNestedEgress(nestedCircuit *policylangv1.NestedCircuit, portName, signalName string) {
nestedCircuit.Components = append(nestedCircuit.Components, &policylangv1.Component{
Component: &policylangv1.Component_NestedSignalEgress{
NestedSignalEgress: &policylangv1.NestedSignalEgress{
PortName: portName,
InPorts: &policylangv1.NestedSignalEgress_Ins{
Signal: &policylangv1.InPort{
Value: &policylangv1.InPort_SignalName{
SignalName: signalName,
},
},
},
},
},
})
}