Closed pataquets closed 1 week ago
Hi there!
Are you referring to the creds.js file or the dnsconfig.js file?
Hi there!
Are you referring to the creds.js file or the dnsconfig.js file?
My bad, I was meaning credentials. Fixed issue title and description. Thanks!
Sure! Sounds reasonable!
Would you be interested in contributing a PR?
This would be a good starter project!
All the changes would be in pkg/credsfile/providerConfig.go
Update LoadProviderConfigs()
to check for a .yaml
suffix, and call a function to load it.
The function would look a lot like readCredsFile()
but would read from YAML instead of JSON.
Despite not having enough Go skills to tackle that, I went looking at the code to try grasping the complexity, in case it could be some "low hanging fruit" type of task (which might it be) or at least, be labeled as such for potential contributors.
However, while reading the code I remembered reading somewhere the "configuration from script execution" feature. I instantly realized that that approach was within my skills, so I took a stab at it and figured out a solution.
The solution involves a creds.sh
which will be used as the new credentials file for the --creds
switch and a creds.yaml
which will hold your credentials, as previously did the creds.json
file.
When using the creds.sh
as configuration file, a readable JSON-formated configuration will be output on the fly from the YAML creds.
creds.sh
:#!/bin/sh
yq -p yaml -o json "$(dirname $0)/creds.yaml"
creds.yaml
:mycloudflare:
TYPE: CLOUDFLAREAPI
accountid: your-acct-id
apitoken: your-api-token
dohcloudflare:
TYPE: DNSOVERHTTPS
host: cloudflare-dns.com
namecom:
TYPE: NAMEDOTCOM
apikey: key
apiuser: username
dsp-none:
TYPE: NONE
reg-none:
TYPE: NONE
That's an excellent solution! Good idea!
Is your feature request related to a problem? Please describe. YAML files are easier and better for humans (e.g. they support comments)
Describe the solution you'd like Support YAML in the credentials file as an alternative configuration syntax.
Describe alternatives you've considered Placing comments meant for credentials config file outside of it, out of reach from where they belong :smile: EDIT: After posting the issue, it came to me an alternative way to do this, which ended up working. See comment below for the solution.
Additional context Related issue found: #1458 No issue for the FR which I've found, so creating this one. Seen as ~planned~ scheduled for someday :tm: , as found in docs: https://github.com/StackExchange/dnscontrol/blob/d160b828ff29fe3c00217c59e4e6f7655feff72f/documentation/creds-json.md?plain=1#L178
Edit: fixed ambiguity on which file between credentials or DNS configuration.