integration_handler.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package api
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. ints "github.com/porter-dev/porter/internal/models/integrations"
  6. )
  7. // HandleListClusterIntegrations lists the cluster integrations available to the
  8. // instance
  9. func (app *App) HandleListClusterIntegrations(w http.ResponseWriter, r *http.Request) {
  10. clusters := ints.PorterClusterIntegrations
  11. w.WriteHeader(http.StatusOK)
  12. if err := json.NewEncoder(w).Encode(&clusters); err != nil {
  13. app.handleErrorFormDecoding(err, ErrProjectDecode, w)
  14. return
  15. }
  16. }
  17. // HandleListRegistryIntegrations lists the image registry integrations available to the
  18. // instance
  19. func (app *App) HandleListRegistryIntegrations(w http.ResponseWriter, r *http.Request) {
  20. registries := ints.PorterRegistryIntegrations
  21. w.WriteHeader(http.StatusOK)
  22. if err := json.NewEncoder(w).Encode(&registries); err != nil {
  23. app.handleErrorFormDecoding(err, ErrProjectDecode, w)
  24. return
  25. }
  26. }
  27. // HandleListRepoIntegrations lists the repo integrations available to the
  28. // instance
  29. func (app *App) HandleListRepoIntegrations(w http.ResponseWriter, r *http.Request) {
  30. repos := ints.PorterRepoIntegrations
  31. w.WriteHeader(http.StatusOK)
  32. if err := json.NewEncoder(w).Encode(&repos); err != nil {
  33. app.handleErrorFormDecoding(err, ErrProjectDecode, w)
  34. return
  35. }
  36. }