You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+21-36Lines changed: 21 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,52 +21,48 @@ Requirements:
21
21
* Run unit and acceptance tests (See [Running Acceptance Tests](#running-acceptance-tests)).
22
22
* Run `make fmt`, `make lint`.
23
23
* All checks also run automatically on every PR.
24
-
* Add a changelog entry in `CHANGELOG.md` under the `Unreleased` section. This will be included in the release notes of the next release.
25
24
* Submit your PR for review.
25
+
* Add a changelog entry in `CHANGELOG.md` under the `Unreleased` section. This will be included in the release notes of the next release. The changelog entry references the PR, so it has to be added after the PR has been opened.
26
26
27
27
When creating new resources:
28
28
* Use the [Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) for new resources.
29
29
* Use an existing resource (e.g. `internal/elasticsearch/security/system_user`) as a template.
30
30
* Some resources use the deprecated Terraform SDK, so only resources using the new Terraform Framework should be used as reference.
31
31
* Use the generated API clients to interact with the Kibana APIs. (See [Working with Generated API Clients](#working-with-generated-api-clients)
32
-
* Add documentation and examples for the resource. Update the generated docs with `make docs-generate`.
32
+
* Add a documentation template and examples for the resource. See [Updating Documentation](#updating-documentation) for more details.
33
33
* Write unit and acceptance tests.
34
34
35
-
36
-
## Using Copilot
37
-
38
-
GitHub Copilot can speed up development, but you’re responsible for correctness:
39
-
* Create an issue describing the desired change and acceptance criteria.
40
-
* Assign the issue to Copilot and iterate with prompts.
41
-
* Review outputs carefully; add tests and adjust as needed.
42
-
* Example issue: https://github.com/elastic/terraform-provider-elasticstack/issues/1219
43
-
44
35
### Useful Commands
45
36
46
37
*`make build`: Build the provider.
47
-
*`make install`: Install the provider.
48
-
*`make fmt`: Format the code.
49
-
*`make lint`: Lint the code.
38
+
*`make lint`: Lints and formats the code.
50
39
*`make test`: Run unit tests.
51
40
*`make docs-generate`: Generate documentation.
52
41
42
+
### Running & Debugging the Provider
43
+
44
+
Run the provider in debug mode and reattach the provider in Terraform:
45
+
* Launch `main.go` with the `-debug` flag from your IDE.
46
+
* After launching, the provider will print an env var. Copy the printed `TF_REATTACH_PROVIDERS='{…}'` value.
47
+
* Export it in your shell where you run Terraform: `export TF_REATTACH_PROVIDERS='{…}'`.
48
+
* Terraform will now talk to your debug instance, and you can set breakpoints.
49
+
53
50
#### Running Acceptance Tests
54
51
55
52
Acceptance tests spin up Elasticsearch, Kibana, and Fleet with Docker and run tests in a Go container.
56
53
57
-
Quick start (default stack version from Makefile):
58
54
```bash
59
-
make docker-testacc
60
-
```
55
+
# Start Elasticsearch, Kibana, and Fleet
56
+
make docker-fleet
61
57
62
-
Run a single test with terraform debug enabled:
63
-
```bash
64
-
env TF_LOG=DEBUG make docker-testacc TESTARGS='-run ^TestAccResourceDataStreamLifecycle$$'
65
-
```
58
+
# Run all tests
59
+
make testacc
66
60
67
-
A way to forward debug logs to a file:
68
-
```bash
69
-
env TF_ACC_LOG_PATH=/tmp/tf.log TF_ACC_LOG=DEBUG TF_LOG=DEBUG make docker-testacc
61
+
# Run a specific test
62
+
make testacc TESTARGS='-run ^TestAccResourceDataStreamLifecycle$$'
63
+
64
+
# Cleanup created docker containers
65
+
make docker-clean
70
66
```
71
67
72
68
### Working with Generated API Clients
@@ -81,10 +77,7 @@ If your work involves the Kibana API, the API client can be generated directly f
81
77
82
78
The codebase includes a number of deprecated clients which should not be used anymore:
83
79
-`libs/go-kibana-rest`: Fork of an external library, which is not maintained anymore.
84
-
-`generated/alerting`
85
-
-`generated/connectors`
86
-
-`generated/slo`
87
-
-`internal/clients/*`: Manually written clients. These should only be used/extended if it is not possible to use the generated clients.
80
+
-`generated/alerting`, `generated/connectors`, `generated/slo`: Older generated clients, but based on non-standard specs. If any of these APIs are needed, they should be included in the `kbapi` client.
88
81
89
82
### Updating Documentation
90
83
@@ -93,14 +86,6 @@ Docs are generated from templates in `templates/` and examples in `examples/`.
93
86
* Run `make docs-generate` to produce files under `docs/`.
94
87
* Commit the generated files. `make lint` will fail if docs are stale.
95
88
96
-
### Debugging
97
-
98
-
Run the provider in debug mode and reattach the provider in Terraform:
99
-
* Launch `main.go` with the `-debug` flag from your IDE.
100
-
* After launching, the provider will print an env var. Copy the printed `TF_REATTACH_PROVIDERS='{…}'` value.
101
-
* Export it in your shell where you run Terraform: `export TF_REATTACH_PROVIDERS='{…}'`.
102
-
* Terraform will now talk to your debug instance, and you can set breakpoints.
0 commit comments