Skip to content

Commit

Permalink
Merge pull request #24 from openinfradev/add_stack
Browse files Browse the repository at this point in the history
[WIP] Add stack
  • Loading branch information
ktkfree authored Apr 13, 2023
2 parents 99dd645 + 5dcc97e commit 341686e
Show file tree
Hide file tree
Showing 27 changed files with 1,987 additions and 185 deletions.
449 changes: 449 additions & 0 deletions api/swagger/docs.go

Large diffs are not rendered by default.

449 changes: 449 additions & 0 deletions api/swagger/swagger.json

Large diffs are not rendered by default.

290 changes: 290 additions & 0 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ definitions:
type: string
organizationId:
type: string
stackTemplate:
$ref: '#/definitions/domain.StackTemplate'
stackTemplateId:
type: string
status:
type: integer
statusDesc:
Expand Down Expand Up @@ -405,6 +409,7 @@ definitions:
type: string
required:
- name
- organizationId
- secretKey
- secretKeyId
type: object
Expand Down Expand Up @@ -454,6 +459,28 @@ definitions:
required:
- name
type: object
domain.CreateStackRequest:
properties:
cloudSettingId:
type: string
cpNodeCnt:
type: integer
description:
type: string
name:
type: string
stackTemplateId:
type: string
tksNodeCnt:
type: integer
userNodeCnt:
type: integer
type: object
domain.CreateStackResponse:
properties:
id:
type: string
type: object
domain.CreateStackTemplateRequest:
properties:
cloudService:
Expand Down Expand Up @@ -545,6 +572,11 @@ definitions:
- secretKey
- secretKeyId
type: object
domain.DeleteStackRequest:
properties:
id:
type: string
type: object
domain.GetAppGroupResponse:
properties:
appGroup:
Expand Down Expand Up @@ -609,6 +641,11 @@ definitions:
type: string
type: object
type: object
domain.GetStackResponse:
properties:
stack:
$ref: '#/definitions/domain.StackResponse'
type: object
domain.GetStackTemplateResponse:
properties:
stackTemplate:
Expand All @@ -621,6 +658,13 @@ definitions:
$ref: '#/definitions/domain.StackTemplateResponse'
type: array
type: object
domain.GetStacksResponse:
properties:
stacks:
items:
$ref: '#/definitions/domain.StackResponse'
type: array
type: object
domain.GetUserResponse:
properties:
user:
Expand Down Expand Up @@ -780,6 +824,70 @@ definitions:
name:
type: string
type: object
domain.StackResponse:
properties:
cloudSetting:
$ref: '#/definitions/domain.CloudSettingResponse'
createdAt:
type: string
creator:
$ref: '#/definitions/domain.SimpleUserResponse'
description:
type: string
id:
type: string
name:
type: string
organizationId:
type: string
primaryCluster:
type: boolean
stackTemplate:
$ref: '#/definitions/domain.StackTemplateResponse'
status:
type: string
statusDesc:
type: string
updatedAt:
type: string
updator:
$ref: '#/definitions/domain.SimpleUserResponse'
type: object
domain.StackTemplate:
properties:
cloudService:
type: string
createdAt:
type: string
creator:
$ref: '#/definitions/domain.User'
creatorId:
type: string
description:
type: string
id:
type: string
kubeType:
type: string
kubeVersion:
type: string
name:
type: string
organizationId:
type: string
platform:
type: string
template:
type: string
updatedAt:
type: string
updator:
$ref: '#/definitions/domain.User'
updatorId:
type: string
version:
type: string
type: object
domain.StackTemplateResponse:
properties:
cloudService:
Expand Down Expand Up @@ -947,6 +1055,11 @@ definitions:
primaryClusterId:
type: string
type: object
domain.UpdateStackRequest:
properties:
id:
type: string
type: object
domain.UpdateStackTemplateRequest:
properties:
description:
Expand Down Expand Up @@ -1711,6 +1824,183 @@ paths:
summary: Update primary cluster
tags:
- Organizations
/organizations/{organizationId}/stacks:
get:
consumes:
- application/json
description: Get Stacks
parameters:
- description: organizationId
in: path
name: organizationId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.GetStacksResponse'
security:
- JWT: []
summary: Get Stacks
tags:
- Stacks
post:
consumes:
- application/json
description: Create Stack
parameters:
- description: organizationId
in: path
name: organizationId
required: true
type: string
- description: create cloud setting request
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.CreateStackRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.CreateStackResponse'
security:
- JWT: []
summary: Create Stack
tags:
- Stacks
/organizations/{organizationId}/stacks/{stackId}:
delete:
consumes:
- application/json
description: Delete Stack
parameters:
- description: organizationId
in: path
name: organizationId
required: true
type: string
- description: stackId
in: path
name: stackId
required: true
type: string
- description: Delete cloud setting request
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.DeleteStackRequest'
- description: stackId
in: path
name: stackId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
security:
- JWT: []
summary: Delete Stack
tags:
- Stacks
get:
consumes:
- application/json
description: Get Stack
parameters:
- description: organizationId
in: path
name: organizationId
required: true
type: string
- description: stackId
in: path
name: stackId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.GetStackResponse'
security:
- JWT: []
summary: Get Stack
tags:
- Stacks
put:
consumes:
- application/json
description: Update Stack
parameters:
- description: organizationId
in: path
name: organizationId
required: true
type: string
- description: stackId
in: path
name: stackId
required: true
type: string
- description: Update cloud setting request
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.UpdateStackRequest'
produces:
- application/json
responses:
"200":
description: OK
security:
- JWT: []
summary: Update Stack
tags:
- Stacks
/organizations/{organizationId}/stacks/name/{name}/existence:
get:
consumes:
- application/json
description: Check name for stack
parameters:
- description: organizationId
in: path
name: organizationId
required: true
type: string
- description: stackId
in: path
name: stackId
required: true
type: string
- description: name
in: path
name: name
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
security:
- JWT: []
summary: Check name for stack
tags:
- Stacks
/organizations/{organizationId}/users:
get:
consumes:
Expand Down
2 changes: 2 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
)

func init() {
flag.String("external-address", "http://tks-api.tks.svc:9110", "service address")
flag.Int("port", 8080, "service port")
flag.String("web-root", "../../web", "path of root path for web")
flag.String("argo-address", "http://localhost", "service address for argoworkflow")
Expand All @@ -32,6 +33,7 @@ func init() {
flag.String("git-base-url", "https://github.com", "git base url")
flag.String("git-account", "decapod10", "git account of admin cluster")
flag.String("revision", "main", "revision")
flag.Bool("migrate-db", true, "If the values is true, enable db migration. recommend only development")

// app-serve-apps
flag.String("image-registry-url", "harbor-dev.taco-cat.xyz/appserving", "URL of image registry")
Expand Down
6 changes: 4 additions & 2 deletions internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ func InitDB() (*gorm.DB, error) {
return nil, err
}

if err := migrateSchema(db); err != nil {
return nil, err
if viper.GetBool("migrate-db") {
if err := migrateSchema(db); err != nil {
return nil, err
}
}

return db, nil
Expand Down
Loading

0 comments on commit 341686e

Please sign in to comment.