Skip to content

Commit a48dc25

Browse files
committed
Adds generated egress rules by simple array.
It is easy to maintain Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent dd09123 commit a48dc25

File tree

3 files changed

+25
-76
lines changed

3 files changed

+25
-76
lines changed

container_ci_suite/helm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,15 @@ def check_test_output(self, output, expected_str: List[str]):
261261
print("Function expects list of strings to check.")
262262
return False
263263
check_list.extend(expected_str)
264+
print(f"Strings to check in helm output log: {check_list}")
264265
result_list = [x in ''.join(output) for x in check_list]
265266
if False in result_list:
266267
return False
267268
return True
268269

269270
def test_helm_chart(self, expected_str: List[str]) -> bool:
270271
for count in range(60):
271-
time.sleep(1)
272+
time.sleep(2)
272273
try:
273274
output = HelmChartsAPI.run_helm_command(
274275
f"test {self.package_name} --logs", json_output=False

container_ci_suite/openshift.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
self.shared_random_name = ""
6262
self.config_tenant_name = "core-services-ocp--config"
6363
self.openshift_ops = OpenShiftOperations(pod_name_prefix=pod_name_prefix)
64+
print(f"Namespace is: {namespace}")
6465
if namespace == "default":
6566
self.create_project()
6667
else:

container_ci_suite/utils.py

Lines changed: 22 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,27 @@ def save_tenant_namespace_yaml(project_name: str) -> str:
280280
return temp_file.name
281281

282282

283-
def save_tenant_egress_yaml(project_name: str) -> str:
283+
def save_tenant_egress_yaml(project_name: str, rules: List[str] = []) -> str:
284+
if not rules:
285+
rules = [
286+
"github.com", "api.github.com", "codeload.github.com", "pypi.org", "www.cpan.org",
287+
"backpan.perl.org", "www.metacpan.org", "files.pythonhosted.org", "getcomposer.org",
288+
]
289+
generated_yaml = []
290+
for rule in rules:
291+
generated_yaml.append({
292+
"to": {
293+
"dnsName": f"{rule}"
294+
},
295+
"type": "Allow"
296+
})
297+
for rule in ["172.0.0.0/8", "10.0.0.0/9", "52.218.128.0/17", "52.92.128.0/17", "52.216.0.0/15"]:
298+
generated_yaml.append({
299+
"to": {
300+
"cidrSelector": f"{rule}"
301+
},
302+
"type": "Allow"
303+
})
284304
tenant_egress_yaml = {
285305
"apiVersion": "tenant.paas.redhat.com/v1alpha1",
286306
"kind": "TenantEgress",
@@ -289,80 +309,7 @@ def save_tenant_egress_yaml(project_name: str) -> str:
289309
"namespace": f"core-services-ocp--{project_name}"
290310
},
291311
"spec": {
292-
"egress": [
293-
{
294-
"to": {
295-
"dnsName": "github.com"
296-
},
297-
"type": "Allow"
298-
},
299-
{
300-
"to": {
301-
"dnsName": "pypi.org"
302-
},
303-
"type": "Allow"
304-
},
305-
{
306-
"to": {
307-
"dnsName": "www.cpan.org"
308-
},
309-
"type": "Allow"
310-
},
311-
{
312-
"to": {
313-
"dnsName": "backpan.perl.org"
314-
},
315-
"type": "Allow"
316-
},
317-
{
318-
"to": {
319-
"dnsName": "www.metacpan.org"
320-
},
321-
"type": "Allow"
322-
},
323-
{
324-
"to": {
325-
"dnsName": "files.pythonhosted.org"
326-
},
327-
"type": "Allow"
328-
},
329-
{
330-
"to": {
331-
"cidrSelector": "172.0.0.0/8"
332-
},
333-
"type": "Allow"
334-
},
335-
{
336-
"to": {
337-
"cidrSelector": "172.0.0.0/8"
338-
},
339-
"type": "Allow"
340-
},
341-
{
342-
"to": {
343-
"cidrSelector": "10.0.0.0/9"
344-
},
345-
"type": "Allow"
346-
},
347-
{
348-
"to": {
349-
"cidrSelector": "52.218.128.0/17"
350-
},
351-
"type": "Allow"
352-
},
353-
{
354-
"to": {
355-
"cidrSelector": "52.92.128.0/17"
356-
},
357-
"type": "Allow"
358-
},
359-
{
360-
"to": {
361-
"cidrSelector": "52.216.0.0/15"
362-
},
363-
"type": "Allow"
364-
}
365-
]
312+
"egress": generated_yaml
366313
}
367314
}
368315
temp_file = tempfile.NamedTemporaryFile(prefix="tenant-egress-yml", delete=False)

0 commit comments

Comments
 (0)