[FEAT] Add new resource for repository vulnerability alerts#3166
[FEAT] Add new resource for repository vulnerability alerts#3166deiga wants to merge 15 commits intointegrations:mainfrom
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
fb54b9b to
5b5d40c
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
This is looking good.
5b5d40c to
8ba3a26
Compare
8ba3a26 to
7ea9d1a
Compare
|
@deiga could you please rebase? |
7ea9d1a to
9791700
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
This looks good, just two minor nits which I think are worth fixing for readability and because I think this resource will be one we can use as an example for people contributing.
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>
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>
9791700 to
4f3c392
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
This PR looks great, I just have a concern about string matching on an error message (we know errors aren't consistent across GHAS), especially one that isn't explicit about the cause. If we think it's valuable to provide a custom error message, which I'm personally not sure about, then we ought to use the API to get a definitive answer.
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
| if err != nil { | ||
| return diag.Errorf("error reading repository vulnerability alerts: %s", err.Error()) | ||
| } |
There was a problem hiding this comment.
If the repository is deleted outside Terraform, GetVulnerabilityAlerts will return a 404. The Read function does not check for this and will return an error instead of calling d.SetId("") to remove the resource from state. This breaks terraform plan and terraform apply when the backing repository no longer exists.
| if err != nil { | |
| return diag.Errorf("error reading repository vulnerability alerts: %s", err.Error()) | |
| } | |
| if err != nil { | |
| if resp != nil && resp.StatusCode == http.StatusNotFound { | |
| tflog.Warn(ctx, "Repository not found, removing from state", map[string]any{"repository": repoName}) | |
| d.SetId("") | |
| return nil | |
| } | |
| return diag.Errorf("error reading repository vulnerability alerts: %s", err.Error()) | |
| } |
Resolves #3038
Before the change?
github_repositoryresource.After the change?
vulnerability_alertsin thegithub_repositoryresource are marked as deprecatedPull 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!