Skip to content

Commit cb994b8

Browse files
authored
Merge pull request #214 from cloudfoundry-community/fixes/bad-host-resolution
fixes(push) fixes host resolution
2 parents 3db5572 + 2ce7bb6 commit cb994b8

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
name: Python package
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
49

510
jobs:
611
build:
7-
812
runs-on: ubuntu-latest
913
strategy:
1014
max-parallel: 1
@@ -13,16 +17,20 @@ jobs:
1317

1418
steps:
1519
- uses: actions/checkout@v4
20+
1621
- name: Set up Python ${{ matrix.python-version }}
1722
uses: actions/setup-python@v5
1823
with:
1924
python-version: ${{ matrix.python-version }}
25+
2026
- name: Install dependencies
2127
run: |
2228
python -m pip install --upgrade pip
2329
pip install -r requirements.txt
2430
pip install -r dev-requirements.txt
31+
2532
- name: Launch tests
2633
run: python setup.py test
34+
2735
- name: Launch Linting
2836
run: flake8 --show-source --statistics

main/cloudfoundry_client/operations/push/push.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,18 @@ def _build_new_requested_routes(
152152
_logger.error("Neither path nor port provided for route", requested_route)
153153
raise AssertionError("Cannot set both port and path for route: %s" % requested_route)
154154
host, domain_name, domain = PushOperation._resolve_domain(route, private_domains, shared_domains)
155-
if port is not None and host is not None:
156-
_logger.error("Host provided in route %s for tcp domain %s", requested_route, domain_name)
157-
raise AssertionError(
158-
"For route (%s) refers to domain %s that is a tcp one. It is hence routed by port and not by host"
159-
% (requested_route, domain_name)
160-
)
161155
route_to_map = None
162-
if port is not None and domain["entity"].get("router_group_type") != "tcp":
163-
_logger.error("Port provided in route %s for non tcp domain %s", requested_route, domain_name)
164-
raise AssertionError("Cannot set port on route(%s) for non tcp domain" % requested_route)
165-
elif domain["entity"].get("router_group_type") == "tcp" and port is None:
166-
_logger.error("No port provided in route %s for tcp domain %s", requested_route, domain_name)
167-
raise AssertionError("Please specify a port on route (%s) for tcp domain" % requested_route)
168-
elif domain["entity"].get("router_group_type") == "tcp":
156+
if port is not None:
157+
if domain["entity"].get("router_group_type") != "tcp":
158+
_logger.error("Port provided in route %s for non tcp domain %s", requested_route, domain_name)
159+
raise AssertionError("Cannot set port on route(%s) for non tcp domain" % requested_route)
160+
elif len(host) > 0:
161+
_logger.error("Host provided in route %s for tcp domain %s", requested_route, domain_name)
162+
raise AssertionError(
163+
"For route (%s) refers to domain %s that is a tcp one. "
164+
"It is hence routed by port and not by host"
165+
% (requested_route, domain_name)
166+
)
169167
if not any(
170168
[route["entity"]["domain_guid"] == domain["metadata"]["guid"] and route["entity"]["port"] == port]
171169
for route in existing_routes

0 commit comments

Comments
 (0)