feat : cluster api 文档

This commit is contained in:
wangzhengkun
2022-06-06 15:39:42 +08:00
parent e1a8621a7b
commit 419ad211ad
8 changed files with 3677 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,8 @@ import (
"runtime"
_ "github.com/KubeOperator/kubepi/cmd/server/docs"
_ "github.com/KubeOperator/kubepi/internal/model/v1/cluster"
_ "github.com/KubeOperator/kubepi/internal/model/v1/clusterrepo"
_ "github.com/KubeOperator/kubepi/internal/model/v1/docs"
_ "github.com/KubeOperator/kubepi/internal/model/v1/imagerepo"
_ "github.com/KubeOperator/kubepi/internal/model/v1/role"
@@ -13,6 +15,7 @@ import (
"github.com/KubeOperator/kubepi/internal/server"
"github.com/KubeOperator/kubepi/pkg/network/ip"
"github.com/spf13/cobra"
_ "k8s.io/api/rbac/v1"
)
//go:generate swag init

View File

@@ -48,6 +48,16 @@ func NewHandler() *Handler {
}
}
// Create Cluster
// @Tags clusters
// @Summary Create Cluster
// @Description Create Cluster
// @Accept json
// @Produce json
// @Param request body Cluster true "request"
// @Success 200 {object} Cluster
// @Security ApiKeyAuth
// @Router /clusters [post]
func (h *Handler) CreateCluster() iris.Handler {
return func(ctx *context.Context) {
var req Cluster
@@ -389,6 +399,16 @@ func getExtraClusterInfo(context goContext.Context, client kubernetes.Interface)
}
// Get Cluster
// @Tags clusters
// @Summary Get cluster by name
// @Description Get cluster by name
// @Accept json
// @Produce json
// @Param name path string true "集群名称"
// @Success 200 {object} v1Cluster.Cluster
// @Security ApiKeyAuth
// @Router /clusters/{name} [get]
func (h *Handler) GetCluster() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -402,6 +422,17 @@ func (h *Handler) GetCluster() iris.Handler {
}
}
// Update Cluster
// @Tags clusters
// @Summary Update cluster by name
// @Description Update cluster by name
// @Accept json
// @Produce json
// @Param request body UpdateCluster true "request"
// @Param name path string true "集群名称"
// @Success 200 {object} UpdateCluster
// @Security ApiKeyAuth
// @Router /clusters/{name} [put]
func (h *Handler) UpdateCluster() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -431,6 +462,15 @@ func (h *Handler) UpdateCluster() iris.Handler {
}
}
// List Clusters
// @Tags clusters
// @Summary List all clusters
// @Description List all clusters
// @Accept json
// @Produce json
// @Success 200 {object} []v1Cluster.Cluster
// @Security ApiKeyAuth
// @Router /clusters [get]
func (h *Handler) ListClusters() iris.Handler {
return func(ctx *context.Context) {
var clusters []v1Cluster.Cluster
@@ -465,6 +505,16 @@ func (h *Handler) ListClusters() iris.Handler {
}
}
// Delete Cluster
// @Tags clusters
// @Summary Delete cluster by name
// @Description Delete cluster by name
// @Accept json
// @Produce json
// @Param name path string true "集群名称"
// @Success 200 {object} v1Cluster.Cluster
// @Security ApiKeyAuth
// @Router /clusters/{name} [delete]
func (h *Handler) DeleteCluster() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")

View File

@@ -2,6 +2,7 @@ package cluster
import (
"github.com/KubeOperator/kubepi/internal/model/v1/clusterrepo"
_ "github.com/KubeOperator/kubepi/internal/model/v1/imagerepo"
"github.com/KubeOperator/kubepi/internal/server"
"github.com/KubeOperator/kubepi/internal/service/v1/common"
"github.com/asdine/storm/v3"
@@ -9,6 +10,16 @@ import (
"github.com/kataras/iris/v12/context"
)
// List ClusterRepos
// @Tags clusters
// @Summary List all clusterRepos
// @Description List all clusterRepos
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Success 200 {object} []clusterrepo.ClusterRepo
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/repos [get]
func (h *Handler) ListClusterRepos() iris.Handler {
return func(ctx *context.Context) {
cluster := ctx.Params().GetString("name")
@@ -22,6 +33,16 @@ func (h *Handler) ListClusterRepos() iris.Handler {
}
}
// Get ClusterRepo Detail
// @Tags clusters
// @Summary Get ClusterRepo Detail
// @Description Get ClusterRepo Detail
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Success 200 {object} []imagerepo.ImageRepo
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/repos [get]
func (h *Handler) ListClusterReposDetail() iris.Handler {
return func(ctx *context.Context) {
cluster := ctx.Params().GetString("name")
@@ -35,6 +56,17 @@ func (h *Handler) ListClusterReposDetail() iris.Handler {
}
}
// Create Cluster Repo
// @Tags clusters
// @Summary Create Cluster Repo
// @Description Create Cluster Repo
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param request body CreateRepo true "request"
// @Success 200 {object} CreateRepo
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/repos [post]
func (h *Handler) AddCLusterRepo() iris.Handler {
return func(ctx *context.Context) {
var req CreateRepo
@@ -67,6 +99,17 @@ func (h *Handler) AddCLusterRepo() iris.Handler {
}
}
// Delete ClusterRepo
// @Tags clusters
// @Summary Delete clusterRepo by name
// @Description Delete clusterRepo by name
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param repo path string true "镜像仓库名称"
// @Success 200 {number} 200
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/repos/{repo} [delete]
func (h *Handler) DeleteClusterRepo() iris.Handler {
return func(ctx *context.Context) {
cluster := ctx.Params().GetString("name")

View File

@@ -14,6 +14,18 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Update Cluster Role
// @Tags clusters
// @Summary Update Cluster Role
// @Description Update Cluster Role
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param clusterrole path string true "权限名称"
// @Param request body rbacV1.ClusterRole true "request"
// @Success 200 {object} rbacV1.ClusterRole
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/clusterroles/{clusterrole} [put]
func (h *Handler) UpdateClusterRole() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -63,6 +75,17 @@ func (h *Handler) UpdateClusterRole() iris.Handler {
}
}
// Create Cluster Role
// @Tags clusters
// @Summary Create Cluster Role
// @Description Create Cluster Role
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param request body rbacV1.ClusterRole true "request"
// @Success 200 {object} rbacV1.ClusterRole
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/clusterroles [post]
func (h *Handler) CreateClusterRole() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -116,6 +139,18 @@ func (h *Handler) CreateClusterRole() iris.Handler {
ctx.Values().Set("data", resp)
}
}
// Delete ClusterRole
// @Tags clusters
// @Summary Delete clusterRole by name
// @Description Delete clusterRole by name
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param clusterrole path string true "权限名称"
// @Success 200 {number} 200
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/clusterroles/{clusterrole} [delete]
func (h *Handler) DeleteClusterRole() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -155,6 +190,16 @@ func (h *Handler) DeleteClusterRole() iris.Handler {
}
}
// List ClusterRoles
// @Tags clusters
// @Summary List all clusterRoles
// @Description List all clusterRoles
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Success 200 {object} []rbacV1.ClusterRole
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/clusterroles [get]
func (h *Handler) ListClusterRoles() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")

View File

@@ -19,6 +19,18 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Update Cluster Member
// @Tags clusters
// @Summary Update Cluster Member
// @Description Update Cluster Member
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param member path string true "成员名称"
// @Param request body Member true "request"
// @Success 200 {object} Member
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/members/{member} [put]
func (h *Handler) UpdateClusterMember() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -72,6 +84,17 @@ func (h *Handler) UpdateClusterMember() iris.Handler {
}
}
// Get Cluster Member By name
// @Tags clusters
// @Summary Get Cluster Member By name
// @Description Get Cluster Member By name
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param member path string true "成员名称"
// @Success 200 {object} Member
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/members/{member} [get]
func (h *Handler) GetClusterMember() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -149,6 +172,16 @@ func (h *Handler) GetClusterMember() iris.Handler {
}
// List ClusterMembers
// @Tags clusters
// @Summary List all ClusterMembers
// @Description List all ClusterMembers
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Success 200 {object} []Member
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/members [get]
func (h *Handler) ListClusterMembers() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -170,6 +203,17 @@ func (h *Handler) ListClusterMembers() iris.Handler {
}
}
// Create Cluster Member
// @Tags clusters
// @Summary Create Cluster Member
// @Description Create Cluster Member
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param request body Member true "request"
// @Success 200 {object} Member
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/members [post]
func (h *Handler) CreateClusterMember() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")
@@ -252,6 +296,17 @@ func (h *Handler) CreateClusterMember() iris.Handler {
}
}
// Delete ClusterMember
// @Tags clusters
// @Summary Delete clusterMember by name
// @Description Delete clusterMember by name
// @Accept json
// @Produce json
// @Param cluster path string true "集群名称"
// @Param members path string true "成员名称"
// @Success 200 {number} 200
// @Security ApiKeyAuth
// @Router /clusters/{cluster}/members/{member} [delete]
func (h *Handler) DeleteClusterMember() iris.Handler {
return func(ctx *context.Context) {
name := ctx.Params().GetString("name")