-
Notifications
You must be signed in to change notification settings - Fork 769
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
Bugfix: Make security_and_analysis settings optional #1489
Bugfix: Make security_and_analysis settings optional #1489
Conversation
for public repositories - default to - not setting advanced_security - as it is enabled by default and uneditable - disabling - secret scanning and - secret scanning push protection.
…sh_protection properties optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious about the reason for requiring interfaces rather than a concrete type, but this makes great updates to our repository resource and its tests, which are passing after this PR! Thank you for the contribution.
|
||
return &github.Repository{SecurityAndAnalysis: update} | ||
return []interface{}{securityAndAnalysisMap} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason this can't be a concrete type here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A concrete type could be introduced so that there is one, but the flattenSecurityAndAnalysis
function return type previously was []interface{}
, so I kept it the same when I was refactoring it / making the properties optional.
I also removed the expandSecurityAndAnalysis
function. The diff is lining the changes with flattenSecurityAndAnalysis
up with the expandSecurityAndAnalysis
removal.
@@ -0,0 +1,18 @@ | |||
# Repository Visibility Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming that executing the examples succeeds as planned.
* make advanced security property optional, defaulting to disabled for public repositories - default to - not setting advanced_security - as it is enabled by default and uneditable - disabling - secret scanning and - secret scanning push protection. * add example repository security and analysis * make security_and_analysis secret_scanning and secret_scanning_and_push_protection properties optional Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Resolves #1419
Resolves #1466
Behavior
Before the change?
The
security_and_analysis
settings were all required.This resulted in failures for public repos where it is not possible to change the Advanced Settings (see #1419)
Additional testing revealed that the
advanced_security
cannot always be set for private/internal repositories and thatsecret_scanning
andsecret_scanning_push_protection
settings also can only be set in certain scenarios (e.g. Advanced Security must be available (purchased) for organizations/private repos)Additionally, before this change updating the provider attempted to remove the
security_and_analysis
settings if it was not configured in the terraform config (see #1466)After the change?
After the change, the
security_and_analysis
settings are all optional. In addition, they have been changed tocomputed
properties and they are set with the initial repo creation request, not edited after it has been created. If thesecurity_and_analysis
settings are not supplied in the terraform config they are not sent along to GitHub (whereas previously they were all set todisabled
).The intent is to let the GitHub API tell us when we can and can't do stuff, instead of trying to re-encode that within the provider. So this change would allow someone to create a terraform config that will pass validate/plan, but will fail to apply (which is already the case before this change, but now there are a few additional ways to do so). I think this is okay though since the fix is simply to set the
security_and_analysis
sub properties appropriately based on the error messages the GitHub API returns. Before this change, that is not always possible - the module is completely broken for public repos.Pull request checklist
Does this introduce a breaking change?
Type: Breaking change
label)