Skip to content

Commit

Permalink
remove pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Dec 13, 2023
1 parent bfb4796 commit 7dc2656
Show file tree
Hide file tree
Showing 82 changed files with 117 additions and 4,230 deletions.
17 changes: 4 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,14 @@ generate-import-client: ## Generate import client
addcopy: ## Add copyright to all files
@scripts/add-copy.sh

.PHONY: generate-branch-client
generate-branch-client:
@echo "==> Generating branch client"
go install github.com/go-swagger/go-swagger/cmd/swagger@latest
swagger generate client -f pkg/tidbcloud/branch/branch.swagger.json -A tidbcloud-branch -t pkg/tidbcloud/branch

.PHONY: generate-serverless-client
generate-serverless-client:
@echo "==> Generating serverless client"
go install github.com/go-swagger/go-swagger/cmd/swagger@latest
swagger generate client -f pkg/tidbcloud/serverless/serverless.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/serverless

.PHONY: generate-v1beta1-client
generate-v1beta1-client:
@echo "==> Generating branch client"
go install github.com/go-swagger/go-swagger/cmd/swagger@latest
@echo "==> Generating branch client"
swagger generate client -f pkg/tidbcloud/v1beta1/branch/branch.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/branch
@echo "==> Generating serverless client"
swagger generate client -f pkg/tidbcloud/v1beta1/serverless/serverless.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless


.PHONY: fmt
fmt: ## Format changed go
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/connect/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os/user"
"strconv"
"strings"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/config"
Expand All @@ -31,8 +32,6 @@ import (
"tidbcloud-cli/internal/util"
branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/fatih/color"
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/dataimport/start/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"runtime"
"strconv"
"strings"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
"time"

"tidbcloud-cli/internal"
Expand All @@ -32,8 +33,6 @@ import (
"tidbcloud-cli/internal/ui"
"tidbcloud-cli/internal/util"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"

Expand Down
34 changes: 17 additions & 17 deletions internal/cli/dataimport/start/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"path/filepath"
"runtime"
"testing"
"tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
"tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/config"
Expand All @@ -30,8 +32,6 @@ import (
"tidbcloud-cli/internal/service/cloud"
connectInfoService "tidbcloud-cli/pkg/tidbcloud/connect_info/client/connect_info_service"
connectInfoModel "tidbcloud-cli/pkg/tidbcloud/connect_info/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"

mockTool "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -198,11 +198,11 @@ func (suite *MySQLImportSuite) TestMySQLImportArgs() {
"-p" + password,
}
suite.mockHelper.On("ImportToServerless", mockTool.Anything, importArgs, cachePath).Return(nil)
suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams().
WithClusterID(clusterID)).Return(&serverlessApi.ServerlessServiceGetClusterOK{
Payload: &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{
Endpoints: &serverlessModel.V1beta1ClusterEndpoints{
PublicEndpoint: &serverlessModel.EndpointsPublic{
suite.mockClient.On("GetCluster", serverless_service.NewServerlessServiceGetClusterParams().
WithClusterID(clusterID)).Return(&serverless_service.ServerlessServiceGetClusterOK{
Payload: &models.TidbCloudOpenApiserverlessv1beta1Cluster{
Endpoints: &models.V1beta1ClusterEndpoints{
PublicEndpoint: &models.EndpointsPublic{
Host: targetHost,
Port: targetPort,
},
Expand Down Expand Up @@ -312,11 +312,11 @@ func (suite *MySQLImportSuite) TestMySQLImportWithoutCreateTable() {
"-p" + password,
}
suite.mockHelper.On("ImportToServerless", mockTool.Anything, importArgs, cachePath).Return(nil)
suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams().
WithClusterID(clusterID)).Return(&serverlessApi.ServerlessServiceGetClusterOK{
Payload: &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{
Endpoints: &serverlessModel.V1beta1ClusterEndpoints{
PublicEndpoint: &serverlessModel.EndpointsPublic{
suite.mockClient.On("GetCluster", serverless_service.NewServerlessServiceGetClusterParams().
WithClusterID(clusterID)).Return(&serverless_service.ServerlessServiceGetClusterOK{
Payload: &models.TidbCloudOpenApiserverlessv1beta1Cluster{
Endpoints: &models.V1beta1ClusterEndpoints{
PublicEndpoint: &models.EndpointsPublic{
Host: targetHost,
Port: targetPort,
},
Expand Down Expand Up @@ -421,11 +421,11 @@ func (suite *MySQLImportSuite) TestMySQLImportWithSpecificUser() {
"-p" + password,
}
suite.mockHelper.On("ImportToServerless", mockTool.Anything, importArgs, cachePath).Return(nil)
suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams().
WithClusterID(clusterID)).Return(&serverlessApi.ServerlessServiceGetClusterOK{
Payload: &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{
Endpoints: &serverlessModel.V1beta1ClusterEndpoints{
PublicEndpoint: &serverlessModel.EndpointsPublic{
suite.mockClient.On("GetCluster", serverless_service.NewServerlessServiceGetClusterParams().
WithClusterID(clusterID)).Return(&serverless_service.ServerlessServiceGetClusterOK{
Payload: &models.TidbCloudOpenApiserverlessv1beta1Cluster{
Endpoints: &models.V1beta1ClusterEndpoints{
PublicEndpoint: &models.EndpointsPublic{
Host: targetHost,
Port: targetPort,
},
Expand Down
8 changes: 4 additions & 4 deletions internal/cli/serverless/connectinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import (
"strconv"
"strings"

"github.com/juju/errors"
"github.com/spf13/cobra"

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/config"
"tidbcloud-cli/internal/flag"
"tidbcloud-cli/internal/service/cloud"
"tidbcloud-cli/internal/util"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"

"github.com/juju/errors"
"github.com/spf13/cobra"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
)

type connectInfoOpts struct {
Expand Down
12 changes: 6 additions & 6 deletions internal/cli/serverless/connectinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import (
"fmt"
"os"
"testing"
"tidbcloud-cli/internal/config"

"github.com/juju/errors"
"tidbcloud-cli/internal/config"
connectInfoService "tidbcloud-cli/pkg/tidbcloud/connect_info/client/connect_info_service"
connectInfoModel "tidbcloud-cli/pkg/tidbcloud/connect_info/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/iostream"
"tidbcloud-cli/internal/mock"
"tidbcloud-cli/internal/service/cloud"
connectInfoService "tidbcloud-cli/pkg/tidbcloud/connect_info/client/connect_info_service"
connectInfoModel "tidbcloud-cli/pkg/tidbcloud/connect_info/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"

"github.com/juju/errors"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand Down
5 changes: 2 additions & 3 deletions internal/cli/serverless/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import (
"tidbcloud-cli/internal/telemetry"
"tidbcloud-cli/internal/ui"
"tidbcloud-cli/internal/util"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
Expand Down
5 changes: 2 additions & 3 deletions internal/cli/serverless/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import (
"tidbcloud-cli/internal/iostream"
"tidbcloud-cli/internal/mock"
"tidbcloud-cli/internal/service/cloud"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/serverless/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ package serverless

import (
"fmt"

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/config"
"tidbcloud-cli/internal/flag"
"tidbcloud-cli/internal/service/cloud"
"tidbcloud-cli/internal/telemetry"
"tidbcloud-cli/internal/util"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
Expand Down
5 changes: 2 additions & 3 deletions internal/cli/serverless/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import (
"tidbcloud-cli/internal/iostream"
"tidbcloud-cli/internal/mock"
"tidbcloud-cli/internal/service/cloud"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/serverless/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (
"tidbcloud-cli/internal/flag"
"tidbcloud-cli/internal/service/cloud"
"tidbcloud-cli/internal/telemetry"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"

"github.com/juju/errors"
"github.com/spf13/cobra"
Expand Down
5 changes: 2 additions & 3 deletions internal/cli/serverless/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import (
"tidbcloud-cli/internal/iostream"
"tidbcloud-cli/internal/mock"
"tidbcloud-cli/internal/service/cloud"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/serverless/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (
"tidbcloud-cli/internal/output"
"tidbcloud-cli/internal/service/cloud"
"tidbcloud-cli/internal/telemetry"

serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/juju/errors"
"github.com/spf13/cobra"
Expand Down
5 changes: 2 additions & 3 deletions internal/cli/serverless/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ import (
"tidbcloud-cli/internal/iostream"
"tidbcloud-cli/internal/mock"
"tidbcloud-cli/internal/service/cloud"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/serverless/regions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/config"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"

"github.com/juju/errors"
"github.com/spf13/cobra"
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/serverless/spending_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"tidbcloud-cli/internal/service/cloud"
"tidbcloud-cli/internal/ui"
"tidbcloud-cli/internal/util"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/serverless/models"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"
serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models"

"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
Expand Down
8 changes: 3 additions & 5 deletions internal/cli/serverless/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ package serverless
import (
"encoding/json"
"fmt"

"tidbcloud-cli/internal"
"tidbcloud-cli/internal/config"
"tidbcloud-cli/internal/flag"
"tidbcloud-cli/internal/service/cloud"
"tidbcloud-cli/internal/telemetry"
"tidbcloud-cli/internal/ui"
"tidbcloud-cli/internal/util"

"github.com/fatih/color"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"

"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"

"github.com/fatih/color"
"github.com/juju/errors"
"github.com/spf13/cobra"
)
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/serverless/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import (
"tidbcloud-cli/internal/iostream"
"tidbcloud-cli/internal/mock"
"tidbcloud-cli/internal/service/cloud"

serverlessApi "tidbcloud-cli/pkg/tidbcloud/serverless/client/serverless_service"
serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
Loading

0 comments on commit 7dc2656

Please sign in to comment.