Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 4.51 KB

CONTRIBUTING.md

File metadata and controls

92 lines (66 loc) · 4.51 KB

Contributing

Table of content

  1. Submitting a pull request
  2. Development setup
  3. Commands available
  4. Add a new DNS provider
  5. License

Submitting a pull request

  1. Fork and clone the repository
  2. Create a new branch git checkout -b my-branch-name
  3. Modify the code
  4. Commit your modifications
  5. 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.

  1. 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
  2. With Visual Studio Code, install the dev containers extension
  3. In Visual Studio Code, press on F1 and select Dev Containers: Open Folder in Container...
  4. 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 qmcgaw/ddns-updater .
  • Run the Docker container: docker run -it --rm -v /yourpath/data:/updater/data qmcgaw/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:

  1. Copy the directory internal/provider/providers/example to internal/provider/providers/yourprovider where yourprovider is the name of the DNS provider you want to add, in a single word without spaces, dashes or underscores.

  2. Modify the internal/provider/providers/yourprovider/provider.go file to fit the requirements of your DNS provider. There are many // TODO comments you can follow and need to remove when done.

  3. Add the provider name constant to the ProviderChoices function in internal/provider/constants/providers.go. For example:

    func ProviderChoices() []models.Provider {
      return []models.Provider{
        // ...
        Example,
        // ...
      }
    }
  4. Add a case for your provider in the switch statement in the New function in internal/provider/provider.go. For example:

    case constants.Example:
      return example.New(data, domain, owner, ipVersion, ipv6Suffix)
  5. Copy the file docs/example.md to docs/yourprovider.md and 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.

  6. In the README.md:

    1. Add your provider name to the list of providers supported - Your provider
    2. Add your provider name and link to its document to the second list: - [Your provider](docs/yourprovider.md)
  7. 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.1 manually and then run the updater to see if the update succeeds.

  8. Profit 🎉 Don't forget to open a pull request

License

Contributions are released to the public under the open source license of this project.