US1094711:- Add httpMethods field to L7Api PortalMeta for per-API HTTP method restriction - #100
Merged
Conversation
jb683638
reviewed
Jul 21, 2026
Comment on lines
+22
to
+26
| PublishedTs int `json:"publishedTs"` | ||
| CreateTs int `json:"createTs"` | ||
| ModifyTs int `json:"modifyTs"` | ||
| SsgServiceType string `json:"ssgServiceType"` | ||
| SsgServiceType string `json:"ssgServiceType"` | ||
| HttpMethods []string `json:"httpMethods,omitempty"` |
Contributor
There was a problem hiding this comment.
[Nit] ❌ gofmt reports this block as misformatted: running gofmt -l internal/templategen/templategen.go on this branch flags this file. The struct-tag column padding on PublishedTs/CreateTs/ModifyTs/SsgServiceType doesn't match what gofmt would produce after adding the HttpMethods field.
✅ Run gofmt -w internal/templategen/templategen.go (or make lint-fix) before merge so CI's fmt check doesn't drift.
jb683638
approved these changes
Aug 18, 2026
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.
What
Adds an
httpMethodsfield toPortalMetaon theL7ApiCRD so Portal API authors canrestrict which HTTP verbs a published API accepts (e.g.
GETonly), instead of the Gatewayunconditionally allowing all 7 verbs.
Changes
api/v1alpha1/l7api_types.go: newHttpMethodenum type (8 consts) +HttpMethods []HttpMethodon
PortalMeta.internal/templategen/templategen.go: mirroredHttpMethods []stringonPortalAPI(requiredfor the
PortalMeta→PortalAPIJSON round-trip indeployL7ApiToGateway).internal/templategen/portal-api-restman-template.qtpl(+ regenerated.qtpl.go):<l7:Verbs>now emits from
HttpMethodswhen set, falling back to the existing hardcoded 7-verb list whenunset — fully backward compatible.
config/crd/bases/,bundle/manifests/,charts/layer7-operator/crds/).templategen_test.go.Enforcement itself is native to the Gateway via Graphman's
WebApiServiceInput.MethodsAllowed—no new assertion logic.
Testing
go build,go vet,go test ./internal/templategen/...— all pass.L7ApiCR withhttpMethods: ["GET"], confirmedvia the Gateway's Graphman API that
methodsAllowedmatched, and confirmedPOST/DELETEare rejected with
"HTTP method ... not allowed"whileGETpasses through to policy.