-
Notifications
You must be signed in to change notification settings - Fork 762
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
[BUG]: Validation of resource_github_actions_repository_permissions requiring allowed_actions_config is wrong/problematic #2105
Comments
I shortly tried to rework the related code by removing the validation and add a test, but it seem to have a bit bigger impact: As GitHub will "copy" the configuration from the Organization or Enterprise level, the Terraform provider downloads this related data which leads to an inconsistency (terraform defining nothing vs. state defining values). Maybe some more experienced devs from the project know how to handle such scenarios. AFAIK typically this is solved in TF providers by properly have a 1:1 mapping between Terraform Resources and API endpoints which is not the case here. 1 Resource in TF are 2 resources in the GitHub API. Any hints are appreciated how this can be tackled as I'd be happy to attempt a PR. |
Do you mind explaining more about what you mean here? I'm not sure I follow, sorry.
In this scenario, would you be suggesting that the |
Thanks a bunch for the detailed explanation! That's great. Breaking changes are a little obnoxious in the Terraform world since they require state migration functions, extra testing, and Hashicorp recommends we don't release more than one per year. We have #2091 ready that I'd like to get officially released in the near future...do you have any interest in creating a PR to fix this behavior as you've described? |
I'm not a big expert in Go and the Terraform provider implementations but could give it a try to prepare a PR which would separate the TF resource into two if thats what we're aiming for. I am still wondering if there would be maybe an alternative to a breaking change by handling the loading of the resource differently. I started preparing a change where I allow
I adjusted the related code on the read operation and I think this way things should be fine. PR here: #2114 |
Expected Behavior
It should be possible to enable github actions on a repository via
resource_github_actions_repository_permissions
andallowed_actions="selected"
without manually specfiying aallowed_actions_config
. The implemented custom validation is incorrect.And in scenarios where you are not allowed to change the actions list on repository level, you will get an error with further validation errors.
Please allow
resource_github_actions_repository_permissions
withallowed_actions="selected"
andallowed_actions_config
unset.Actual Behavior
This check kicks in and reports an error if you do not specify
allowed_actions_config
:terraform-provider-github/github/resource_github_actions_repository_permissions.go
Line 101 in 5752b25
There are config variations where the policies are defined on organization/enterprise level and they cannot be customized on repository level. In the UI they are readonly if you select the respective radio button:
On REST API level it is possible to control whether GHA is enabled and what actions are allowed without yet specfiying the list yet.
https://docs.github.com/en/rest/actions/permissions?apiVersion=2022-11-28#set-github-actions-permissions-for-a-repository
The list of actions and other policies are part of a separate resource which is not mandatory to be customized per repository:
https://docs.github.com/en/rest/actions/permissions?apiVersion=2022-11-28#set-allowed-actions-and-reusable-workflows-for-a-repository
Terraform Version
Terraform 1.5.6 on Windows Server 2022
CDKTF for .net, NuGet Package: HashiCorp.Cdktf.Providers.Github 12.0.2
Provider Version: 5.42.0 (https://github.com/cdktf/cdktf-provider-github/releases/tag/v12.0.2)
Affected Resource(s)
Terraform Configuration Files
No response
Steps to Reproduce
CDKTF for .net:
Debug Output
No response
Panic Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: