From ebb5177e8cae70836997d5bf7077dab14dc3dba9 Mon Sep 17 00:00:00 2001 From: Ben Einaudi Date: Fri, 3 May 2024 09:18:57 +0200 Subject: [PATCH 1/2] fixes(push) fixes host resolution fixes #211 --- .../operations/push/push.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/main/cloudfoundry_client/operations/push/push.py b/main/cloudfoundry_client/operations/push/push.py index d4dd0c3..c894bd1 100644 --- a/main/cloudfoundry_client/operations/push/push.py +++ b/main/cloudfoundry_client/operations/push/push.py @@ -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 From 2ce7bb60934332620f008a1626950f437c8ebb1c Mon Sep 17 00:00:00 2001 From: Ben Einaudi Date: Fri, 3 May 2024 09:26:13 +0200 Subject: [PATCH 2/2] fixes(ci) improve workflow trigger --- .github/workflows/pythonpackage.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 2434630..f676ae3 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -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 @@ -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