Welcome to the Terraform Provider Astro project! We're excited that you're interested in contributing. This document will guide you through the process of setting up your development environment, making changes, submitting pull requests, and reporting issues.
- Development Environment Setup
- Adding Dependencies
- Making Changes
- Testing
- Reporting Issues
- Best Practices
- Additional Resources
Ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/astronomer/terraform-provider-astro.git cd terraform-provider-astro
-
Build the provider:
make dep make build
-
Create a
.terraformrc
file in your home directory (~
) with the following content:provider_installation { dev_overrides { "registry.terraform.io/astronomer/astro" = "/path/to/your/terraform-provider-astro/bin" } direct {} }
Replace
/path/to/your/terraform-provider-astro/bin
with the actual path to thebin
directory in your cloned repository. -
Create a
main.tf
file for testing:terraform { required_providers { astro = { source = "astronomer/astro" } } } provider "astro" { organization_id = "<your-org-id>" } # Add resources and data sources here for testing
-
Set up your Astro API token:
export ASTRO_API_TOKEN=<your-api-token>
This provider uses Go modules. Please see the Go documentation for the most up-to-date information about using Go modules.
To add a new dependency github.com/author/dependency
to your Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name
-
Make your changes in the appropriate files. Common areas for changes include:
internal/provider/
for provider logicinternal/resources/
for resource implementationsinternal/datasources/
for data source implementationsexamples/
for example configurations
-
Update or add tests in the corresponding
*_test.go
files. If a new data source or resource is added, create a new test file in the*_test.go
file for that feature. -
Update documentation if your changes affect the provider's behavior or add new features.
Unit tests can be run with make test
.
Acceptance integration tests use a Terraform CLI binary to run real Terraform commands against the Astro API. The goal is to approximate using the provider with Terraform in production as closely as possible.
Using the terraform-plugin-testing framework, each resource.Test
runs an acceptance test on a resource.
ProtoV6ProviderFactories
: map of the provider factories that the test suite will use to create the provider - just has theastronomer
providerPreCheck
: a function that runs before the test suite starts to check that all the required environment variables are setSteps
: a list ofterraform apply
sequences that the test suite will run. Each step is aresource.TestStep
that contains aConfig
andCheck
function.Config
: the Terraform configuration that the test will run (ie. the.tf
file)Check
: function that will verify the state of the resources after theterraform apply
command has run.
In order to run the full suite of Acceptance tests, run make testacc
.
You will also need to set all the environment variables described in internal/provider/provider_test_utils.go
.
The acceptance tests will run against the Astronomer API and create/read/update/delete real resources.
If you encounter a bug or have a suggestion for improvement, please create an issue on the GitHub repository. This helps us track and address problems efficiently.
- Go to the Issues page of the repository.
- Click on "New Issue".
- Choose the appropriate issue template if available, or start with a blank issue.
- Provide a clear and concise title that summarizes the issue.
- In the description, include:
- A detailed description of the bug or feature request
- Steps to reproduce the issue (for bugs)
- Expected behavior
- Actual behavior (for bugs)
- Screenshots or error messages, if applicable
- Your environment details:
- Terraform version
- Terraform Provider Astro version
- Operating System
- Any other relevant information
- Add appropriate labels to the issue (e.g., "bug", "enhancement", "documentation")
- Submit the issue
- Search existing issues before creating a new one to avoid duplicates.
- One issue per report. If you have multiple bugs or feature requests, create separate issues for each.
- Be responsive to questions or requests for additional information.
- If you find a solution to your problem before the issue is resolved, add a comment describing the solution for others who might encounter the same issue.
If you discover a security vulnerability, please do NOT open an issue. Email [email protected] instead.
- Follow Go best practices and conventions.
- Ensure your code is well-commented and easy to understand.
- Keep your changes focused. If you're working on multiple features, submit separate pull requests.
- Update the README.md if your changes affect the overall usage of the provider.
- Add example configurations to the
examples/
directory for any new features or resources. - If you're adding a new resource or data source, ensure you've added corresponding acceptance tests.
- Terraform Provider Astro Documentation
- Astro API Documentation
- Terraform Plugin Framework Documentation
- Go Documentation
Thank you for contributing to the Terraform Provider Astro project! Your efforts help improve the experience for all Astro users.