From e3c37c5c46c25d087dfb60608dd9b60ed01f138b Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Tue, 16 Jul 2024 15:02:02 +0900 Subject: [PATCH 1/2] trivial. fix parameters for creating lma --- internal/usecase/app-group.go | 6 ++---- internal/usecase/cluster.go | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/usecase/app-group.go b/internal/usecase/app-group.go index 9d9490d5..37896b64 100644 --- a/internal/usecase/app-group.go +++ b/internal/usecase/app-group.go @@ -80,8 +80,7 @@ func (u *AppGroupUsecase) Create(ctx context.Context, dto model.AppGroup) (id do // check cloudAccount tksCloudAccountId := "" - //tksObjectStore := "minio" // FOR TEST - tksObjectStore := "s3" + tksObjectStore := "minio" if cluster.CloudService != domain.CloudService_BYOH { tksObjectStore = "s3" cloudAccounts, err := u.cloudAccountRepo.Fetch(ctx, cluster.OrganizationId, nil) @@ -181,8 +180,7 @@ func (u *AppGroupUsecase) Delete(ctx context.Context, id domain.AppGroupId) (err // check cloudAccount tksCloudAccountId := "" - //tksObjectStore := "minio" // FOR TEST - tksObjectStore := "s3" + tksObjectStore := "minio" if cluster.CloudService != domain.CloudService_BYOH { tksObjectStore = "s3" cloudAccounts, err := u.cloudAccountRepo.Fetch(ctx, cluster.OrganizationId, nil) diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index 1a76d3d7..dcdd7e9e 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -417,6 +417,7 @@ func (u *ClusterUsecase) Install(ctx context.Context, clusterId domain.ClusterId "cloud_account_id=NULL", "base_repo_branch=" + viper.GetString("revision"), "keycloak_url=" + viper.GetString("keycloak-address"), + "policy_ids=", //"manifest_repo_url=" + viper.GetString("git-base-url") + "/" + viper.GetString("git-account") + "/" + clusterId + "-manifests", }, }) From 2d255a57ea4cf8f6047ed778b06e112aa91af744 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Tue, 16 Jul 2024 17:57:43 +0900 Subject: [PATCH 2/2] feature. add domain to clusterDomains --- internal/delivery/http/stack.go | 107 +++++++++++++++++++------------- pkg/domain/stack.go | 2 + 2 files changed, 67 insertions(+), 42 deletions(-) diff --git a/internal/delivery/http/stack.go b/internal/delivery/http/stack.go index ed467a6b..b7714901 100644 --- a/internal/delivery/http/stack.go +++ b/internal/delivery/http/stack.go @@ -67,32 +67,7 @@ func (h *StackHandler) CreateStack(w http.ResponseWriter, r *http.Request) { 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.Domains = clusterDomainFromRequest(input) dto.OrganizationId = organizationId stackId, err := h.usecase.Create(r.Context(), dto) if err != nil { @@ -234,22 +209,8 @@ 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) } - 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 - } - } + + out.Stack.Domain = clusterDomainFromResponse(stack.Domains) err = json.Unmarshal(stack.StackTemplate.Services, &out.Stack.StackTemplate.Services) if err != nil { @@ -612,3 +573,65 @@ func (h StackHandler) syncKeycloakWithClusterAdminPermission(ctx context.Context return nil } + +func clusterDomainFromRequest(input domain.CreateStackRequest) []model.ClusterDomain { + domains := make([]model.ClusterDomain, 6) + domains[0] = model.ClusterDomain{ + DomainType: "grafana", + Url: input.Domain.Grafana, + } + domains[1] = model.ClusterDomain{ + DomainType: "loki", + Url: input.Domain.Loki, + } + domains[2] = model.ClusterDomain{ + DomainType: "loki_user", + Url: input.Domain.LokiUser, + } + domains[3] = model.ClusterDomain{ + DomainType: "minio", + Url: input.Domain.Minio, + } + domains[4] = model.ClusterDomain{ + DomainType: "thanos_sidecar", + Url: input.Domain.ThanosSidecar, + } + domains[5] = model.ClusterDomain{ + DomainType: "thanos_ruler", + Url: input.Domain.ThanosRuler, + } + domains[6] = model.ClusterDomain{ + DomainType: "jaeger", + Url: input.Domain.Jaeger, + } + domains[7] = model.ClusterDomain{ + DomainType: "kiali", + Url: input.Domain.Kiali, + } + + return domains +} + +func clusterDomainFromResponse(domains []model.ClusterDomain) (out domain.StackDomain) { + for _, domain := range domains { + switch domain.DomainType { + case "grafana": + out.Grafana = domain.Url + case "loki": + out.Loki = domain.Url + case "loki_user": + out.LokiUser = domain.Url + case "minio": + out.Minio = domain.Url + case "thanos_sidecar": + out.ThanosSidecar = domain.Url + case "thanos_ruler": + out.ThanosRuler = domain.Url + case "jaeger": + out.Jaeger = domain.Url + case "kiali": + out.Kiali = domain.Url + } + } + return out +} diff --git a/pkg/domain/stack.go b/pkg/domain/stack.go index dbd9b20e..b8f1a5a3 100644 --- a/pkg/domain/stack.go +++ b/pkg/domain/stack.go @@ -122,8 +122,10 @@ type StackConfResponse struct { type StackDomain struct { Grafana string `json:"grafana"` Loki string `json:"loki"` + LokiUser string `json:"lokiUser"` Minio string `json:"minio"` ThanosSidecar string `json:"thanosSidecar"` + ThanosRuler string `json:"thanosRuler"` Jaeger string `json:"jaeger"` Kiali string `json:"kiali"` }