[MAINT] Fix github_organization_ruleset and github_repository_ruleset with push target#2958
Conversation
stevehipwell
left a comment
There was a problem hiding this comment.
I think this change likely wants to wait for the SDK upgrade as a lot of this area is modified in future versions.
FYI the error behaviours previously seen should have been mitigated by #2705 so if there is an error the provider should handle it gracefully.
0531db8 to
9dd2965
Compare
1bdfa45 to
efd67ae
Compare
github_organization_ruleset with push targetgithub_organization_ruleset with push target
52d95d4 to
6782aab
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
Would it be possible to either de-scope this PR or open a new PR with the smallest number of changes possible to fix the outstanding bugs?
|
@stevehipwell Yes, I agree. I've done that already in this PR: #2976 But I can't switch the base of this PR to point to that :) |
github_organization_ruleset with push targetgithub_organization_ruleset and github_repository_ruleset with push target
1fe74fc to
2a2277a
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
I've added some review comments, mainly about the code structure.
c1019c3 to
d51fea0
Compare
5c0112b to
c8d93e0
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
@deiga I've added some comments but the main concern here is that we keep only the relevant changes in the PR. If you could tidy the PR up, rebase, and then I'll give this a full PR with the aim of getting it merged ASAP.
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…anything Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…thing Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…o ruleset Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
6da201a to
00afcdb
Compare
…set` with `push` target (integrations#2958) * Update descriptions and validations Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add `CustomizeDiff` logic to validate on `plan` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add first validation test Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add validation error when `conditions` is missing Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add further validation tests Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Remove unnecessary skip blocks as `individual` and `anonymous` access to org rulesets will never be a thing Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Switch `ref_name` to `Optional` as `push` doesn't need a `ref_name` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add Debug logging with `tflog` to validation Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix validation as `ref_name`, `repository_name` and `repository_id` are empty lists by default Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Remove unnecessary panic test Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Improve validation output messages Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix condition to require only one of `repository_name` or `repository_id` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add validation to `required_workflow.path` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Rename test resources for easier debugging Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix linter issues Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add validation to ensure `rules.required_status_checks.required_checks.context` is not empty Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add test to ensure that `required_checks` is always required Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix tests after rebase Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Improve legibility of `conditions` description Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Update descriptions Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add Acc test for push ruleset. This turns out to be failing as there is a bug in our implementation! Unit tests and fix coming up Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add failing test for `flattenConditions` with no `ref_name` condition Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix `flattenConditions` to work with `push` rulesets Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add more tests for `flattenConditions` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Enable debug logging in `flattenConditions` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Ensures that `flattenConditions` returns an empty list on empty API response Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add validation for `push` `rules` As they differ from `branch` and `tag` rules Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Get `TestAccGithubRepositoryRulesets` to work Signed-off-by: Timo Sand <timo.sand@f-secure.com> * `repository_ruleset`: Add tests for validations Signed-off-by: Timo Sand <timo.sand@f-secure.com> * `repository_ruleset`: Implement validations for `target`, `conditions` and `rules` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Updated ruleset docs Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Extract validation functions to separate utils file with unit tests Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix push ruleset test config Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Remove `repository` target after thorough testing that it doesn't do anything Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Use idiomatic test naming convention Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Address code structure comment in tests Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix inconsistent logging Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Refactor to use typed constant string for ruleset `Target` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix indentation issue with `github_repository_file` and heredocs Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Rename files to be more sensible Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Refactor validation functions so that Repo and Org share almost everything Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Address review comments Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Use `github.RepositoryRuleType` instead of strings Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Refactor `flattenRules` and `expandRules` to use context Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix failing validation Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Refactor to use `ValidateDiagFunc` and `validation.ToDiagFunc` in repo ruleset Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Use `strings.Join` to make `Description` of `target` dynamic Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add validation to `operator` attributes Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Add missing validations to repo ruleset attributes Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Refactor to use `ValidateDiagFunc` and `validation.ToDiagFunc` in org ruleset * Use `strings.Join` to make `Description` of `target` dynamic * Add validation to `operator` attributes * Add missing validations to org ruleset attributes * Ensure attribute names map correctly to rule names Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Don't ignore errors Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Address review comments Signed-off-by: Timo Sand <timo.sand@f-secure.com> --------- Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Resolves #2929, #2467
Before the change?
ref_namewould cause the provider to Panic asref_nameis a required fieldruleswhich weren't valid forpushrulesetsAfter the change?
pushrulesets to an organizationref_nameshould no longer be needed to be set forpushtargetconditions&targetvalidation logic should ensure correct fields are populatedPull request checklist
Schema migrations have been created if needed (example)Does this introduce a breaking change?
Please see our docs on breaking changes to help!