Skip to content

Commit

Permalink
feature. refactoring usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkfree committed Feb 21, 2024
1 parent 87f78e8 commit d4ee7d6
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 69 deletions.
52 changes: 52 additions & 0 deletions api/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,50 @@ const docTemplate = `{
}
}
},
"/organizations/{organizationId}/projects/{projectId}/kubeconfig": {
"get": {
"security": [
{
"JWT": []
}
],
"description": "Get project kubeconfig",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Projects"
],
"summary": "Get project kubeconfig",
"parameters": [
{
"type": "string",
"description": "Organization ID",
"name": "organizationId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Project ID",
"name": "projectId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.GetProjectKubeconfigResponse"
}
}
}
}
},
"/organizations/{organizationId}/projects/{projectId}/members": {
"get": {
"security": [
Expand Down Expand Up @@ -7093,6 +7137,14 @@ const docTemplate = `{
}
}
},
"domain.GetProjectKubeconfigResponse": {
"type": "object",
"properties": {
"kubeconfig": {
"type": "string"
}
}
},
"domain.GetProjectMemberCountResponse": {
"type": "object",
"properties": {
Expand Down
52 changes: 52 additions & 0 deletions api/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3328,6 +3328,50 @@
}
}
},
"/organizations/{organizationId}/projects/{projectId}/kubeconfig": {
"get": {
"security": [
{
"JWT": []
}
],
"description": "Get project kubeconfig",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Projects"
],
"summary": "Get project kubeconfig",
"parameters": [
{
"type": "string",
"description": "Organization ID",
"name": "organizationId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Project ID",
"name": "projectId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.GetProjectKubeconfigResponse"
}
}
}
}
},
"/organizations/{organizationId}/projects/{projectId}/members": {
"get": {
"security": [
Expand Down Expand Up @@ -7087,6 +7131,14 @@
}
}
},
"domain.GetProjectKubeconfigResponse": {
"type": "object",
"properties": {
"kubeconfig": {
"type": "string"
}
}
},
"domain.GetProjectMemberCountResponse": {
"type": "object",
"properties": {
Expand Down
33 changes: 33 additions & 0 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,11 @@ definitions:
type: string
type: object
type: object
domain.GetProjectKubeconfigResponse:
properties:
kubeconfig:
type: string
type: object
domain.GetProjectMemberCountResponse:
properties:
projectLeaderCount:
Expand Down Expand Up @@ -4425,6 +4430,34 @@ paths:
summary: Check duplicate appServeAppName
tags:
- AppServeApps
/organizations/{organizationId}/projects/{projectId}/kubeconfig:
get:
consumes:
- application/json
description: Get project kubeconfig
parameters:
- description: Organization ID
in: path
name: organizationId
required: true
type: string
- description: Project ID
in: path
name: projectId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.GetProjectKubeconfigResponse'
security:
- JWT: []
summary: Get project kubeconfig
tags:
- Projects
/organizations/{organizationId}/projects/{projectId}/members:
delete:
consumes:
Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type AlertHandler struct {
usecase usecase.IAlertUsecase
}

func NewAlertHandler(h usecase.IAlertUsecase) *AlertHandler {
func NewAlertHandler(h usecase.Usecase) *AlertHandler {
return &AlertHandler{
usecase: h,
usecase: h.Alert,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/app-group.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type AppGroupHandler struct {
usecase usecase.IAppGroupUsecase
}

func NewAppGroupHandler(h usecase.IAppGroupUsecase) *AppGroupHandler {
func NewAppGroupHandler(h usecase.Usecase) *AppGroupHandler {
return &AppGroupHandler{
usecase: h,
usecase: h.AppGroup,
}
}

Expand Down
14 changes: 7 additions & 7 deletions internal/delivery/http/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ type AppServeAppHandler struct {
usecase usecase.IAppServeAppUsecase
}

func NewAppServeAppHandler(h usecase.IAppServeAppUsecase) *AppServeAppHandler {
func NewAppServeAppHandler(h usecase.Usecase) *AppServeAppHandler {
return &AppServeAppHandler{
usecase: h,
usecase: h.AppServeApp,
}
}

Expand Down Expand Up @@ -289,10 +289,10 @@ func (h *AppServeAppHandler) GetAppServeApps(w http.ResponseWriter, r *http.Requ
// @Router /organizations/{organizationId}/projects/{projectId}/app-serve-apps/{appId} [get]
// @Security JWT
func (h *AppServeAppHandler) GetAppServeApp(w http.ResponseWriter, r *http.Request) {
//////////////////////////////////////////////////////////////////////////////////////////
// TODO: this API will'be deprecated soon once the new task-related API's are verified.
// Until then, this is available (except for stage info) just for backward compatibility.
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// TODO: this API will'be deprecated soon once the new task-related API's are verified.
// Until then, this is available (except for stage info) just for backward compatibility.
//////////////////////////////////////////////////////////////////////////////////////////

vars := mux.Vars(r)

Expand Down Expand Up @@ -333,7 +333,7 @@ func (h *AppServeAppHandler) GetAppServeApp(w http.ResponseWriter, r *http.Reque

var out domain.GetAppServeAppResponse
out.AppServeApp = *app
// NOTE: makeStages function's been changed to use task instead of app
// NOTE: makeStages function's been changed to use task instead of app
//out.Stages = makeStages(app)

ResponseJSON(w, r, http.StatusOK, out)
Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type AuthHandler struct {
usecase usecase.IAuthUsecase
}

func NewAuthHandler(h usecase.IAuthUsecase) IAuthHandler {
func NewAuthHandler(h usecase.Usecase) IAuthHandler {
return &AuthHandler{
usecase: h,
usecase: h.Auth,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/cloud-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type CloudAccountHandler struct {
usecase usecase.ICloudAccountUsecase
}

func NewCloudAccountHandler(h usecase.ICloudAccountUsecase) *CloudAccountHandler {
func NewCloudAccountHandler(h usecase.Usecase) *CloudAccountHandler {
return &CloudAccountHandler{
usecase: h,
usecase: h.CloudAccount,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type ClusterHandler struct {
usecase usecase.IClusterUsecase
}

func NewClusterHandler(h usecase.IClusterUsecase) *ClusterHandler {
func NewClusterHandler(h usecase.Usecase) *ClusterHandler {
return &ClusterHandler{
usecase: h,
usecase: h.Cluster,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type DashboardHandler struct {
usecase usecase.IDashboardUsecase
}

func NewDashboardHandler(h usecase.IDashboardUsecase) *DashboardHandler {
func NewDashboardHandler(h usecase.Usecase) *DashboardHandler {
return &DashboardHandler{
usecase: h,
usecase: h.Dashboard,
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/delivery/http/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ type OrganizationHandler struct {
userUsecase usecase.IUserUsecase
}

func NewOrganizationHandler(o usecase.IOrganizationUsecase, u usecase.IUserUsecase) *OrganizationHandler {
func NewOrganizationHandler(u usecase.Usecase) *OrganizationHandler {
return &OrganizationHandler{
usecase: o,
userUsecase: u,
usecase: u.Organization,
userUsecase: u.User,
}
}

Expand Down
11 changes: 6 additions & 5 deletions internal/delivery/http/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package http

import (
"fmt"
"github.com/google/uuid"
"github.com/openinfradev/tks-api/internal/middleware/auth/request"
"github.com/openinfradev/tks-api/internal/serializer"
"net/http"
"strings"
"time"

"github.com/google/uuid"
"github.com/openinfradev/tks-api/internal/middleware/auth/request"
"github.com/openinfradev/tks-api/internal/serializer"

"github.com/gorilla/mux"
"github.com/openinfradev/tks-api/internal/usecase"
"github.com/openinfradev/tks-api/pkg/domain"
Expand Down Expand Up @@ -54,9 +55,9 @@ type ProjectHandler struct {
usecase usecase.IProjectUsecase
}

func NewProjectHandler(u usecase.IProjectUsecase) IProjectHandler {
func NewProjectHandler(u usecase.Usecase) IProjectHandler {
return &ProjectHandler{
usecase: u,
usecase: u.Project,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/stack-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type StackTemplateHandler struct {
usecase usecase.IStackTemplateUsecase
}

func NewStackTemplateHandler(h usecase.IStackTemplateUsecase) *StackTemplateHandler {
func NewStackTemplateHandler(h usecase.Usecase) *StackTemplateHandler {
return &StackTemplateHandler{
usecase: h,
usecase: h.StackTemplate,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type StackHandler struct {
usecase usecase.IStackUsecase
}

func NewStackHandler(h usecase.IStackUsecase) *StackHandler {
func NewStackHandler(h usecase.Usecase) *StackHandler {
return &StackHandler{
usecase: h,
usecase: h.Stack,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/delivery/http/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ type UserHandler struct {
usecase usecase.IUserUsecase
}

func NewUserHandler(h usecase.IUserUsecase) IUserHandler {
func NewUserHandler(h usecase.Usecase) IUserHandler {
return &UserHandler{
usecase: h,
usecase: h.User,
}
}

Expand Down
Loading

0 comments on commit d4ee7d6

Please sign in to comment.