Commit 47fa46c5 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'change_from_endpoint_format_to_align_policy_with_behaviour' into 'master'

Updates fromEndpoints&toEndpoints to be allow all

See merge request gitlab-org/gitlab!53940
parents e6cf292b 9046c10b
...@@ -129,10 +129,10 @@ export default function humanizeNetworkPolicy(policy) { ...@@ -129,10 +129,10 @@ export default function humanizeNetworkPolicy(policy) {
const template = const template =
direction === RuleDirectionInbound direction === RuleDirectionInbound
? s__( ? s__(
'NetworkPolicies|Deny all inbound traffic to %{selector} from %{ruleSelector} on %{ports}', 'NetworkPolicies|Allow all inbound traffic to %{selector} from %{ruleSelector} on %{ports}',
) )
: s__( : s__(
'NetworkPolicies|Deny all outbound traffic from %{selector} to %{ruleSelector} on %{ports}', 'NetworkPolicies|Allow all outbound traffic from %{selector} to %{ruleSelector} on %{ports}',
); );
const ruleSelector = humanizeNetworkPolicyRule(rule); const ruleSelector = humanizeNetworkPolicyRule(rule);
const ports = humanizeNetworkPolicyRulePorts(rule); const ports = humanizeNetworkPolicyRulePorts(rule);
......
...@@ -23,7 +23,6 @@ function commonSpec(rule) { ...@@ -23,7 +23,6 @@ function commonSpec(rule) {
*/ */
function ruleEndpointSpec({ direction, matchLabels }) { function ruleEndpointSpec({ direction, matchLabels }) {
const matchSelector = labelSelector(matchLabels); const matchSelector = labelSelector(matchLabels);
if (Object.keys(matchSelector).length === 0) return {};
return { return {
[direction === RuleDirectionInbound ? 'fromEndpoints' : 'toEndpoints']: [ [direction === RuleDirectionInbound ? 'fromEndpoints' : 'toEndpoints']: [
......
---
title: Revert text back to Allow instead of Deny. Fixes fromEndpoints/toEndpoints
format to keep it aligned with the allow all logic. The previous code was causing
a allowing none while it should be allowing all.
merge_request: 53940
author:
type: fixed
...@@ -36,7 +36,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -36,7 +36,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods ' + 'Allow all inbound traffic to <strong>all</strong> pods ' +
'from <strong>all</strong> pods ' + 'from <strong>all</strong> pods ' +
'on <strong>any</strong> port', 'on <strong>any</strong> port',
); );
...@@ -50,7 +50,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -50,7 +50,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to pods <strong>[one: , two: another]</strong> ' + 'Allow all inbound traffic to pods <strong>[one: , two: another]</strong> ' +
'from <strong>all</strong> pods ' + 'from <strong>all</strong> pods ' +
'on <strong>any</strong> port', 'on <strong>any</strong> port',
); );
...@@ -66,9 +66,9 @@ describe('humanizeNetworkPolicy', () => { ...@@ -66,9 +66,9 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods from <strong>all</strong> pods on <strong>any</strong> port' + 'Allow all inbound traffic to <strong>all</strong> pods from <strong>all</strong> pods on <strong>any</strong> port' +
'<br><br>AND<br><br>' + '<br><br>AND<br><br>' +
'Deny all outbound traffic from <strong>all</strong> pods to <strong>all</strong> pods on <strong>any</strong> port', 'Allow all outbound traffic from <strong>all</strong> pods to <strong>all</strong> pods on <strong>any</strong> port',
); );
}); });
}); });
...@@ -81,7 +81,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -81,7 +81,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods ' + 'Allow all inbound traffic to <strong>all</strong> pods ' +
'from <strong>all</strong> pods ' + 'from <strong>all</strong> pods ' +
'on ports <strong>80/TCP, 81/UDP</strong>', 'on ports <strong>80/TCP, 81/UDP</strong>',
); );
...@@ -95,7 +95,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -95,7 +95,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods ' + 'Allow all inbound traffic to <strong>all</strong> pods ' +
'from pods <strong>[one: , two: another]</strong> ' + 'from pods <strong>[one: , two: another]</strong> ' +
'on <strong>any</strong> port', 'on <strong>any</strong> port',
); );
...@@ -111,7 +111,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -111,7 +111,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods ' + 'Allow all inbound traffic to <strong>all</strong> pods ' +
'from <strong>host, world</strong> ' + 'from <strong>host, world</strong> ' +
'on <strong>any</strong> port', 'on <strong>any</strong> port',
); );
...@@ -127,7 +127,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -127,7 +127,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods ' + 'Allow all inbound traffic to <strong>all</strong> pods ' +
'from <strong>0.0.0.0/32, 1.1.1.1/24</strong> ' + 'from <strong>0.0.0.0/32, 1.1.1.1/24</strong> ' +
'on <strong>any</strong> port', 'on <strong>any</strong> port',
); );
...@@ -143,7 +143,7 @@ describe('humanizeNetworkPolicy', () => { ...@@ -143,7 +143,7 @@ describe('humanizeNetworkPolicy', () => {
it('returns policy description', () => { it('returns policy description', () => {
expect(humanizeNetworkPolicy(policy)).toEqual( expect(humanizeNetworkPolicy(policy)).toEqual(
'Deny all inbound traffic to <strong>all</strong> pods ' + 'Allow all inbound traffic to <strong>all</strong> pods ' +
'from <strong>some-service.com, another-service.com</strong> ' + 'from <strong>some-service.com, another-service.com</strong> ' +
'on <strong>any</strong> port', 'on <strong>any</strong> port',
); );
......
...@@ -77,8 +77,14 @@ describe('ruleSpec', () => { ...@@ -77,8 +77,14 @@ describe('ruleSpec', () => {
rule = buildRule(RuleTypeEndpoint); rule = buildRule(RuleTypeEndpoint);
}); });
it('returns empty spec', () => { it('returns empty matchLabels', () => {
expect(ruleSpec(rule)).toEqual({}); expect(ruleSpec(rule)).toEqual({
fromEndpoints: [
{
matchLabels: {},
},
],
});
}); });
testPortMatchers(); testPortMatchers();
......
...@@ -19529,6 +19529,12 @@ msgstr "" ...@@ -19529,6 +19529,12 @@ msgstr ""
msgid "NetworkPolicies|Allow" msgid "NetworkPolicies|Allow"
msgstr "" msgstr ""
msgid "NetworkPolicies|Allow all inbound traffic to %{selector} from %{ruleSelector} on %{ports}"
msgstr ""
msgid "NetworkPolicies|Allow all outbound traffic from %{selector} to %{ruleSelector} on %{ports}"
msgstr ""
msgid "NetworkPolicies|Are you sure you want to delete this policy? This action cannot be undone." msgid "NetworkPolicies|Are you sure you want to delete this policy? This action cannot be undone."
msgstr "" msgstr ""
...@@ -19547,12 +19553,6 @@ msgstr "" ...@@ -19547,12 +19553,6 @@ msgstr ""
msgid "NetworkPolicies|Delete policy: %{policy}" msgid "NetworkPolicies|Delete policy: %{policy}"
msgstr "" msgstr ""
msgid "NetworkPolicies|Deny all inbound traffic to %{selector} from %{ruleSelector} on %{ports}"
msgstr ""
msgid "NetworkPolicies|Deny all outbound traffic from %{selector} to %{ruleSelector} on %{ports}"
msgstr ""
msgid "NetworkPolicies|Deny all traffic" msgid "NetworkPolicies|Deny all traffic"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment