Skip to content

Commit

Permalink
loopia: add configuratble API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Aug 24, 2022
1 parent d7b0593 commit ca2cc96
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/zz_gen_cmd_dnshelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,7 @@ func displayDNSHelp(name string) error {
ew.writeln()

ew.writeln(`Additional Configuration:`)
ew.writeln(` - "LOOPIA_API_URL": API endpoint. Ex: https://api.loopia.se/RPCSERV or https://api.loopia.rs/RPCSERV`)
ew.writeln(` - "LOOPIA_HTTP_TIMEOUT": API request timeout`)
ew.writeln(` - "LOOPIA_POLLING_INTERVAL": Time between DNS propagation check`)
ew.writeln(` - "LOOPIA_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
Expand Down
1 change: 1 addition & 0 deletions docs/content/dns/zz_gen_loopia.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ More information [here]({{< ref "dns#configuration-and-credentials" >}}).

| Environment Variable Name | Description |
|--------------------------------|-------------|
| `LOOPIA_API_URL` | API endpoint. Ex: https://api.loopia.se/RPCSERV or https://api.loopia.rs/RPCSERV |
| `LOOPIA_HTTP_TIMEOUT` | API request timeout |
| `LOOPIA_POLLING_INTERVAL` | Time between DNS propagation check |
| `LOOPIA_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
Expand Down
7 changes: 6 additions & 1 deletion providers/dns/loopia/loopia.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (

EnvAPIUser = envNamespace + "API_USER"
EnvAPIPassword = envNamespace + "API_PASSWORD"
EnvAPIURL = envNamespace + "API_URL"

EnvTTL = envNamespace + "TTL"
EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
Expand Down Expand Up @@ -50,7 +51,6 @@ type Config struct {
// NewDefaultConfig returns a default configuration for the DNSProvider.
func NewDefaultConfig() *Config {
return &Config{
BaseURL: internal.DefaultBaseURL,
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 40*time.Minute),
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 60*time.Second),
Expand Down Expand Up @@ -83,6 +83,7 @@ func NewDNSProvider() (*DNSProvider, error) {
config := NewDefaultConfig()
config.APIUser = values[EnvAPIUser]
config.APIPassword = values[EnvAPIPassword]
config.BaseURL = env.GetOrDefaultString(EnvAPIURL, internal.DefaultBaseURL)

return NewDNSProviderConfig(config)
}
Expand All @@ -108,6 +109,10 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
client.HTTPClient = config.HTTPClient
}

if config.BaseURL != "" {
client.BaseURL = config.BaseURL
}

return &DNSProvider{
config: config,
client: client,
Expand Down
1 change: 1 addition & 0 deletions providers/dns/loopia/loopia.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ It needs to have the following permissions:
LOOPIA_API_USER = "API username"
LOOPIA_API_PASSWORD = "API password"
[Configuration.Additional]
LOOPIA_API_URL = "API endpoint. Ex: https://api.loopia.se/RPCSERV or https://api.loopia.rs/RPCSERV"
LOOPIA_POLLING_INTERVAL = "Time between DNS propagation check"
LOOPIA_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
LOOPIA_TTL = "The TTL of the TXT record used for the DNS challenge"
Expand Down

0 comments on commit ca2cc96

Please sign in to comment.