Skip to content

Commit

Permalink
add drift detection internal endpoint (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes authored Sep 3, 2024
1 parent 7c38ccf commit fc02440
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions next/controllers/drift.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package controllers

import (
"github.com/gin-gonic/gin"
"log"
"net/http"
)

type TriggerDriftRequest struct {
ProjectId string `json:"project_id"`
}

func (d DiggerController) TriggerDriftDetectionForProject(c *gin.Context) {

var request TriggerDriftRequest

err := c.BindJSON(&request)

if err != nil {
log.Printf("Error binding JSON: %v", err)
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid payload received"})
return
}
projectId := request.ProjectId

c.JSON(200, gin.H{
"status": "successful",
"project_id": projectId,
})
return

}
1 change: 1 addition & 0 deletions next/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func main() {
r.POST("/github-app-webhook", diggerController.GithubAppWebHook)

r.POST("/_internal/process_runs_queue", middleware.WebhookAuth(), diggerController.ProcessRunQueueItems)
r.POST("/_internal/trigger_drift", middleware.WebhookAuth(), diggerController.TriggerDriftDetectionForProject)
//authorized := r.Group("/")
//authorized.Use(middleware.GetApiMiddleware(), middleware.AccessLevel(dbmodels.CliJobAccessType, dbmodels.AccessPolicyType, models.AdminPolicyType))

Expand Down

0 comments on commit fc02440

Please sign in to comment.