Pick a similar provider as your base. Providers basically fall
into three general categories:
* **zone:** The API requires you to upload the entire zone every time. (BIND, GANDI).
* **incremental-record:** The API lets you add/change/delete individual DNS records. (ACTIVEDIR, CLOUDFLARE, NAMEDOTCOM, GCLOUD, ROUTE53)
* **incremental-label:** Similar to incremental, but the API requires you to update all the records related to a particular label each time. For example, if a label (www.example.com) has an A and MX record, any change requires replacing all the records for that label.
TODO: Categorize DNSIMPLE, NAMECHEAP
All providers use the "diff" module to detect differences. It takes
two zones and returns records that are unchanged, created, deleted,
and modified. The incremental providers use the differences to
update individual records or recordsets. The zone providers use the
information to print a human-readable list of what is being changed,
but upload the entire new zone.
## Step 3: Create the driver skeleton
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
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.
## Step 6: Unit Test
Make sure the existing unit tests work. Add unit tests for any
complex algorithms in the new code.
Run the unit tests with this command:
cd dnscontrol
go test ./...
## Step 7: Integration Test
This is the most important kind of testing when adding a new provider.
Integration tests use a test account and a real domain.
* Edit [integrationTest/providers.json](https://github.com/StackExchange/dnscontrol/blob/master/integrationTest/providers.json): Add the creds.json info required for this provider.
For example, this will run the tests using BIND:
```
cd dnscontrol/integrationTest
go test -v -verbose -provider BIND
```
(BIND is a good place to start since it doesn't require any API keys.)
This will run the tests on Amazon AWS Route53:
```
export R53_DOMAIN=dnscontroltest-r53.com # Use a test domain.
export R53_KEY_ID=CHANGE_TO_THE_ID
export R53_KEY='CHANGE_TO_THE_KEY'
go test -v -verbose -provider ROUTE53
```
## Step 5: Update docs
* Edit [README.md](https://github.com/StackExchange/dnscontrol): Add the provider to the bullet list.
If your provider depends on other go packages, then you must vendor them. To do this, use [govendor](https://github.com/kardianos/govendor). A command like this is usually suffient: