validate-org: do not enforce protected owners before the org is onboarded - #71
validate-org: do not enforce protected owners before the org is onboarded#71dev-milos wants to merge 1 commit into
Conversation
…rded With protected owners configured and no organisation config in the repository yet, every pull request was rejected for removing owners that were never there. Treating an absent members.yaml as an empty member list is right for an organisation already under management, where an empty list plans a member wipe. Before adoption it is not: with no organisation config anywhere, Terraform creates no membership resources, so there is no state a plan could remove. runValidateOrg already computed and printed the distinguishing condition without acting on it. Enforcement is now skipped only when teams.yaml and members.yaml are both absent from the promoted and the staged location, and the run says so. It resumes as soon as either file exists, including staged bootstrap output, so the import that first takes ownership of the organisation is still checked.
|
Closing unmerged — the exemption reopens the hole the guard exists to close. The predicate that would make it safe is "Terraform state contains no Verified against this branch:
The reasoning in the description — "Terraform creates no membership resources from that The original complaint stands but is not worth weakening a permanent control for: the |
Closes G-Research/gr-oss#1428
With
protected_ownersconfigured and no organisation config in the repository yet,validate-orgrejects every pull request:Nothing is being removed — the organisation has never been onboarded.
Why it blocks adoption
The guard is meant to be set before the bootstrap import, so that the import pull request
itself is checked. The bootstrap pull request does pass, because its staged
members.yamllists the protected owners. But between setting the variable and merging that import,
every unrelated pull request is rejected — repository config changes have nothing to do
with organisation membership, yet they cannot get past the gate.
Cause
Treating an absent
members.yamlas an empty member list is right for an organisationalready under management, where an empty list plans a member wipe. Before adoption it is
not: with no organisation config anywhere, Terraform creates no
github_membershipresources, so there is no state a plan could remove.
runValidateOrgalready computed and printed the distinguishing condition without actingon it.
Change
teams.yamlandmembers.yamlboth absentmembers.yamlabsent,teams.yamlpresentmembers.yamlpresent, owner omittedEnforcement resumes as soon as either file exists, including staged bootstrap output, so
the highest-stakes plan is still checked. The command's help text stated the rule without
this exception and has been updated.
Tests
Two added, and the existing coverage is what proves the guard was not weakened:
UnmanagedOrgDoesNotEnforceProtectedOwners— no config, owners set, passes with a warningStagedBootstrapEnforcesProtectedOwners— staged output omitting an owner is still rejectedDeletedMembersFileStillEnforcesProtectedOwnersandEmptyMembersListEnforcesProtectedOwnerscontinue to pass unchanged
Verification
go build,go vet,go test ./...passafter; adding a
teams.yamlmakes it fail again, as intended