Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 12 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
steps:
- name: Abort building on push with open PR
id: debounce
uses: MrMatAP/mrmat-build-avoider-action@1.0.19
uses: MrMatAP/mrmat-debounce-action@latest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Version the project
id: version
uses: MrMatAP/mrmat-versioning-action@1.0.7
uses: MrMatAP/mrmat-versioning-action@latest
with:
ecosystem: python
major: 1
Expand Down Expand Up @@ -56,59 +56,27 @@ jobs:
run: uv build --wheel
- name: Test
run: uv run --frozen pytest --junit-xml=${GITHUB_WORKSPACE}/build/junit.xml --cov-report=xml:${GITHUB_WORKSPACE}/build/coverage.xml
- name: Upload linting results
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: Lint Results
path: build/lint.xml
retention-days: 1
- name: Upload unit test results
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: build/junit.xml
retention-days: 1
- name: Upload coverage results
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: Coverage Results
path: build/coverage.xml
retention-days: 1
- name: Report on unit tests
if: ${{ github.event_name == 'pull_request' }}
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: "Unit Tests"
comment_title: "Unit Test Results"
files: build/junit.xml
- name: Report on code coverage
if: ${{ github.event_name == 'pull_request' }}
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: build/coverage.xml

# The release job only executes when pushing to the main branch
release:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
if:
${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- prep
- build
steps:
- name: Checkout out our code
uses: actions/checkout@v5.0.0
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: MrMatAP/mrmat-release-action@latest
with:
tag_name: ${{ needs.prep.outputs.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
release_name: Release ${{ needs.prep.outputs.version }}
body: |
release_version: ${{ needs.prep.outputs.version }}
release_description: |
Release ${{ needs.prep.outputs.version }}
draft: false
prerelease: false
update_latest: false
7 changes: 6 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations/cli.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/runConfigurations/format_check.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/runConfigurations/format_write.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions .idea/runConfigurations/lint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 11 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@ dependencies = [
"kubernetes-asyncio==33.3.0",
"pyyaml==6.0.3",
"zeroconf==0.148.0",
"pydantic==2.12.2",
"pydantic-settings==2.11.0",
"pydantic==2.12.5",
"pydantic-settings==2.12.0",
"dnspython==2.8.0",
"pytest-coverage>=0.0",
"types-pyyaml==6.0.12.20250915",
"setuptools==80.9.0",
"build==1.3.0",
"wheel==0.45.1",
"pyrefly>=0.45.2",
"ruff>=0.14.9",
]
[dependency-groups]
dev = [
"mypy==1.18.2",
"types-PyYAML==6.0.12.20250915",
"pytest==8.4.2",
"pytest-asyncio==1.2.0",
"pytest==9.0.2",
"pytest-asyncio==1.3.0",
"pytest-mock==3.15.1",
"black>=25.9.0"
"ruff>=0.14.9",
"pyrefly>=0.45.2",
]

[tool.setuptools.packages.find]
Expand All @@ -72,14 +74,6 @@ log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(linen
log_cli_date_format="%Y-%m-%d %H:%M:%S"
asyncio_default_fixture_loop_scope = 'session'

[tool.mypy]
plugins = [ 'pydantic.mypy' ]

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true

[tool.black]
line-length = 80
target-version = ['py313']
[tool.pyrefly]
project-includes = ["src"]
search-path = ["src"]
36 changes: 8 additions & 28 deletions src/cloud_provider_mdns/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ class HTTPRouteSpec(PydanticIgnoreExtraFields):
We omit the rules field since we do not need to parse it for registering DNS
"""

parentRefs: typing.List[ParentReference] = pydantic.Field(
default_factory=list
)
parentRefs: typing.List[ParentReference] = pydantic.Field(default_factory=list)
hostnames: typing.List[str] = pydantic.Field(default_factory=list)


Expand Down Expand Up @@ -97,9 +95,7 @@ class HTTPRouteStatus(PydanticIgnoreExtraFields):
Status for a HTTPRoute
"""

parents: typing.List[HTTPRouteParentStatus] = pydantic.Field(
default_factory=list
)
parents: typing.List[HTTPRouteParentStatus] = pydantic.Field(default_factory=list)


class HTTPRoute(PydanticIgnoreExtraFields):
Expand Down Expand Up @@ -129,17 +125,11 @@ def spec_parent_by_status_parent_ref(
Return the spec parent for the given status parent ref of the HTTPRoute
"""
spec_parent = next(
(
p
for p in self.spec.parentRefs
if p.name == parent.parentRef.name
),
(p for p in self.spec.parentRefs if p.name == parent.parentRef.name),
None,
)
if spec_parent is None:
raise ValueError(
f"No spec parent found for {parent.parentRef.name}"
)
raise ValueError(f"No spec parent found for {parent.parentRef.name}")
return spec_parent

def __str__(self) -> str:
Expand Down Expand Up @@ -216,9 +206,7 @@ def port_by_section_name(self, section_name: str) -> int | None:
"""
Return the port for a given section name
"""
section = list(
filter(lambda s: s.name == section_name, self.spec.listeners)
)
section = list(filter(lambda s: s.name == section_name, self.spec.listeners))
if len(section) == 0:
return None
return section[0].port
Expand Down Expand Up @@ -401,7 +389,6 @@ async def remove(self, rec: Record):


class BaseWatcher(BaseTask):

def __init__(self, registry: "Registry") -> None:
super().__init__()
self._registry = registry
Expand All @@ -414,19 +401,15 @@ async def register_record(self, op: str, record: Record):
match op:
case "ADDED":
await self._registry.add_record(record)
self._logger.info(
f"Record {record.owner_id} adds {record.hostname}"
)
self._logger.info(f"Record {record.owner_id} adds {record.hostname}")
case "MODIFIED":
await self._registry.modify_record(record)
self._logger.info(
f"Record {record.owner_id} modifies {record.hostname}"
)
case "DELETED":
await self._registry.remove_record(record)
self._logger.info(
f"Record {record.owner_id} removes {record.hostname}"
)
self._logger.info(f"Record {record.owner_id} removes {record.hostname}")

@staticmethod
async def _has_api(required_api_name: str) -> bool:
Expand All @@ -436,8 +419,5 @@ async def _has_api(required_api_name: str) -> bool:
apis_api = kubernetes.client.ApisApi()
resources = await apis_api.get_api_versions()
return (
list(
filter(lambda r: r.name == required_api_name, resources.groups)
)
!= []
list(filter(lambda r: r.name == required_api_name, resources.groups)) != []
)
8 changes: 2 additions & 6 deletions src/cloud_provider_mdns/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ class Settings(pydantic_settings.BaseSettings):
default="k8s",
description="Register only names ending in this domain within unicast DNS",
)
unicast_key_name: str = pydantic.Field(
default="", description="The TSIG key name"
)
unicast_key_name: str = pydantic.Field(default="", description="The TSIG key name")
unicast_key_secret: str = pydantic.Field(
default="", description="The TSIG key secret"
)
Expand Down Expand Up @@ -126,9 +124,7 @@ async def main() -> int:
async with asyncio.TaskGroup() as tg:
ingress_watcher_task = tg.create_task(ingress_watcher.run())
httproute_watcher_task = tg.create_task(httproute_watcher.run())
virtual_service_watcher_task = tg.create_task(
virtual_service_watcher.run()
)
virtual_service_watcher_task = tg.create_task(virtual_service_watcher.run())
return 0
except asyncio.CancelledError:
print("Shut down")
Expand Down
Loading