Skip to content

Display the interpolated domain for DNS setup from service info#2139

Merged
lionello merged 1 commit into
mainfrom
edw/cert-gen-use-service-info
Jun 4, 2026
Merged

Display the interpolated domain for DNS setup from service info#2139
lionello merged 1 commit into
mainfrom
edw/cert-gen-use-service-info

Conversation

@edwardrf

@edwardrf edwardrf commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

Right now the DNS instruction displays the raw value of domainname from compose file, which main contain uninterpreted variables, making the instruction invalid, we should display the actual domain name returned from serviceinfo.

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed certificate generation to prioritize the deployed service's domain name when it differs from the configuration file's domain name.
    • Certificate generation now gracefully skips services without a deployed domain name and logs a warning.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Certificate generation now prefers deployed service domain names over compose file definitions. When a deployed service lacks a domain, cert generation is skipped with a warning. Subsequent domain expansion and certificate issuance use this corrected domain base.

Changes

Domain Selection in Cert Generation

Layer / File(s) Summary
Domain selection and empty domain guard
src/pkg/cli/cert.go
Domain selection logic shifts from the compose file's service.DomainName to the deployed serviceInfo.Domainname. An explicit guard now skips cert generation and logs a warning when the deployed domain is empty, preventing fallback to the compose definition.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A domain name, so precious and true,
From services deployed, not the compose view,
When empty it lingers, we skip and we warn,
For certificates flourish where domains are born! 🔐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Display the interpolated domain for DNS setup from service info' directly matches the PR's core objective of displaying the actual interpolated domain name instead of the raw compose value.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch edw/cert-gen-use-service-info

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=warning msg="The linter 'gomodguard' is deprecated (since v2.12.0) due to: new major version. Replaced by gomodguard_v2."
level=warning msg="Suggested new configuration:\nlinters:\n enable:\n - gomodguard_v2\n"
level=warning msg="[linters_context] running gomodguard failed: unable to read module file go.mod: current working directory must have a go.mod file: if you are not using go modules it is suggested to disable this linter"
level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/pkg/cli/cert.go (1)

116-119: 💤 Low value

Consider clarifying the warning message wording.

The message "domainname is deployed without a domainname" is slightly redundant. Consider simplifying to make the intent clearer.

📝 Suggested rewording
-			term.Warnf("service %q: `domainname` is deployed without a domainname, skipping cert generation", service.Name)
+			term.Warnf("service %q: deployed without a domainname, skipping cert generation", service.Name)

or alternatively:

-			term.Warnf("service %q: `domainname` is deployed without a domainname, skipping cert generation", service.Name)
+			term.Warnf("service %q: no domainname in deployed service, skipping cert generation", service.Name)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pkg/cli/cert.go` around lines 116 - 119, The warning message in the loop
that checks serviceInfo.Domainname (where serviceInfo.Domainname == "" and
service.Name is used) is redundant and should be reworded; update the term.Warnf
call to a clearer message such as "service %q: no domainname set, skipping
certificate generation" or "service %q: domain not configured, skipping cert
generation" so it references service.Name and clearly explains why certificate
generation is skipped.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/pkg/cli/cert.go`:
- Around line 116-119: The warning message in the loop that checks
serviceInfo.Domainname (where serviceInfo.Domainname == "" and service.Name is
used) is redundant and should be reworded; update the term.Warnf call to a
clearer message such as "service %q: no domainname set, skipping certificate
generation" or "service %q: domain not configured, skipping cert generation" so
it references service.Name and clearly explains why certificate generation is
skipped.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e586a68c-6817-4149-a9c6-685b7c708c93

📥 Commits

Reviewing files that changed from the base of the PR and between 1b17e3c and cb06b44.

📒 Files selected for processing (1)
  • src/pkg/cli/cert.go

@jordanstephens jordanstephens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

makes sense to me

@lionello lionello merged commit 1260feb into main Jun 4, 2026
22 of 24 checks passed
@lionello lionello deleted the edw/cert-gen-use-service-info branch June 4, 2026 17:11
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.

4 participants