Skip to content

Commit

Permalink
Refactor zone import configuration and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
th-schwarz committed Oct 27, 2024
1 parent ab878e9 commit fc7bbfa
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
3 changes: 2 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ dyndrest:
- name: dynhost.info
ns: ns.domain.info
hosts:
- myhost:1234567890abcdef
- sld: myhost
api-token: 1234567890abcdef
domainrobot:
autodns:
Expand Down
23 changes: 18 additions & 5 deletions docs/dyndrest-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,25 @@ spring:

[source,yaml]
----
spring:
security:
user:
name: oauthuser
password: oauthpasswd
domainrobot:
autodns:
user: userName
password: secretPwd
----
That's the minimal setting for the domainrobot-api. For further fine adjustments, the following settings can be overwritten or changed:
[source,yaml]
----
domainrobot:
default-ttl: 60
# connection properties
autodns:
context: 4
url: https://api.autodns.com/v1
# custom headers
custom-header:
X-Domainrobot-WS: NONE
----

[[backup_restore]]
=== Backup and Restore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ public List<HostEnriched> getHosts() {
return enrichedHosts;
}
for (ZoneImportConfig.Zone zone : zones) {
for (String hostRaw : zone.hosts()) {
String[] parts = hostRaw.split(":");
if (parts.length != 2) {
throw new IllegalArgumentException(
"The host entry must be in the following format: [sld|:[apiToken], but it was: "
+ hostRaw);
}
for (Host host : zone.hosts()) {
HostEnriched hostEnriched = new HostEnriched();
hostEnriched.setName(parts[0]);
hostEnriched.setApiToken(parts[1]);
hostEnriched.setName(host.sld());
hostEnriched.setApiToken(host.apiToken());
hostEnriched.setZone(zone.name);
hostEnriched.setNs(zone.ns);
enrichedHosts.add(hostEnriched);
Expand All @@ -51,5 +45,14 @@ public List<HostEnriched> getHosts() {
* @param ns name server
* @param hosts host / subdomains
*/
public record Zone(String name, String ns, List<String> hosts) {}
public record Zone(String name, String ns, List<Host> hosts) {}


/**
* Represents a Host entity with an sld (second-level domain) and an apiToken.
*
* @param sld The second-level domain associated with the host.
* @param apiToken The API token for authentication or other purposes.
*/
public record Host(String sld, String apiToken) {}
}
15 changes: 8 additions & 7 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ dyndrest:
path: ./restore
dump-file: dump.sql

## disable springdoc endpoints and swagger-ui by default
springdoc:
api-docs:
enabled: false
swagger-ui:
enabled: false

## configuration for the domain robot sdk
domainrobot:
default-ttl: 60
Expand All @@ -54,6 +47,14 @@ domainrobot:
custom-header:
X-Domainrobot-WS: NONE


## disable springdoc endpoints and swagger-ui by default
springdoc:
api-docs:
enabled: false
swagger-ui:
enabled: false

## import of the individual configuration settings
spring:
config:
Expand Down
9 changes: 6 additions & 3 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ dyndrest:
- name: dynhost0.info
ns: ns0.domain.info
hosts:
- my3:api1
- sld: my3
api-token: api1
- name: zone1.info
ns: ns1.domain.info
hosts:
- host1:abc
- host2:123
- sld: host1
api-token: abc
- sld: host2
api-token: 123

domainrobot:
default-ttl: 61
Expand Down

0 comments on commit fc7bbfa

Please sign in to comment.