Skip to content

Commit

Permalink
Merge pull request #214 from cloudfoundry-community/fixes/bad-host-re…
Browse files Browse the repository at this point in the history
…solution

fixes(push) fixes host resolution
  • Loading branch information
antechrestos committed May 3, 2024
2 parents 3db5572 + 2ce7bb6 commit cb994b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Python package

on: [push, pull_request]
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 1
Expand All @@ -13,16 +17,20 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
- name: Launch tests
run: python setup.py test

- name: Launch Linting
run: flake8 --show-source --statistics
24 changes: 11 additions & 13 deletions main/cloudfoundry_client/operations/push/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,18 @@ def _build_new_requested_routes(
_logger.error("Neither path nor port provided for route", requested_route)
raise AssertionError("Cannot set both port and path for route: %s" % requested_route)
host, domain_name, domain = PushOperation._resolve_domain(route, private_domains, shared_domains)
if port is not None and host is not None:
_logger.error("Host provided in route %s for tcp domain %s", requested_route, domain_name)
raise AssertionError(
"For route (%s) refers to domain %s that is a tcp one. It is hence routed by port and not by host"
% (requested_route, domain_name)
)
route_to_map = None
if port is not None and domain["entity"].get("router_group_type") != "tcp":
_logger.error("Port provided in route %s for non tcp domain %s", requested_route, domain_name)
raise AssertionError("Cannot set port on route(%s) for non tcp domain" % requested_route)
elif domain["entity"].get("router_group_type") == "tcp" and port is None:
_logger.error("No port provided in route %s for tcp domain %s", requested_route, domain_name)
raise AssertionError("Please specify a port on route (%s) for tcp domain" % requested_route)
elif domain["entity"].get("router_group_type") == "tcp":
if port is not None:
if domain["entity"].get("router_group_type") != "tcp":
_logger.error("Port provided in route %s for non tcp domain %s", requested_route, domain_name)
raise AssertionError("Cannot set port on route(%s) for non tcp domain" % requested_route)
elif len(host) > 0:
_logger.error("Host provided in route %s for tcp domain %s", requested_route, domain_name)
raise AssertionError(
"For route (%s) refers to domain %s that is a tcp one. "
"It is hence routed by port and not by host"
% (requested_route, domain_name)
)
if not any(
[route["entity"]["domain_guid"] == domain["metadata"]["guid"] and route["entity"]["port"] == port]
for route in existing_routes
Expand Down

0 comments on commit cb994b8

Please sign in to comment.