2
0

infra.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. InfraS3 InfraKind = "s3"
  28. )
  29. type Infra struct {
  30. ID uint `json:"id"`
  31. CreatedAt time.Time `json:"created_at"`
  32. UpdatedAt time.Time `json:"updated_at"`
  33. // The project that this integration belongs to
  34. ProjectID uint `json:"project_id"`
  35. Name string `json:"name"`
  36. APIVersion string `json:"api_version,omitempty"`
  37. SourceLink string `json:"source_link,omitempty"`
  38. SourceVersion string `json:"source_version,omitempty"`
  39. // The type of infra that was provisioned
  40. Kind InfraKind `json:"kind"`
  41. // Status is the status of the infra
  42. Status InfraStatus `json:"status"`
  43. // The AWS integration that was used to create the infra
  44. AWSIntegrationID uint `json:"aws_integration_id,omitempty"`
  45. // The GCP integration that was used to create the infra
  46. GCPIntegrationID uint `json:"gcp_integration_id,omitempty"`
  47. // The DO integration that was used to create the infra:
  48. // this points to an OAuthIntegrationID
  49. DOIntegrationID uint `json:"do_integration_id,omitempty"`
  50. // The Azure integration that was used to create the infra
  51. AzureIntegrationID uint `json:"azure_integration_id,omitempty"`
  52. // The last-applied, non-sensitive input variables to the provisioner. For now,
  53. // this is a map[string]string since we marshal into env vars anyway, but
  54. // eventually this config will be more complex.
  55. LastApplied map[string]string `json:"last_applied"`
  56. // LatestOperation is the last operation that was run against this infra, if
  57. // one exists
  58. LatestOperation *Operation `json:"latest_operation"`
  59. }
  60. type InfraCredentials struct {
  61. AWSIntegrationID uint `json:"aws_integration_id,omitempty"`
  62. GCPIntegrationID uint `json:"gcp_integration_id,omitempty"`
  63. DOIntegrationID uint `json:"do_integration_id,omitempty"`
  64. AzureIntegrationID uint `json:"azure_integration_id,omitempty"`
  65. }
  66. type CreateInfraRequest struct {
  67. *InfraCredentials
  68. ClusterID uint `json:"cluster_id"`
  69. Kind string `json:"kind" form:"required"`
  70. Values map[string]interface{} `json:"values" form:"required"`
  71. }
  72. type ListInfraRequest struct {
  73. Version string `schema:"version"`
  74. }
  75. type DeleteInfraRequest struct {
  76. *InfraCredentials
  77. }
  78. type RetryInfraRequest struct {
  79. // Integration IDs are not required -- if they are passed in, they will override the
  80. // existing integration IDs
  81. *InfraCredentials
  82. // Values are not required -- if they are not passed in, the values will be
  83. // automatically populated from the previous operation
  84. Values map[string]interface{} `json:"values"`
  85. }
  86. type OperationMeta struct {
  87. LastUpdated time.Time `json:"last_updated"`
  88. UID string `json:"id"`
  89. InfraID uint `json:"infra_id"`
  90. Type string `json:"type"`
  91. Status string `json:"status"`
  92. Errored bool `json:"errored"`
  93. Error string `json:"error"`
  94. }
  95. type Operation struct {
  96. *OperationMeta
  97. LastApplied map[string]interface{} `json:"last_applied"`
  98. Form *FormYAML `json:"form"`
  99. }
  100. type InfraTemplateMeta struct {
  101. Icon string `json:"icon"`
  102. Description string `json:"description"`
  103. Name string `json:"name"`
  104. Version string `json:"version"`
  105. Kind string `json:"kind"`
  106. RequiredCredential string `json:"required_credential"`
  107. }
  108. type InfraTemplate struct {
  109. *InfraTemplateMeta
  110. Form *FormYAML `json:"form"`
  111. }