Conversation
| 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"` |
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.
| CreateTs int `json:"createTs,omitempty"` | ||
| ModifyTs int `json:"modifyTs,omitempty"` | ||
| SsgServiceType string `json:"ssgServiceType,omitempty"` | ||
| HttpMethods []HttpMethod `json:"httpMethods,omitempty"` |
There was a problem hiding this comment.
[Suggestion] ❌ No +kubebuilder:validation:Enum marker on HttpMethods []HttpMethod, even though HttpMethod is defined as a closed enum type below with 8 named consts. As generated, the CRD schema only enforces type: array of type: string (see httpMethods: in config/crd/bases/security.brcmlabs.com_l7apis.yaml) — any string value passes admission and flows straight into the Graphman bundle's <l7:Verb> elements via the qtpl template.
✅ Consider adding // +kubebuilder:validation:Enum=GET;POST;PUT;PATCH;DELETE;HEAD;OPTIONS;OTHER above the field so the API server rejects typos/invalid verbs at admission time rather than letting them reach the Gateway.
(Noting the rest of this file doesn't use Enum markers elsewhere, so this is a suggestion rather than a blocking pattern violation.)
There was a problem hiding this comment.
Intentional — mirrors StateStoreType/RedisType in l7statestore_types.go, which also has no enum marker.
| HttpMethodDelete HttpMethod = "DELETE" | ||
| HttpMethodHead HttpMethod = "HEAD" | ||
| HttpMethodOptions HttpMethod = "OPTIONS" | ||
| HttpMethodOther HttpMethod = "OTHER" |
There was a problem hiding this comment.
[Question] ❓ HttpMethodOther = "OTHER" isn't a real HTTP verb. If a caller sets httpMethods: ["OTHER"], the template will render <l7:Verb>OTHER</l7:Verb> into the Graphman bundle for the l7:HttpMapping. What's the intended use case for this constant? If it's meant as a catch-all for arbitrary/custom verbs, is <l7:Verb>OTHER</l7:Verb> actually meaningful to the Gateway/Graphman schema, or should it be dropped until there's a concrete use for it?
There was a problem hiding this comment.
OTHER is a Gateway-native value (see the HttpMethod enum's doc comment in generated-modified.go), not invented here — Portal is just mirroring what the Gateway already exposes.
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.