diff --git a/internal/flag/flag.go b/internal/flag/flag.go index e50706fa..f04b0eb3 100644 --- a/internal/flag/flag.go +++ b/internal/flag/flag.go @@ -67,8 +67,6 @@ const ( View string = "view" ViewShort string = "v" SpendingLimitMonthly string = "spending-limit-monthly" - UpdateField string = "field" - UpdateValue string = "value" ServerlessLabels string = "labels" ServerlessAnnotations string = "annotations" Monthly string = "monthly" diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index ca3e936c..af2f23c3 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -90,8 +90,8 @@ type ClientDelegate struct { sc *serverlessClient.TidbcloudServerless } -func NewClientDelegate(publicKey string, privateKey string, apiUrl string, serverlessApiUrl string) (*ClientDelegate, error) { - c, ic, cc, bc, sc, err := NewApiClient(publicKey, privateKey, apiUrl, serverlessApiUrl) +func NewClientDelegate(publicKey string, privateKey string, apiUrl string, serverlessEndpoint string) (*ClientDelegate, error) { + c, ic, cc, bc, sc, err := NewApiClient(publicKey, privateKey, apiUrl, serverlessEndpoint) if err != nil { return nil, err } @@ -196,7 +196,7 @@ func (d *ClientDelegate) DeleteBranch(params *branchOp.BranchServiceDeleteBranch return r, err } -func NewApiClient(publicKey string, privateKey string, apiUrl string, serverlessApiUrl string) (*apiClient.GoTidbcloud, *importClient.TidbcloudImport, +func NewApiClient(publicKey string, privateKey string, apiUrl string, serverlessEndpoint string) (*apiClient.GoTidbcloud, *importClient.TidbcloudImport, *connectInfoClient.TidbcloudConnectInfo, *branchClient.TidbcloudServerless, *serverlessClient.TidbcloudServerless, error) { httpclient := &http.Client{ Transport: NewTransportWithAgent(&digest.Transport{ @@ -212,18 +212,16 @@ func NewApiClient(publicKey string, privateKey string, apiUrl string, serverless } transport := httpTransport.NewWithClient(u.Host, u.Path, []string{u.Scheme}, httpclient) - // serverless api - serverlessUrl, err := prop.ValidateApiUrl(serverlessApiUrl) + // v1beta1 api + serverlessURL, err := prop.ValidateApiUrl(serverlessEndpoint) if err != nil { return nil, nil, nil, nil, nil, err } - newTransport := httpTransport.NewWithClient(serverlessUrl.Host, serverlessClient.DefaultBasePath, []string{serverlessUrl.Scheme}, httpclient) - - // v1beta1 branch - branchTransport := httpTransport.NewWithClient(serverlessUrl.Host, "", []string{serverlessUrl.Scheme}, httpclient) + serverlessTransport := httpTransport.NewWithClient(serverlessURL.Host, serverlessClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) + branchTransport := httpTransport.NewWithClient(serverlessURL.Host, branchClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) return apiClient.New(transport, strfmt.Default), importClient.New(transport, strfmt.Default), connectInfoClient.New(transport, strfmt.Default), - branchClient.New(branchTransport, strfmt.Default), serverlessClient.New(newTransport, strfmt.Default), nil + branchClient.New(branchTransport, strfmt.Default), serverlessClient.New(serverlessTransport, strfmt.Default), nil } // NewTransportWithAgent returns a new http.RoundTripper that add the User-Agent header,