provision_handler.go 815 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package api
  2. import (
  3. "net/http"
  4. "strconv"
  5. "github.com/go-chi/chi"
  6. "github.com/porter-dev/porter/internal/kubernetes"
  7. )
  8. // HandleProvisionTest will create a test resource by deploying a provisioner
  9. // container pod. This assumes the integration_id was passed as a query param
  10. func (app *App) HandleProvisionTest(w http.ResponseWriter, r *http.Request) {
  11. projID, err := strconv.ParseUint(chi.URLParam(r, "project_id"), 0, 64)
  12. if err != nil || projID == 0 {
  13. app.handleErrorFormDecoding(err, ErrProjectDecode, w)
  14. return
  15. }
  16. // create a new agent
  17. agent, err := kubernetes.GetAgentInClusterConfig()
  18. if err != nil {
  19. app.handleErrorDataRead(err, w)
  20. return
  21. }
  22. _, err = agent.ProvisionTest(uint(projID))
  23. if err != nil {
  24. app.handleErrorInternal(err, w)
  25. return
  26. }
  27. w.WriteHeader(http.StatusOK)
  28. }