diff --git a/.github/workflows/prevent-new-sdk-additions.yml b/.github/workflows/prevent-new-sdk-additions.yml new file mode 100644 index 000000000..58bb8e4db --- /dev/null +++ b/.github/workflows/prevent-new-sdk-additions.yml @@ -0,0 +1,31 @@ +name: Prevent New Terraform SDK additions + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +jobs: + detect-new-sdk-files: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Check for new SDK resources or datasources + run: | + git diff --name-status origin/main..${{ vars.GITHUB_REF }} | grep '^A' | grep '^A\s\+octopusdeploy/' > new_files.txt || true + if [ -s new_files.txt ]; then + echo "New files were found in the 'octopusdeploy/' directory." + cat new_files.txt + echo "::error::We are no longer creating new Terraform SDK resources or datasources. Anything new should be added using Terraform Framework in the 'octopusdeploy_framework' folder instead." + exit 1 + else + echo "::notice::No new files detected in the 'octopusdeploy/' directory." + fi diff --git a/README.md b/README.md index 55aa5a43f..d85a3fca7 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,16 @@ Terraform will scan the local plugins folder directory structure (first) to qual ## Create a New Resource -The provider is currently undergoing migration from Terraform SDK to Terraform Plugin Framework. Ensure all **new** resources are created under the `octopusdeploy-framework` directory using existing resources within the `octopusdeploy-framework` directory as a guideline. +> [!IMPORTANT] +> We're currently migrating all resources and data sources from Terraform SDK to Terraform Plugin Framework. +> +> All new resources should be created using Framework, in the `octopusdeploy-framework` directory. [A GitHub action](.github/workflows/prevent-new-sdk-additions.yml) will detect and prevent any new additions to the old `octopusdeploy` SDK directory. +> +> When modifying an existing SDK resource, we strongly recommend migrating it to Framework first - but this might not always be feasible. We'll judge it on a case-by-case basis. All new resources need an acceptance test that will ensure the lifecycle of the resource works correctly this includes Create, Read, Update and Delete. -Please avoid using blocks in favour of nested attribute types. Blocks are mainly used for resources migrated from SDK to maintain backwards compatability. +Please avoid using [blocks](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/blocks): these are mainly used for backwards compatability of resources migrated from SDK. Use [nested attributes](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes#nested-attribute-types) instead. ## Debugging If you want to debug the provider follow these steps!