list_templates.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. "rds": {
  45. Icon: "",
  46. Description: "Create a Relational Database Service instance.",
  47. Name: "RDS",
  48. Version: "v0.1.0",
  49. Kind: "rds",
  50. RequiredCredential: "aws_integration_id",
  51. },
  52. "s3": {
  53. Icon: "",
  54. Description: "Create an S3 bucket.",
  55. Name: "S3",
  56. Version: "v0.1.0",
  57. Kind: "s3",
  58. RequiredCredential: "aws_integration_id",
  59. },
  60. "eks": {
  61. Icon: "https://img.stackshare.io/service/7991/amazon-eks.png",
  62. Description: "Create an Elastic Kubernetes Service cluster.",
  63. Name: "EKS",
  64. Version: "v0.1.0",
  65. Kind: "eks",
  66. RequiredCredential: "aws_integration_id",
  67. },
  68. "gcr": {
  69. Icon: "https://carlossanchez.files.wordpress.com/2019/06/21046548.png?w=640",
  70. Description: "Create a Google Container Registry.",
  71. Name: "GCR",
  72. Version: "v0.1.0",
  73. Kind: "gcr",
  74. RequiredCredential: "gcp_integration_id",
  75. },
  76. "gar": {
  77. Icon: "https://carlossanchez.files.wordpress.com/2019/06/21046548.png?w=640",
  78. Description: "Create a Google Artifact Registry.",
  79. Name: "GAR",
  80. Version: "v0.1.0",
  81. Kind: "gar",
  82. RequiredCredential: "gcp_integration_id",
  83. },
  84. "gke": {
  85. Icon: "https://sysdig.com/wp-content/uploads/2016/08/GKE_color.png",
  86. Description: "Create a Google Kubernetes Engine cluster.",
  87. Name: "GKE",
  88. Version: "v0.1.0",
  89. Kind: "gke",
  90. RequiredCredential: "gcp_integration_id",
  91. },
  92. "docr": {
  93. Icon: "",
  94. Description: "Create a Digital Ocean Container Registry.",
  95. Name: "DOCR",
  96. Version: "v0.1.0",
  97. Kind: "docr",
  98. RequiredCredential: "do_integration_id",
  99. },
  100. "doks": {
  101. Icon: "",
  102. Description: "Create a Digital Ocean Kubernetes Service cluster.",
  103. Name: "DOKS",
  104. Version: "v0.1.0",
  105. Kind: "doks",
  106. RequiredCredential: "do_integration_id",
  107. },
  108. "acr": {
  109. Icon: "",
  110. Description: "Create an Azure Container Registry.",
  111. Name: "ACR",
  112. Version: "v0.1.0",
  113. Kind: "acr",
  114. RequiredCredential: "azure_integration_id",
  115. },
  116. "aks": {
  117. Icon: "",
  118. Description: "Create an Azure Kubernetes Service cluster",
  119. Name: "AKS",
  120. Version: "v0.1.0",
  121. Kind: "aks",
  122. RequiredCredential: "azure_integration_id",
  123. },
  124. }