diff --git a/internal/delivery/http/stack.go b/internal/delivery/http/stack.go index a4e1a3e6..ed467a6b 100644 --- a/internal/delivery/http/stack.go +++ b/internal/delivery/http/stack.go @@ -66,11 +66,31 @@ func (h *StackHandler) CreateStack(w http.ResponseWriter, r *http.Request) { if err = serializer.Map(r.Context(), input, &dto.Conf); err != nil { log.Info(r.Context(), err) } - dto.Domains = make([]model.ClusterDomain, len(input.Domains)) - for i, domain := range input.Domains { - if err = serializer.Map(r.Context(), domain, &dto.Domains[i]); err != nil { - log.Info(r.Context(), err) - } + + dto.Domains = make([]model.ClusterDomain, 6) + dto.Domains[0] = model.ClusterDomain{ + DomainType: "grafana", + Url: input.Domain.Grafana, + } + dto.Domains[1] = model.ClusterDomain{ + DomainType: "loki", + Url: input.Domain.Loki, + } + dto.Domains[2] = model.ClusterDomain{ + DomainType: "minio", + Url: input.Domain.Minio, + } + dto.Domains[3] = model.ClusterDomain{ + DomainType: "thanos_sidecar", + Url: input.Domain.ThanosSidecar, + } + dto.Domains[4] = model.ClusterDomain{ + DomainType: "jaeger", + Url: input.Domain.Jaeger, + } + dto.Domains[5] = model.ClusterDomain{ + DomainType: "kiali", + Url: input.Domain.Kiali, } dto.OrganizationId = organizationId @@ -214,10 +234,20 @@ func (h *StackHandler) GetStack(w http.ResponseWriter, r *http.Request) { if err := serializer.Map(r.Context(), stack, &out.Stack); err != nil { log.Info(r.Context(), err) } - out.Stack.Domains = make([]domain.ClusterDomain, len(stack.Domains)) - for i, domain := range stack.Domains { - if err = serializer.Map(r.Context(), domain, &out.Stack.Domains[i]); err != nil { - log.Info(r.Context(), err) + for _, domain := range stack.Domains { + switch domain.DomainType { + case "grafana": + out.Stack.Domain.Grafana = domain.Url + case "loki": + out.Stack.Domain.Loki = domain.Url + case "minio": + out.Stack.Domain.Minio = domain.Url + case "thanos_sidecar": + out.Stack.Domain.ThanosSidecar = domain.Url + case "jaeger": + out.Stack.Domain.Jaeger = domain.Url + case "kiali": + out.Stack.Domain.Kiali = domain.Url } } diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index 425bdd7d..1a76d3d7 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -543,6 +543,12 @@ func (u *ClusterUsecase) GetClusterSiteValues(ctx context.Context, clusterId dom if err := serializer.Map(ctx, cluster, &out); err != nil { log.Error(ctx, err) } + out.Domains = make([]domain.ClusterDomain, len(cluster.Domains)) + for i, domain := range cluster.Domains { + if err = serializer.Map(ctx, domain, &out.Domains[i]); err != nil { + log.Info(ctx, err) + } + } if cluster.StackTemplate.CloudService == "AWS" && cluster.StackTemplate.KubeType == "AWS" { out.TksUserNode = cluster.TksUserNode / domain.MAX_AZ_NUM diff --git a/pkg/domain/cluster.go b/pkg/domain/cluster.go index be1e7d55..f9bbb3bd 100644 --- a/pkg/domain/cluster.go +++ b/pkg/domain/cluster.go @@ -230,20 +230,21 @@ type SimpleClusterResponse struct { } type ClusterSiteValuesResponse struct { - ClusterType string `json:"clusterType"` - SshKeyName string `json:"sshKeyName"` - ClusterRegion string `json:"clusterRegion"` - TksCpNode int `json:"tksCpNode"` - TksCpNodeMax int `json:"tksCpNodeMax,omitempty"` - TksCpNodeType string `json:"tksCpNodeType,omitempty"` - TksInfraNode int `json:"tksInfraNode"` - TksInfraNodeMax int `json:"tksInfraNodeMax,omitempty"` - TksInfraNodeType string `json:"tksInfraNodeType,omitempty"` - TksUserNode int `json:"tksUserNode"` - TksUserNodeMax int `json:"tksUserNodeMax,omitempty"` - TksUserNodeType string `json:"tksUserNodeType,omitempty"` - ByoClusterEndpointHost string `json:"byoClusterEndpointHost"` - ByoClusterEndpointPort int `json:"byoClusterEndpointPort"` + ClusterType string `json:"clusterType"` + SshKeyName string `json:"sshKeyName"` + ClusterRegion string `json:"clusterRegion"` + TksCpNode int `json:"tksCpNode"` + TksCpNodeMax int `json:"tksCpNodeMax,omitempty"` + TksCpNodeType string `json:"tksCpNodeType,omitempty"` + TksInfraNode int `json:"tksInfraNode"` + TksInfraNodeMax int `json:"tksInfraNodeMax,omitempty"` + TksInfraNodeType string `json:"tksInfraNodeType,omitempty"` + TksUserNode int `json:"tksUserNode"` + TksUserNodeMax int `json:"tksUserNodeMax,omitempty"` + TksUserNodeType string `json:"tksUserNodeType,omitempty"` + ByoClusterEndpointHost string `json:"byoClusterEndpointHost"` + ByoClusterEndpointPort int `json:"byoClusterEndpointPort"` + Domains []ClusterDomain `json:"domains,omitempty"` } type GetClustersResponse struct { diff --git a/pkg/domain/stack.go b/pkg/domain/stack.go index afd7c0ee..dbd9b20e 100644 --- a/pkg/domain/stack.go +++ b/pkg/domain/stack.go @@ -83,24 +83,24 @@ type StackStepStatus struct { } type CreateStackRequest struct { - Name string `json:"name" validate:"required,name,rfc1123"` - Description string `json:"description"` - ClusterId string `json:"clusterId"` - CloudService string `json:"cloudService" validate:"required,oneof=AWS BYOH"` - StackTemplateId string `json:"stackTemplateId" validate:"required"` - CloudAccountId string `json:"cloudAccountId"` - ClusterEndpoint string `json:"userClusterEndpoint,omitempty"` - PolicyIds []string `json:"policyIds,omitempty"` - TksCpNode int `json:"tksCpNode"` - TksCpNodeMax int `json:"tksCpNodeMax,omitempty"` - TksCpNodeType string `json:"tksCpNodeType,omitempty"` - TksInfraNode int `json:"tksInfraNode"` - TksInfraNodeMax int `json:"tksInfraNodeMax,omitempty"` - TksInfraNodeType string `json:"tksInfraNodeType,omitempty"` - TksUserNode int `json:"tksUserNode"` - TksUserNodeMax int `json:"tksUserNodeMax,omitempty"` - TksUserNodeType string `json:"tksUserNodeType,omitempty"` - Domains []ClusterDomain `json:"domains,omitempty"` + Name string `json:"name" validate:"required,name,rfc1123"` + Description string `json:"description"` + ClusterId string `json:"clusterId"` + CloudService string `json:"cloudService" validate:"required,oneof=AWS BYOH"` + StackTemplateId string `json:"stackTemplateId" validate:"required"` + CloudAccountId string `json:"cloudAccountId"` + ClusterEndpoint string `json:"userClusterEndpoint,omitempty"` + PolicyIds []string `json:"policyIds,omitempty"` + TksCpNode int `json:"tksCpNode"` + TksCpNodeMax int `json:"tksCpNodeMax,omitempty"` + TksCpNodeType string `json:"tksCpNodeType,omitempty"` + TksInfraNode int `json:"tksInfraNode"` + TksInfraNodeMax int `json:"tksInfraNodeMax,omitempty"` + TksInfraNodeType string `json:"tksInfraNodeType,omitempty"` + TksUserNode int `json:"tksUserNode"` + TksUserNodeMax int `json:"tksUserNodeMax,omitempty"` + TksUserNodeType string `json:"tksUserNodeType,omitempty"` + Domain StackDomain `json:"domain,omitempty"` } type CreateStackResponse struct { @@ -119,6 +119,15 @@ type StackConfResponse struct { TksUserNodeType string `json:"tksUserNodeType,omitempty"` } +type StackDomain struct { + Grafana string `json:"grafana"` + Loki string `json:"loki"` + Minio string `json:"minio"` + ThanosSidecar string `json:"thanosSidecar"` + Jaeger string `json:"jaeger"` + Kiali string `json:"kiali"` +} + type StackResponse struct { ID StackId `json:"id"` Name string `json:"name"` @@ -137,7 +146,7 @@ type StackResponse struct { ClusterEndpoint string `json:"userClusterEndpoint,omitempty"` Resource DashboardStackResponse `json:"resource,omitempty"` AppServeAppCnt int `json:"appServeAppCnt"` - Domains []ClusterDomain `json:"domains"` + Domain StackDomain `json:"domain"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }