feat(templates): support importing blueprint/templates with domain initially inactive (#5390) - #5445
fliptrigga13 wants to merge 1 commit into
Conversation
| enabled: | ||
| domain.enabled !== undefined | ||
| ? Boolean(domain.enabled) | ||
| : domain.active !== undefined | ||
| ? Boolean(domain.active) | ||
| : true, |
There was a problem hiding this comment.
When an imported TOML or JSON blueprint contains a quoted boolean such as enabled = "false" or active = "false", no runtime validation rejects or normalizes the string. Because Boolean("false") evaluates to true, the domain is persisted as enabled and included in generated Traefik routing, exposing a service that the template author intended to keep inactive.
| function processDomains( | ||
| template: CompleteTemplate, | ||
| variables: Record<string, string>, | ||
| ): Array<DomainConfig & { enabled: boolean; host: string }> { | ||
| if ( | ||
| !template?.config?.domains || | ||
| template.config.domains.length === 0 || | ||
| template.config.domains.every((domain) => !domain.serviceName) | ||
| ) { | ||
| return []; | ||
| } | ||
|
|
||
| return template.config.domains.map((domain: DomainConfig) => ({ | ||
| ...domain, | ||
| enabled: | ||
| domain.enabled !== undefined | ||
| ? Boolean(domain.enabled) | ||
| : domain.active !== undefined | ||
| ? Boolean(domain.active) | ||
| : true, | ||
| host: domain.host || "test.example.com", | ||
| })); | ||
| } |
There was a problem hiding this comment.
These tests exercise a local copy of processDomains instead of the exported production implementation. They will continue passing if the real enabled/active precedence or defaulting logic regresses, leaving this feature without effective regression coverage. Import and test the production processor, as the neighboring template tests already do.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Fixes #5390
Problem
When importing blueprints and templates (e.g. Elasticsearch + Kibana stacks), some companion services are internal-only or optional (such as the raw Elasticsearch REST API port) while others are user-facing (like the Kibana web dashboard). Maintainers and users wanted to pre-configure domain routing for these services in the template without immediately exposing them to the internet until explicitly activated by the administrator.
While PR #4697 introduced domain enabling/disabling capabilities for existing domains, blueprint and template importing had no mechanism to mark domains initially inactive.
Solution
DomainConfiginpackages/server/src/templates/processors.tswith optionalactive?: booleanandenabled?: booleanfields.processDomainsto propagate the initial enabled state (defaulting totrueif neither is specified, but respectingfalsewhen eitheractive = falseorenabled = falseis defined).enabled: truetoapiCreateDomaininpackages/server/src/db/schema/domain.ts, allowing domains created during template deployment and project cloning to preserve their configured status.apps/dokploy/__test__/templates/template-inactive-domain.test.tscovering active/inactive configurations and precedence rules (4/4 tests passing).The PR is not yet safe to merge because a realistically quoted false value can enable and externally route a domain intended to remain inactive.
Summary
activeandenabledsupport to template domain processing.Reviews (1) · Last reviewed commit: "feat(templates): support importing bluep..."