feat(tmpl): {{domain_name}} placeholder — materialize on diff/apply, parameterize on snapshot

Adds internal/tmpl with Materialize (template placeholder -> zone name) and
Parameterize (zone name -> placeholder, the inverse used by the
template-from-zone snapshot). service.resolve now materializes the template
against DomainRef.ZoneName before diffing, so one template can be reused
across domains. LoadDomainFull (source query + hand-edited sqlc output, since
sqlc is not installed) now also selects zone_name to populate it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BwxdSt4reTm7Dj1oxRvpP3
This commit is contained in:
2026-07-05 13:41:18 +07:00
parent 135917216c
commit df895d8850
9 changed files with 158 additions and 11 deletions
+3 -1
View File
@@ -184,7 +184,7 @@ func (q *Queries) ListDomains(ctx context.Context, projectID uuid.UUID) ([]Domai
}
const loadDomainFull = `-- name: LoadDomainFull :one
SELECT d.zone_id, a.provider, a.secret_enc, t.doc
SELECT d.zone_id, d.zone_name, a.provider, a.secret_enc, t.doc
FROM domains d
JOIN provider_accounts a ON a.id = d.provider_account_id
LEFT JOIN templates t ON t.id = d.template_id
@@ -198,6 +198,7 @@ type LoadDomainFullParams struct {
type LoadDomainFullRow struct {
ZoneID string `json:"zone_id"`
ZoneName string `json:"zone_name"`
Provider string `json:"provider"`
SecretEnc string `json:"secret_enc"`
Doc *dto.TemplateDoc `json:"doc"`
@@ -208,6 +209,7 @@ func (q *Queries) LoadDomainFull(ctx context.Context, arg LoadDomainFullParams)
var i LoadDomainFullRow
err := row.Scan(
&i.ZoneID,
&i.ZoneName,
&i.Provider,
&i.SecretEnc,
&i.Doc,
+1
View File
@@ -27,6 +27,7 @@ func (s *Store) LoadDomain(ctx context.Context, projectID, domainID uuid.UUID) (
}
return service.DomainRef{
ZoneID: row.ZoneID,
ZoneName: row.ZoneName,
Provider: row.Provider,
SecretEnc: row.SecretEnc,
Template: *row.Doc,
+1 -1
View File
@@ -23,7 +23,7 @@ SELECT * FROM domains WHERE project_id = $1 ORDER BY created_at;
DELETE FROM domains WHERE id = $1 AND project_id = $2;
-- name: LoadDomainFull :one
SELECT d.zone_id, a.provider, a.secret_enc, t.doc
SELECT d.zone_id, d.zone_name, a.provider, a.secret_enc, t.doc
FROM domains d
JOIN provider_accounts a ON a.id = d.provider_account_id
LEFT JOIN templates t ON t.id = d.template_id