Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trivial. fix parameters for creating lma #532

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 65 additions & 42 deletions internal/delivery/http/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
6 changes: 2 additions & 4 deletions internal/usecase/app-group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions internal/usecase/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
Expand Down
2 changes: 2 additions & 0 deletions pkg/domain/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
Loading