fix: Allow removing runner group networks - #4541
austenstone wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Add explicit removal flags for organization and enterprise runner group updates, preserving existing omission and string behavior.
9788c28 to
c4d4c88
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4541 +/- ##
==========================================
+ Coverage 98.54% 98.59% +0.04%
==========================================
Files 196 197 +1
Lines 17938 18344 +406
==========================================
+ Hits 17677 18086 +409
+ Misses 261 258 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@austenstone - just like in another recent PR, we now have a CLA problem because an agent signed a commit that was pushed to this PR. So now, you can either clean up the commits locall and force-push the changes to this PR to get rid of the bot's commits or you can close this PR and open a brand new one. Your choice, but we cannot continue this PR with the current CLA state, unfortunately. |
Keep explicit JSON null removal separate from empty-string compatibility. Document the primitive-pointer encoding contract and exercise the removal flag through organization and enterprise update requests.
b0fc528 to
6cf8993
Compare
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @austenstone.
One wording suggestion, otherwise, LGTM.
| For optional primitive fields where the zero value has API semantics, use a | ||
| pointer with `omitempty`. A nil pointer omits the field, while a pointer to the | ||
| zero value includes it, such as `false`, `0`, or `""`. | ||
|
|
||
| Neither `omitempty` nor `omitzero` makes a pointer to a zero value encode as | ||
| JSON `null`. When an update must distinguish omission, assignment, and explicit | ||
| removal using `null`, follow `UpdateTeamRequest.RemoveParentTeam`: add a Go-only | ||
| removal flag and a value-receiver `MarshalJSON` method. This supports marshaling | ||
| both request values and pointers without changing the request. |
There was a problem hiding this comment.
How about this?
| For optional primitive fields where the zero value has API semantics, use a | |
| pointer with `omitempty`. A nil pointer omits the field, while a pointer to the | |
| zero value includes it, such as `false`, `0`, or `""`. | |
| Neither `omitempty` nor `omitzero` makes a pointer to a zero value encode as | |
| JSON `null`. When an update must distinguish omission, assignment, and explicit | |
| removal using `null`, follow `UpdateTeamRequest.RemoveParentTeam`: add a Go-only | |
| removal flag and a value-receiver `MarshalJSON` method. This supports marshaling | |
| both request values and pointers without changing the request. | |
| Optional pointer fields should use `omitempty`: a nil pointer omits the field, | |
| while a pointer to a zero value such as `false`, `0`, or `""` includes it. | |
| `omitzero` behaves identically for pointers, so prefer `omitempty`. | |
| Neither tag can send JSON `null`, so an update that must distinguish omission, | |
| assignment, and removal follows `UpdateTeamRequest.RemoveParentTeam` in | |
| `github/teams.go`: a Go-only removal flag tagged `json:"-"`, plus a | |
| value-receiver `MarshalJSON` that also serves `*T` call sites. `new("")` sends | |
| an empty string, not `null`. |
Add
RemoveNetworkConfigurationto organization and enterprise runner-group update requests, followingUpdateTeamRequest.RemoveParentTeam. Setting it sends"network_configuration_id": nulland takes precedence over a supplied ID. The value-receiver marshaler supports both values and pointers without mutation. Creates and responses are unchanged.The Go 1.26.0
encoding/jsonrepro shows that*stringbehaves identically withomitemptyandomitzero: nil omits the field,new("network-id")sends a string, andnew("")sends"". Neither tag produces JSON null. Empty-string behavior is preserved for compatibility, but empty-string detachment is unverified. Both PATCH schemas allow null: organization and enterprise.Regression tests cover omission, assignment, empty-string compatibility, explicit null, flag precedence, preservation of other fields, value/pointer marshaling, request immutability, and both native PATCH bodies. The null cases fail without the marshalers. On Go 1.26.0, runner-group race tests, all-module
script/test.shrace tests,script/fmt.sh,script/generate.sh,script/lint.sh, and OpenAPI metadata validation pass. No live API writes were made for this revision.This revises the earlier
omitzeroimplementation and still needs maintainer agreement on explicit-null removal. Needed by integrations/terraform-provider-github#3274, which remains gated on a merged and released SDK fix.Copilot assisted with implementation, tests, and this description.