diff --git a/internal/cli/root.go b/internal/cli/root.go index 3529f86b..c6324131 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -58,11 +58,11 @@ func Execute(ctx context.Context) { if apiUrl == "" { apiUrl = cloud.DefaultApiUrl } - serverlessApiUrl := config.GetNewApiUrl() - if serverlessApiUrl == "" { - serverlessApiUrl = cloud.DefaultServerlessApiUrl + serverlessEndpoint := config.GetServerlessEndpoint() + if serverlessEndpoint == "" { + serverlessEndpoint = cloud.DefaultServerlessEndpoint } - delegate, err := cloud.NewClientDelegate(publicKey, privateKey, apiUrl, serverlessApiUrl) + delegate, err := cloud.NewClientDelegate(publicKey, privateKey, apiUrl, serverlessEndpoint) if err != nil { return nil, err } diff --git a/internal/config/profile.go b/internal/config/profile.go index c41066cb..60b4dc6f 100644 --- a/internal/config/profile.go +++ b/internal/config/profile.go @@ -120,8 +120,8 @@ func (p *Profile) GetApiUrl() (apiUrl string) { return } -func GetNewApiUrl() (apiUrl string) { return activeProfile.GetNewApiUrl() } -func (p *Profile) GetNewApiUrl() (newApiUrl string) { - newApiUrl = viper.GetString(fmt.Sprintf("%s.%s", p.name, prop.NewApiUrl)) +func GetServerlessEndpoint() (apiUrl string) { return activeProfile.GetServerlessEndpoint() } +func (p *Profile) GetServerlessEndpoint() (newApiUrl string) { + newApiUrl = viper.GetString(fmt.Sprintf("%s.%s", p.name, prop.ServerlessEndpoint)) return } diff --git a/internal/prop/property.go b/internal/prop/property.go index 50905095..ae5132ed 100644 --- a/internal/prop/property.go +++ b/internal/prop/property.go @@ -21,12 +21,12 @@ import ( ) const ( - PublicKey string = "public-key" - PrivateKey string = "private-key" - CurProfile string = "current-profile" - ApiUrl string = "api-url" - NewApiUrl string = "new-api-url" - TelemetryEnabled string = "telemetry-enabled" + PublicKey string = "public-key" + PrivateKey string = "private-key" + CurProfile string = "current-profile" + ApiUrl string = "api-url" + ServerlessEndpoint string = "serverless-endpoint" + TelemetryEnabled string = "telemetry-enabled" ) func GlobalProperties() []string { diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index cda0fe05..7f477012 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -39,9 +39,9 @@ import ( ) const ( - DefaultApiUrl = "https://" + apiClient.DefaultHost - DefaultServerlessApiUrl = "https://" + serverlessClient.DefaultHost - userAgent = "User-Agent" + DefaultApiUrl = "https://" + apiClient.DefaultHost + DefaultServerlessEndpoint = "https://" + serverlessClient.DefaultHost + userAgent = "User-Agent" ) type TiDBCloudClient interface {