Skip to content

Commit

Permalink
fix invalid swagger and upgrade to go 1.23 (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyangyu authored Nov 21, 2024
1 parent 64b4ca4 commit 2e57e1a
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
go-version-file: './go.mod'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3.3.0
uses: golangci/golangci-lint-action@v6
with:
version: v1.56.2
version: v1.62.0

fmt:
name: fmt
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ linters:
- bodyclose
- durationcheck
- errcheck
- exportloopref
- goimports
- gosec
- gosimple
Expand All @@ -31,6 +30,7 @@ linters-settings:
confidence: "low"
excludes:
- G101
- G115
- G404
# exclude warnings of using crypto/sha1
- G505
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ generate-pingchat-client: ## Generate PingChat client
@echo "==> Generating PingChat client"
rm -rf pkg/tidbcloud/pingchat
cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/pingchat.swagger.json -g go -o ../../pkg/tidbcloud/pingchat --package-name pingchat
go fmt ./pkg/tidbcloud/pingchat/...
cd pkg && go fmt ./tidbcloud/pingchat/...

.PHONY: addcopy
addcopy: ## Add copyright to all files
Expand All @@ -44,7 +44,7 @@ generate-v1beta1-client: install-openapi-generator ## Generate v1beta1 client
cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/branch.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/branch --package-name branch
@echo "==> Generating serverless cluster client"
rm -rf pkg/tidbcloud/v1beta1/serverless/cluster
cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/cluster --package-name cluster --skip-validate-spec
cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/cluster --package-name cluster
@echo "==> Generating serverless export client"
rm -rf pkg/tidbcloud/v1beta1/serverless/export
cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/export.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/export --package-name export
Expand All @@ -57,7 +57,7 @@ generate-v1beta1-client: install-openapi-generator ## Generate v1beta1 client
@echo "==> Generating serverless import client"
rm -rf pkg/tidbcloud/v1beta1/serverless/imp
cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/import.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/imp --package-name imp
go fmt ./pkg/tidbcloud/v1beta1/...
cd pkg && go fmt ./tidbcloud/v1beta1/...

.PHONY: install-openapi-generator
install-openapi-generator:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tidbcloud/tidbcloud-cli

go 1.22
go 1.23

require (
github.com/AlecAivazis/survey/v2 v2.3.6
Expand Down
2 changes: 1 addition & 1 deletion pkg/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/tidbcloud/tidbcloud-cli/pkg

go 1.22
go 1.23
21 changes: 13 additions & 8 deletions pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/tidb_cloud_open_apiserverlessv1beta1Cluster",
"required": [
"cluster"
]
"$ref": "#/definitions/tidb_cloud_open_apiserverlessv1beta1Cluster"
}
}
],
Expand Down Expand Up @@ -378,6 +375,14 @@
}
},
"definitions": {
"ClusterHighAvailabilityType": {
"type": "string",
"enum": [
"ZONAL",
"REGIONAL"
],
"title": "- ZONAL: High availability within a single zone\n - REGIONAL: High availability across multiple zones within a region"
},
"ClusterSpendingLimit": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -648,6 +653,9 @@
}
]
},
"highAvailabilityType": {
"$ref": "#/definitions/ClusterHighAvailabilityType"
},
"version": {
"type": "string",
"description": "Output_only. The TiDB version of the cluster.",
Expand Down Expand Up @@ -727,10 +735,7 @@
]
}
},
"description": "Message for requesting to create a TiDB Cloud Serverless cluster.",
"required": [
"cluster"
]
"description": "Message for requesting to create a TiDB Cloud Serverless cluster."
},
"tidb_cloud_open_apiserverlessv1beta1ListClustersResponse": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ api_serverless_service.go
client.go
configuration.go
git_push.sh
model_cluster_high_availability_type.go
model_cluster_spending_limit.go
model_commonv1beta1_cluster_state.go
model_commonv1beta1_region.go
Expand Down
1 change: 1 addition & 0 deletions pkg/tidbcloud/v1beta1/serverless/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Class | Method | HTTP request | Description

## Documentation For Models

- [ClusterHighAvailabilityType](docs/ClusterHighAvailabilityType.md)
- [ClusterSpendingLimit](docs/ClusterSpendingLimit.md)
- [Commonv1beta1ClusterState](docs/Commonv1beta1ClusterState.md)
- [Commonv1beta1Region](docs/Commonv1beta1Region.md)
Expand Down
19 changes: 17 additions & 2 deletions pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@ paths:
- ServerlessService
components:
schemas:
ClusterHighAvailabilityType:
enum:
- ZONAL
- REGIONAL
title: |-
- ZONAL: High availability within a single zone
- REGIONAL: High availability across multiple zones within a region
type: string
ClusterSpendingLimit:
description: Message for spending limit configuration.
properties:
Expand Down Expand Up @@ -652,6 +660,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand Down Expand Up @@ -700,6 +709,8 @@ components:
- $ref: '#/components/schemas/v1beta1ClusterEncryptionConfig'
description: Optional. Encryption settings for the cluster.
type: object
highAvailabilityType:
$ref: '#/components/schemas/ClusterHighAvailabilityType'
version:
description: Output_only. The TiDB version of the cluster.
readOnly: true
Expand Down Expand Up @@ -761,8 +772,6 @@ components:
- $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster'
description: Required. The cluster to be created.
type: object
required:
- cluster
type: object
tidb_cloud_open_apiserverlessv1beta1ListClustersResponse:
description: Responses message to the request for listing of TiDB Cloud Serverless
Expand All @@ -786,6 +795,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand All @@ -806,6 +816,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand Down Expand Up @@ -881,6 +892,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand All @@ -901,6 +913,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand Down Expand Up @@ -933,6 +946,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand All @@ -953,6 +967,7 @@ components:
spendingLimit: "{}"
createdBy: createdBy
createTime: 2000-01-23T04:56:07.000+00:00
highAvailabilityType: ZONAL
name: name
userPrefix: userPrefix
state: "{}"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e57e1a

Please sign in to comment.