MCPcopy
hub / github.com/cyclops-ui/cyclops / ListModules

Method ListModules

cyclops-ctrl/internal/controller/modules.go:112–136  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

110}
111
112func (m *Modules) ListModules(ctx *gin.Context) {
113 ctx.Header("Access-Control-Allow-Origin", "*")
114
115 modules, err := m.kubernetesClient.ListModules()
116 if err != nil {
117 fmt.Println(err)
118 ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching modules", err.Error()))
119 return
120 }
121
122 dtoModules := mapper.ModuleListToDTO(modules)
123
124 for i, dtoModule := range dtoModules {
125 dtoModuleStatus, err := m.kubernetesClient.GetModuleResourcesHealth(dtoModule.Name)
126 if err != nil {
127 fmt.Println(err)
128 ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching modules", err.Error()))
129 return
130 }
131
132 dtoModules[i].Status = dtoModuleStatus
133 }
134
135 ctx.JSON(http.StatusOK, dtoModules)
136}
137
138func (m *Modules) DeleteModule(ctx *gin.Context) {
139 ctx.Header("Access-Control-Allow-Origin", "*")

Callers

nothing calls this directly

Calls 4

PrintlnMethod · 0.80
ErrorMethod · 0.80
ListModulesMethod · 0.65

Tested by

no test coverage detected