From 58fdd755969ea6a996f585c6924571a1f42bc64b Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Wed, 1 Nov 2023 11:20:35 +0900 Subject: [PATCH 1/5] feature. add cluster type to GetClusterSiteValues --- api/swagger/docs.go | 3 +++ api/swagger/swagger.json | 3 +++ api/swagger/swagger.yaml | 2 ++ pkg/domain/cluster.go | 1 + 4 files changed, 9 insertions(+) diff --git a/api/swagger/docs.go b/api/swagger/docs.go index ed5ebcd8..a61e0384 100644 --- a/api/swagger/docs.go +++ b/api/swagger/docs.go @@ -4650,6 +4650,9 @@ const docTemplate = `{ "clusterRegion": { "type": "string" }, + "clusterType": { + "type": "string" + }, "sshKeyName": { "type": "string" }, diff --git a/api/swagger/swagger.json b/api/swagger/swagger.json index 94f8ea8b..76af67e7 100644 --- a/api/swagger/swagger.json +++ b/api/swagger/swagger.json @@ -4643,6 +4643,9 @@ "clusterRegion": { "type": "string" }, + "clusterType": { + "type": "string" + }, "sshKeyName": { "type": "string" }, diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index 86e1eed0..f9c2c460 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -531,6 +531,8 @@ definitions: type: integer clusterRegion: type: string + clusterType: + type: string sshKeyName: type: string tksCpNode: diff --git a/pkg/domain/cluster.go b/pkg/domain/cluster.go index 003e3549..64dee853 100644 --- a/pkg/domain/cluster.go +++ b/pkg/domain/cluster.go @@ -247,6 +247,7 @@ type SimpleClusterResponse struct { } type ClusterSiteValuesResponse struct { + ClusterType string `json:"clusterType"` SshKeyName string `json:"sshKeyName"` ClusterRegion string `json:"clusterRegion"` TksCpNode int `json:"tksCpNode"` From eb2d8fc053d27b6c4f6e4261ea9f8155ece5ba96 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Wed, 1 Nov 2023 13:35:28 +0900 Subject: [PATCH 2/5] bugfix. remove test code --- internal/delivery/http/cluster.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/delivery/http/cluster.go b/internal/delivery/http/cluster.go index 28a850a8..7565403b 100644 --- a/internal/delivery/http/cluster.go +++ b/internal/delivery/http/cluster.go @@ -220,7 +220,6 @@ func (h *ClusterHandler) ImportCluster(w http.ResponseWriter, r *http.Request) { dto.Conf.SetDefault() log.InfoWithContext(r.Context(), dto.Conf) - dto.CloudService = "AWS" dto.CloudAccountId = uuid.Nil clusterId, err := h.usecase.Import(r.Context(), dto) if err != nil { From 808e37318e5df8fa3227e3ee9802de0fb95a9973 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Wed, 1 Nov 2023 15:29:39 +0900 Subject: [PATCH 3/5] bugfix. change admin clutserId to tksadmin --- internal/usecase/cluster.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index cf339797..43a94679 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -238,8 +238,8 @@ func (u *ClusterUsecase) Import(ctx context.Context, dto domain.Cluster) (cluste userId := user.GetUserId() dto.CreatorId = &userId if dto.ClusterType == domain.ClusterType_ADMIN { - dto.ID = "tks-admin" - dto.Name = "tks-admin" + dto.ID = "tksadmin" + dto.Name = "tksadmin" } clusterId, err = u.repo.Create(dto) if err != nil { From 23d8cf50cc0510ee1fabe90c50b394ac64306794 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Thu, 2 Nov 2023 16:45:42 +0900 Subject: [PATCH 4/5] feature. change clusterId ctksadmin from tksadmin --- internal/helper/id.go | 4 ---- internal/usecase/cluster.go | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/helper/id.go b/internal/helper/id.go index a194a158..3e8225e1 100644 --- a/internal/helper/id.go +++ b/internal/helper/id.go @@ -7,7 +7,6 @@ import ( ) var ( - TKS_ADMIN = "tks-admin" PREFIX_USER_ID = "u" PREFIX_CLUSTER_ID = "c" PREFIX_ORGANIZATION_ID = "o" @@ -30,9 +29,6 @@ func GenerateApplicaionGroupId() string { } func ValidateClusterId(id string) bool { - if id == TKS_ADMIN { - return true - } if !strings.HasPrefix(id, PREFIX_CLUSTER_ID) { return false } diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index 43a94679..16df8b46 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -238,8 +238,8 @@ func (u *ClusterUsecase) Import(ctx context.Context, dto domain.Cluster) (cluste userId := user.GetUserId() dto.CreatorId = &userId if dto.ClusterType == domain.ClusterType_ADMIN { - dto.ID = "tksadmin" - dto.Name = "tksadmin" + dto.ID = "ctksadmin" + dto.Name = "ctksadmin" } clusterId, err = u.repo.Create(dto) if err != nil { From 20763aaac52edf589c446aa2ce348c2396950ef5 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Fri, 3 Nov 2023 14:39:48 +0900 Subject: [PATCH 5/5] feature. rollback to tks-admin --- internal/helper/id.go | 4 ++++ internal/usecase/cluster.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/helper/id.go b/internal/helper/id.go index 3e8225e1..a194a158 100644 --- a/internal/helper/id.go +++ b/internal/helper/id.go @@ -7,6 +7,7 @@ import ( ) var ( + TKS_ADMIN = "tks-admin" PREFIX_USER_ID = "u" PREFIX_CLUSTER_ID = "c" PREFIX_ORGANIZATION_ID = "o" @@ -29,6 +30,9 @@ func GenerateApplicaionGroupId() string { } func ValidateClusterId(id string) bool { + if id == TKS_ADMIN { + return true + } if !strings.HasPrefix(id, PREFIX_CLUSTER_ID) { return false } diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index 16df8b46..cf339797 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -238,8 +238,8 @@ func (u *ClusterUsecase) Import(ctx context.Context, dto domain.Cluster) (cluste userId := user.GetUserId() dto.CreatorId = &userId if dto.ClusterType == domain.ClusterType_ADMIN { - dto.ID = "ctksadmin" - dto.Name = "ctksadmin" + dto.ID = "tks-admin" + dto.Name = "tks-admin" } clusterId, err = u.repo.Create(dto) if err != nil {