Skip to content

Commit

Permalink
Only do this if ports are set
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson committed Jan 12, 2024
1 parent 87bde7b commit 624235a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kr8s/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,12 +981,14 @@ def gen(
>>> pod = Pod.gen(name="wordpress", image="wordpress:latest", ports=[{"containerPort": 80}])
>>> pod.create()
"""
if isinstance(ports, int):
ports = [ports]
# Convert any integer ports to valid v1.ContainerPort format
ports = [
{"containerPort": port} if isinstance(port, int) else port for port in ports
]
if ports:
if isinstance(ports, int):
ports = [ports]
# Convert any integer ports to valid v1.ContainerPort format
ports = [
{"containerPort": port} if isinstance(port, int) else port
for port in ports
]

return cls(
xdict(
Expand Down

0 comments on commit 624235a

Please sign in to comment.