Skip to content

Commit

Permalink
fix: Fix the problems encountered in the front-end and back-end inter…
Browse files Browse the repository at this point in the history
…facing
  • Loading branch information
noovertime7 committed Aug 14, 2022
1 parent aba9d27 commit 3eb871c
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func init() {
MaxOpenConns = SystemConf.Database.MaxOpenConns
JWTSecret = SystemConf.JWTSecret
KubeConfigFile = "C:\\Users\\18495\\.kube\\config"
WebSocketListenAddr = ":9091"
WebSocketListenAddr = SystemConf.WebSocketListenAddr
}

var SystemConf = new(System)
Expand Down
4 changes: 2 additions & 2 deletions controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (p *pod) DeletePod(ctx *gin.Context) {
middleware.ResponseError(ctx, 10004, err)
return
}
middleware.ResponseSuccess(ctx, "")
middleware.ResponseSuccess(ctx, "删除成功")
}

// UpdatePod 更新POD
Expand Down Expand Up @@ -132,7 +132,7 @@ func (p *pod) UpdatePod(ctx *gin.Context) {
middleware.ResponseError(ctx, 10005, err)
return
}
middleware.ResponseSuccess(ctx, "")
middleware.ResponseSuccess(ctx, "更新成功")
}

// GetPodContainer 获取Pod内容器名
Expand Down
26 changes: 13 additions & 13 deletions dao/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import (
)

type WorkflowResp struct {
Items []*Workflow
Total int
Items []*Workflow `json:"items"`
Total int `json:"total"`
}
type Workflow struct {
ID uint `json:"id" gorm:"pk"`
Name string `json:"name"`
NameSpace string `json:"namespace"`
Replicas int32 `json:"replicas"`
Deployment string `json:"deployment"`
Service string `json:"service"`
Ingress string `json:"ingress"`
Name string `json:"name" gorm:"column:name"`
NameSpace string `json:"namespace" gorm:"column:namespace"`
Replicas int32 `json:"replicas" gorm:"column:replicas"`
Deployment string `json:"deployment" gorm:"column:deployment"`
Service string `json:"service" gorm:"column:service"`
Ingress string `json:"ingress" gorm:"column:ingress"`
ServiceType string `json:"service_type" gorm:"column:service_type"`
IsDeleted uint `json:"is_deleted"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
IsDeleted uint `json:"is_deleted" gorm:"column:is_deleted"`
CreatedAt *time.Time `json:"created_at" gorm:"column:created_at"`
UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"`
DeletedAt *time.Time `json:"deleted_at" gorm:"column:deleted_at"`
}

func (w *Workflow) TableName() string {
Expand Down Expand Up @@ -61,7 +61,7 @@ func (w *Workflow) Find(search *Workflow) (*Workflow, error) {
func (w *Workflow) DeleteById() error {
w.IsDeleted = 1
return Gorm.Table(w.TableName()).Where("id = ?", w.ID).Updates(map[string]interface{}{
"status": w.IsDeleted,
"is_deleted": w.IsDeleted,
"deleted_at": time.Now(),
}).Error
}
2 changes: 1 addition & 1 deletion dto/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ConfigmapNameNS struct {

type ConfigmapUpdateInput struct {
NameSpace string `json:"namespace" form:"namespace" comment:"命名空间" validate:"required"`
Content string `json:"content" validate:"required" comment:"更新内容"`
Content string `json:"content" form:"content" validate:"required" comment:"更新内容"`
}

type ConfigmapListInput struct {
Expand Down
12 changes: 6 additions & 6 deletions dto/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ type DeployCreateInput struct {
NameSpace string `json:"namespace" form:"namespace" comment:"命名空间" validate:"required"`
Replicas int32 `json:"replicas" validate:"required" comment:"副本数"`
Image string `json:"image" validate:"required" comment:"镜像名"`
Labels map[string]string `json:"labels" validate:"required" comment:"标签"`
Cpu string `json:"cpu" validate:"required" comment:"Cpu限制"`
Memory string `json:"memory" validate:"required" comment:"内存限制"`
ContainerPort int32 `json:"container_port" validate:"required" comment:"容器端口"`
HealthCheck bool `json:"health_check" validate:"required" comment:"健康检查开关"`
HealthPath string `json:"health_path" validate:"required" comment:"Http健康检查路径"`
Labels map[string]string `json:"label" validate:"" comment:"标签"`
Cpu string `json:"cpu" validate:"" comment:"Cpu限制"`
Memory string `json:"memory" validate:"" comment:"内存限制"`
ContainerPort int32 `json:"container_port" validate:"" comment:"容器端口"`
HealthCheck bool `json:"health_check" validate:"" comment:"健康检查开关"`
HealthPath string `json:"health_path" validate:"" comment:"Http健康检查路径"`
}

type UpdateDeployInput struct {
Expand Down
2 changes: 1 addition & 1 deletion dto/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type IngressNameNS struct {
}

type IngressUpdateInput struct {
Content string `json:"content" validate:"required" comment:"更新内容"`
Content string `json:"content" form:"content" validate:"required" comment:"更新内容"`
NameSpace string `json:"namespace" form:"namespace" comment:"命名空间" validate:"required"`
}

Expand Down
2 changes: 1 addition & 1 deletion dto/persistentVolumeClaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type PersistentVolumeClaimNameNS struct {

type PersistentVolumeClaimUpdateInput struct {
NameSpace string `json:"namespace" form:"namespace" comment:"命名空间" validate:"required"`
Content string `json:"content" validate:"required" comment:"更新内容"`
Content string `json:"content" form:"content" validate:"required" comment:"更新内容"`
}

type PersistentVolumeClaimListInput struct {
Expand Down
2 changes: 1 addition & 1 deletion dto/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type SecretNameNS struct {

type SecretUpdateInput struct {
NameSpace string `json:"namespace" form:"namespace" comment:"命名空间" validate:"required"`
Content string `json:"content" validate:"required" comment:"更新内容"`
Content string `json:"content" form:"content" validate:"required" comment:"更新内容"`
}

type SecretListInput struct {
Expand Down
2 changes: 1 addition & 1 deletion dto/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type ServiceCreateInput struct {
Name string `json:"name"`
NameSpace string `json:"name_space"`
NameSpace string `json:"namespace"`
Type string `json:"type"`
ContainerPort int32 `json:"container_port"`
Port int32 `json:"port"`
Expand Down
2 changes: 1 addition & 1 deletion dto/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type StatefulSetNameNS struct {

type StatefulSetUpdateInput struct {
NameSpace string `json:"namespace" form:"namespace" comment:"命名空间" validate:"required"`
Content string `json:"content" validate:"required" comment:"更新内容"`
Content string `json:"content" form:"content" validate:"required" comment:"更新内容"`
}

type StatefulSetListInput struct {
Expand Down
2 changes: 1 addition & 1 deletion dto/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type WorkFlowCreateInput struct {
}

type WorkFlowIDInput struct {
ID int `json:"id"`
ID int `json:"id" form:"id"`
}

func (params *WorkFlowCreateInput) BindingValidParams(c *gin.Context) error {
Expand Down
1 change: 1 addition & 0 deletions router/httpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func HttpServerRun() {
go func() {
logger.Info("启动容器websocket服务")
http.HandleFunc("/ws/terminal", service.Terminal.WsHandler)
logger.Info("websocket开始监听,地址:", config.WebSocketListenAddr)
http.ListenAndServe(config.WebSocketListenAddr, nil)
}()
r := InitRouter()
Expand Down
4 changes: 2 additions & 2 deletions service/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type PodsResp struct {
}

type PodsNp struct {
Namespace string
PodNum int
Namespace string `json:"namespace"`
PodNum int `json:"pod_num"`
}

// GetPods 获取pod列表支持、过滤、排序以及分页
Expand Down
4 changes: 2 additions & 2 deletions service/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (t *terminal) WsHandler(w http.ResponseWriter, r *http.Request) {
}
// 如果解析成功
namespace := r.Form.Get("namespace")
podName := r.Form.Get("podName")
containerName := r.Form.Get("containerName")
podName := r.Form.Get("pod_name")
containerName := r.Form.Get("container_name")
logger.Info("exec pod: %s, container: %s, namespace: %s\n", podName, containerName, namespace)

// new一个TerminalSession类型的pty实例
Expand Down
3 changes: 3 additions & 0 deletions service/workflow.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package service

import (
"fmt"
"github.com/noovertime7/kubemanage/dao"
"github.com/noovertime7/kubemanage/dto"
)
Expand Down Expand Up @@ -60,7 +61,9 @@ func (w *workflow) CreateWorkFlow(params *dto.WorkFlowCreateInput) error {
func (w *workflow) DelById(id int) (err error) {
//获取workflow数据
in := &dao.Workflow{ID: uint(id)}
fmt.Println("in = ", in)
workflow, err := in.Find(in)
fmt.Println(workflow, in)
if err != nil {
return err
}
Expand Down

0 comments on commit 3eb871c

Please sign in to comment.