Skip to content

Add copilot instructions and issue template tweaks #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
123 changes: 123 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
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.




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.

## 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.

## 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

• **docs/** - Documentation files
• **data-sources/** - Documentation for Terraform data sources
• **guides/** - User guides and tutorials
• **resources/** - Documentation for Terraform resources
• **examples/** - Example Terraform configurations
• **cloud/** - Examples using the cloud to launch testing stacks
• **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
• **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.
* 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

Loading