diff --git a/build/generate/featureMatrix.go b/build/generate/featureMatrix.go index 3d8804aea..c27926095 100644 --- a/build/generate/featureMatrix.go +++ b/build/generate/featureMatrix.go @@ -137,8 +137,7 @@ type FeatureMatrix struct { var tmpl = template.Must(template.New("").Funcs(template.FuncMap{ "safe": func(s string) template.HTML { return template.HTML(s) }, -}).Parse(` - {% comment %} +}).Parse(`{% comment %} Matrix generated by build/generate/featureMatrix.go. DO NOT HAND EDIT! {% endcomment %}{{$providers := .Providers}} diff --git a/commands/previewPush.go b/commands/previewPush.go index 5ba7b09f6..a5bfc4608 100644 --- a/commands/previewPush.go +++ b/commands/previewPush.go @@ -203,6 +203,11 @@ func InitializeProviders(credsFile string, cfg *models.DNSConfig, notifyFlag boo isNonDefault[name] = true } } + + // Collect the names of all providers. + // Run through the providerConfigs and output a warning if any are + // invalid. + registrars := map[string]providers.Registrar{} dnsProviders := map[string]providers.DNSServiceProvider{} for _, d := range cfg.Domains { diff --git a/docs/_includes/providerfield.html b/docs/_includes/providerfield.html new file mode 100644 index 000000000..9f562f9ce --- /dev/null +++ b/docs/_includes/providerfield.html @@ -0,0 +1,6 @@ + +NOTE: The `_PROVIDER` field is ignored by the provider. It is used by +DNSControl to cross-check that this entry is used with the proper +provider code. DNSControl produces warnings if it is missing or +invalid. In the future these warnings will become hard errors. + diff --git a/docs/_providers/activedir.md b/docs/_providers/activedir.md index 172801bc0..8876478fd 100644 --- a/docs/_providers/activedir.md +++ b/docs/_providers/activedir.md @@ -30,6 +30,7 @@ The `ActiveDirectory_PS` provider reads an `ADServer` setting from `creds.json` ```js { "activedir": { + "_PROVIDER": "ACTIVEDIRECTORY_PS", "ADServer": "ny-dc01" } } @@ -41,6 +42,7 @@ If you want to modify the "fake powershell" mode details, you can set them in th ```js { "activedir": { + "_PROVIDER": "ACTIVEDIRECTORY_PS", "ADServer": "ny-dc01", "fakeps": "true", "pslog": "powershell.log", @@ -49,6 +51,7 @@ If you want to modify the "fake powershell" mode details, you can set them in th } ``` +{% include providerfield.html %} An example DNS configuration: diff --git a/docs/_providers/akamaiedgedns.md b/docs/_providers/akamaiedgedns.md index aa6464808..0d1e7cf8b 100644 --- a/docs/_providers/akamaiedgedns.md +++ b/docs/_providers/akamaiedgedns.md @@ -28,6 +28,7 @@ In the credentials file (creds.json), you must provide the following: ```json "akamaiedgedns": { + "_PROVIDER": "AKAMAIEDGEDNS", "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "host": "akaa-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxx.akamaiapis.net", "access_token": "akaa-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", diff --git a/docs/_providers/autodns.md b/docs/_providers/autodns.md index da7de8946..59ea0bc45 100644 --- a/docs/_providers/autodns.md +++ b/docs/_providers/autodns.md @@ -14,6 +14,7 @@ In your credentials file, you must provide [username, password and a context](ht {% highlight json %} { "autodns": { + "_PROVIDER": "AUTODNS", "username": "autodns.service-account@example.com", "password": "[***]", "context": "33004" diff --git a/docs/_providers/axfrddns.md b/docs/_providers/axfrddns.md index 44151c72e..6464b2f39 100644 --- a/docs/_providers/axfrddns.md +++ b/docs/_providers/axfrddns.md @@ -42,6 +42,7 @@ For instance, your `creds.json` might looks like: ```json { "axfrddns": { + "_PROVIDER": "AXFRDDNS", "transfer-key": "hmac-sha256:transfer-key-id:Base64EncodedSecret=", "update-key": "hmac-sha256:update-key-id:AnotherSecret=" } diff --git a/docs/_providers/azuredns.md b/docs/_providers/azuredns.md index 6953e73d5..3db97608b 100644 --- a/docs/_providers/azuredns.md +++ b/docs/_providers/azuredns.md @@ -11,6 +11,7 @@ You can specify the API credentials in the credentials json file: ```json { "azuredns_main":{ + "_PROVIDER": "AZURE_DNS", "SubscriptionID": "AZURE_SUBSCRIPTION_ID", "ResourceGroup": "AZURE_RESOURCE_GROUP", "TenantID": "AZURE_TENANT_ID", @@ -33,6 +34,7 @@ export AZURE_CLIENT_SECRET=BBBBBBBBB ```json { "azuredns_main":{ + "_PROVIDER": "AZURE_DNS", "SubscriptionID": "$AZURE_SUBSCRIPTION_ID", "ResourceGroup": "$AZURE_RESOURCE_GROUP", "TenantID": "$AZURE_TENANT_ID", diff --git a/docs/_providers/bind.md b/docs/_providers/bind.md index 95041438a..2be733258 100644 --- a/docs/_providers/bind.md +++ b/docs/_providers/bind.md @@ -18,6 +18,7 @@ you can specify a `directory` where the provider will look for and create zone f ```json { "bind": { + "_PROVIDER": "BIND", "directory": "myzones", "filenameformat": "%U.zone" << The default } diff --git a/docs/_providers/cloudflare.md b/docs/_providers/cloudflare.md index 3b2271f1d..ae9cddb80 100644 --- a/docs/_providers/cloudflare.md +++ b/docs/_providers/cloudflare.md @@ -25,6 +25,7 @@ This method is enabled by setting the "apitoken" value in `creds.json`: ```json { "cloudflare": { + "_PROVIDER": "CLOUDFLAREAPI", "apitoken": "your-cloudflare-api-token", "accountid": "your-cloudflare-account-id" } diff --git a/docs/_providers/cloudns.md b/docs/_providers/cloudns.md index 928aabd86..88465bbc8 100644 --- a/docs/_providers/cloudns.md +++ b/docs/_providers/cloudns.md @@ -14,6 +14,7 @@ Current version of provider doesn't support `sub-auth-user`. ```json { "cloudns": { + "_PROVIDER": "CLOUDNS", "auth-id": "12345", "sub-auth-id": "12345", "auth-password": "your-password" diff --git a/docs/_providers/cscglobal.md b/docs/_providers/cscglobal.md index 362d26385..9c108ea2c 100644 --- a/docs/_providers/cscglobal.md +++ b/docs/_providers/cscglobal.md @@ -14,6 +14,7 @@ In your `creds.json` file, you must provide your API key and user/client token. ```json { "cscglobal": { + "_PROVIDER": "CSCGLOBAL", "api-key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "user-token": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "notification_emails": "test@exmaple.tld,hostmaster@example.tld" diff --git a/docs/_providers/desec.md b/docs/_providers/desec.md index 8528a07c1..39ea2ec3d 100644 --- a/docs/_providers/desec.md +++ b/docs/_providers/desec.md @@ -11,6 +11,7 @@ In your providers credentials file you must provide a deSEC account auth token: ```json { "desec": { + "_PROVIDER": "DESEC", "auth-token": "your-deSEC-auth-token" } } diff --git a/docs/creds-json.md b/docs/creds-json.md index bcff1e406..e9b58ef09 100644 --- a/docs/creds-json.md +++ b/docs/creds-json.md @@ -8,19 +8,22 @@ title: creds.json file format When dnscontrol interacts with a provider, any API keys, credentials, or other configuration parameters required are stored in `creds.json`. The file contains a set of key/value pairs for each configuration. That is, since a provider can be used multiple times with different credentials, the file contains a section for each set of credentials. -Here's a sample file: +Here's a sample `creds.json` file: ```json { "cloudflare_tal": { + "_PROVIDER": "CLOUDFLAREAPI", "apikey": "REDACTED", "apiuser": "REDACTED" }, "inside": { + "_PROVIDER": "BIND", "directory": "inzones", "filenameformat": "db_%T%?_%D" }, "hexonet": { + "_PROVIDER": "HEXONET", "apilogin": "$HEXONET_APILOGIN", "apipassword": "$HEXONET_APIPASSWORD", "debugmode": "$HEXONET_DEBUGMODE", @@ -39,6 +42,7 @@ Here's a sample file: * ...are whatever the provider specifies. * ...can be credentials, secrets, or configuration settings. In the above examples the `inside` setting is configuration parameters for the BIND provider, not credentials. * A missing subkey is not an error. The value is the empty string. + * The subkey `_PROVIDER` indicates which provider plug-in to use. In the future it will be required and dnscontrol will report an error if it is missing or invalid. Currently DNSControl reports warnings. * Values: * ...may include any JSON string value including the empty string. * If a subkey starts with `$`, it is taken as an env variable. In the above example, `$HEXONET_APILOGIN` would be replaced by the value of the environment variable `HEXONET_APILOGIN` or the empty string if no such environment variable exists. diff --git a/providers/config/providerConfig.go b/providers/config/providerConfig.go index a1b2aa7dd..56cedf9ca 100644 --- a/providers/config/providerConfig.go +++ b/providers/config/providerConfig.go @@ -57,9 +57,24 @@ func LoadProviderConfigs(fname string) (map[string]map[string]string, error) { if err = replaceEnvVars(results); err != nil { return nil, err } + + ckeys := keysWithColons(results) + if len(ckeys) != 0 { + fmt.Printf("WARNING: Cred entries may not contain colons in the future. Please fix: %v\n", quotedList(ckeys)) + } + + pkeys := entriesWithoutProvider(results) + if len(pkeys) != 0 { + fmt.Printf("WARNING: Please add a PROVIDER field to these credential entries: %v\n", quotedList(pkeys)) + } + return results, nil } +func quotedList(l []string) string { + return `"` + strings.Join(l, `", "`) + `"` +} + func isExecutable(filename string) bool { if stat, statErr := os.Stat(filename); statErr == nil { if mode := stat.Mode(); mode&0111 == 0111 {