Repository navigation
Open
Description
Summary
Add ALB_NAME to the placeholder tokens that docs-vars.js marks for a signed-in reader. Hovering ALB_NAME shows the ALBs in the reader's current project, so they can copy a name or the whole code block filled in, as they already can with your-project-id.
Depends on datum-cloud/cloud-portal#1787 (merged, closes cloud-portal#1786). Instead of adding project.albs to session-status, which holds the navbar loader on every page, the portal now has a separate route:
GET /api/website/projects/:projectId/albs
→ 200 { "items": [{ "name": "...", "displayName": "..." }], "truncated": true }
- Same website group as
session-status: exact-origin CORS with credentials, rate limiter, session cookie. - One metadata-only LIST with the reader's own token, capped at 500 items.
truncated: trueis set only when the cap was hit. displayNamecomes from theapp.kubernetes.io/nameannotation (the portal's "chosen name") and is omitted when unset.- Cached 60 seconds per user, project, and type, so a new ALB can take up to a minute to show.
- Errors: 401 signed out, 403 foreign or missing project, 400 invalid project id, 404 unknown type, 429 rate limited, 502 anything else.
Why
ALB_NAME is one of the most used placeholders in the docs, and the only common one readers still swap by hand:
| Page | Uses |
|---|---|
alb/observability.mdx |
7 (datumctl alb describe, MetricsQL gateway_name="ALB_NAME") |
alb/operations/overview.mdx |
6 |
alb/authentication/basic-auth.mdx |
5 |
connectors/observability.mdx |
3 |
alb/authentication/overview.mdx |
2 |
domain-dns/point-to-alb.mdx |
1 |
The MetricsQL queries already fill PROJECT_ID. Without ALB_NAME the copied query still won't run.
Changes
docs-vars.js
- Add
ALB_NAMEtoTOKEN_PATTERNand to thefill()pre-check (it skips any<code>withoutyour-,PROJECT_ID, orALB_NAME). - After
window.datumSessionStatusresolves with a validproject.name, fetch/api/website/projects/{project}/albswithcredentials: 'include'and a timeout. Mark the other tokens first. The ALB fetch must not delay them. - Keep only entries whose
namematchesNAME_PATTERN. Treat any non-2xx, network error, or bad body as "no ALBs". - Add a
TIP_COPY['ALB_NAME']entry ("Your load balancer") with a link to the project's load balancer list in the portal (/project/{project}/alb). - Hover card:
- One ALB: works like
your-project-id. Shows the value, with Copy value and Copy code with my values. - Several ALBs: lists them (name, plus
displayNamewhen set). Nothing is selected by default. The reader picks one, and the pick applies to everyALB_NAMEon the page. Both copy buttons stay disabled until they pick. This matters on pages likedatumctl alb delete ALB_NAME --yes, where a wrong default does real damage. truncated: say the list shows the first 500 and link to the full list in the portal.- No ALBs, request failed, or no project:
ALB_NAMEisn't marked, as today.
- One ALB: works like
- Today
valuesmaps each token to one string.ALB_NAMEneeds a list and a selection, sofilledCode()and the copy buttons need to handle that. "Copy code with my values" from another token's card leaves an unpickedALB_NAMEas written.
Content
alb/operations/overview.mdxusesALB_NAMEindatumctl alb create ALB_NAME ...and in the--display-namerow ("If you omitALB_NAME…"). There it's a new name, so filling it with an existing ALB is wrong. Rename those toNEW_ALB_NAME. The token regex won't match it.- Check the other uses for the same case.
README.md (Placeholders)
- Add a row:
ALB_NAME→ one of the reader's ALBs in the current project, chosen on hover when there are several. Use it for an existing load balancer (datumctl alb describe|logs|delete|auth,gateway_name=in metrics). - Update the rule that lists
ALB_NAMEas never replaced. AddNEW_ALB_NAMEfor creating one.
Resolved questions
- Is
gateway_namethe same as the ALB'sHTTPProxyname? Yes. The portal's own metrics querygateway_namewith the proxy name (app/features/edge/proxy/metrics/queries.tsin cloud-portal), so the MetricsQL blocks can useALB_NAME. - Is the list capped? Yes, at 500, with
truncated: truewhen hit.
Acceptance criteria
- With one ALB in the current project, hovering
ALB_NAMEshows it, and both copy buttons fill it in - With several ALBs, the reader must pick one before either copy button works. The pick applies to every
ALB_NAMEon the page - With no ALBs, a failed ALB request, or signed out,
ALB_NAMEstays a plain placeholder with no errors in the console - The other tokens are marked without waiting for the ALB request
-
NEW_ALB_NAMEin the create section is never marked - README Placeholders section updated
- Tested on
website.staging.env.datum.netagainst a staging portal that includes cloud-portal#1787
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity