1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Merge branch 'master' into tlim_cfaliases

This commit is contained in:
Tom Limoncelli
2017-06-01 18:06:05 -04:00
6 changed files with 58 additions and 9 deletions

View File

@ -40,7 +40,7 @@ Example javascript (Registrar only. DNS hosted elsewhere):
{% highlight js %}
var REG_NAMECOM = NewRegistrar("name.com","NAMEDOTCOM");
var R53 = NewDnsProvider("r53", ROUTE53);
var R53 = NewDnsProvider("r53", "ROUTE53");
D("example.tld", REG_NAMECOM, DnsProvider(R53),
A("test","1.2.3.4")

View File

@ -49,7 +49,7 @@ Example javascript:
{% highlight js %}
var namecheap = NewRegistrar("namecheap.com","NAMECHEAP");
var R53 = NewDnsProvider("r53", ROUTE53);
var R53 = NewDnsProvider("r53", "ROUTE53");
D("example.tld", namecheap, DnsProvider(R53),
A("test","1.2.3.4")

View File

@ -7,7 +7,7 @@ jsId: ROUTE53
## Configuration
By default, you can configure aws setting like the [go sdk configuration](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html). For example you can use environment variables:
By default, you can configure aws setting like the [go sdk configuration](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html). For example you can use environment variables:
```
$ export AWS_ACCESS_KEY_ID=XXXXXXXXX
$ export AWS_SECRET_ACCESS_KEY=YYYYYYYYY
@ -34,7 +34,7 @@ Example javascript:
{% highlight js %}
var REG_NAMECOM = NewRegistrar("name.com","NAMEDOTCOM");
var R53 = NewDnsProvider("r53", ROUTE53);
var R53 = NewDnsProvider("r53", "ROUTE53");
D("example.tld", REG_NAMECOM, DnsProvider(R53),
A("test","1.2.3.4")
@ -47,7 +47,7 @@ DNSControl depends on a standard [aws access key](https://aws.amazon.com/develop
## New domains
If a domain does not exist in your Route53 account, DNSControl
If a domain does not exist in your Route53 account, DNSControl
will *not* automatically add it. You can do that either manually
via the control panel, or via the command `dnscontrol create-domains`
command.

View File

@ -11,10 +11,12 @@ Dnscontrol is a platform for seamlessly managing your dns configuration across a
## [Language Reference]({{site.github.url}}/js): Description of the DNSControl language (DSL).
## [Examples]({{site.github.url}}/examples): DSL examples.
## [Examples]({{site.github.url}}/examples): The DNSControl language by example.
## [Migrating]({{site.github.url}}/migrating): Migrating zones to DNSControl.
## [Testing]({{site.github.url}}/unittests): Unit Testing DNS Data.
## [github](https://github.com/StackExchange/dnscontrol): Get the source!

33
docs/unittests.md Normal file
View File

@ -0,0 +1,33 @@
# Unit Testing DNS Data
## Testing
DNSControl performs a number of tests during the validation stage.
You can find them in `pkg/normalize/validate.go`.
## External tests
Tests specific to your environment may be added as external tests.
Output the intermediate representation as a JSON file and perform
tests on this data.
Output the intermediate representation:
dnscontrol -debugjson foo.json print
Here is a sample test written in `bash` using the [jq](https://stedolan.github.io/jq/) command. This fails if the number of MX records in the `stackex.com` domain is not exactly 5:
COUNTMX=$(jq --raw-output <foo.json '.domains[] | select(.name == "stackex.com") | .records[] | select(.type == "MX") | .target' | wc -l)
echo COUNT=:"$COUNTMX":
if [[ "$COUNTMX" -eq "5" ]]; then
echo GOOD
else
echo BAD
fi
## Future directions
Manipulting JSON data is difficult. If you implement ways to make it easier, we'd
gladly accept contributions.

View File

@ -4,11 +4,25 @@ layout: default
# Writing new DNS providers
Writing a new DNS provider is a relatively straightforward process. You essentially need to implement the [providers.DNSServiceProvider interface.](https://godoc.org/github.com/StackExchange/dnscontrol/providers#DNSServiceProvider)
Writing a new DNS provider is a relatively straightforward process. You essentially need to implement the [providers.DNSServiceProvider interface.](https://godoc.org/github.com/StackExchange/dnscontrol/providers#DNSServiceProvider) and the system takes care of the rest.
...
Use another provider as the basis for yours. Pick the provider that has the most similar
API. Some APIs update one DNS record at a time (cloudflare, namedotcom, activedir), some APIs update
all the DNS records on a particular label, some APIs require you to upload the entire
zone every time (bind, gandi).
More info to follow soon.
You'll notice that most providers use the "diff" module to detect differences. It takes
two zones and returns records that are unchanged, created, deleted, and modified. Even
if the API simply requires the entire zone to be uploaded each time, we prefer to list
the specific changes so the user knows exactly what changed.
Here are some tips:
* Create a directory for the provider called `providers/name` where `name` is all lowercase and represents the commonly-used name for the service.
* The main driver should be called `providers/name/nameProvider.go`. The API abstraction is usually in a separate file (often called `api.go`).
* List the provider in `providers/_all/all.go` so DNSControl knows it exists.
* Implement all the calls in [providers.DNSServiceProvider interface.](https://godoc.org/github.com/StackExchange/dnscontrol/providers#DNSServiceProvider). The function `GetDomainCorrections` is a bit interesting. It returns a list of corrections to be made. These are in the form of functions that DNSControl can call to actually make the corrections.
* If you have any questions, please dicuss them in the Github issue related to the request for this provider. Please let us know what was confusing so we can update this document with advice for future authors (or feel free to update this document yourself!).
## Documentation