Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow full profile updates through the PATCH handler (#2990)
* Allow full profile updates through the PATCH handler We used to use a bespoke PATCH handler to update profiles but the PATCH method only allowed changing alert and remediate. We can make the code simpler and allow more updates by modifying the existing profile using the UpdateMask and then just relaying the update to the existing UpdateProfile method of the Profile service. Examples: Adding a rule to a profile: ``` curl -XPATCH -H "Authorization: Bearer $MINDER_BEARER_TOKEN" 'http://localhost:8080/api/v1/profile/ce746798-c30c-46f3-8a12-0654747b49ec?context.project=1900c9f6-ef0f-43e4-8af7-108beb72de0e&context.provider=github' -d '{"name":"dependabot-enabled-profile", "labels":[], "buildEnvironment":[], "repository":[{"type":"dependabot_configured","params":null,"def":{"apply_if_file":"requirements.txt","package_ecosystem":"pypi","schedule_interval":"weekly"},"name":"dependabot_configured"},{"type":"dependabot_configured","params":null,"def":{"apply_if_file":"go.mod","package_ecosystem":"gomod","schedule_interval":"weekly"},"name":"dependabot_configured_go"}], "pullRequest":[], "remediate ":"on", "alert":"off", "type":"", "version":"", "displayName":"gah" } ``` Remove the rule back: ``` curl -XPATCH -H "Authorization: Bearer $MINDER_BEARER_TOKEN" 'http://localhost:8080/api/v1/profile/ce746798-c30c-46f3-8a12-0654747b49ec?context.project=1900c9f6-ef0f-43e4-8af7-108beb72de0e&context.provider=github' -d '{"name":"dependabot-enabled-profile", "labels":[], "buildEnvironment":[], "repository":[{"type":"dependabot_configured","params":null,"def":{"apply_if_file":"requirements.txt","package_ecosystem":"pypi","schedule_interval":"weekly"},"name":"dependabot_configured"}], "pullRequest":[], "remediate":"on", "alert":"off", "type":"", "version":"", "displayName":"gah"}}' ``` Fixes: #2971 * Drop the subscriptionID * Move code that doesn't change in a for loop out of that for loop * Rename variable to better signal its intent * Reword a confusing comment
- Loading branch information