Skip to content

Commit

Permalink
ci: workflow to prevent new SDK resources being added
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhilton authored Dec 12, 2024
1 parent 96faef6 commit da3bf7f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/prevent-new-sdk-additions.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit da3bf7f

Please sign in to comment.