list_templates.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package infra
  2. import (
  3. "net/http"
  4. "github.com/porter-dev/porter/api/server/handlers"
  5. "github.com/porter-dev/porter/api/server/shared"
  6. "github.com/porter-dev/porter/api/server/shared/config"
  7. "github.com/porter-dev/porter/api/types"
  8. )
  9. type InfraListTemplateHandler struct {
  10. handlers.PorterHandlerWriter
  11. }
  12. func NewInfraListTemplateHandler(
  13. config *config.Config,
  14. writer shared.ResultWriter,
  15. ) *InfraListTemplateHandler {
  16. return &InfraListTemplateHandler{
  17. PorterHandlerWriter: handlers.NewDefaultPorterHandler(config, nil, writer),
  18. }
  19. }
  20. func (c *InfraListTemplateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  21. res := make([]types.InfraTemplateMeta, 0)
  22. for _, val := range templateMap {
  23. res = append(res, *val)
  24. }
  25. c.WriteResult(w, r, res)
  26. }
  27. var templateMap = map[string]*types.InfraTemplateMeta{
  28. "test": {
  29. Icon: "",
  30. Description: "Create a test resource.",
  31. Name: "Test",
  32. Version: "v0.1.0",
  33. Kind: "test",
  34. RequiredCredential: "do_integration_id",
  35. },
  36. "ecr": {
  37. Icon: "https://avatars2.githubusercontent.com/u/52505464?s=400&u=da920f994c67665c7ad6c606a5286557d4f8555f&v=4",
  38. Description: "Create an Elastic Container Registry.",
  39. Name: "ECR",
  40. Version: "v0.1.0",
  41. Kind: "ecr",
  42. RequiredCredential: "aws_integration_id",
  43. },
  44. "eks": {
  45. Icon: "https://img.stackshare.io/service/7991/amazon-eks.png",
  46. Description: "Create an Elastic Kubernetes Service cluster.",
  47. Name: "EKS",
  48. Version: "v0.1.0",
  49. Kind: "eks",
  50. RequiredCredential: "aws_integration_id",
  51. },
  52. "gcr": {
  53. Icon: "https://carlossanchez.files.wordpress.com/2019/06/21046548.png?w=640",
  54. Description: "Create a Google Container Registry.",
  55. Name: "GCR",
  56. Version: "v0.1.0",
  57. Kind: "gcr",
  58. RequiredCredential: "gcp_integration_id",
  59. },
  60. "gke": {
  61. Icon: "https://sysdig.com/wp-content/uploads/2016/08/GKE_color.png",
  62. Description: "Create a Google Kubernetes Engine cluster.",
  63. Name: "GKE",
  64. Version: "v0.1.0",
  65. Kind: "gke",
  66. RequiredCredential: "gcp_integration_id",
  67. },
  68. "docr": {
  69. Icon: "",
  70. Description: "Create a Digital Ocean Container Registry.",
  71. Name: "DOCR",
  72. Version: "v0.1.0",
  73. Kind: "docr",
  74. RequiredCredential: "do_integration_id",
  75. },
  76. "doks": {
  77. Icon: "",
  78. Description: "Create a Digital Ocean Kubernetes Service cluster.",
  79. Name: "DOKS",
  80. Version: "v0.1.0",
  81. Kind: "doks",
  82. RequiredCredential: "do_integration_id",
  83. },
  84. }