|
| 1 | +# Contributing to Terraform Provider for Appwrite |
| 2 | + |
| 3 | +Thank you for your interest in contributing! This document provides guidelines for contributing to the Appwrite Terraform provider. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- [Go](https://golang.org/doc/install) (see `go.mod` for required version) |
| 10 | +- [Terraform](https://www.terraform.io/downloads.html) >= 1.0 |
| 11 | +- An Appwrite instance (Cloud or Community Edition) for acceptance testing |
| 12 | + |
| 13 | +### Building |
| 14 | + |
| 15 | +```bash |
| 16 | +make build |
| 17 | +``` |
| 18 | + |
| 19 | +### Installing Locally |
| 20 | + |
| 21 | +```bash |
| 22 | +make install |
| 23 | +``` |
| 24 | + |
| 25 | +This installs the provider to `~/.terraform.d/plugins/` for local testing. |
| 26 | + |
| 27 | +### Running Tests |
| 28 | + |
| 29 | +Unit tests: |
| 30 | + |
| 31 | +```bash |
| 32 | +make test |
| 33 | +``` |
| 34 | + |
| 35 | +Acceptance tests (requires a running Appwrite instance): |
| 36 | + |
| 37 | +```bash |
| 38 | +export APPWRITE_ENDPOINT="https://cloud.appwrite.io/v1" |
| 39 | +export APPWRITE_PROJECT_ID="your-project-id" |
| 40 | +export APPWRITE_API_KEY="your-api-key" |
| 41 | +make acceptance-test |
| 42 | +``` |
| 43 | + |
| 44 | +### Linting |
| 45 | + |
| 46 | +```bash |
| 47 | +make lint |
| 48 | +``` |
| 49 | + |
| 50 | +### Generating Documentation |
| 51 | + |
| 52 | +```bash |
| 53 | +make docs |
| 54 | +``` |
| 55 | + |
| 56 | +Documentation is auto-generated from schema definitions and examples using [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs). Always run `make docs` after changing resource schemas or examples. |
| 57 | + |
| 58 | +## Adding a New Resource |
| 59 | + |
| 60 | +1. Create a new directory under `internal/services/<service>/` |
| 61 | +2. Implement `resource.go` with the Plugin Framework interfaces |
| 62 | +3. Add the resource to `provider.go` in the `Resources()` method |
| 63 | +4. Create an example in `examples/resources/appwrite_<resource_name>/resource.tf` |
| 64 | +5. Create an import example in `examples/resources/appwrite_<resource_name>/import.sh` |
| 65 | +6. Create a doc template in `templates/resources/<resource_name>.md.tmpl` |
| 66 | +7. Write acceptance tests in `resource_test.go` |
| 67 | +8. Run `make docs` to generate documentation |
| 68 | + |
| 69 | +## Adding a New Data Source |
| 70 | + |
| 71 | +Follow the same pattern as resources, but use `datasource.DataSource` interface and register in the `DataSources()` method. |
| 72 | + |
| 73 | +## Pull Request Process |
| 74 | + |
| 75 | +1. Fork the repository and create a feature branch |
| 76 | +2. Write or update tests for your changes |
| 77 | +3. Run `make lint` and `make test` to verify your changes |
| 78 | +4. Run `make docs` and commit any generated documentation changes |
| 79 | +5. Open a pull request with a clear description of the changes |
| 80 | + |
| 81 | +## Code Style |
| 82 | + |
| 83 | +- Follow standard Go conventions (`gofmt`, `go vet`) |
| 84 | +- Use the Terraform Plugin Framework (not SDK v2) for new resources |
| 85 | +- Keep resource implementations consistent with existing patterns |
| 86 | +- Mark sensitive fields with `Sensitive: true` |
| 87 | +- Handle 404 errors in Read by calling `resp.State.RemoveResource(ctx)` |
0 commit comments