feat: type all policy action constants by service#246
Conversation
Give every policy action constant its proper service type (Action, AdminAction, STSAction, KMSAction, TableAction, VectorsAction, MemoryAction) instead of an untyped string. This lets generic helpers constrained by ActionType accept any typed action via inference (an untyped string constant would otherwise infer as `string`, which the union rejects). Where the base Action-keyed engine aggregates heterogeneous actions — the predefined policies in constants.go, implicitActions, and the per-service condition-key maps — the typed constants are converted explicitly with Action(...). No behavior change; go build, go vet, and go test ./policy/... pass.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughChangesThe policy package now explicitly types exported action constants and consistently converts specialized actions to Policy action typing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Gives every policy action constant its proper service type —
Action,AdminAction,STSAction,KMSAction,TableAction,VectorsAction,MemoryAction— instead of an untyped string constant.Why
ActionType(#245) lets generic helpers accept any typed action. But anuntyped string constant passed to
func[T ActionType]infersT = string,which the union rejects:
Typing the constants makes them satisfy the union via inference, so consumers
(MinIO AIStor) can make request-auth helpers like
checkRequestAuthTypegenericover
ActionTypeand pass typed constants directly — no per-callAction(...).Changes
Action-keyed engine aggregates heterogeneous actions —predefined policies (
constants.go),implicitActions, and the per-servicecondition-key maps — the typed constants are converted explicitly with
Action(...). This is the one place the design intentionally unifies on thebase type; the conversions are explicit and local.
No behavior change.
go build ./...,go vet ./..., andgo test ./policy/...pass.
Note
Consumers that used these constants where a bare
stringis required will needan explicit
string(...)/Action(...)conversion — hence a minor version bump.Summary by CodeRabbit
Refactor
Tests