mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudMigrations: Avoid building GMS base path when provided (#93793)
Avoid building GMS base path when provided
This commit is contained in:
parent
7928245eb6
commit
826245f511
@ -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)
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user