Skip to content

Commit

Permalink
feature. add byoDomian parameter on creating byoh cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkfree committed Oct 18, 2023
1 parent fe95bb6 commit 3f0737a
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 207 deletions.
37 changes: 26 additions & 11 deletions api/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4190,7 +4190,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"expiration": {
"type": "string"
"type": "integer"
}
}
},
Expand Down Expand Up @@ -4356,6 +4356,12 @@ const docTemplate = `{
"domain.Cluster": {
"type": "object",
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"cloudAccount": {
"$ref": "#/definitions/domain.CloudAccount"
},
Expand All @@ -4365,9 +4371,6 @@ const docTemplate = `{
"cloudService": {
"type": "string"
},
"clusterEndpoint": {
"type": "string"
},
"clusterType": {
"type": "integer"
},
Expand Down Expand Up @@ -4527,13 +4530,19 @@ const docTemplate = `{
"type": "string"
},
"validity": {
"type": "string"
"type": "integer"
}
}
},
"domain.ClusterResponse": {
"type": "object",
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"cloudAccount": {
"$ref": "#/definitions/domain.SimpleCloudAccountResponse"
},
Expand Down Expand Up @@ -4581,15 +4590,18 @@ const docTemplate = `{
},
"updator": {
"$ref": "#/definitions/domain.SimpleUserResponse"
},
"userClusterEndpoint": {
"type": "string"
}
}
},
"domain.ClusterSiteValuesResponse": {
"type": "object",
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"clusterRegion": {
"type": "string"
},
Expand Down Expand Up @@ -4819,6 +4831,12 @@ const docTemplate = `{
"stackTemplateId"
],
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"cloudAccountId": {
"type": "string"
},
Expand Down Expand Up @@ -4873,9 +4891,6 @@ const docTemplate = `{
},
"tksUserNodeType": {
"type": "string"
},
"userClusterEndpoint": {
"type": "string"
}
}
},
Expand Down
37 changes: 26 additions & 11 deletions api/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4183,7 +4183,7 @@
"type": "object",
"properties": {
"expiration": {
"type": "string"
"type": "integer"
}
}
},
Expand Down Expand Up @@ -4349,6 +4349,12 @@
"domain.Cluster": {
"type": "object",
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"cloudAccount": {
"$ref": "#/definitions/domain.CloudAccount"
},
Expand All @@ -4358,9 +4364,6 @@
"cloudService": {
"type": "string"
},
"clusterEndpoint": {
"type": "string"
},
"clusterType": {
"type": "integer"
},
Expand Down Expand Up @@ -4520,13 +4523,19 @@
"type": "string"
},
"validity": {
"type": "string"
"type": "integer"
}
}
},
"domain.ClusterResponse": {
"type": "object",
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"cloudAccount": {
"$ref": "#/definitions/domain.SimpleCloudAccountResponse"
},
Expand Down Expand Up @@ -4574,15 +4583,18 @@
},
"updator": {
"$ref": "#/definitions/domain.SimpleUserResponse"
},
"userClusterEndpoint": {
"type": "string"
}
}
},
"domain.ClusterSiteValuesResponse": {
"type": "object",
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"clusterRegion": {
"type": "string"
},
Expand Down Expand Up @@ -4812,6 +4824,12 @@
"stackTemplateId"
],
"properties": {
"byoClusterEndpointHost": {
"type": "string"
},
"byoClusterEndpointPort": {
"type": "integer"
},
"cloudAccountId": {
"type": "string"
},
Expand Down Expand Up @@ -4866,9 +4884,6 @@
},
"tksUserNodeType": {
"type": "string"
},
"userClusterEndpoint": {
"type": "string"
}
}
},
Expand Down
26 changes: 18 additions & 8 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ definitions:
domain.BootstrapKubeconfig:
properties:
expiration:
type: string
type: integer
type: object
domain.ChartData:
properties:
Expand Down Expand Up @@ -363,14 +363,16 @@ definitions:
type: object
domain.Cluster:
properties:
byoClusterEndpointHost:
type: string
byoClusterEndpointPort:
type: integer
cloudAccount:
$ref: '#/definitions/domain.CloudAccount'
cloudAccountId:
type: string
cloudService:
type: string
clusterEndpoint:
type: string
clusterType:
type: integer
conf:
Expand Down Expand Up @@ -476,10 +478,14 @@ definitions:
type:
type: string
validity:
type: string
type: integer
type: object
domain.ClusterResponse:
properties:
byoClusterEndpointHost:
type: string
byoClusterEndpointPort:
type: integer
cloudAccount:
$ref: '#/definitions/domain.SimpleCloudAccountResponse'
cloudService:
Expand Down Expand Up @@ -512,11 +518,13 @@ definitions:
type: string
updator:
$ref: '#/definitions/domain.SimpleUserResponse'
userClusterEndpoint:
type: string
type: object
domain.ClusterSiteValuesResponse:
properties:
byoClusterEndpointHost:
type: string
byoClusterEndpointPort:
type: integer
clusterRegion:
type: string
sshKeyName:
Expand Down Expand Up @@ -670,6 +678,10 @@ definitions:
type: object
domain.CreateClusterRequest:
properties:
byoClusterEndpointHost:
type: string
byoClusterEndpointPort:
type: integer
cloudAccountId:
type: string
cloudService:
Expand Down Expand Up @@ -707,8 +719,6 @@ definitions:
type: integer
tksUserNodeType:
type: string
userClusterEndpoint:
type: string
required:
- cloudService
- name
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func init() {
flag.String("jwt-secret", "tks-api-secret", "secret value of jwt")
flag.String("git-base-url", "https://github.com", "git base url")
flag.String("git-account", "decapod10", "git account of admin cluster")
flag.String("external-gitea-url", "http://gitea-dev.taco-cat.xyz", "gitea url for byoh agent download")
flag.String("external-gitea-url", "http://ip-10-0-76-86.ap-northeast-2.compute.internal:30303", "gitea url for byoh agent download")
flag.String("revision", "main", "revision")
flag.String("aws-secret", "awsconfig-secret", "aws secret")
flag.Int("migrate-db", 1, "If the values is true, enable db migration. recommend only development")
Expand Down
4 changes: 4 additions & 0 deletions internal/delivery/http/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ func (h *ClusterHandler) CreateCluster(w http.ResponseWriter, r *http.Request) {
//txHandle := r.Context().Value("txHandle").(*gorm.DB)
clusterId := domain.ClusterId("")
if input.CloudService == domain.CloudService_BYOH {
if dto.ByoClusterEndpointHost == "" || dto.ByoClusterEndpointPort == 0 {
ErrorJSON(w, r, httpErrors.NewBadRequestError(fmt.Errorf("Invalid byoh cluster endpoint"), "CL_INVALID_BYOH_CLUSTER_ENDPOINT", ""))
return
}
clusterId, err = h.usecase.Bootstrap(r.Context(), dto)
if err != nil {
ErrorJSON(w, r, err)
Expand Down
Loading

0 comments on commit 3f0737a

Please sign in to comment.