From 481e0194504c55f38ae6ce6a614977eadaf43db4 Mon Sep 17 00:00:00 2001 From: donggyu Date: Fri, 15 Mar 2024 14:55:21 +0900 Subject: [PATCH] fix conflict during rebase --- internal/delivery/http/alert.go | 12 +++---- internal/delivery/http/app-group.go | 12 +++---- internal/delivery/http/app-serve-app.go | 28 ++++++++-------- internal/delivery/http/audit.go | 6 ++-- internal/delivery/http/auth.go | 2 +- internal/delivery/http/cloud-account.go | 14 ++++---- internal/delivery/http/cluster.go | 10 +++--- internal/delivery/http/dashboard.go | 8 ++--- internal/delivery/http/organization.go | 24 +++++++------- internal/delivery/http/permission.go | 6 ++-- internal/delivery/http/policy-template.go | 12 +++---- internal/delivery/http/project.go | 16 ++++----- internal/delivery/http/role.go | 4 +-- internal/delivery/http/stack-template.go | 40 +++++++++++------------ internal/delivery/http/stack.go | 14 ++++---- internal/delivery/http/user.go | 28 ++++++++-------- internal/pagination/pagination.go | 7 ++-- internal/repository/policy-template.go | 4 +-- internal/serializer/serializer.go | 21 ++++++------ internal/usecase/cluster.go | 4 +-- internal/usecase/dashboard.go | 2 +- internal/usecase/organization.go | 2 +- internal/usecase/policy-template.go | 20 ++++++------ internal/usecase/project.go | 2 +- internal/usecase/stack.go | 10 +++--- pkg/domain/mapper.go | 0 26 files changed, 155 insertions(+), 153 deletions(-) delete mode 100644 pkg/domain/mapper.go diff --git a/internal/delivery/http/alert.go b/internal/delivery/http/alert.go index 4829e8d3..5ec1fa9b 100644 --- a/internal/delivery/http/alert.go +++ b/internal/delivery/http/alert.go @@ -126,13 +126,13 @@ func (h *AlertHandler) GetAlerts(w http.ResponseWriter, r *http.Request) { var out domain.GetAlertsResponse out.Alerts = make([]domain.AlertResponse, len(alerts)) for i, alert := range alerts { - if err := serializer.Map(alert, &out.Alerts[i]); err != nil { + if err := serializer.Map(r.Context(), alert, &out.Alerts[i]); err != nil { log.Info(r.Context(), err) } outAlertActions := make([]domain.AlertActionResponse, len(alert.AlertActions)) for j, alertAction := range alert.AlertActions { - if err := serializer.Map(alertAction, &outAlertActions[j]); err != nil { + if err := serializer.Map(r.Context(), alertAction, &outAlertActions[j]); err != nil { log.Info(r.Context(), err) } } @@ -142,7 +142,7 @@ func (h *AlertHandler) GetAlerts(w http.ResponseWriter, r *http.Request) { } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -182,12 +182,12 @@ func (h *AlertHandler) GetAlert(w http.ResponseWriter, r *http.Request) { } var out domain.GetAlertResponse - if err := serializer.Map(alert, &out.Alert); err != nil { + if err := serializer.Map(r.Context(), alert, &out.Alert); err != nil { log.Info(r.Context(), err) } outAlertActions := make([]domain.AlertActionResponse, len(alert.AlertActions)) for j, alertAction := range alert.AlertActions { - if err := serializer.Map(alertAction, &outAlertActions[j]); err != nil { + if err := serializer.Map(r.Context(), alertAction, &outAlertActions[j]); err != nil { log.Info(r.Context(), err) continue } @@ -274,7 +274,7 @@ func (h *AlertHandler) CreateAlertAction(w http.ResponseWriter, r *http.Request) log.Info(r.Context(), "alert : ", helper.ModelToJson(input)) var dto model.AlertAction - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.AlertId = alertId diff --git a/internal/delivery/http/app-group.go b/internal/delivery/http/app-group.go index dd7142a3..0a497091 100644 --- a/internal/delivery/http/app-group.go +++ b/internal/delivery/http/app-group.go @@ -45,7 +45,7 @@ func (h *AppGroupHandler) CreateAppGroup(w http.ResponseWriter, r *http.Request) } var dto model.AppGroup - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } @@ -96,13 +96,13 @@ func (h *AppGroupHandler) GetAppGroups(w http.ResponseWriter, r *http.Request) { var out domain.GetAppGroupsResponse out.AppGroups = make([]domain.AppGroupResponse, len(appGroups)) for i, appGroup := range appGroups { - if err := serializer.Map(appGroup, &out.AppGroups[i]); err != nil { + if err := serializer.Map(r.Context(), appGroup, &out.AppGroups[i]); err != nil { log.Info(r.Context(), err) continue } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -139,7 +139,7 @@ func (h *AppGroupHandler) GetAppGroup(w http.ResponseWriter, r *http.Request) { } var out domain.GetAppGroupResponse - if err := serializer.Map(appGroup, &out.AppGroup); err != nil { + if err := serializer.Map(r.Context(), appGroup, &out.AppGroup); err != nil { log.Info(r.Context(), err) } @@ -225,7 +225,7 @@ func (h *AppGroupHandler) GetApplications(w http.ResponseWriter, r *http.Request var out domain.GetApplicationsResponse out.Applications = make([]domain.ApplicationResponse, len(applications)) for i, application := range applications { - if err := serializer.Map(application, &out.Applications[i]); err != nil { + if err := serializer.Map(r.Context(), application, &out.Applications[i]); err != nil { log.Info(r.Context(), err) continue } @@ -266,7 +266,7 @@ func (h *AppGroupHandler) CreateApplication(w http.ResponseWriter, r *http.Reque } var dto model.Application - if err := serializer.Map(input, &dto); err != nil { + if err := serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.AppGroupId = appGroupId diff --git a/internal/delivery/http/app-serve-app.go b/internal/delivery/http/app-serve-app.go index f75ff95c..2430d0e9 100644 --- a/internal/delivery/http/app-serve-app.go +++ b/internal/delivery/http/app-serve-app.go @@ -118,7 +118,7 @@ func (h *AppServeAppHandler) CreateAppServeApp(w http.ResponseWriter, r *http.Re (appReq).SetDefaultValue() var app model.AppServeApp - if err = serializer.Map(appReq, &app); err != nil { + if err = serializer.Map(r.Context(), appReq, &app); err != nil { ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) return } @@ -134,7 +134,7 @@ func (h *AppServeAppHandler) CreateAppServeApp(w http.ResponseWriter, r *http.Re app.CreatedAt = now var task model.AppServeAppTask - if err = serializer.Map(appReq, &task); err != nil { + if err = serializer.Map(r.Context(), appReq, &task); err != nil { ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) return } @@ -209,7 +209,7 @@ func (h *AppServeAppHandler) CreateAppServeApp(w http.ResponseWriter, r *http.Re } var out domain.CreateAppServeAppResponse - if err = serializer.Map(app, &out); err != nil { + if err = serializer.Map(r.Context(), app, &out); err != nil { ErrorJSON(w, r, err) return } @@ -268,13 +268,13 @@ func (h *AppServeAppHandler) GetAppServeApps(w http.ResponseWriter, r *http.Requ var out domain.GetAppServeAppsResponse out.AppServeApps = make([]domain.AppServeAppResponse, len(apps)) for i, app := range apps { - if err := serializer.Map(app, &out.AppServeApps[i]); err != nil { + if err := serializer.Map(r.Context(), app, &out.AppServeApps[i]); err != nil { log.Info(r.Context(), err) continue } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -338,7 +338,7 @@ func (h *AppServeAppHandler) GetAppServeApp(w http.ResponseWriter, r *http.Reque app.AppServeAppTasks = newTasks var out domain.GetAppServeAppResponse - if err := serializer.Map(app, &out.AppServeApp); err != nil { + if err := serializer.Map(r.Context(), app, &out.AppServeApp); err != nil { log.Info(r.Context(), err) } @@ -388,7 +388,7 @@ func (h *AppServeAppHandler) GetAppServeAppLatestTask(w http.ResponseWriter, r * } var out domain.GetAppServeAppTaskResponse - if err := serializer.Map(task, &out.AppServeAppTask); err != nil { + if err := serializer.Map(r.Context(), task, &out.AppServeAppTask); err != nil { log.Info(r.Context(), err) } @@ -478,13 +478,13 @@ func (h *AppServeAppHandler) GetAppServeAppTasksByAppId(w http.ResponseWriter, r var out domain.GetAppServeAppTasksResponse out.AppServeAppTasks = make([]domain.AppServeAppTaskResponse, len(tasks)) for i, task := range tasks { - if err := serializer.Map(task, &out.AppServeAppTasks[i]); err != nil { + if err := serializer.Map(r.Context(), task, &out.AppServeAppTasks[i]); err != nil { log.Info(r.Context(), err) continue } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -552,10 +552,10 @@ func (h *AppServeAppHandler) GetAppServeAppTaskDetail(w http.ResponseWriter, r * } var out domain.GetAppServeAppTaskResponse - if err := serializer.Map(app, &out.AppServeApp); err != nil { + if err := serializer.Map(r.Context(), app, &out.AppServeApp); err != nil { log.Info(r.Context(), err) } - if err := serializer.Map(task, &out.AppServeAppTask); err != nil { + if err := serializer.Map(r.Context(), task, &out.AppServeAppTask); err != nil { log.Info(r.Context(), err) } @@ -809,18 +809,18 @@ func (h *AppServeAppHandler) UpdateAppServeApp(w http.ResponseWriter, r *http.Re // break // } //} - //if err = serializer.Map(latestTask, &task); err != nil { + //if err = serializer.Map(r.Context(), latestTask, &task); err != nil { // ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) // return //} var latestTask = app.AppServeAppTasks[0] - if err = serializer.Map(latestTask, &task); err != nil { + if err = serializer.Map(r.Context(), latestTask, &task); err != nil { //ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) return } - if err = serializer.Map(appReq, &task); err != nil { + if err = serializer.Map(r.Context(), appReq, &task); err != nil { //ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) return } diff --git a/internal/delivery/http/audit.go b/internal/delivery/http/audit.go index 5b8defff..e95ae959 100644 --- a/internal/delivery/http/audit.go +++ b/internal/delivery/http/audit.go @@ -68,12 +68,12 @@ func (h *AuditHandler) GetAudits(w http.ResponseWriter, r *http.Request) { var out domain.GetAuditsResponse out.Audits = make([]domain.AuditResponse, len(audits)) for i, audit := range audits { - if err := serializer.Map(audit, &out.Audits[i]); err != nil { + if err := serializer.Map(r.Context(), audit, &out.Audits[i]); err != nil { log.Info(r.Context(), err) } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -113,7 +113,7 @@ func (h *AuditHandler) GetAudit(w http.ResponseWriter, r *http.Request) { log.Info(r.Context(), audit) var out domain.GetAuditResponse - if err := serializer.Map(audit, &out.Audit); err != nil { + if err := serializer.Map(r.Context(), audit, &out.Audit); err != nil { log.Info(r.Context(), err) } diff --git a/internal/delivery/http/auth.go b/internal/delivery/http/auth.go index 5208a42a..bf81e50e 100644 --- a/internal/delivery/http/auth.go +++ b/internal/delivery/http/auth.go @@ -97,7 +97,7 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) { } var out domain.LoginResponse - if err = serializer.Map(user, &out.User); err != nil { + if err = serializer.Map(r.Context(), user, &out.User); err != nil { log.Error(r.Context(), err) } diff --git a/internal/delivery/http/cloud-account.go b/internal/delivery/http/cloud-account.go index c2685eb8..53295041 100644 --- a/internal/delivery/http/cloud-account.go +++ b/internal/delivery/http/cloud-account.go @@ -55,7 +55,7 @@ func (h *CloudAccountHandler) CreateCloudAccount(w http.ResponseWriter, r *http. } var dto model.CloudAccount - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.OrganizationId = organizationId @@ -107,13 +107,13 @@ func (h *CloudAccountHandler) GetCloudAccounts(w http.ResponseWriter, r *http.Re var out domain.GetCloudAccountsResponse out.CloudAccounts = make([]domain.CloudAccountResponse, len(cloudAccounts)) for i, cloudAccount := range cloudAccounts { - if err := serializer.Map(cloudAccount, &out.CloudAccounts[i]); err != nil { + if err := serializer.Map(r.Context(), cloudAccount, &out.CloudAccounts[i]); err != nil { log.Info(r.Context(), err) continue } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -153,7 +153,7 @@ func (h *CloudAccountHandler) GetCloudAccount(w http.ResponseWriter, r *http.Req } var out domain.GetCloudAccountResponse - if err := serializer.Map(cloudAccount, &out.CloudAccount); err != nil { + if err := serializer.Map(r.Context(), cloudAccount, &out.CloudAccount); err != nil { log.Info(r.Context(), err) } @@ -200,7 +200,7 @@ func (h *CloudAccountHandler) UpdateCloudAccount(w http.ResponseWriter, r *http. } var dto model.CloudAccount - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.ID = cloudAccountId @@ -250,7 +250,7 @@ func (h *CloudAccountHandler) DeleteCloudAccount(w http.ResponseWriter, r *http. } var dto model.CloudAccount - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.ID = parsedId @@ -416,7 +416,7 @@ func (h *CloudAccountHandler) GetResourceQuota(w http.ResponseWriter, r *http.Re } var out domain.GetCloudAccountResourceQuotaResponse - if err := serializer.Map(resourceQuota, &out.ResourceQuota); err != nil { + if err := serializer.Map(r.Context(), resourceQuota, &out.ResourceQuota); err != nil { log.Info(r.Context(), err) } out.Available = available diff --git a/internal/delivery/http/cluster.go b/internal/delivery/http/cluster.go index 7dea7c9e..b67042e4 100644 --- a/internal/delivery/http/cluster.go +++ b/internal/delivery/http/cluster.go @@ -54,7 +54,7 @@ func (h *ClusterHandler) GetClusters(w http.ResponseWriter, r *http.Request) { var out domain.GetClustersResponse out.Clusters = make([]domain.ClusterResponse, len(clusters)) for i, cluster := range clusters { - if err := serializer.Map(cluster, &out.Clusters[i]); err != nil { + if err := serializer.Map(r.Context(), cluster, &out.Clusters[i]); err != nil { log.Info(r.Context(), err) continue } @@ -67,7 +67,7 @@ func (h *ClusterHandler) GetClusters(w http.ResponseWriter, r *http.Request) { } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -100,7 +100,7 @@ func (h *ClusterHandler) GetCluster(w http.ResponseWriter, r *http.Request) { } var out domain.GetClusterResponse - if err := serializer.Map(cluster, &out.Cluster); err != nil { + if err := serializer.Map(r.Context(), cluster, &out.Cluster); err != nil { log.Info(r.Context(), err) } @@ -158,7 +158,7 @@ func (h *ClusterHandler) CreateCluster(w http.ResponseWriter, r *http.Request) { } var dto model.Cluster - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } @@ -212,7 +212,7 @@ func (h *ClusterHandler) ImportCluster(w http.ResponseWriter, r *http.Request) { } var dto model.Cluster - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.SetDefaultConf() diff --git a/internal/delivery/http/dashboard.go b/internal/delivery/http/dashboard.go index 55c75cd5..69e49c6f 100644 --- a/internal/delivery/http/dashboard.go +++ b/internal/delivery/http/dashboard.go @@ -74,7 +74,7 @@ func (h *DashboardHandler) GetCharts(w http.ResponseWriter, r *http.Request) { var out domain.GetDashboardChartsResponse out.Charts = make([]domain.DashboardChartResponse, len(charts)) for i, chart := range charts { - if err := serializer.Map(chart, &out.Charts[i]); err != nil { + if err := serializer.Map(r.Context(), chart, &out.Charts[i]); err != nil { log.Info(r.Context(), err) continue } @@ -153,7 +153,7 @@ func (h *DashboardHandler) GetChart(w http.ResponseWriter, r *http.Request) { } var out domain.DashboardChartResponse - if err := serializer.Map(charts[0], &out); err != nil { + if err := serializer.Map(r.Context(), charts[0], &out); err != nil { log.Info(r.Context(), err) } @@ -193,7 +193,7 @@ func (h *DashboardHandler) GetStacks(w http.ResponseWriter, r *http.Request) { var out domain.GetDashboardStacksResponse out.Stacks = make([]domain.DashboardStackResponse, len(stacks)) for i, stack := range stacks { - if err := serializer.Map(stack, &out.Stacks[i]); err != nil { + if err := serializer.Map(r.Context(), stack, &out.Stacks[i]); err != nil { log.Info(r.Context(), err) continue } @@ -231,7 +231,7 @@ func (h *DashboardHandler) GetResources(w http.ResponseWriter, r *http.Request) return } var out domain.GetDashboardResourcesResponse - if err := serializer.Map(resources, &out.Resources); err != nil { + if err := serializer.Map(r.Context(), resources, &out.Resources); err != nil { log.Info(r.Context(), err) } diff --git a/internal/delivery/http/organization.go b/internal/delivery/http/organization.go index a224781d..683873d4 100644 --- a/internal/delivery/http/organization.go +++ b/internal/delivery/http/organization.go @@ -55,7 +55,7 @@ func (h *OrganizationHandler) CreateOrganization(w http.ResponseWriter, r *http. ctx := r.Context() var organization model.Organization - if err = serializer.Map(input, &organization); err != nil { + if err = serializer.Map(r.Context(), input, &organization); err != nil { log.Error(r.Context(), err) } @@ -122,14 +122,14 @@ func (h *OrganizationHandler) CreateOrganization(w http.ResponseWriter, r *http. err = h.usecase.ChangeAdminId(r.Context(), organizationId, admin.ID) if err != nil { - log.ErrorfWithContext(r.Context(), "error is :%s(%T)", err.Error(), err) + log.Errorf(r.Context(), "error is :%s(%T)", err.Error(), err) ErrorJSON(w, r, err) return } organization.AdminId = &admin.ID var out domain.CreateOrganizationResponse - if err = serializer.Map(organization, &out); err != nil { + if err = serializer.Map(r.Context(), organization, &out); err != nil { log.Error(r.Context(), err) } @@ -166,14 +166,14 @@ func (h *OrganizationHandler) GetOrganizations(w http.ResponseWriter, r *http.Re out.Organizations = make([]domain.OrganizationResponse, len(*organizations)) for i, organization := range *organizations { - if err = serializer.Map(organization, &out.Organizations[i]); err != nil { + if err = serializer.Map(r.Context(), organization, &out.Organizations[i]); err != nil { log.Error(r.Context(), err) } log.Info(r.Context(), organization) } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -211,24 +211,24 @@ func (h *OrganizationHandler) GetOrganization(w http.ResponseWriter, r *http.Req return } var out domain.GetOrganizationResponse - if err = serializer.Map(organization, &out.Organization); err != nil { + if err = serializer.Map(r.Context(), organization, &out.Organization); err != nil { log.Error(r.Context(), err) } out.Organization.StackTemplates = make([]domain.SimpleStackTemplateResponse, len(organization.StackTemplates)) for i, stackTemplate := range organization.StackTemplates { - if err = serializer.Map(stackTemplate, &out.Organization.StackTemplates[i]); err != nil { - log.ErrorWithContext(r.Context(), err) + if err = serializer.Map(r.Context(), stackTemplate, &out.Organization.StackTemplates[i]); err != nil { + log.Error(r.Context(), err) } err := json.Unmarshal(stackTemplate.Services, &out.Organization.StackTemplates[i].Services) if err != nil { - log.ErrorWithContext(r.Context(), err) + log.Error(r.Context(), err) } } out.Organization.PolicyTemplates = make([]domain.SimplePolicyTemplateResponse, len(organization.PolicyTemplates)) for i, policyTemplate := range organization.PolicyTemplates { - if err = serializer.Map(policyTemplate, &out.Organization.PolicyTemplates[i]); err != nil { - log.ErrorWithContext(r.Context(), err) + if err = serializer.Map(r.Context(), policyTemplate, &out.Organization.PolicyTemplates[i]); err != nil { + log.Error(r.Context(), err) } } @@ -325,7 +325,7 @@ func (h *OrganizationHandler) UpdateOrganization(w http.ResponseWriter, r *http. } var out domain.UpdateOrganizationResponse - if err = serializer.Map(organization, &out); err != nil { + if err = serializer.Map(r.Context(), organization, &out); err != nil { log.Error(r.Context(), err) } diff --git a/internal/delivery/http/permission.go b/internal/delivery/http/permission.go index 488c971a..84ea905d 100644 --- a/internal/delivery/http/permission.go +++ b/internal/delivery/http/permission.go @@ -42,7 +42,7 @@ func (h PermissionHandler) GetPermissionTemplates(w http.ResponseWriter, r *http permissionSet := model.NewDefaultPermissionSet() var premissionSetResponse domain.PermissionSetResponse - if err := serializer.Map(permissionSet, &premissionSetResponse); err != nil { + if err := serializer.Map(r.Context(), permissionSet, &premissionSetResponse); err != nil { log.Info(r.Context(), err) } @@ -86,7 +86,7 @@ func (h PermissionHandler) GetPermissionsByRoleId(w http.ResponseWriter, r *http } var premissionSetResponse domain.PermissionSetResponse - if err := serializer.Map(permissionSet, &premissionSetResponse); err != nil { + if err := serializer.Map(r.Context(), permissionSet, &premissionSetResponse); err != nil { log.Info(r.Context(), err) } @@ -135,7 +135,7 @@ func (h PermissionHandler) UpdatePermissionsByRoleId(w http.ResponseWriter, r *h for _, permissionResponse := range input.Permissions { var permission model.Permission - if err := serializer.Map(permissionResponse, &permission); err != nil { + if err := serializer.Map(r.Context(), permissionResponse, &permission); err != nil { log.Info(r.Context(), err) } diff --git a/internal/delivery/http/policy-template.go b/internal/delivery/http/policy-template.go index 20590ece..ccb5ada7 100644 --- a/internal/delivery/http/policy-template.go +++ b/internal/delivery/http/policy-template.go @@ -69,7 +69,7 @@ func (h *PolicyTemplateHandler) CreatePolicyTemplate(w http.ResponseWriter, r *h } var dto model.PolicyTemplate - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } @@ -229,7 +229,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplate(w http.ResponseWriter, r *http } var out domain.GetPolicyTemplateResponse - if err = serializer.Map(*policyTemplate, &out.PolicyTemplate); err != nil { + if err = serializer.Map(r.Context(), *policyTemplate, &out.PolicyTemplate); err != nil { log.Error(r.Context(), err) } @@ -265,13 +265,13 @@ func (h *PolicyTemplateHandler) ListPolicyTemplate(w http.ResponseWriter, r *htt var out domain.ListPolicyTemplateResponse out.PolicyTemplates = make([]domain.PolicyTemplateResponse, len(policyTemplates)) for i, policyTemplate := range policyTemplates { - if err := serializer.Map(policyTemplate, &out.PolicyTemplates[i]); err != nil { + if err := serializer.Map(r.Context(), policyTemplate, &out.PolicyTemplates[i]); err != nil { log.Info(r.Context(), err) continue } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -319,7 +319,7 @@ func (h *PolicyTemplateHandler) ListPolicyTemplateVersions(w http.ResponseWriter } var out domain.ListPolicyTemplateVersionsResponse - if err = serializer.Map(*policyTemplateVersions, &out); err != nil { + if err = serializer.Map(r.Context(), *policyTemplateVersions, &out); err != nil { log.Error(r.Context(), err) } @@ -426,7 +426,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplateVersion(w http.ResponseWriter, } var out domain.GetPolicyTemplateVersionResponse - if err = serializer.Map(*policyTemplate, &out.PolicyTemplate); err != nil { + if err = serializer.Map(r.Context(), *policyTemplate, &out.PolicyTemplate); err != nil { log.Error(r.Context(), err) } diff --git a/internal/delivery/http/project.go b/internal/delivery/http/project.go index 015c4c48..10c38379 100644 --- a/internal/delivery/http/project.go +++ b/internal/delivery/http/project.go @@ -189,7 +189,7 @@ func (p ProjectHandler) GetProjects(w http.ResponseWriter, r *http.Request) { var out domain.GetProjectsResponse out.Projects = pr - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -231,7 +231,7 @@ func (p ProjectHandler) Admin_GetProjects(w http.ResponseWriter, r *http.Request var out domain.GetProjectsResponse out.Projects = pr - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -301,7 +301,7 @@ func (p ProjectHandler) GetProject(w http.ResponseWriter, r *http.Request) { } var pdr domain.ProjectDetailResponse - if err = serializer.Map(*project, &pdr); err != nil { + if err = serializer.Map(r.Context(), *project, &pdr); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -764,7 +764,7 @@ func (p ProjectHandler) GetProjectMembers(w http.ResponseWriter, r *http.Request } out = domain.GetProjectMembersResponse{ProjectMembers: pmrs} - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -1298,7 +1298,7 @@ func (p ProjectHandler) GetProjectNamespaces(w http.ResponseWriter, r *http.Requ pnrs := make([]domain.ProjectNamespaceResponse, 0) for _, pn := range pns { var pnr domain.ProjectNamespaceResponse - if err = serializer.Map(pn, &pnr); err != nil { + if err = serializer.Map(r.Context(), pn, &pnr); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -1382,7 +1382,7 @@ func (p ProjectHandler) GetProjectNamespace(w http.ResponseWriter, r *http.Reque } var pnr domain.ProjectNamespaceResponse - if err = serializer.Map(*pn, &pnr); err != nil { + if err = serializer.Map(r.Context(), *pn, &pnr); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -1631,7 +1631,7 @@ func (p ProjectHandler) GetProjectNamespaceK8sResources(w http.ResponseWriter, r } var out domain.GetProjectNamespaceK8sResourcesResponse - if err = serializer.Map(k8sResources, &out.K8sResources); err != nil { + if err = serializer.Map(r.Context(), k8sResources, &out.K8sResources); err != nil { log.Error(r.Context(), err) } ResponseJSON(w, r, http.StatusOK, out) @@ -1684,7 +1684,7 @@ func (p ProjectHandler) GetProjectNamespaceResourcesUsage(w http.ResponseWriter, } var out domain.GetProjectNamespaceResourcesUsageResponse - if err = serializer.Map(resourcesUsage, &out.ResourcesUsage); err != nil { + if err = serializer.Map(r.Context(), resourcesUsage, &out.ResourcesUsage); err != nil { log.Error(r.Context(), err) } ResponseJSON(w, r, http.StatusOK, out) diff --git a/internal/delivery/http/role.go b/internal/delivery/http/role.go index c760b9d2..8aebd4ab 100644 --- a/internal/delivery/http/role.go +++ b/internal/delivery/http/role.go @@ -143,7 +143,7 @@ func (h RoleHandler) ListTksRoles(w http.ResponseWriter, r *http.Request) { } } - if err := serializer.Map(*pg, &out.Pagination); err != nil { + if err := serializer.Map(r.Context(), *pg, &out.Pagination); err != nil { log.Info(r.Context(), err) } @@ -320,7 +320,7 @@ func (h RoleHandler) Admin_ListTksRoles(w http.ResponseWriter, r *http.Request) } } - if err := serializer.Map(*pg, &out.Pagination); err != nil { + if err := serializer.Map(r.Context(), *pg, &out.Pagination); err != nil { log.Info(r.Context(), err) } diff --git a/internal/delivery/http/stack-template.go b/internal/delivery/http/stack-template.go index a03b41fd..3297f29a 100644 --- a/internal/delivery/http/stack-template.go +++ b/internal/delivery/http/stack-template.go @@ -48,7 +48,7 @@ func (h *StackTemplateHandler) CreateStackTemplate(w http.ResponseWriter, r *htt } var dto model.StackTemplate - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } @@ -91,13 +91,13 @@ func (h *StackTemplateHandler) GetStackTemplates(w http.ResponseWriter, r *http. var out domain.GetStackTemplatesResponse out.StackTemplates = make([]domain.StackTemplateResponse, len(stackTemplates)) for i, stackTemplate := range stackTemplates { - if err := serializer.Map(stackTemplate, &out.StackTemplates[i]); err != nil { + if err := serializer.Map(r.Context(), stackTemplate, &out.StackTemplates[i]); err != nil { log.Info(r.Context(), err) } out.StackTemplates[i].Organizations = make([]domain.SimpleOrganizationResponse, len(stackTemplate.Organizations)) for j, organization := range stackTemplate.Organizations { - if err := serializer.Map(organization, &out.StackTemplates[i].Organizations[j]); err != nil { + if err := serializer.Map(r.Context(), organization, &out.StackTemplates[i].Organizations[j]); err != nil { log.Info(r.Context(), err) continue } @@ -109,7 +109,7 @@ func (h *StackTemplateHandler) GetStackTemplates(w http.ResponseWriter, r *http. } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -148,13 +148,13 @@ func (h *StackTemplateHandler) GetStackTemplate(w http.ResponseWriter, r *http.R } var out domain.GetStackTemplateResponse - if err := serializer.Map(stackTemplate, &out.StackTemplate); err != nil { + if err := serializer.Map(r.Context(), stackTemplate, &out.StackTemplate); err != nil { log.Info(r.Context(), err) } out.StackTemplate.Organizations = make([]domain.SimpleOrganizationResponse, len(stackTemplate.Organizations)) for i, organization := range stackTemplate.Organizations { - if err := serializer.Map(organization, &out.StackTemplate.Organizations[i]); err != nil { + if err := serializer.Map(r.Context(), organization, &out.StackTemplate.Organizations[i]); err != nil { log.Info(r.Context(), err) continue } @@ -194,7 +194,7 @@ func (h *StackTemplateHandler) UpdateStackTemplate(w http.ResponseWriter, r *htt } var dto model.StackTemplate - if err := serializer.Map(r, &dto); err != nil { + if err := serializer.Map(r.Context(), r, &dto); err != nil { log.Info(r.Context(), err) } dto.ID = stackTemplateId @@ -289,7 +289,7 @@ func (h *StackTemplateHandler) UpdateStackTemplateOrganizations(w http.ResponseW } var dto model.StackTemplate - if err := serializer.Map(input, &dto); err != nil { + if err := serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.ID = stackTemplateId @@ -336,25 +336,25 @@ func (h *StackTemplateHandler) GetOrganizationStackTemplates(w http.ResponseWrit var out domain.GetStackTemplatesResponse out.StackTemplates = make([]domain.StackTemplateResponse, len(stackTemplates)) for i, stackTemplate := range stackTemplates { - if err := serializer.Map(stackTemplate, &out.StackTemplates[i]); err != nil { - log.InfoWithContext(r.Context(), err) + if err := serializer.Map(r.Context(), stackTemplate, &out.StackTemplates[i]); err != nil { + log.Info(r.Context(), err) } out.StackTemplates[i].Organizations = make([]domain.SimpleOrganizationResponse, len(stackTemplate.Organizations)) for j, organization := range stackTemplate.Organizations { - if err := serializer.Map(organization, &out.StackTemplates[i].Organizations[j]); err != nil { - log.InfoWithContext(r.Context(), err) + if err := serializer.Map(r.Context(), organization, &out.StackTemplates[i].Organizations[j]); err != nil { + log.Info(r.Context(), err) } } err := json.Unmarshal(stackTemplate.Services, &out.StackTemplates[i].Services) if err != nil { - log.ErrorWithContext(r.Context(), err) + log.Error(r.Context(), err) } } - if out.Pagination, err = pg.Response(); err != nil { - log.InfoWithContext(r.Context(), err) + if out.Pagination, err = pg.Response(r.Context()); err != nil { + log.Info(r.Context(), err) } ResponseJSON(w, r, http.StatusOK, out) @@ -397,20 +397,20 @@ func (h *StackTemplateHandler) GetOrganizationStackTemplate(w http.ResponseWrite } var out domain.GetStackTemplateResponse - if err := serializer.Map(stackTemplate, &out.StackTemplate); err != nil { - log.InfoWithContext(r.Context(), err) + if err := serializer.Map(r.Context(), stackTemplate, &out.StackTemplate); err != nil { + log.Info(r.Context(), err) } out.StackTemplate.Organizations = make([]domain.SimpleOrganizationResponse, len(stackTemplate.Organizations)) for i, organization := range stackTemplate.Organizations { - if err := serializer.Map(organization, &out.StackTemplate.Organizations[i]); err != nil { - log.InfoWithContext(r.Context(), err) + if err := serializer.Map(r.Context(), organization, &out.StackTemplate.Organizations[i]); err != nil { + log.Info(r.Context(), err) } } err = json.Unmarshal(stackTemplate.Services, &out.StackTemplate.Services) if err != nil { - log.ErrorWithContext(r.Context(), err) + log.Error(r.Context(), err) } ResponseJSON(w, r, http.StatusOK, out) diff --git a/internal/delivery/http/stack.go b/internal/delivery/http/stack.go index be985e76..62f3ee7b 100644 --- a/internal/delivery/http/stack.go +++ b/internal/delivery/http/stack.go @@ -53,7 +53,7 @@ func (h *StackHandler) CreateStack(w http.ResponseWriter, r *http.Request) { } var dto model.Stack - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.OrganizationId = organizationId @@ -122,11 +122,11 @@ func (h *StackHandler) GetStacks(w http.ResponseWriter, r *http.Request) { var out domain.GetStacksResponse out.Stacks = make([]domain.StackResponse, len(stacks)) for i, stack := range stacks { - if err := serializer.Map(stack, &out.Stacks[i]); err != nil { + if err := serializer.Map(r.Context(), stack, &out.Stacks[i]); err != nil { log.Info(r.Context(), err) } - if err := serializer.Map(stack.CreatedAt, &out.Stacks[i].CreatedAt); err != nil { + if err := serializer.Map(r.Context(), stack.CreatedAt, &out.Stacks[i].CreatedAt); err != nil { log.Info(r.Context(), err) } @@ -136,7 +136,7 @@ func (h *StackHandler) GetStacks(w http.ResponseWriter, r *http.Request) { } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -170,7 +170,7 @@ func (h *StackHandler) GetStack(w http.ResponseWriter, r *http.Request) { } var out domain.GetStackResponse - if err := serializer.Map(stack, &out.Stack); err != nil { + if err := serializer.Map(r.Context(), stack, &out.Stack); err != nil { log.Info(r.Context(), err) } @@ -212,7 +212,7 @@ func (h *StackHandler) GetStackStatus(w http.ResponseWriter, r *http.Request) { var out domain.GetStackStatusResponse out.StepStatus = make([]domain.StackStepStatus, len(steps)) for i, step := range steps { - if err := serializer.Map(step, &out.StepStatus[i]); err != nil { + if err := serializer.Map(r.Context(), step, &out.StepStatus[i]); err != nil { log.Info(r.Context(), err) } } @@ -261,7 +261,7 @@ func (h *StackHandler) UpdateStack(w http.ResponseWriter, r *http.Request) { } var dto model.Stack - if err = serializer.Map(input, &dto); err != nil { + if err = serializer.Map(r.Context(), input, &dto); err != nil { log.Info(r.Context(), err) } dto.ID = stackId diff --git a/internal/delivery/http/user.go b/internal/delivery/http/user.go index 203194db..9d6f09ef 100644 --- a/internal/delivery/http/user.go +++ b/internal/delivery/http/user.go @@ -88,7 +88,7 @@ func (u UserHandler) Create(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var user model.User - if err = serializer.Map(input, &user); err != nil { + if err = serializer.Map(r.Context(), input, &user); err != nil { log.Error(r.Context(), err) } user.Organization = model.Organization{ @@ -121,7 +121,7 @@ func (u UserHandler) Create(w http.ResponseWriter, r *http.Request) { } var out domain.CreateUserResponse - if err = serializer.Map(*resUser, &out.User); err != nil { + if err = serializer.Map(r.Context(), *resUser, &out.User); err != nil { log.Error(r.Context(), err) } @@ -168,7 +168,7 @@ func (u UserHandler) Get(w http.ResponseWriter, r *http.Request) { } var out domain.GetUserResponse - if err = serializer.Map(*user, &out.User); err != nil { + if err = serializer.Map(r.Context(), *user, &out.User); err != nil { log.Error(r.Context(), err) } @@ -211,12 +211,12 @@ func (u UserHandler) List(w http.ResponseWriter, r *http.Request) { var out domain.ListUserResponse out.Users = make([]domain.ListUserBody, len(*users)) for i, user := range *users { - if err = serializer.Map(user, &out.Users[i]); err != nil { + if err = serializer.Map(r.Context(), user, &out.Users[i]); err != nil { log.Error(r.Context(), err) } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -300,7 +300,7 @@ func (u UserHandler) Update(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var user model.User - if err = serializer.Map(input, &user); err != nil { + if err = serializer.Map(r.Context(), input, &user); err != nil { ErrorJSON(w, r, err) return } @@ -334,7 +334,7 @@ func (u UserHandler) Update(w http.ResponseWriter, r *http.Request) { } var out domain.UpdateUserResponse - if err = serializer.Map(*resUser, &out.User); err != nil { + if err = serializer.Map(r.Context(), *resUser, &out.User); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -401,7 +401,7 @@ func (u UserHandler) GetMyProfile(w http.ResponseWriter, r *http.Request) { } var out domain.GetMyProfileResponse - if err = serializer.Map(*user, &out.User); err != nil { + if err = serializer.Map(r.Context(), *user, &out.User); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -453,7 +453,7 @@ func (u UserHandler) UpdateMyProfile(w http.ResponseWriter, r *http.Request) { ctx := r.Context() var user model.User - if err = serializer.Map(input, &user); err != nil { + if err = serializer.Map(r.Context(), input, &user); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -471,7 +471,7 @@ func (u UserHandler) UpdateMyProfile(w http.ResponseWriter, r *http.Request) { } var out domain.UpdateMyProfileResponse - if err = serializer.Map(*resUser, &out.User); err != nil { + if err = serializer.Map(r.Context(), *resUser, &out.User); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return @@ -801,12 +801,12 @@ func (u UserHandler) Admin_List(w http.ResponseWriter, r *http.Request) { var out admin_domain.ListUserResponse out.Users = make([]domain.ListUserBody, len(*users)) for i, user := range *users { - if err = serializer.Map(user, &out.Users[i]); err != nil { + if err = serializer.Map(r.Context(), user, &out.Users[i]); err != nil { log.Error(r.Context(), err) } } - if out.Pagination, err = pg.Response(); err != nil { + if out.Pagination, err = pg.Response(r.Context()); err != nil { log.Info(r.Context(), err) } @@ -851,7 +851,7 @@ func (u UserHandler) Admin_Get(w http.ResponseWriter, r *http.Request) { } var out admin_domain.GetUserResponse - if err = serializer.Map(*user, &out.User); err != nil { + if err = serializer.Map(r.Context(), *user, &out.User); err != nil { log.Error(r.Context(), err) } @@ -1010,7 +1010,7 @@ func (u UserHandler) Admin_Update(w http.ResponseWriter, r *http.Request) { } var out admin_domain.UpdateUserResponse - if err = serializer.Map(*resUser, &out.User); err != nil { + if err = serializer.Map(r.Context(), *resUser, &out.User); err != nil { log.Error(r.Context(), err) ErrorJSON(w, r, err) return diff --git a/internal/pagination/pagination.go b/internal/pagination/pagination.go index 591a498c..5630bbb2 100644 --- a/internal/pagination/pagination.go +++ b/internal/pagination/pagination.go @@ -1,6 +1,7 @@ package pagination import ( + "context" "net/url" "strconv" "strings" @@ -144,13 +145,13 @@ func (p *Pagination) Fetch(db *gorm.DB, dest interface{}) (*database.Paginator, return paginator, db } -func (p *Pagination) Response() (out domain.PaginationResponse, err error) { - if err := serializer.Map(*p, &out); err != nil { +func (p *Pagination) Response(ctx context.Context) (out domain.PaginationResponse, err error) { + if err := serializer.Map(ctx, *p, &out); err != nil { return out, err } out.Filters = make([]domain.FilterResponse, len(p.Filters)) for i, f := range p.Filters { - if err := serializer.Map(f, &out.Filters[i]); err != nil { + if err := serializer.Map(ctx, f, &out.Filters[i]); err != nil { continue } } diff --git a/internal/repository/policy-template.go b/internal/repository/policy-template.go index dcd45c22..92053bb4 100644 --- a/internal/repository/policy-template.go +++ b/internal/repository/policy-template.go @@ -188,10 +188,10 @@ func (r *PolicyTemplateRepository) Fetch(ctx context.Context, pg *pagination.Pag } func (r *PolicyTemplateRepository) reflectPolicyTemplate(ctx context.Context, policyTemplate model.PolicyTemplate, policyTemplateVersion model.PolicyTemplateSupportedVersion) (out model.PolicyTemplate) { - if err := serializer.Map(policyTemplate.Model, &out); err != nil { + if err := serializer.Map(ctx, policyTemplate.Model, &out); err != nil { log.Error(ctx, err) } - if err := serializer.Map(policyTemplate, &out); err != nil { + if err := serializer.Map(ctx, policyTemplate, &out); err != nil { log.Error(ctx, err) } out.TemplateName = policyTemplate.Name diff --git a/internal/serializer/serializer.go b/internal/serializer/serializer.go index 01fdec59..ddb434a7 100644 --- a/internal/serializer/serializer.go +++ b/internal/serializer/serializer.go @@ -1,6 +1,7 @@ package serializer import ( + "context" "fmt" "reflect" @@ -16,7 +17,7 @@ type compositeKey struct { dstType reflect.Type } -func recursiveMap(src interface{}, dst interface{}, converterMap ConverterMap) error { +func recursiveMap(ctx context.Context, src interface{}, dst interface{}, converterMap ConverterMap) error { srcVal := reflect.ValueOf(src) srcType := srcVal.Type() @@ -40,14 +41,14 @@ func recursiveMap(src interface{}, dst interface{}, converterMap ConverterMap) e dstField.Set(srcField) continue } else if srcField.Type().Kind() == reflect.Struct && dstField.Type().Kind() == reflect.Struct { - if err := recursiveMap(srcField.Interface(), dstField.Addr().Interface(), converterMap); err != nil { - log.Error(err) + if err := recursiveMap(ctx, srcField.Interface(), dstField.Addr().Interface(), converterMap); err != nil { + log.Error(ctx, err) continue } } else if srcField.Kind() == reflect.Pointer && dstField.Type().Kind() == reflect.Struct { if !reflect.Value.IsNil(srcField) { - if err := recursiveMap(srcField.Elem().Interface(), dstField.Addr().Interface(), converterMap); err != nil { - log.Error(err) + if err := recursiveMap(ctx, srcField.Elem().Interface(), dstField.Addr().Interface(), converterMap); err != nil { + log.Error(ctx, err) continue } } @@ -74,13 +75,13 @@ func recursiveMap(src interface{}, dst interface{}, converterMap ConverterMap) e converterKey := compositeKey{srcType: srcField.Type(), dstType: dstField.Type()} if converter, ok := converterMap[converterKey]; ok { if converted, err := converter(srcField.Interface()); err != nil { - log.Error(err) + log.Error(ctx, err) continue } else { dstField.Set(reflect.ValueOf(converted)) } } else { - log.Debugf("no converter found for %s -> %s", srcField.Type(), dstField.Type()) + log.Debugf(ctx, "no converter found for %s -> %s", srcField.Type(), dstField.Type()) continue } } @@ -96,7 +97,7 @@ func recursiveMap(src interface{}, dst interface{}, converterMap ConverterMap) e */ } else { if fieldName == "Model" { - if err := recursiveMap(srcField.Interface(), dst, converterMap); err != nil { + if err := recursiveMap(ctx, srcField.Interface(), dst, converterMap); err != nil { return err } } @@ -106,8 +107,8 @@ func recursiveMap(src interface{}, dst interface{}, converterMap ConverterMap) e return nil } -func Map(src interface{}, dst interface{}) error { - return recursiveMap(src, dst, ConverterMap{ +func Map(ctx context.Context, src interface{}, dst interface{}) error { + return recursiveMap(ctx, src, dst, ConverterMap{ {srcType: reflect.TypeOf((*uuid.UUID)(nil)).Elem(), dstType: reflect.TypeOf("")}: func(i interface{}) (interface{}, error) { return i.(uuid.UUID).String(), nil }, diff --git a/internal/usecase/cluster.go b/internal/usecase/cluster.go index 52fb3287..a2b04912 100644 --- a/internal/usecase/cluster.go +++ b/internal/usecase/cluster.go @@ -457,7 +457,7 @@ func (u *ClusterUsecase) GetClusterSiteValues(ctx context.Context, clusterId dom out.SshKeyName = "tks-seoul" out.ClusterRegion = "ap-northeast-2" - if err := serializer.Map(cluster, &out); err != nil { + if err := serializer.Map(ctx, cluster, &out); err != nil { log.Error(ctx, err) } @@ -466,7 +466,7 @@ func (u *ClusterUsecase) GetClusterSiteValues(ctx context.Context, clusterId dom out.TksUserNodeMax = cluster.TksUserNodeMax / domain.MAX_AZ_NUM } - if err := serializer.Map(cluster, &out); err != nil { + if err := serializer.Map(ctx, cluster, &out); err != nil { log.Error(ctx, err) } diff --git a/internal/usecase/dashboard.go b/internal/usecase/dashboard.go index 12d15d91..40a8b9b4 100644 --- a/internal/usecase/dashboard.go +++ b/internal/usecase/dashboard.go @@ -105,7 +105,7 @@ func (u *DashboardUsecase) GetStacks(ctx context.Context, organizationId string) } stack := reflectClusterToStack(ctx, cluster, appGroups) dashboardStack := domain.DashboardStack{} - if err := serializer.Map(stack, &dashboardStack); err != nil { + if err := serializer.Map(ctx, stack, &dashboardStack); err != nil { log.Info(ctx, err) } diff --git a/internal/usecase/organization.go b/internal/usecase/organization.go index 7fe6ea4f..83970930 100644 --- a/internal/usecase/organization.go +++ b/internal/usecase/organization.go @@ -105,7 +105,7 @@ func (u *OrganizationUsecase) Get(ctx context.Context, organizationId string) (o clusters, err := u.clusterRepo.FetchByOrganizationId(ctx, organizationId, uuid.Nil, nil) if err != nil { - log.Info(err) + log.Info(ctx, err) out.ClusterCount = 0 } out.ClusterCount = len(clusters) diff --git a/internal/usecase/policy-template.go b/internal/usecase/policy-template.go index ed503e7a..7f38429e 100644 --- a/internal/usecase/policy-template.go +++ b/internal/usecase/policy-template.go @@ -91,9 +91,9 @@ func (u *PolicyTemplateUsecase) Fetch(ctx context.Context, pg *pagination.Pagina organizations, err := u.organizationRepo.Fetch(ctx, nil) if err == nil { for i, policyTemplate := range policyTemplates { - permittedOrgIdSet := u.getPermittedOrganiationIdSet(&policyTemplate) + permittedOrgIdSet := u.getPermittedOrganiationIdSet(ctx, &policyTemplate) - u.updatePermittedOrganizations(organizations, permittedOrgIdSet, &policyTemplates[i]) + u.updatePermittedOrganizations(ctx, organizations, permittedOrgIdSet, &policyTemplates[i]) } } @@ -108,11 +108,11 @@ func (u *PolicyTemplateUsecase) Get(ctx context.Context, policyTemplateID uuid.U return nil, err } - permittedOrgIdSet := u.getPermittedOrganiationIdSet(policyTemplate) + permittedOrgIdSet := u.getPermittedOrganiationIdSet(ctx, policyTemplate) organizations, err := u.organizationRepo.Fetch(ctx, nil) if err == nil { - u.updatePermittedOrganizations(organizations, permittedOrgIdSet, policyTemplate) + u.updatePermittedOrganizations(ctx, organizations, permittedOrgIdSet, policyTemplate) } return policyTemplate, nil @@ -182,21 +182,21 @@ func (u *PolicyTemplateUsecase) GetPolicyTemplateVersion(ctx context.Context, po return nil, err } - permittedOrgIdSet := u.getPermittedOrganiationIdSet(policyTemplate) + permittedOrgIdSet := u.getPermittedOrganiationIdSet(ctx, policyTemplate) organizations, err := u.organizationRepo.Fetch(ctx, nil) if err == nil { - u.updatePermittedOrganizations(organizations, permittedOrgIdSet, policyTemplate) + u.updatePermittedOrganizations(ctx, organizations, permittedOrgIdSet, policyTemplate) } return policyTemplate, nil } -func (*PolicyTemplateUsecase) updatePermittedOrganizations(organizations *[]model.Organization, permittedOrgIdSet map[string]string, policyTemplate *model.PolicyTemplate) { +func (*PolicyTemplateUsecase) updatePermittedOrganizations(ctx context.Context, organizations *[]model.Organization, permittedOrgIdSet map[string]string, policyTemplate *model.PolicyTemplate) { // 허용리스트가 비어있으면 모든 Org에 대해서 허용 permitted := len(permittedOrgIdSet) == 0 - log.Info("CHECK HERE ", permitted) + log.Info(ctx, "CHECK HERE ", permitted) for _, organization := range *organizations { @@ -219,7 +219,7 @@ func (*PolicyTemplateUsecase) updatePermittedOrganizations(organizations *[]mode } } -func (*PolicyTemplateUsecase) getPermittedOrganiationIdSet(policyTemplate *model.PolicyTemplate) map[string]string { +func (*PolicyTemplateUsecase) getPermittedOrganiationIdSet(ctx context.Context, policyTemplate *model.PolicyTemplate) map[string]string { permittedOrgIdSet := make(map[string]string) for _, permittedOrg := range policyTemplate.PermittedOrganizations { @@ -228,7 +228,7 @@ func (*PolicyTemplateUsecase) getPermittedOrganiationIdSet(policyTemplate *model // ktkfree : 이부분 확인 부탁 드립니다. // //permittedOrgIdSet[permittedOrg.OrganizationId] = "1" - log.Info("CHECK HERE ", permittedOrg) + log.Info(ctx, "CHECK HERE ", permittedOrg) } return permittedOrgIdSet } diff --git a/internal/usecase/project.go b/internal/usecase/project.go index 2fa7d364..817eb24e 100644 --- a/internal/usecase/project.go +++ b/internal/usecase/project.go @@ -274,7 +274,7 @@ func (u *ProjectUsecase) GetProjectUser(ctx context.Context, projectUserId strin return nil, errors.Wrap(err, "Failed to retrieve user by id") } var pu model.ProjectUser - if err = serializer.Map(user, &pu); err != nil { + if err = serializer.Map(ctx, user, &pu); err != nil { log.Error(ctx, err) return nil, err } diff --git a/internal/usecase/stack.go b/internal/usecase/stack.go index f49dc70c..00a2e6c9 100644 --- a/internal/usecase/stack.go +++ b/internal/usecase/stack.go @@ -104,7 +104,7 @@ func (u *StackUsecase) Create(ctx context.Context, dto model.Stack) (stackId dom // Make stack nodes var stackConf domain.StackConfResponse - if err = serializer.Map(dto, &stackConf); err != nil { + if err = serializer.Map(ctx, dto, &stackConf); err != nil { log.Info(ctx, err) } if stackTemplate.CloudService == "AWS" && stackTemplate.KubeType == "AWS" { @@ -197,7 +197,7 @@ func (u *StackUsecase) Install(ctx context.Context, stackId domain.StackId) (err // Make stack nodes var stackConf domain.StackConfResponse - if err = serializer.Map(cluster, &stackConf); err != nil { + if err = serializer.Map(ctx, cluster, &stackConf); err != nil { log.Info(ctx, err) } @@ -250,7 +250,7 @@ func (u *StackUsecase) Get(ctx context.Context, stackId domain.StackId) (out mod for _, resource := range stackResources { if resource.ID == domain.StackId(cluster.ID) { - if err := serializer.Map(resource, &out.Resource); err != nil { + if err := serializer.Map(ctx, resource, &out.Resource); err != nil { log.Error(ctx, err) } } @@ -337,7 +337,7 @@ func (u *StackUsecase) Fetch(ctx context.Context, organizationId string, pg *pag for _, resource := range stackResources { if resource.ID == domain.StackId(cluster.ID) { - if err := serializer.Map(resource, &outStack.Resource); err != nil { + if err := serializer.Map(ctx, resource, &outStack.Resource); err != nil { log.Error(ctx, err) } } @@ -619,7 +619,7 @@ func (u *StackUsecase) DeleteFavorite(ctx context.Context, stackId domain.StackI } func reflectClusterToStack(ctx context.Context, cluster model.Cluster, appGroups []model.AppGroup) (out model.Stack) { - if err := serializer.Map(cluster, &out); err != nil { + if err := serializer.Map(ctx, cluster, &out); err != nil { log.Error(ctx, err) } diff --git a/pkg/domain/mapper.go b/pkg/domain/mapper.go deleted file mode 100644 index e69de29b..00000000