Thanks for your interest in contributing to the Terraform Provider for Omada! This guide covers the contribution workflow, expectations for tests, the conventions used to structure a service, and how to run the provider locally.
- Fork the repository to your own GitHub account.
- Branch from
mainin your fork using a short, descriptive name (e.g.feat/site-tags,fix/site-import). - Implement your change, following the code structure described below.
- Add or update tests — every change must be covered by automated tests (see Testing requirements).
- Run the checks locally before pushing:
If you have changed the schema or examples, also run
make fmt make lint make testacc
make generateto refresh the docs under docs/. - Open a pull request against
Tohaker/terraform-provider-omada:main. Describe the motivation, the change, and any user-visible behaviour. Link related issues. - Review. A maintainer will review your PR. Please respond to feedback by pushing additional commits to the same branch (do not force-push during review unless asked). CI must be green before merge.
- Merge. PRs are squash-merged into
mainonce approved and CI is green. - Release. Releases are cut by maintainers from
mainby tagging a new semver version. The tag triggers the release workflow which publishes to the Terraform Registry. Add a brief entry to CHANGELOG.md as part of your PR when the change is user-visible.
All changes must be accompanied by automated tests. PRs without tests will not be merged.
- New resources, data sources, or schema attributes require acceptance tests under the matching
internal/service/<name>/package (resource_test.go,data_source_*_test.go). - Bug fixes require a regression test that fails without the fix.
- Acceptance tests run against an in-process
httptestOmada API stand-in provided by internal/acctest/acctest.go — no live controller is needed. Useacctest.NewTestServer(t)and register handlers on itsMux. - Run the full suite with
make testacc. Tests are gated byTF_ACC=1, which the make target sets for you.
Each managed object lives in its own package under internal/service/<name>/. The site service (internal/service/site/) is the canonical reference. A service is split into the following files so that schema, API translation, and Terraform plumbing stay separated:
model.go— Go structs that mirror the Terraform schema usingterraform-plugin-framework/types(e.g.siteResourceModel,siteCommonModel). Also holds small package-internal types like thesiteClientwrapper around the SDK.expand.go— Functions that expand Terraform plan/state models into the request payloads expected by the Omada SDK. One direction only: Terraform → API.flatten.go— Functions that flatten Omada API responses back into the Terraform model types. One direction only: API → Terraform.resource.go— Theresource.Resourceimplementation:Metadata,Schema,Configure,Create,Read,Update,Delete, and (where supported)ImportState. This file should be thin — it wires the framework lifecycle toexpand/flattenand the SDK client.data_source_<name>.go— Adatasource.DataSourceimplementation following the same pattern as the resource. Use one file per data source (e.g.data_source_list.go).*_test.go— Acceptance tests for the corresponding file (resource_test.go,data_source_list_test.go). Shared test helpers go inacctest_test.go.
When adding a new service:
- Create
internal/service/<name>/with the files above. - Register the resource/data source in internal/provider/provider.go.
- Add an example under
examples/resources/omada_<name>/orexamples/data-sources/omada_<name>/somake generateproduces docs.
The repository ships with a VS Code dev container that installs Go, Terraform, and a ~/.terraformrc with a dev_overrides block pointing at $GOPATH/bin. If you use it, most of the setup below is already done for you.
From the repo root:
go install .This builds the provider and writes the binary to $GOPATH/bin (typically /go/bin
in the dev container, or $(go env GOPATH)/bin otherwise).
Create or edit ~/.terraformrc so Terraform resolves Tohaker/omada from your local
build instead of the registry. Replace /go/bin with the directory containing the
binary you just installed:
provider_installation {
dev_overrides {
"registry.terraform.io/Tohaker/omada" = "/go/bin"
}
# All other providers continue to install from their origin registry.
direct {}
}The dev container writes this file automatically via .devcontainer/postCreateCommand.sh.
Note: with
dev_overridesset, do not runterraform initfor the omada provider — Terraform will warn and use your local binary directly.terraform planandterraform applywork as normal.
Point the provider at your Omada controller and run a config from examples/:
provider "omada" {
host = "https://omada.example.com"
controller_id = "<your-controller-id>"
client_id = "<openapi-client-id>"
client_secret = "<openapi-client-secret>"
}cd examples/resources/omada_site
terraform plan| Target | What it does |
|---|---|
make build |
go build ./... |
make install |
Build and go install ./... |
make fmt |
gofmt -s -w over the repo |
make lint |
Run golangci-lint |
make test |
Unit tests |
make testacc |
Full acceptance test suite (TF_ACC=1) |
make generate |
Regenerate provider docs under docs/ |
go get github.com/author/dependency
go mod tidyCommit the resulting go.mod and go.sum changes.