Skip to content

Commit 95f902d

Browse files
committed
make runs list nested
1 parent 63f509f commit 95f902d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

backend/controllers/runs.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ func RunsForProject(c *gin.Context) {
5050
return
5151
}
5252

53+
if project.OrganisationID != org.ID {
54+
log.Printf("Forbidden access: not allowed to access projectID: %v logged in org: %v", project.OrganisationID, org.ID)
55+
c.String(http.StatusForbidden, "No access to this project")
56+
return
57+
58+
}
59+
5360
runs, err := models.DB.ListDiggerRunsForProject(project.Name, project.Repo.ID)
5461
if err != nil {
5562
log.Printf("could not fetch runs: %v", err)
@@ -67,5 +74,15 @@ func RunsForProject(c *gin.Context) {
6774
}
6875
serializedRuns = append(serializedRuns, serializedRun)
6976
}
70-
c.JSON(http.StatusOK, serializedRuns)
77+
response := make(map[string]interface{})
78+
response["runs"] = serializedRuns
79+
c.JSON(http.StatusOK, response)
80+
}
81+
82+
func RunDetails(c *gin.Context) {
83+
//currentOrg, exists := c.Get(middleware.ORGANISATION_ID_KEY)
84+
//projectIdStr := c.Param("project_id")
85+
86+
response := make(map[string]interface{})
87+
c.JSON(http.StatusOK, response)
7188
}

backend/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ func main() {
167167
projectsApiGroup.GET("/", controllers.FindProjectsForOrg)
168168
projectsApiGroup.GET("/:project_id/runs", controllers.RunsForProject)
169169

170+
runsApiGroup := apiGroup.Group("/runs")
171+
runsApiGroup.Use(middleware.GetWebMiddleware())
172+
projectsApiGroup.GET("/:project_id/runs/:id", controllers.RunDetails)
173+
170174
fronteggWebhookProcessor.POST("/create-org-from-frontegg", controllers.CreateFronteggOrgFromWebhook)
171175

172176
r.Run(fmt.Sprintf(":%d", cfg.GetInt("port")))

0 commit comments

Comments
 (0)