Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DS records #55

Merged
merged 2 commits into from
Jan 15, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.0.4 - 2025-??-?? - ???

* Support for `DS` record types

## v0.0.3 - 2023-02-08 - AKA

* Support for `ALIAS` record types
Expand Down
25 changes: 25 additions & 0 deletions octodns_googlecloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class GoogleCloudProvider(BaseProvider):
'ALIAS',
'CAA',
'CNAME',
'DS',
'MX',
'NAPTR',
'NS',
Expand Down Expand Up @@ -293,6 +294,19 @@ def _data_for_CAA(self, gcloud_record):
def _data_for_CNAME(self, gcloud_record):
return {'value': gcloud_record.rrdatas[0]}

def _data_for_DS(self, gcloud_record):
return {
'values': [
{
'key_tag': v[0],
'algorithm': v[1],
'digest_type': v[2],
'digest': v[3],
}
for v in [shlex.split(g) for g in gcloud_record.rrdatas]
]
}

def _data_for_MX(self, gcloud_record):
return {
'values': [
Expand Down Expand Up @@ -367,6 +381,17 @@ def _rrset_for_CNAME(self, gcloud_zone, record):
record.fqdn, record._type, record.ttl, [record.value]
)

def _rrset_for_DS(self, gcloud_zone, record):
return gcloud_zone.resource_record_set(
record.fqdn,
record._type,
record.ttl,
[
f'{v.key_tag} {v.algorithm} {v.digest_type} {v.digest}'
for v in record.values
],
)

def _rrset_for_MX(self, gcloud_zone, record):
return gcloud_zone.resource_record_set(
record.fqdn,
Expand Down
8 changes: 8 additions & 0 deletions tests/config/unit.tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ dname:
ttl: 300
type: DNAME
value: unit.tests.
ds:
ttl: 9
type: DS
value:
key_tag: 0
algorithm: 1
digest_type: 2
digest: abcdef0123456
excluded:
octodns:
excluded:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_octodns_provider_googlecloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@
},
)
)
octo_records.append(
Record.new(
zone,
'ds',
{
'ttl': 9,
'type': 'DS',
'values': [
{
'key_tag': 0,
'algorithm': 1,
'digest_type': 2,
'digest': 'abcdef0123456',
},
{
'key_tag': 1,
'algorithm': 2,
'digest_type': 3,
'digest': '0123456abcdef',
},
],
},
)
)
for record in octo_records:
zone.add_record(record)

Expand Down Expand Up @@ -215,6 +239,12 @@
],
),
(u'caa.unit.tests.', u'CAA', 9, [u'0 issue ca.unit.tests']),
(
u'ds.unit.tests.',
u'DS',
9,
[u'0 1 2 abcdef0123456', '1 2 3 0123456abcdef'],
),
]


Expand Down
Loading