Repository navigation
refactor(team): extract pkg/team store from cmd (#326b) - #342
Merged
Merged
Conversation
Second store-layer extraction (#326). cmd/team.go talked to DynamoDB directly across all six subcommands with item structs + a teamDDBClient helper in cmd/. Added pkg/team (Client mirrors pkg/alerts.Client) holding TeamRecord/MemberRecord and the CRUD/query methods (PutTeam/GetTeam/ DeleteTeam, Inc/DecrementMemberCount with the >0 guard, PutMembership/ DeleteMembership/GetMembership, ListTeamsForMember (GSI)/ListMembers). Rewired all handlers; STS caller-ARN derivation stays in cmd (passed into methods). resolveTeamMembership → requireMembership over the store. Wire format preserved: the dynamodbav tags moved verbatim (a diff vs the old cmd structs confirms them byte-identical — the dashboard-api Lambda, a separate module, shares this format). Table names unchanged (spawn-teams / spawn-team-memberships). Verified: go build ./..., go vet, gofmt clean; new pkg/team substrate tests pass (create/list/show flow, add/remove + member_count, GSI lookup); tag-equivalence check; cmd tests green; command tree byte-identical vs main.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #326 (store-layer extraction, audit #328). Second of 4 domain PRs. No behavior change; wire format preserved and asserted.
What changed
cmd/team.gotalked to DynamoDB directly across all six subcommands (create/list/show/add/remove/delete), withteamRecord/memberRecordstructs and ateamDDBClienthelper incmd/. Addedpkg/team(Clientmirroringpkg/alerts.Client,NewClient/NewClientWithTableNames) holdingTeamRecord/MemberRecordand the domain methods:PutTeam,GetTeam,DeleteTeam,IncrementMemberCount,DecrementMemberCount(keeps themember_count > 0guard).PutMembership,DeleteMembership,GetMembership,ListTeamsForMember(via themember_arn-indexGSI),ListMembers.STS caller-ARN derivation stays in
cmd/(passed into the store methods, not baked into the store).resolveTeamMembershipbecame a thinrequireMembershipoverGetMembership.Wire format preserved
The
dynamodbavtags moved verbatim — a diff against the oldcmd/team.gostructs onmainconfirms them byte-identical. Thedashboard-apiLambda (separate module) shares this item format, so nothing on the wire changed. Table names unchanged (spawn-teams/spawn-team-memberships).Verification
go build ./...,go vet ./cmd ./pkg/team,gofmtclean.pkg/team/team_substrate_test.gopasses against the Substrate emulator: create→list→show flow (GetTeam round-trip + missing→nil, GetMembership present/absent, GSIListTeamsForMember), and add/remove withmember_countinc/dec + delete.go test ./cmdgreen (excl. pre-existingTestCatalogValid/ feat(plugin): permissions declaration block (#388) #392).bin/spawn; recursive command+flag tree byte-identical vsmain.Next: sweep store + collect account-fix (#326c), then pkg/bot (#326d).