2
0

infra.go 4.1 KB

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