Skip to content

Empty ruleset required_deployment_environments is now valid - #1942

Merged
kfcampbell merged 4 commits into
integrations:mainfrom
o-sama:fix-1915-2
Oct 25, 2023
Merged

kfcampbell merged 4 commits into
integrations:mainfrom
o-sama:fix-1915-2

Conversation

@o-sama

@o-sama o-sama commented Oct 6, 2023

Copy link
Copy Markdown
Contributor

Resolves #1915


Before the change?

  • Adding DefaultFunc fixed the issue for existing rulesets but not new ones.

After the change?

  • Removed DefaultFunc from this field so that you can't define an empty block for required_deployments rule. If required_deployment_environments is empty then we know we'll have a nil interface, and we manually set the value to an empty slice of interfaces, otherwise we just cast the value to a slice of interfaces as usual.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No, existing rulesets with a non-empty list aren't affected since we do the same thing now as done previously, and setting an empty list in the state for new rulesets doesn't conflict with non-empty slices that are created when environments are defined.

Comment thread github/respository_rules_utils.go Resolved

@kfcampbell kfcampbell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kfcampbell
kfcampbell merged commit b86c22c into integrations:main Oct 25, 2023
avidspartan1 pushed a commit to avidspartan1/terraform-provider-github that referenced this pull request Feb 5, 2024
…ions#1942)

* Empty ruleset required_deployment_environments is now valid

* Update github/respository_rules_utils.go

---------

Co-authored-by: Keegan Campbell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: repository_ruleset crash on empty required_deployment_environments

2 participants