@@ -18,32 +18,8 @@ import (
1818// ReconcileClusterLogForwarderNetworkPolicy reconciles the NetworkPolicy for the clusterlogforwarder
1919// It handles both AllowAllIngressEgress and RestrictIngressEgress rule sets, parsing ports from outputs and inputs when needed.
2020func ReconcileClusterLogForwarderNetworkPolicy (k8Client client.Client , namespace , policyName , instanceName , component string , policyRuleSet obsv1.NetworkPolicyRuleSetType , outputs []obsv1.OutputSpec , inputs []obsv1.InputSpec , ownerRef metav1.OwnerReference , visitor func (o runtime.Object )) error {
21- var egressPorts []factory.PortProtocol
22- var ingressPorts []int32
23-
24- // For RestrictIngressEgress, determine the ports to use based on URLs in outputs and defaults
25- if policyRuleSet == obsv1 .NetworkPolicyRuleSetTypeRestrictIngressEgress {
26- // Parse ports from inputs (receiver inputs use TCP)
27- if len (inputs ) > 0 {
28- ingressPorts = GetInputPorts (inputs )
29- }
30-
31- // Parse ports for egress from outputs and proxy configuration if any
32- egressPortMap := map [factory.PortProtocol ]bool {}
33- // Parse ports with protocols from outputs
34- if len (outputs ) > 0 {
35- GetOutputPortsWithProtocols (outputs , egressPortMap )
36-
37- }
38- // Add proxy ports if any for cluster-wide proxy configuration
39- GetProxyPorts (egressPortMap )
40-
41- // Convert map to slice
42- egressPorts = make ([]factory.PortProtocol , 0 , len (egressPortMap ))
43- for pp := range egressPortMap {
44- egressPorts = append (egressPorts , pp )
45- }
46- }
21+ egressPorts := DetermineEgressPortProtocols (outputs , policyRuleSet )
22+ ingressPorts := DetermineIngressPortProtocols (inputs , policyRuleSet )
4723
4824 desired := factory .NewNetworkPolicyWithProtocolPorts (namespace , policyName , instanceName , component , string (policyRuleSet ), egressPorts , ingressPorts , visitor )
4925 utils .AddOwnerRefToObject (desired , ownerRef )
0 commit comments