4.5 KiB
Contributing
Table of content
Submitting a pull request
- Fork and clone the repository
- Create a new branch
git checkout -b my-branch-name - Modify the code
- Commit your modifications
- Push to your fork and submit a pull request
Additional resources:
Development setup
Using VSCode and Docker
That should be easier and better than a local setup, although it might use more memory if you're not on Linux.
- Install Docker
- On Windows, share a drive with Docker Desktop and have the project on that partition
- On OSX, share your project directory with Docker Desktop
- With Visual Studio Code, install the dev containers extension
- In Visual Studio Code, press on
F1and selectDev Containers: Open Folder in Container... - Your dev environment is ready to go!... and it's running in a container 👍
Locally
Install Go, Docker and Git; then:
go mod download
And finally install golangci-lint.
You might want to use an editor such as Visual Studio Code with the Go extension.
Commands available
- Test the code:
go test ./... - Lint the code
golangci-lint run - Build the program:
go build -o app cmd/ddns-updater/main.go - Build the Docker image (tests and lint included):
docker build -t ghcr.io/qdm12/ddns-updater . - Run the Docker container:
docker run -it --rm -v /yourpath/data:/updater/data ghcr.io/qdm12/ddns-updater
Add a new DNS provider
An "example" DNS provider is present in the code, you can simply copy paste it modify it to your needs. In more detailed steps:
-
Copy the directory
internal/provider/providers/exampletointernal/provider/providers/yourproviderwhereyourprovideris the name of the DNS provider you want to add, in a single word without spaces, dashes or underscores. -
Modify the
internal/provider/providers/yourprovider/provider.gofile to fit the requirements of your DNS provider. There are many// TODOcomments you can follow and need to remove when done. -
Add the provider name constant to the
ProviderChoicesfunction ininternal/provider/constants/providers.go. For example:func ProviderChoices() []models.Provider { return []models.Provider{ // ... Example, // ... } } -
Add a case for your provider in the
switchstatement in theNewfunction ininternal/provider/provider.go. For example:case constants.Example: return example.New(data, domain, owner, ipVersion, ipv6Suffix) -
Copy the file
docs/example.mdtodocs/yourprovider.mdand modify it to fit the configuration and domain setup of your DNS provider. There are a few<!-- ... -->comments indicating what to change, please remove them when done. -
In the README.md:
- Add your provider name to the list of providers supported
- Your provider - Add your provider name and link to its document to the second list:
- [Your provider](docs/yourprovider.md)
- Add your provider name to the list of providers supported
-
Make sure to run the actual program (in Docker or directly) and check it updates your DNS records as expected, of course 😉 You can do this by setting a record to
127.0.0.1manually and then run the updater to see if the update succeeds. -
Profit 🎉 Don't forget to open a pull request
License
Contributions are released to the public under the open source license of this project.