From d09b456409cb3ee7d3814f8709794696f8f7217e Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Tue, 15 Jul 2025 09:25:06 +1000 Subject: [PATCH 1/8] Add copilot instructions and issue template tweaks --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/copilot-instructions.md | 61 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/copilot-instructions.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index c3f5cea54..30682190a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -36,4 +36,4 @@ If applicable, add screenshots to help explain your problem. - Elasticsearch Version [e.g. 7.16.0] **Additional context** -Add any other context about the problem here. +Add any other context about the problem here. Links to specific affected code files and paths here are also extremely useful (if known). diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..33c7dddbf --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,61 @@ +This is a Go based repository hosting a Terrform provider for the elastic stack (elasticsearch and kibana) APIs. This repo currently supports both [plugin framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) and [sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2) resources. All new resources _must_ use the plugin framework. + +For further information, please see [README.md](../README.md) and the [CONTRIBUTING.md](../CONTRIBUTING.md) docs. + +## Code Standards + +### Required Before Each Commit +- Run `make fmt` before committing any changes to ensure proper code formatting, this will run gofmt on all Go files to maintain consistent style. +- Run `make lint` to ensure any linting errors have not surfaced with your changes + +### Required Before Pull Request +- Run `make gen` to update the documentation and code based on your changes. + +### Development Flow +- Develop feature or fix bug +- Write tests to validate behavior +- Run `make test` to run test suite + +## Repository Structure + +• **docs/** - Documentation files + • **data-sources/** - Documentation for Terraform data sources (51 files) + • **guides/** - User guides and tutorials + • **resources/** - Documentation for Terraform resources (35 files) +• **examples/** - Example Terraform configurations + • **cloud/** - Examples using the cloud to launch testing stacks + • **data-sources/** - Data source usage examples (45+ examples) + • **resources/** - Resource usage examples (30+ examples) + • **provider/** - Provider configuration examples +• **generated/** - Auto-generated clients from the `generate-clients` make target + • **alerting/** - Kibana alerting API client + • **connectors/** - Kibana connectors API client + • **kbapi/** - Kibana API client + • **slo/** - SLO (Service Level Objective) API client +• **internal/** - Internal Go packages + • **acctest/** - Acceptance test utilities + • **clients/** - API client implementations + • **elasticsearch/** - Elasticsearch-specific logic + • **fleet/** - Fleet management functionality + • **kibana/** - Kibana-specific logic + • **models/** - Data models and structures + • **schema/** - Connection schema definitions for plugin framework + • **utils/** - Utility functions + • **versionutils/** - Version handling utilities +• **libs/** - External libraries + • **go-kibana-rest/** - Kibana REST API client library +• **provider/** - Core Terraform provider implementation +• **scripts/** - Utility scripts for development and CI +• **templates/** - Template files for documentation generation + • **data-sources/** - Data source documentation templates + • **resources/** - Resource documentation templates + • **guides/** - Guide documentation templates +• **xpprovider/** - Additional provider functionality needed for Crossplane + +## Key Guidelines +* Follow Go best practices and idiomatic patterns +* Maintain existing code structure and organization +* Write unit tests for new functionality. Use table-driven unit tests when possible. +* Avoid adding any extra functionality into the `utils` package, instead preferencing adding to a more specific package or creating one to match the purpose +* Think through your planning first using the codebase as your guide before creating new resources and data sources + From 18a33b55c840ac1e79830b05a5e75ee6118886b4 Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 18 Jul 2025 20:42:55 +1000 Subject: [PATCH 2/8] Update .github/copilot-instructions.md Co-authored-by: Toby Brain --- .github/copilot-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 33c7dddbf..5bb7ba3fe 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,4 +1,4 @@ -This is a Go based repository hosting a Terrform provider for the elastic stack (elasticsearch and kibana) APIs. This repo currently supports both [plugin framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) and [sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2) resources. All new resources _must_ use the plugin framework. +This is a Go based repository hosting a Terrform provider for the elastic stack (elasticsearch and kibana) APIs. This repo currently supports both [plugin framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) and [sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2) resources. Unless you're told otherwise, all new resources _must_ use the plugin framework. For further information, please see [README.md](../README.md) and the [CONTRIBUTING.md](../CONTRIBUTING.md) docs. From 044a48713a1c2dad0369a0ba43c1a420ecf38bb4 Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 18 Jul 2025 20:44:45 +1000 Subject: [PATCH 3/8] Update .github/copilot-instructions.md Co-authored-by: Toby Brain --- .github/copilot-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 5bb7ba3fe..534845e8a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -9,7 +9,7 @@ For further information, please see [README.md](../README.md) and the [CONTRIBUT - Run `make lint` to ensure any linting errors have not surfaced with your changes ### Required Before Pull Request -- Run `make gen` to update the documentation and code based on your changes. +- Run `make docs-generate` to update the documentation. ### Development Flow - Develop feature or fix bug From 14a99545fe552ff3687b248aee678344aa5029eb Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 18 Jul 2025 20:44:54 +1000 Subject: [PATCH 4/8] Update .github/copilot-instructions.md Co-authored-by: Toby Brain --- .github/copilot-instructions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 534845e8a..ad9a380be 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -56,6 +56,7 @@ For further information, please see [README.md](../README.md) and the [CONTRIBUT * Follow Go best practices and idiomatic patterns * Maintain existing code structure and organization * Write unit tests for new functionality. Use table-driven unit tests when possible. +* When creating a new Plugin Framework based resource, follow the code organisation of `internal/elasticsearch/security/system_user` * Avoid adding any extra functionality into the `utils` package, instead preferencing adding to a more specific package or creating one to match the purpose * Think through your planning first using the codebase as your guide before creating new resources and data sources From 28bd8dd8f63bf156cb6ac2ed41250613b74cfc5a Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 18 Jul 2025 20:45:22 +1000 Subject: [PATCH 5/8] remove dumb file counts --- .github/copilot-instructions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index ad9a380be..6549b9707 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -19,13 +19,13 @@ For further information, please see [README.md](../README.md) and the [CONTRIBUT ## Repository Structure • **docs/** - Documentation files - • **data-sources/** - Documentation for Terraform data sources (51 files) + • **data-sources/** - Documentation for Terraform data sources • **guides/** - User guides and tutorials - • **resources/** - Documentation for Terraform resources (35 files) + • **resources/** - Documentation for Terraform resources • **examples/** - Example Terraform configurations • **cloud/** - Examples using the cloud to launch testing stacks - • **data-sources/** - Data source usage examples (45+ examples) - • **resources/** - Resource usage examples (30+ examples) + • **data-sources/** - Data source usage examples + • **resources/** - Resource usage examples • **provider/** - Provider configuration examples • **generated/** - Auto-generated clients from the `generate-clients` make target • **alerting/** - Kibana alerting API client From 70d8a20016fe40b2cdf49a41ba044f73cd22c63a Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 18 Jul 2025 20:56:13 +1000 Subject: [PATCH 6/8] Build out prompt further --- .github/copilot-instructions.md | 83 ++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 6549b9707..948983634 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,20 +1,81 @@ -This is a Go based repository hosting a Terrform provider for the elastic stack (elasticsearch and kibana) APIs. This repo currently supports both [plugin framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) and [sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2) resources. Unless you're told otherwise, all new resources _must_ use the plugin framework. +You will be tasked to fix an issue from an open-source repository. This is a Go based repository hosting a Terrform provider for the elastic stack (elasticsearch and kibana) APIs. This repo currently supports both [plugin framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) and [sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2) resources. Unless you're told otherwise, all new resources _must_ use the plugin framework. -For further information, please see [README.md](../README.md) and the [CONTRIBUTING.md](../CONTRIBUTING.md) docs. -## Code Standards -### Required Before Each Commit -- Run `make fmt` before committing any changes to ensure proper code formatting, this will run gofmt on all Go files to maintain consistent style. + +Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided. + + +Please see [README.md](../README.md) and the [CONTRIBUTING.md](../CONTRIBUTING.md) docs before getting started. + + +# Workflow + +## High-Level Problem Solving Strategy + +1. Understand the problem deeply. Carefully read the issue and think critically about what is required. +2. Investigate the codebase. Explore relevant files, search for key functions, and gather context. +3. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. +4. Implement the fix incrementally. Make small, testable code changes. +5. Debug as needed. Use debugging techniques to isolate and resolve issues. +6. Test frequently. Run tests after each change to verify correctness. +7. Iterate until the root cause is fixed and all tests pass. +8. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete. + +Refer to the detailed sections below for more information on each step. + +## 1. Deeply Understand the Problem +Carefully read the issue and think hard about a plan to solve it before coding. Your thinking should be thorough and so it's fine if it's very long. You can think step by step before and after each action you decide to take. + +## 2. Codebase Investigation +- Explore relevant files and directories. +- Search for key functions, classes, or variables related to the issue. +- Read and understand relevant code snippets. +- Identify the root cause of the problem. +- Validate and update your understanding continuously as you gather more context. + +## 3. Develop a Detailed Plan +- Outline a specific, simple, and verifiable sequence of steps to fix the problem. +- Break down the fix into small, incremental changes. + +## 4. Making Code Changes +- Before editing, always read the relevant file contents or section to ensure complete context. +- If a patch is not applied correctly, attempt to reapply it. +- Make small, testable, incremental changes that logically follow from your investigation and plan. + +## 5. Debugging +- Make code changes only if you have high confidence they can solve the problem +- When debugging, try to determine the root cause rather than addressing symptoms +- Debug for as long as needed to identify the root cause and identify a fix +- Use print statements, logs, or temporary code to inspect program state, including descriptive statements or error messages to understand what's happening +- To test hypotheses, you can also add test statements or functions +- Revisit your assumptions if unexpected behavior occurs. +- You MUST iterate and keep going until the problem is solved. + +## 6. Testing +- Run tests frequently using `make test` +- After each change, verify correctness by running relevant tests. +- If tests fail, analyze failures and revise your patch. +- Write additional tests if needed to capture important behaviors or edge cases. +- Ensure all tests pass before finalizing. + +## 7. Final Verification +- Confirm the root cause is fixed. +- Review your solution for logic correctness and robustness. +- Iterate until you are extremely confident the fix is complete and all tests pass. - Run `make lint` to ensure any linting errors have not surfaced with your changes +- Run `make fmt` before committing any changes to ensure proper code formatting, this will run gofmt on all Go files to maintain consistent style. -### Required Before Pull Request -- Run `make docs-generate` to update the documentation. +## 8. Final Reflection and Additional Testing +- Reflect carefully on the original intent of the user and the problem statement. +- Think about potential edge cases or scenarios that may not be covered by existing tests. +- Write additional tests that would need to pass to fully validate the correctness of your solution. +- Run these new tests and ensure they all pass. +- Be aware that there are additional hidden tests that must also pass for the solution to be successful. +- Do not assume the task is complete just because the visible tests pass; continue refining until you are confident the fix is robust and comprehensive. -### Development Flow -- Develop feature or fix bug -- Write tests to validate behavior -- Run `make test` to run test suite +## 9. Before Submitting Pull Requests +- Run `make docs-generate` to update the documentation, and ensure the results of this command make it into your pull request. ## Repository Structure From c8e17704a51a76e63ec096e9d04da14b4801d71e Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 25 Jul 2025 17:03:05 +1000 Subject: [PATCH 7/8] Update copilot-instructions.md Co-authored-by: Toby Brain --- .github/copilot-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 948983634..cf1807fca 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -53,7 +53,7 @@ Carefully read the issue and think hard about a plan to solve it before coding. - You MUST iterate and keep going until the problem is solved. ## 6. Testing -- Run tests frequently using `make test` +- Run tests frequently using `make test` and `make testacc` - After each change, verify correctness by running relevant tests. - If tests fail, analyze failures and revise your patch. - Write additional tests if needed to capture important behaviors or edge cases. From cf3ff59afed4ca20b62a2c51391d6d568f6ef7c1 Mon Sep 17 00:00:00 2001 From: Nick Clark Date: Fri, 25 Jul 2025 17:03:13 +1000 Subject: [PATCH 8/8] Update copilot-instructions.md Co-authored-by: Toby Brain --- .github/copilot-instructions.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index cf1807fca..27611aa2f 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -63,8 +63,7 @@ Carefully read the issue and think hard about a plan to solve it before coding. - Confirm the root cause is fixed. - Review your solution for logic correctness and robustness. - Iterate until you are extremely confident the fix is complete and all tests pass. -- Run `make lint` to ensure any linting errors have not surfaced with your changes -- Run `make fmt` before committing any changes to ensure proper code formatting, this will run gofmt on all Go files to maintain consistent style. +- Run `make lint` to ensure any linting errors have not surfaced with your changes. This task may automatically correct any linting errors, and regenerate documentation. Include any changes in your commit. ## 8. Final Reflection and Additional Testing - Reflect carefully on the original intent of the user and the problem statement.