Skip to content

Add port metadata and placeholder support for container ports - #25

Merged
Pierre-Gilles merged 2 commits into
mainfrom
claude/sdk-adaptation-pr-2787-kvo7qu
Aug 7, 2026
Merged

Add port metadata and placeholder support for container ports#25
Pierre-Gilles merged 2 commits into
mainfrom
claude/sdk-adaptation-pr-2787-kvo7qu

Conversation

@Pierre-Gilles

Copy link
Copy Markdown
Contributor

Summary

This PR enhances the container port system to support dynamic URL generation in configuration sections through placeholder tokens. It adds metadata to published ports (protocol, label, name, browsable flag) and introduces {{gladys_host}} and {{port:<name>}} placeholder substitution in section texts.

Key Changes

  • Extended ContainerPort interface with new fields:

    • protocol: Transport protocol ('tcp' or 'udp')
    • label: Multi-language display name for the port
    • name: Optional stable identifier for referencing ports in placeholders
    • browsable: Boolean flag indicating if a web UI link should be shown
    • Changed host_port type from number to number | null to represent unassigned ports
  • Added placeholder token support in section label and description fields:

    • {{gladys_host}}: Resolves to the hostname the browser uses to reach Gladys
    • {{port:<name>}}: Resolves to the assigned host port of a named container port
    • Includes validation rules: unknown port references reject the manifest, {{port:<name>}} is forbidden in contact_schema, unassigned ports display as-is
  • Updated documentation with:

    • Detailed explanation of placeholder syntax and substitution rules
    • Example manifest showing OCPP charge point configuration
    • Rules for port naming and placeholder usage
    • Guidance on port assignment timing and reverse proxy behavior
  • Updated tests to verify:

    • Full port metadata structure including name and null host_port states
    • Proper handling of ports with and without assigned host ports
  • Updated TypeScript definitions to reflect the new ContainerPort structure and nullable host_port

Implementation Details

The changes enable integrations to dynamically display connection URLs to users without hardcoding addresses, solving the problem that servers cannot reliably determine which LAN address users reach them by. The browser-side placeholder resolution ensures accurate hostname and port information is shown in configuration screens.

https://claude.ai/code/session_01Bb3mfS9ufKovY8WxwDk9VB

…pdate)

Mirror GladysAssistant/Gladys#2787: a declared sub-container port may
carry an optional `name` ([a-z0-9_]{2,20}, unique across the whole
manifest), which makes the host port Gladys assigned to it referenceable
from the manifest section texts through the `{{port:<name>}}` placeholder
— the OCPP case: showing the user "point your charge point to
ws://{{gladys_host}}:{{port:ocpp}}", an address the server cannot build
reliably but the browser knows by construction.

- ContainerPort typings realigned on what GET /container actually
  returns: the new `name` (string | null), plus the `protocol`, `label`
  and `browsable` fields that were already sent but never typed, and
  `host_port` widened to `number | null` (no host port is assigned while
  the sub-container has never been started)
- README: a "Placeholders in section texts" subsection (both tokens, the
  manifest-rejected unknown reference, the contact_schema refusal, the
  left-as-is unresolved token and the reverse-proxy limitation), a
  "Published ports" block in Sub-containers and the getContainers() row
- tests: the sub-container fixture carries the full port shape, plus a
  case covering a named port with no assigned host port yet

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb3mfS9ufKovY8WxwDk9VB
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Pierre-Gilles, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 065d9735-55f5-4bdd-857f-557f754be853

📥 Commits

Reviewing files that changed from the base of the PR and between 4b7ea0c and 2744e68.

📒 Files selected for processing (5)
  • README.md
  • index.d.ts
  • lib/gladys-integration.js
  • test/containers.test.js
  • test/types/api.test-d.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Resolve the overlap with #24 (adaptation of GladysAssistant/Gladys#2786),
which landed on main the port fields this branch had added on its own:
keep main's version of `protocol`, `label`, `browsable` and the nullable
`host_port` (its ContainerPortProtocol union and its direct-assignment
type check are the stronger form), and keep only the delta specific to
GladysAssistant/Gladys#2787 on top — the `name` field of ContainerPort,
its JSDoc/README documentation and a dedicated test.

- index.d.ts: `name: string | null` added to main's ContainerPort
- getContainers JSDoc and the README port entry list `name`
- README: the "Placeholders in section texts" subsection stays, the
  Sub-containers block explains `name` after main's `browsable` paragraph
- tests: main's browsable/unassigned-port case kept as is, the port name
  gets its own case; the type test keeps both direct assignments

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb3mfS9ufKovY8WxwDk9VB
@Pierre-Gilles
Pierre-Gilles merged commit 6a15242 into main Aug 7, 2026
6 checks passed
@Pierre-Gilles
Pierre-Gilles deleted the claude/sdk-adaptation-pr-2787-kvo7qu branch August 7, 2026 10:05
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