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
* Make your changes. See [Useful Commands](#useful-commands) and [Debugging](#debugging).
19
-
* GitHub Copilot can be used to help with these changes (See [Using Copilot](#using-copilot))
18
+
* Make your changes. See [Useful Commands](#useful-commands) and [Debugging](#running--debugging-the-provider).
20
19
* Validate your changes
21
20
* Run unit and acceptance tests (See [Running Acceptance Tests](#running-acceptance-tests)).
22
-
* Run `make fmt`, `make lint`.
21
+
* Run `make lint` to check linting and formatting. For this check to succeed, all changes must have been committed.
23
22
* 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
23
* Submit your PR for review.
24
+
* 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
25
27
26
When creating new resources:
28
27
* Use the [Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) for new resources.
29
28
* Use an existing resource (e.g. `internal/elasticsearch/security/system_user`) as a template.
30
29
* Some resources use the deprecated Terraform SDK, so only resources using the new Terraform Framework should be used as reference.
31
30
* 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`.
31
+
* Add a documentation template and examples for the resource. See [Updating Documentation](#updating-documentation) for more details.
33
32
* Write unit and acceptance tests.
34
33
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
34
### Useful Commands
45
35
46
36
*`make build`: Build the provider.
47
-
*`make install`: Install the provider.
48
-
*`make fmt`: Format the code.
49
-
*`make lint`: Lint the code.
37
+
*`make lint`: Lints and formats the code.
50
38
*`make test`: Run unit tests.
51
39
*`make docs-generate`: Generate documentation.
52
40
41
+
### Running & Debugging the Provider
42
+
43
+
Run the provider in debug mode and reattach the provider in Terraform:
44
+
* Launch `main.go` with the `-debug` flag from your IDE.
45
+
* After launching, the provider will print an env var. Copy the printed `TF_REATTACH_PROVIDERS='{…}'` value.
46
+
* Export it in your shell where you run Terraform: `export TF_REATTACH_PROVIDERS='{…}'`.
47
+
* Terraform will now talk to your debug instance, and you can set breakpoints.
48
+
53
49
#### Running Acceptance Tests
54
50
55
51
Acceptance tests spin up Elasticsearch, Kibana, and Fleet with Docker and run tests in a Go container.
56
52
57
-
Quick start (default stack version from Makefile):
58
53
```bash
59
-
make docker-testacc
60
-
```
54
+
# Start Elasticsearch, Kibana, and Fleet
55
+
make docker-fleet
61
56
62
-
Run a single test with terraform debug enabled:
63
-
```bash
64
-
env TF_LOG=DEBUG make docker-testacc TESTARGS='-run ^TestAccResourceDataStreamLifecycle$$'
65
-
```
57
+
# Run all tests
58
+
make testacc
66
59
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
60
+
# Run a specific test
61
+
make testacc TESTARGS='-run ^TestAccResourceDataStreamLifecycle$$'
62
+
63
+
# Cleanup created docker containers
64
+
make docker-clean
70
65
```
71
66
72
67
### Working with Generated API Clients
@@ -81,10 +76,7 @@ If your work involves the Kibana API, the API client can be generated directly f
81
76
82
77
The codebase includes a number of deprecated clients which should not be used anymore:
83
78
-`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.
79
+
-`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
80
89
81
### Updating Documentation
90
82
@@ -93,14 +85,6 @@ Docs are generated from templates in `templates/` and examples in `examples/`.
93
85
* Run `make docs-generate` to produce files under `docs/`.
94
86
* Commit the generated files. `make lint` will fail if docs are stale.
95
87
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