From f365a572d66a61970c3650d49e341e4135760c9c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 21:14:33 +0000 Subject: [PATCH 1/2] Initial plan From 05b93093b96680f36d44f9f664e05efe4d5aa45f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 21:28:01 +0000 Subject: [PATCH 2/2] Fix misleading error message in cert generation when actual errors occur Co-authored-by: lionello <591860+lionello@users.noreply.github.com> --- src/pkg/cli/cert.go | 12 +++++++++- src/pkg/cli/cert_test.go | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/pkg/cli/cert.go b/src/pkg/cli/cert.go index b21848582..31bba6417 100644 --- a/src/pkg/cli/cert.go +++ b/src/pkg/cli/cert.go @@ -84,6 +84,15 @@ func GenerateLetsEncryptCert(ctx context.Context, project *compose.Project, clie return err } + // First, check if there are any domain names in the compose file at all + hasDomains := false + for _, service := range project.Services { + if service.DomainName != "" { + hasDomains = true + break + } + } + cnt := 0 for _, serviceInfo := range services.Services { if service, ok := project.Services[serviceInfo.Service.Name]; ok && service.DomainName != "" && serviceInfo.ZoneId == "" { @@ -99,7 +108,8 @@ func GenerateLetsEncryptCert(ctx context.Context, project *compose.Project, clie } } } - if cnt == 0 { + // Only show the "no domainname found" message if there truly are no domains in the compose file + if cnt == 0 && !hasDomains { term.Infof("No `domainname` found in compose file; no HTTPS cert generation needed") } diff --git a/src/pkg/cli/cert_test.go b/src/pkg/cli/cert_test.go index be22564b6..8ab049c71 100644 --- a/src/pkg/cli/cert_test.go +++ b/src/pkg/cli/cert_test.go @@ -311,3 +311,51 @@ func TestGetDomainTargets(t *testing.T) { }) } } + +// Test helper function to check if domains exist in compose project +func TestHasDomains(t *testing.T) { + tests := []struct { + name string + services map[string]compose.ServiceConfig + expected bool + }{ + { + name: "no services", + services: map[string]compose.ServiceConfig{}, + expected: false, + }, + { + name: "services without domains", + services: map[string]compose.ServiceConfig{ + "web": {Name: "web", DomainName: ""}, + "api": {Name: "api", DomainName: ""}, + }, + expected: false, + }, + { + name: "services with domains", + services: map[string]compose.ServiceConfig{ + "web": {Name: "web", DomainName: "example.com"}, + "api": {Name: "api", DomainName: ""}, + }, + expected: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Simulate the logic from GenerateLetsEncryptCert + hasDomains := false + for _, service := range tt.services { + if service.DomainName != "" { + hasDomains = true + break + } + } + + if hasDomains != tt.expected { + t.Errorf("expected hasDomains=%v, got %v", tt.expected, hasDomains) + } + }) + } +}