You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,6 +145,44 @@ providers:
145
145
- Set `enabled: true` for the provider(s) you want to use.
146
146
- For Cloudflare, set `proxied: true` to enable the orange cloud (proxy).
147
147
148
+
## Provider Configuration
149
+
150
+
Each provider’s configuration is defined by that provider’s Go package. The main config file’s `providers:` section is a map, and each provider receives its own sub-map at runtime.
151
+
152
+
For example, the Cloudflare provider expects:
153
+
154
+
```yaml
155
+
providers:
156
+
cloudflare:
157
+
enabled: true
158
+
api_token: "your-cloudflare-api-token"
159
+
zone_id: "your-zone-id"
160
+
record_name: "home.example.com"
161
+
record_type: "A"
162
+
proxied: true
163
+
```
164
+
165
+
The Route53 provider expects:
166
+
167
+
```yaml
168
+
providers:
169
+
route53:
170
+
enabled: false
171
+
access_key_id: "AWS_ACCESS_KEY_ID"
172
+
secret_access_key: "AWS_SECRET_ACCESS_KEY"
173
+
hosted_zone_id: "Z1D633PJN98FT9"
174
+
record_name: "home.example.com"
175
+
record_type: "A"
176
+
region: "us-east-1"
177
+
```
178
+
179
+
**To add a new provider:**
180
+
- Implement the `DNSProvider` interface in your own package.
181
+
- Define your own config struct and document the expected YAML.
182
+
- Unmarshal the config using the provided `config.ConfigFromMap` helper.
Package provider implements DNS provider interfaces and concrete implementations for dynago.
241
-
242
-
This package supports multiple DNS providers \(Cloudflare, Route53\) and provides a registry for enabled providers based on application configuration. Each provider implements the DNSProvider interface, which allows for querying and updating DNS records.
UpdateRecordIP updates the Route53 DNS record to the given IP address.
236
+
The provider system has been refactored and is now public and extensible. Provider interfaces, registry, and implementations are no longer in `internal/provider` but in the top-level `providers/` directory.
390
237
391
-
ip: The new IP address to set in the DNS record.
238
+
- See [docs/providers.md](providers.md) for full documentation on the provider system, interface, and how to add new providers.
239
+
- Each provider (e.g., Cloudflare, Route53) is implemented in its own package under `providers/`.
240
+
- The provider registry and interface are now public in `providers/provider.go`.
241
+
- Provider configuration is now loaded as a `map[string]any` and passed to each provider's `New` function for parsing.
392
242
393
-
Returns an error if the update fails.
243
+
Legacy types and functions in `internal/provider` have been removed or replaced. Please refer to the new provider documentation for up-to-date API and usage.
This document describes the provider system in dynago, how to configure providers, and how to add new providers.
4
+
5
+
---
6
+
7
+
## Overview
8
+
9
+
dynago supports multiple DNS providers (e.g., Cloudflare, AWS Route53) for dynamic DNS updates. The provider system is designed to be extensible: each provider is implemented as a separate Go package under `providers/`, and new providers can be added easily by contributors.
10
+
11
+
- The provider interface and registry are public and live in `providers/provider.go`.
12
+
- Each provider (e.g., Cloudflare, Route53) is implemented in its own subpackage (e.g., `providers/cloudflare/`).
13
+
- Each provider defines and unmarshals its own config struct.
14
+
- Provider configs are loaded as generic maps and passed to the provider's `New` function for parsing.
15
+
16
+
---
17
+
18
+
## Provider Interface
19
+
20
+
The core interface for all providers is defined in `providers/provider.go`:
21
+
22
+
```go
23
+
// DNSProvider is the interface all DNS providers must implement.
24
+
typeDNSProviderinterface {
25
+
Name() string
26
+
Enabled() bool
27
+
Update(recordName, recordType, ip string) error
28
+
}
29
+
```
30
+
31
+
Providers must also register themselves using the registry in `provider.go`:
32
+
33
+
```go
34
+
// RegisterProvider registers a provider constructor by name.
- Add a `example_test.go` file with unit tests for your provider.
87
+
88
+
---
89
+
90
+
## Provider Configuration in YAML
91
+
92
+
Provider configs are specified under the `providers:` key in your YAML config file. Each provider's config is a map of options, passed directly to the provider's `New` function.
93
+
94
+
Example:
95
+
96
+
```yaml
97
+
providers:
98
+
cloudflare:
99
+
enabled: true
100
+
api_token: "your-cloudflare-api-token"
101
+
zone_id: "your-zone-id"
102
+
record_name: "home.example.com"
103
+
record_type: "A"
104
+
proxied: true
105
+
route53:
106
+
enabled: false
107
+
access_key_id: "AWS_ACCESS_KEY_ID"
108
+
secret_access_key: "AWS_SECRET_ACCESS_KEY"
109
+
hosted_zone_id: "Z1D633PJN98FT9"
110
+
record_name: "home.example.com"
111
+
record_type: "A"
112
+
region: "us-east-1"
113
+
```
114
+
115
+
- Each provider can define its own config fields.
116
+
- Only providers with `enabled: true` will be used.
117
+
118
+
---
119
+
120
+
## Provider Registry and Discovery
121
+
122
+
- The registry in `provider.go` allows dynago to discover and instantiate all registered providers at runtime.
123
+
- Providers are enabled/disabled via config.
124
+
- The registry makes it easy to add new providers without modifying core code.
125
+
126
+
---
127
+
128
+
## See Also
129
+
- Example provider implementations: `providers/cloudflare/`, `providers/route53/`
130
+
- Main configuration documentation: [README.md](README.md)
0 commit comments