CloudMigrations: Avoid building GMS base path when provided (#93793)

Avoid building GMS base path when provided
This commit is contained in:
Roberto Jiménez Sánchez 2024-09-27 09:22:38 +02:00 committed by GitHub
parent 7928245eb6
commit 826245f511
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -297,7 +297,7 @@ func (c *gmsClientImpl) ReportEvent(ctx context.Context, session cloudmigration.
func (c *gmsClientImpl) buildBasePath(clusterSlug string) string {
domain := c.cfg.CloudMigration.GMSDomain
if strings.HasPrefix(domain, "http://localhost") {
if strings.HasPrefix(domain, "http://") || strings.HasPrefix(domain, "https://") {
return domain
}
return fmt.Sprintf("https://cms-%s.%s/cloud-migrations", clusterSlug, domain)

View File

@ -35,13 +35,19 @@ func Test_buildBasePath(t *testing.T) {
expected string
}{
{
description: "domain starts with http://localhost, should return domain",
domain: "http://localhost:8080",
description: "domain starts with http://, should return domain",
domain: "http://some-domain:8080",
clusterSlug: "anything",
expected: "http://localhost:8080",
expected: "http://some-domain:8080",
},
{
description: "domain doesn't start with http://localhost, should build a string using the domain and clusterSlug",
description: "domain starts with https://, should return domain",
domain: "https://some-domain:8080",
clusterSlug: "anything",
expected: "https://some-domain:8080",
},
{
description: "domain doesn't start with http or https, should build a string using the domain and clusterSlug",
domain: "gms-dev",
clusterSlug: "us-east-1",
expected: "https://cms-us-east-1.gms-dev/cloud-migrations",