Skip to content

Commit

Permalink
feat: migrate to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
neubi4 committed Oct 14, 2024
1 parent d28e1a5 commit 0935184
Show file tree
Hide file tree
Showing 19 changed files with 1,642 additions and 479 deletions.
67 changes: 28 additions & 39 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
name: octoDNS AutoDNSProvider
on: [pull_request, workflow_dispatch]
---
name: tests

on:
push:
pull_request:

jobs:
config:
runs-on: ubuntu-latest
outputs:
json: ${{ steps.load.outputs.json }}
steps:
- id: load
run: |
{
echo 'json<<EOF'
curl -L https://github.com/octodns/octodns/raw/main/.ci-config.json
echo EOF
} >> $GITHUB_OUTPUT
ci:
needs: config
tests:
name: Run tests (py${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(needs.config.outputs.json).python_versions_active }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: CI Build
run: |
./script/cibuild
setup-py:
needs: config
runs-on: ubuntu-latest
python:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ fromJson(needs.config.outputs.json).python_version_current }}
architecture: x64
- name: CI setup.py
run: |
./script/cibuild-setup-py
python-version: ${{ matrix.python }}

- name: Install poetry
run: pip install poetry

- name: Install dependencies
run: poetry install

- name: Run tests
run: poetry run tox
13 changes: 0 additions & 13 deletions .github/workflows/stale.yml

This file was deleted.

49 changes: 28 additions & 21 deletions octodns_autodns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@
# octodns provider for AutoDNS
#

from octodns.provider.base import BaseProvider
from octodns.provider import ProviderException
from octodns.record import Record
from octodns.zone import Zone

from collections import defaultdict
from logging import getLogger

from requests import Session
from requests.auth import HTTPBasicAuth

from octodns.provider import ProviderException
from octodns.provider.base import BaseProvider
from octodns.record import Record
from octodns.zone import Zone

# TODO: remove __VERSION__ with the next major version release
__version__ = __VERSION__ = '0.0.1'


class AutoDNSClientException(ProviderException):
pass


class AutoDNSClientNotFound(AutoDNSClientException):
def __init__(self):
super().__init__('Not Found')


class AutoDNSClientUnauthorized(AutoDNSClientException):
def __init__(self):
super().__init__('Unauthorized')


class AutoDNSClient(object):
BASE_URL = 'https://api.autodns.com/v1'

Expand Down Expand Up @@ -77,8 +82,8 @@ def zone_record_delete(self, zone_id, record_id):

class AutoDNSProvider(BaseProvider):
SUPPORTS_GEO = False
#SUPPORTS_DYNAMIC = False
#SUPPORTS_ROOT_NS = True
# SUPPORTS_DYNAMIC = False
# SUPPORTS_ROOT_NS = True
SUPPORTS = set(
(
'A',
Expand All @@ -92,31 +97,31 @@ class AutoDNSProvider(BaseProvider):
'MX',
'NS',
'SRV',
'ALIAS'
'ALIAS',
)
)

def __init__(
self,
id,
username,
password,
context,
system_name_server="a.ns14.net",
*args,
**kwargs
self,
id,
username,
password,
context,
system_name_server="a.ns14.net",
*args,
**kwargs,
):
self.log = getLogger(f'AutoDNSProvider[{id}]')
self.log.debug(f"__init__: username={username}, password={password}, context={context}, system_name_server={system_name_server}")
self.log.debug(
f"__init__: username={username}, password={password}, context={context}, system_name_server={system_name_server}"
)

super().__init__(id, *args, **kwargs)

self.id = id

sess = Session()
sess.headers.update({
"X-Domainrobot-Context": str(context),
})
sess.headers.update({"X-Domainrobot-Context": str(context)})
sess.auth = HTTPBasicAuth(username, password)

self.client = AutoDNSClient(sess, system_name_server)
Expand Down Expand Up @@ -145,7 +150,9 @@ def populate(self, zone: Zone, target=False, lenient=False):
zone,
name,
{
'ttl': record_data.get("ttl", zone_data["data"][0]["soa"]["ttl"]),
'ttl': record_data.get(
"ttl", zone_data["data"][0]["soa"]["ttl"]
),
'type': record_data["type"],
'value': record_data["value"],
},
Expand Down
Loading

0 comments on commit 0935184

Please sign in to comment.