infra.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package types
  2. import "time"
  3. // InfraStatus is the status that an infrastructure can take
  4. type InfraStatus string
  5. // The allowed statuses
  6. const (
  7. StatusCreating InfraStatus = "creating"
  8. StatusCreated InfraStatus = "created"
  9. StatusError InfraStatus = "error"
  10. StatusDestroying InfraStatus = "destroying"
  11. StatusDestroyed InfraStatus = "destroyed"
  12. )
  13. // InfraKind is the kind that infra can be
  14. type InfraKind string
  15. // The supported infra kinds
  16. const (
  17. InfraTest InfraKind = "test"
  18. InfraECR InfraKind = "ecr"
  19. InfraEKS InfraKind = "eks"
  20. InfraGCR InfraKind = "gcr"
  21. InfraGKE InfraKind = "gke"
  22. InfraDOCR InfraKind = "docr"
  23. InfraDOKS InfraKind = "doks"
  24. InfraAKS InfraKind = "aks"
  25. InfraACR InfraKind = "acr"
  26. InfraRDS InfraKind = "rds"
  27. )
  28. type Infra struct {
  29. ID uint `json:"id"`
  30. CreatedAt time.Time `json:"created_at"`
  31. UpdatedAt time.Time `json:"updated_at"`
  32. // The project that this integration belongs to
  33. ProjectID uint `json:"project_id"`
  34. APIVersion string `json:"api_version,omitempty"`
  35. SourceLink string `json:"source_link,omitempty"`
  36. SourceVersion string `json:"source_version,omitempty"`
  37. // The type of infra that was provisioned
  38. Kind InfraKind `json:"kind"`
  39. // Status is the status of the infra
  40. Status InfraStatus `json:"status"`
  41. // The AWS integration that was used to create the infra
  42. AWSIntegrationID uint `json:"aws_integration_id,omitempty"`
  43. // The GCP integration that was used to create the infra
  44. GCPIntegrationID uint `json:"gcp_integration_id,omitempty"`
  45. // The DO integration that was used to create the infra:
  46. // this points to an OAuthIntegrationID
  47. DOIntegrationID uint `json:"do_integration_id,omitempty"`
  48. // The Azure integration that was used to create the infra
  49. AzureIntegrationID uint `json:"azure_integration_id,omitempty"`
  50. // The last-applied, non-sensitive input variables to the provisioner. For now,
  51. // this is a map[string]string since we marshal into env vars anyway, but
  52. // eventually this config will be more complex.
  53. LastApplied map[string]string `json:"last_applied"`
  54. // LatestOperation is the last operation that was run against this infra, if
  55. // one exists
  56. LatestOperation *Operation `json:"latest_operation"`
  57. }
  58. type InfraCredentials struct {
  59. AWSIntegrationID uint `json:"aws_integration_id,omitempty"`
  60. GCPIntegrationID uint `json:"gcp_integration_id,omitempty"`
  61. DOIntegrationID uint `json:"do_integration_id,omitempty"`
  62. AzureIntegrationID uint `json:"azure_integration_id,omitempty"`
  63. }
  64. type CreateInfraRequest struct {
  65. *InfraCredentials
  66. ClusterID uint `json:"cluster_id"`
  67. Kind string `json:"kind" form:"required"`
  68. Values map[string]interface{} `json:"values" form:"required"`
  69. }
  70. type ListInfraRequest struct {
  71. Version string `schema:"version"`
  72. }
  73. type DeleteInfraRequest struct {
  74. *InfraCredentials
  75. }
  76. type RetryInfraRequest struct {
  77. // Integration IDs are not required -- if they are passed in, they will override the
  78. // existing integration IDs
  79. *InfraCredentials
  80. // Values are not required -- if they are not passed in, the values will be
  81. // automatically populated from the previous operation
  82. Values map[string]interface{} `json:"values"`
  83. }
  84. type OperationMeta struct {
  85. LastUpdated time.Time `json:"last_updated"`
  86. UID string `json:"id"`
  87. InfraID uint `json:"infra_id"`
  88. Type string `json:"type"`
  89. Status string `json:"status"`
  90. Errored bool `json:"errored"`
  91. Error string `json:"error"`
  92. }
  93. type Operation struct {
  94. *OperationMeta
  95. LastApplied map[string]interface{} `json:"last_applied"`
  96. Form *FormYAML `json:"form"`
  97. }
  98. type InfraTemplateMeta struct {
  99. Icon string `json:"icon"`
  100. Description string `json:"description"`
  101. Name string `json:"name"`
  102. Version string `json:"version"`
  103. Kind string `json:"kind"`
  104. RequiredCredential string `json:"required_credential"`
  105. }
  106. type InfraTemplate struct {
  107. *InfraTemplateMeta
  108. Form *FormYAML `json:"form"`
  109. }