Skip to content

Commit 2e8033c

Browse files
committed
Add stack even when the project name is the same as the tenant name
1 parent eb50eca commit 2e8033c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/pkg/cli/client/byoc/baseclient.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ func (b *ByocBaseClient) GetProjectDomain(projectName, zone string) string {
121121
return "" // no project name => no custom domain
122122
}
123123
projectLabel := DnsSafeLabel(projectName)
124+
var domain string
124125
if projectLabel == DnsSafeLabel(b.TenantName) {
125-
return DnsSafe(zone) // the zone will already have the tenant ID
126+
domain = DnsSafe(zone) // the zone will already have the tenant ID
127+
} else {
128+
domain = projectLabel + "." + DnsSafe(zone)
126129
}
127-
domain := projectLabel + "." + DnsSafe(zone)
128130
if hasStack, ok := b.projectBackend.(HasStackSupport); ok {
129-
domain = hasStack.GetStackName() + "." + domain // TODO: Should we dns-safe the stack name too?
131+
domain = DnsSafeLabel(hasStack.GetStackName()) + "." + domain
130132
}
131133
return domain
132134
}

src/pkg/cli/client/byoc/baseclient_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,10 @@ func TestGetProjectDomain(t *testing.T) {
198198
{"test-project", "test-zone", "test-tenant", TestProjectBackendWithoutStack{}, "test-project.test-zone"},
199199
{"test-project", "test-zone", "test-tenant", TestProjectBackendWithStack{stack: "test-stack"}, "test-stack.test-project.test-zone"},
200200
{"project-is-tenant-name", "test-zone", "project-is-tenant-name", TestProjectBackendWithoutStack{}, "test-zone"},
201-
{"project-is-tenant-name", "test-zone", "project-is-tenant-name", TestProjectBackendWithStack{stack: "test-stack"}, "test-zone"}, // Stack is ignored when project name is the same as tenant -- Is that correct?
201+
{"project-is-tenant-name", "test-zone", "project-is-tenant-name", TestProjectBackendWithStack{stack: "test-stack"}, "test-stack.test-zone"}, // Stack is ignored when project name is the same as tenant -- Is that correct?
202202
{"Test.Project", "tesT.zonE", "test-tenant", TestProjectBackendWithoutStack{}, "test-project.test.zone"},
203203
{"Test.Project", "tesT.zonE", "test-tenant", TestProjectBackendWithStack{stack: "test-stack"}, "test-stack.test-project.test.zone"},
204+
{"test-project", "test-zone", "test-tenant", TestProjectBackendWithStack{stack: "tEst.sTack"}, "test-stack.test-project.test-zone"},
204205
}
205206

206207
for _, tt := range tests {

0 commit comments

Comments
 (0)