Skip to content

US1094711:- Add httpMethods field to L7Api PortalMeta for per-API HTTP method restriction - #100

Merged
ksaladi merged 3 commits into
develop/portalfrom
ks_http
Aug 19, 2026
Merged

US1094711:- Add httpMethods field to L7Api PortalMeta for per-API HTTP method restriction#100
ksaladi merged 3 commits into
develop/portalfrom
ks_http

Conversation

@ksaladi

@ksaladi ksaladi commented Jul 16, 2026

Copy link
Copy Markdown

What

Adds an httpMethods field to PortalMeta on the L7Api CRD so Portal API authors can
restrict which HTTP verbs a published API accepts (e.g. GET only), instead of the Gateway
unconditionally allowing all 7 verbs.

Changes

  • api/v1alpha1/l7api_types.go: new HttpMethod enum type (8 consts) + HttpMethods []HttpMethod
    on PortalMeta.
  • internal/templategen/templategen.go: mirrored HttpMethods []string on PortalAPI (required
    for the PortalMetaPortalAPI JSON round-trip in deployL7ApiToGateway).
  • internal/templategen/portal-api-restman-template.qtpl (+ regenerated .qtpl.go): <l7:Verbs>
    now emits from HttpMethods when set, falling back to the existing hardcoded 7-verb list when
    unset — fully backward compatible.
  • CRD schema regenerated in all 3 locations (config/crd/bases/, bundle/manifests/,
    charts/layer7-operator/crds/).
  • Added a test case covering the restricted-methods path in 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.
  • Verified live on a kind cluster: patched an L7Api CR with httpMethods: ["GET"], confirmed
    via the Gateway's Graphman API that methodsAllowed matched, and confirmed POST/DELETE
    are rejected with "HTTP method ... not allowed" while GET passes through to policy.

@ksaladi ksaladi changed the title US1094711:- Change to have httpMethods in L7Api US1094711:- Add httpMethods field to L7Api PortalMeta for per-API HTTP method restriction Jul 16, 2026
@ksaladi
ksaladi requested a review from jb683638 July 16, 2026 19:25
Comment thread internal/templategen/templategen.go Outdated
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"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — ran gofmt -w.

Comment thread api/v1alpha1/l7api_types.go
Comment thread api/v1alpha1/l7api_types.go
@ksaladi
ksaladi requested a review from jb683638 July 21, 2026 08:57
@ksaladi
ksaladi changed the base branch from main to develop/portal August 16, 2026 15:22

@jb683638 jb683638 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread internal/templategen/templategen_test.go
@ksaladi
ksaladi merged commit 7b58f11 into develop/portal Aug 19, 2026
@ksaladi
ksaladi deleted the ks_http branch August 19, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants