Compare commits

..

1 commit

Author SHA1 Message Date
aeddab622f chore(deps): update bitnami/postgresql docker tag to v14.12.0
Some checks failed
build and publish / release-pypackage (pull_request) Successful in 19s
build and publish / update-changelog (pull_request) Failing after 5s
check code / check-code (pull_request) Successful in 26s
2024-05-09 20:16:05 +02:00
14 changed files with 78 additions and 202 deletions

View file

@ -1,4 +1,4 @@
name: build pypackage and create release
name: build and publish
on:
push:
@ -9,55 +9,16 @@ on:
branches: [main, master]
jobs:
release-github:
runs-on: ubuntu-latest
env:
HATCH_INDEX_REPO: main
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PACKAGE_TOKEN }}
steps:
- name: checkout code
uses: actions/checkout@v4
release-pypackage:
uses: actions/workflows/.gitea/workflows/release_pypackage.yml@master
with:
fetch-depth: 0
repository: main
secrets:
username: __token__
token: ${{ secrets.PACKAGE_TOKEN }}
gh-token: ${{ secrets.GH_TOKEN }}
- uses: actions/setup-python@v5
update-changelog:
uses: actions/workflows/.gitea/workflows/update_changelog.yml@master
with:
python-version: "3.11"
- name: setup go
uses: actions/setup-go@v4
with:
go-version: ">=1.20"
- name: install hatc h
run: pip install -U hatch hatchling
- name: build package
run: hatch build --clean
- name: install auto-changelog
run: npm install auto-changelog
- name: generate changelog
run: >-
npx auto-changelog -t keepachangelog
--commit-limit 50 --backfill-limit 50
--ignore-commit-pattern '[Bb]ump version|[Uu]pdate changelog|[Mm]erge pull request'
- name: get release notes
id: release-notes
uses: olofvndrhr/releasenote-gen@v1
- name: publish package
if: gitea.event_name != 'pull_request'
run: hatch publish --yes --no-prompt
- name: create gitea release
uses: https://gitea.com/actions/release-action@main
if: gitea.event_name != 'pull_request'
with:
title: ${{ gitea.ref_name }}
body: ${{ steps.release-notes.outputs.releasenotes }}
files: |-
dist/**
branch: main

View file

@ -9,23 +9,6 @@ on:
jobs:
check-code:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- uses: actions/setup-python@v5
uses: actions/workflows/.gitea/workflows/check_python_hatch.yml@master
with:
python-version: "3.11"
- name: install hatch
run: pip install -U hatch
- name: test codestyle
run: hatch run lint:style
- name: test typing
run: hatch run lint:typing
- name: run tests
run: hatch run default:test
run-tests: true

View file

@ -1,4 +1,4 @@
name: build pypackage and create release
name: build and release
on:
push:
@ -17,7 +17,7 @@ jobs:
HATCH_INDEX_AUTH: ${{ secrets.PACKAGE_TOKEN }}
steps:
- name: checkout code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 0
@ -25,18 +25,12 @@ jobs:
with:
python-version: "3.11"
- name: install hatch
run: pip install -U hatch hatchling
- name: build package
run: hatch build --clean
- name: install auto-changelog
run: npm install auto-changelog
run: npm install -g auto-changelog
- name: generate changelog
run: >-
npx auto-changelog -t keepachangelog
auto-changelog -t keepachangelog
--commit-limit 50 --backfill-limit 50
--ignore-commit-pattern '[Bb]ump version|[Uu]pdate changelog|[Mm]erge pull request'
@ -44,6 +38,12 @@ jobs:
id: release-notes
uses: olofvndrhr/releasenote-gen@v1
- name: install hatch
run: pip install -U hatch hatchling
- name: build package
run: hatch build --clean
- name: create github release
uses: ncipollo/release-action@v1
if: github.event_name != 'pull_request'

View file

@ -1 +1,2 @@
just 1.25.2
lefthook 1.4.6

View file

@ -1,6 +1,6 @@
FROM lscr.io/linuxserver/netbox:4.0.8
FROM lscr.io/linuxserver/netbox:3.7.6
RUN pip install -U \
wheel \
setuptools \
netbox-plugin-dns==1.0.4
netbox-plugin-dns

View file

@ -29,7 +29,7 @@ services:
- SUPERUSER_PASSWORD=netbox-dev
db:
image: bitnami/postgresql:14.13.0
image: bitnami/postgresql:14.12.0
container_name: netbox-dev-db
restart: unless-stopped
user: ${UID}

View file

@ -14,7 +14,7 @@ PLUGINS_CONFIG = {
"zone_nameservers": ["ns1.example.com", "ns2.example.com"],
"zone_soa_mname": "ns1.example.com",
"zone_soa_rname": "admin.example.com",
"tolerate_underscores_in_labels": False,
"tolerate_underscores_in_hostnames": False,
"tolerate_leading_underscore_types": [
"TXT",
"SRV",

View file

@ -1,43 +0,0 @@
manager:
max_workers: 1
plan_outputs:
html:
class: octodns.provider.plan.PlanMarkdown
processors:
spf:
class: octodns_spf.SpfDnsLookupProcessor
no-root-ns:
class: octodns.processor.filter.IgnoreRootNsFilter
min-max-ttl:
class: octodns.processor.restrict.TtlRestrictionFilter
allowed_ttls:
- 60
- 300
- 600
- 900
- 1800
- 3600
- 7200
- 10800
providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: ./zones
default_ttl: 3600
enforce_order: true
populate_should_replace: false
netbox:
class: octodns_netbox_dns.NetBoxDNSProvider
url: http://localhost:8000
token: 1ca8f8de1d651b0859052dc5e6a0858fd1e43e3d # change token for netbox
view: false
replace_duplicates: false
make_absolute: true
zones:
"*":
sources:
- config
processors:
- spf
targets:
- netbox

View file

@ -19,6 +19,7 @@ show_system_info:
setup:
asdf install
lefthook install
create_venv:
@echo "creating venv"
@ -76,8 +77,5 @@ sync *args:
dump *args:
hatch -v run default:dump {{ args }}
dump2 *args:
hatch -v run default:dump2 {{ args }}
validate *args:
hatch -v run default:validate {{ args }}

14
lefthook.yml Normal file
View file

@ -0,0 +1,14 @@
colors: true
no_tty: false
pre-commit:
commands:
01_ruff_check:
stage_fixed: true
glob: "*.py"
run: ruff check --fix-only --exit-zero --silent {all_files}
02_ruff_format:
stage_fixed: true
glob: "*.py"
run: ruff format {all_files}

View file

@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling>=1.24", "hatch-regex-commit>=0.0.3"]
requires = ["hatchling>=1.18", "hatch-regex-commit>=0.0.3"]
build-backend = "hatchling.build"
[project]
@ -11,7 +11,7 @@ requires-python = ">=3.11"
dynamic = ["version"]
authors = [
{ name = "Jeffrey C. Ollie", email = "" },
{ name = "Ivan Schaller", email = "ivan@schaller.sh" },
{ name = "Ivan Schaller", email = "ivan@schaller.sh" }
]
classifiers = [
"License :: OSI Approved :: MIT License",
@ -19,7 +19,10 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.11",
]
dependencies = ["pynetbox>=7.2.0", "dnspython>=2.4.2"]
dependencies = [
"pynetbox>=7.2.0",
"dnspython>=2.4.2",
]
[project.urls]
Homepage = "https://github.com/olofvndrhr/octodns-netbox-dns"
@ -45,9 +48,9 @@ packages = ["src/octodns_netbox_dns"]
[tool.hatch.envs.default]
python = "3.11"
dependencies = [
"pytest==8.2.2",
"coverage==7.5.3",
"octodns==1.9.1",
"pytest==7.4.4",
"coverage==7.4.2",
"octodns==1.7.0",
"octodns-spf==0.0.2",
]
@ -58,23 +61,28 @@ cov-report = ["- coverage combine", "coverage report", "coverage xml"]
cov = ["test-cov", "cov-report"]
sync = ["cd dev && octodns-sync --debug --config-file sync.yml --force {args}"]
dump = [
"cd dev && octodns-dump --debug --config-file sync.yml --output-dir output {args} '*' netbox",
]
dump2 = [
"cd dev && octodns-dump --debug --config-file sync2.yml --output-dir output {args} '*' netbox",
]
dump = ["cd dev && octodns-dump --debug --config-file sync.yml --output-dir output {args} '*' netbox"]
validate = ["cd dev && octodns-validate --debug --config-file sync.yml {args}"]
[tool.hatch.envs.lint]
python = "3.11"
detached = true
dependencies = ["mypy==1.10.0", "ruff==0.4.8"]
dependencies = [
"mypy==1.8.0",
"ruff==0.2.2",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --non-interactive --install-types {args:src/octodns_netbox_dns}"
style = ["ruff check --diff {args:.}", "ruff format --check --diff {args:.}"]
fmt = ["ruff check --fix {args:.}", "ruff format {args:.}", "style"]
style = [
"ruff check --diff {args:.}",
"ruff format --check --diff {args:.}"
]
fmt = [
"ruff check --fix {args:.}",
"ruff format {args:.}",
"style"
]
all = ["style", "typing"]
###
@ -104,7 +112,7 @@ exclude = [
"dist",
"node_modules",
"venv",
"dev",
"dev"
]
[tool.ruff.lint]
@ -135,18 +143,8 @@ select = [
"W",
"YTT",
]
ignore = [
"E501",
"D103",
"D100",
"D102",
"PLR2004",
"D403",
"ISC001",
"FBT001",
"FBT002",
"FBT003",
]
ignore-init-module-imports = true
ignore = ["E501", "D103", "D100", "D102", "PLR2004", "D403", "ISC001", "FBT001", "FBT002", "FBT003"]
unfixable = ["F401"]
[tool.ruff.format]
@ -233,10 +231,7 @@ parallel = true
omit = ["src/octodns_netbox_dns/__about__.py"]
[tool.coverage.paths]
octodns_netbox_dns = [
"src/octodns_netbox_dns",
"*/octodns-netbox-dns/src/octodns_netbox_dns",
]
octodns_netbox_dns = ["src/octodns_netbox_dns", "*/octodns-netbox-dns/src/octodns_netbox_dns"]
tests = ["tests", "*/octodns-netbox-dns/tests"]
[tool.coverage.report]

View file

@ -1 +1 @@
__version__ = "0.3.7"
__version__ = "0.3.5"

View file

@ -75,18 +75,14 @@ class NetBoxDNSProvider(octodns.provider.base.BaseProvider):
self.make_absolute = make_absolute
self.disable_ptr = disable_ptr
def _make_absolute(self, value: str, force: bool = False) -> str:
def _make_absolute(self, value: str) -> str:
"""return dns name with trailing dot to make it absolute
@param value: dns record value
@param force: when `True`, disregard configuration option `make_absolute`
@return: absolute dns record value
"""
if value.endswith("."):
return value
if not (self.make_absolute or force):
if not self.make_absolute or value.endswith("."):
return value
absolute_value = value + "."
@ -434,14 +430,3 @@ class NetBoxDNSProvider(octodns.provider.base.BaseProvider):
value=record,
disable_ptr=self.disable_ptr,
)
def list_zones(self) -> list[str]:
"""get all zones from netbox
@return: a list with all active zones
"""
query_params = {"status": "active", **self.nb_view}
zones = self.api.plugins.netbox_dns.zones.filter(**query_params)
absolute_zones = [self._make_absolute(z.name, True) for z in zones]
return sorted(absolute_zones)

View file

@ -11,7 +11,7 @@ DEFAULT_CONFIG = {
}
def test_absolute():
def test1():
nbdns = NetBoxDNSProvider(**DEFAULT_CONFIG)
rcd = "example.com"
absolute = nbdns._make_absolute(rcd)
@ -19,27 +19,9 @@ def test_absolute():
assert absolute == "example.com."
def test_noop():
def test2():
nbdns = NetBoxDNSProvider(**DEFAULT_CONFIG)
rcd = "example.com."
absolute = nbdns._make_absolute(rcd)
assert absolute == "example.com."
def test_disabled():
args = {**DEFAULT_CONFIG, "make_absolute": False}
nbdns = NetBoxDNSProvider(**args)
rcd = "example.com"
relative = nbdns._make_absolute(rcd, force=False)
assert relative == "example.com"
def test_force():
args = {**DEFAULT_CONFIG, "make_absolute": False}
nbdns = NetBoxDNSProvider(**args)
rcd = "example.com"
absolute = nbdns._make_absolute(rcd, force=True)
assert absolute == "example.com."