Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit baf9712

Browse files
author
Casey Davenport
committed
Merge pull request #77 from caseydavenport/cd4-integer-ports
Ensure ports are integers when creating Rule
2 parents f369aa4 + 52c4bec commit baf9712

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

calico_containers/pycalico/datastore_datatypes.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,13 @@ def to_json_dict(self):
440440
json_dict["dst_net"] = str(json_dict["dst_net"])
441441
if "src_net" in json_dict:
442442
json_dict["src_net"] = str(json_dict["src_net"])
443+
444+
# Convert ports to integers.
445+
if "dst_ports" in json_dict:
446+
json_dict["dst_ports"] = [int(p) for p in json_dict["dst_ports"]]
447+
if "src_ports" in json_dict:
448+
json_dict["src_ports"] = [int(p) for p in json_dict["src_ports"]]
449+
443450
return json_dict
444451

445452
def pprint(self):
@@ -472,4 +479,4 @@ def pprint(self):
472479
if "dst_net" in self:
473480
out.extend(["cidr", str(self["dst_net"])])
474481

475-
return " ".join(out)
482+
return " ".join(out)

0 commit comments

Comments
 (0)