Skip to content

Commit

Permalink
Renamed IstioGatewayPolicy to GatewayPolicy.
Browse files Browse the repository at this point in the history
Signed-off-by: Tanya <[email protected]>
  • Loading branch information
tanyaveksler committed Nov 7, 2023
1 parent 0703d04 commit 1ac861d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions nca/NetworkConfig/NetworkConfigQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from nca.FWRules.ClusterInfo import ClusterInfo
from nca.Resources.NetworkPolicy import PolicyConnectionsFilter
from nca.Resources.CalicoNetworkPolicy import CalicoNetworkPolicy
from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicy
from nca.Resources.GatewayPolicy import GatewayPolicy
from nca.Utils.OutputConfiguration import OutputConfiguration
from .QueryOutputHandler import QueryAnswer, DictOutputHandler, StringOutputHandler, \
PoliciesAndRulesExplanations, PodsListsExplanations, ConnectionsDiffExplanation, IntersectPodsExplanation, \
Expand Down Expand Up @@ -1282,7 +1282,7 @@ def clone_without_ingress(config):
return config # no ingress policies in this config
config_without_ingress = config.clone_without_policies(config.name)
for policy in config.policies_container.policies.values():
if not isinstance(policy, IstioGatewayPolicy): # ignoring ingress policies
if not isinstance(policy, GatewayPolicy): # ignoring ingress policies
config_without_ingress.append_policy_to_config(policy)
return config_without_ingress

Expand Down
4 changes: 2 additions & 2 deletions nca/Parsers/GenericIngressLikeYamlParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from nca.CoreDS.ProtocolSet import ProtocolSet
from nca.CoreDS.ConnectivityProperties import ConnectivityProperties
from nca.CoreDS.ConnectionSet import ConnectionSet
from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicyRule
from nca.Resources.GatewayPolicy import GatewayPolicyRule
from .GenericYamlParser import GenericYamlParser


Expand Down Expand Up @@ -81,7 +81,7 @@ def _make_allow_rules(conn_props, src_peers):
new_props = ConnectivityProperties.make_conn_props(new_conn_cube)
new_conns = ConnectionSet()
new_conns.add_connections('TCP', new_props)
res.append(IstioGatewayPolicyRule(dst_peer_set, new_conns, rule_opt_props))
res.append(GatewayPolicyRule(dst_peer_set, new_conns, rule_opt_props))
return res

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions nca/Parsers/IngressPolicyYamlParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from nca.CoreDS.PortSet import PortSet
from nca.CoreDS.ConnectivityCube import ConnectivityCube
from nca.CoreDS.ConnectivityProperties import ConnectivityProperties
from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicy
from nca.Resources.GatewayPolicy import GatewayPolicy
from nca.Resources.NetworkPolicy import NetworkPolicy
from .GenericIngressLikeYamlParser import GenericIngressLikeYamlParser

Expand Down Expand Up @@ -254,7 +254,7 @@ def parse_policy(self):
return None # Not an Ingress object

self.namespace = self.peer_container.get_namespace(policy_ns)
res_policy = IstioGatewayPolicy(policy_name + '/allow', self.namespace)
res_policy = GatewayPolicy(policy_name + '/allow', self.namespace)
res_policy.policy_kind = NetworkPolicy.PolicyType.Ingress
res_policy.affects_egress = True
policy_spec = self.policy['spec']
Expand Down
4 changes: 2 additions & 2 deletions nca/Parsers/IstioTrafficResourcesYamlParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from nca.CoreDS.ConnectivityCube import ConnectivityCube
from nca.CoreDS.ConnectivityProperties import ConnectivityProperties
from nca.Resources.IstioTrafficResources import Gateway, VirtualService
from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicy
from nca.Resources.GatewayPolicy import GatewayPolicy
from nca.Resources.NetworkPolicy import NetworkPolicy
from .GenericIngressLikeYamlParser import GenericIngressLikeYamlParser

Expand Down Expand Up @@ -390,7 +390,7 @@ def create_istio_traffic_policies(self):
peers_to_hosts[peers] = host_dfa

for peer_set, host_dfa in peers_to_hosts.items():
res_policy = IstioGatewayPolicy(vs.name + '/' + str(host_dfa) + '/allow', vs.namespace)
res_policy = GatewayPolicy(vs.name + '/' + str(host_dfa) + '/allow', vs.namespace)
res_policy.policy_kind = NetworkPolicy.PolicyType.Ingress
res_policy.affects_egress = True
res_policy.selected_peers = peer_set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .NetworkPolicy import PolicyConnections, OptimizedPolicyConnections, NetworkPolicy


class IstioGatewayPolicyRule:
class GatewayPolicyRule:
"""
A class representing a single ingress rule in an Ingress object
"""
Expand All @@ -30,14 +30,14 @@ def __eq__(self, other):

def contained_in(self, other):
"""
:param IstioGatewayPolicyRule other: Another rule
:param GatewayPolicyRule other: Another rule
:return: whether the self rule is contained in the other rule (self doesn't allow anything that other does not)
:type: bool
"""
return self.peer_set.issubset(other.peer_set) and self.connections.contained_in(other.connections)


class IstioGatewayPolicy(NetworkPolicy):
class GatewayPolicy(NetworkPolicy):
"""
This class implements ingress controller logic for incoming http(s) requests
The logic is kept similarly to NetworkPolicy, where the selected_peers are the ingress/egress controller peers,
Expand Down Expand Up @@ -157,12 +157,12 @@ def has_empty_rules(self, _config_name=''):
def clone_without_rule(self, rule_to_exclude, ingress_rule):
"""
Makes a copy of 'self' without a given policy rule
:param IstioGatewayPolicyRule rule_to_exclude: The one rule not to include in the copy
:param GatewayPolicyRule rule_to_exclude: The one rule not to include in the copy
:param bool ingress_rule: Whether the rule is an ingress or egress rule
:return: A copy of 'self' without the provided rule
:rtype: IstioGatewayPolicy
:rtype: GatewayPolicy
"""
res = IstioGatewayPolicy(self.name, self.namespace)
res = GatewayPolicy(self.name, self.namespace)
res.selected_peers = self.selected_peers
res.affects_egress = self.affects_egress
res.affects_ingress = self.affects_ingress
Expand Down

0 comments on commit 1ac861d

Please sign in to comment.