2
0

environment.go 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. package types
  2. import "time"
  3. type Environment struct {
  4. ID uint `json:"id"`
  5. ProjectID uint `json:"project_id"`
  6. ClusterID uint `json:"cluster_id"`
  7. GitInstallationID uint `json:"git_installation_id"`
  8. GitRepoOwner string `json:"git_repo_owner"`
  9. GitRepoName string `json:"git_repo_name"`
  10. GitRepoBranches []string `json:"git_repo_branches"`
  11. Name string `json:"name"`
  12. Mode string `json:"mode"`
  13. DeploymentCount uint `json:"deployment_count"`
  14. LastDeploymentStatus string `json:"last_deployment_status"`
  15. NewCommentsDisabled bool `json:"new_comments_disabled"`
  16. NamespaceLabels map[string]string `json:"namespace_labels,omitempty"`
  17. GitDeployBranches []string `json:"git_deploy_branches"`
  18. }
  19. type CreateEnvironmentRequest struct {
  20. Name string `json:"name" form:"required"`
  21. Mode string `json:"mode" form:"oneof=auto manual" default:"manual"`
  22. DisableNewComments bool `json:"disable_new_comments"`
  23. GitRepoBranches []string `json:"git_repo_branches"`
  24. NamespaceLabels map[string]string `json:"namespace_labels"`
  25. GitDeployBranches []string `json:"git_deploy_branches"`
  26. }
  27. type GitHubMetadata struct {
  28. DeploymentID int64 `json:"gh_deployment_id"`
  29. PRName string `json:"gh_pr_name"`
  30. RepoName string `json:"gh_repo_name"`
  31. RepoOwner string `json:"gh_repo_owner"`
  32. CommitSHA string `json:"gh_commit_sha"`
  33. PRBranchFrom string `json:"gh_pr_branch_from"`
  34. PRBranchInto string `json:"gh_pr_branch_into"`
  35. }
  36. type DeploymentStatus string
  37. const (
  38. DeploymentStatusCreated DeploymentStatus = "created"
  39. DeploymentStatusCreating DeploymentStatus = "creating"
  40. DeploymentStatusUpdating DeploymentStatus = "updating"
  41. DeploymentStatusInactive DeploymentStatus = "inactive"
  42. DeploymentStatusTimedOut DeploymentStatus = "timed_out"
  43. DeploymentStatusFailed DeploymentStatus = "failed"
  44. )
  45. type Deployment struct {
  46. *GitHubMetadata
  47. ID uint `json:"id"`
  48. CreatedAt time.Time `json:"created_at"`
  49. UpdatedAt time.Time `json:"updated_at"`
  50. EnvironmentID uint `json:"environment_id"`
  51. Namespace string `json:"namespace"`
  52. Status DeploymentStatus `json:"status"`
  53. Subdomain string `json:"subdomain"`
  54. PullRequestID uint `json:"pull_request_id"`
  55. InstallationID uint `json:"gh_installation_id"`
  56. LastWorkflowRunURL string `json:"last_workflow_run_url"`
  57. LastErrors string `json:"last_errors"`
  58. }
  59. type CreateGHDeploymentRequest struct {
  60. ActionID uint `json:"action_id" form:"required"`
  61. }
  62. type CreateDeploymentRequest struct {
  63. *CreateGHDeploymentRequest
  64. *GitHubMetadata
  65. Namespace string `json:"namespace" form:"required"`
  66. PullRequestID uint `json:"pull_request_id"`
  67. }
  68. type SuccessfullyDeployedResource struct {
  69. ReleaseName string `json:"release_name" form:"required"`
  70. ReleaseType string `json:"release_type"`
  71. }
  72. type FinalizeDeploymentRequest struct {
  73. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  74. Subdomain string `json:"subdomain"`
  75. PRNumber uint `json:"pr_number"`
  76. Namespace string `json:"namespace"`
  77. }
  78. type FinalizeDeploymentByClusterRequest struct {
  79. RepoOwner string `json:"gh_repo_owner" form:"required"`
  80. RepoName string `json:"gh_repo_name" form:"required"`
  81. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  82. Subdomain string `json:"subdomain"`
  83. PRNumber uint `json:"pr_number"`
  84. Namespace string `json:"namespace"`
  85. }
  86. type FinalizeDeploymentWithErrorsRequest struct {
  87. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  88. Errors map[string]string `json:"errors" form:"required"`
  89. PRNumber uint `json:"pr_number"`
  90. Namespace string `json:"namespace"`
  91. }
  92. type FinalizeDeploymentWithErrorsByClusterRequest struct {
  93. RepoOwner string `json:"gh_repo_owner" form:"required"`
  94. RepoName string `json:"gh_repo_name" form:"required"`
  95. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  96. Errors map[string]string `json:"errors" form:"required"`
  97. PRNumber uint `json:"pr_number"`
  98. Namespace string `json:"namespace"`
  99. }
  100. type UpdateDeploymentRequest struct {
  101. *CreateGHDeploymentRequest
  102. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  103. CommitSHA string `json:"commit_sha" form:"required"`
  104. PRNumber uint `json:"pr_number"`
  105. Namespace string `json:"namespace"`
  106. }
  107. type UpdateDeploymentByClusterRequest struct {
  108. *CreateGHDeploymentRequest
  109. RepoOwner string `json:"gh_repo_owner" form:"required"`
  110. RepoName string `json:"gh_repo_name" form:"required"`
  111. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  112. CommitSHA string `json:"commit_sha" form:"required"`
  113. PRNumber uint `json:"pr_number"`
  114. Namespace string `json:"namespace"`
  115. }
  116. type ListDeploymentRequest struct {
  117. EnvironmentID uint `schema:"environment_id"`
  118. }
  119. type UpdateDeploymentStatusRequest struct {
  120. *CreateGHDeploymentRequest
  121. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  122. Status string `json:"status" form:"required,oneof=created creating inactive failed"`
  123. PRNumber uint `json:"pr_number"`
  124. Namespace string `json:"namespace"`
  125. }
  126. type UpdateDeploymentStatusByClusterRequest struct {
  127. *CreateGHDeploymentRequest
  128. RepoOwner string `json:"gh_repo_owner" form:"required"`
  129. RepoName string `json:"gh_repo_name" form:"required"`
  130. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  131. Status string `json:"status" form:"required,oneof=created creating inactive failed"`
  132. PRNumber uint `json:"pr_number"`
  133. Namespace string `json:"namespace"`
  134. }
  135. type DeleteDeploymentRequest struct {
  136. Namespace string `json:"namespace" form:"required"`
  137. }
  138. type GetDeploymentRequest struct {
  139. DeploymentID uint `schema:"id"`
  140. PRNumber uint `schema:"pr_number"`
  141. Namespace string `schema:"namespace"`
  142. Branch string `schema:"branch"`
  143. }
  144. type PullRequest struct {
  145. Title string `json:"pr_title"`
  146. Number uint `json:"pr_number"`
  147. RepoOwner string `json:"repo_owner"`
  148. RepoName string `json:"repo_name"`
  149. BranchFrom string `json:"branch_from"`
  150. BranchInto string `json:"branch_into"`
  151. CreatedAt time.Time `json:"created_at"`
  152. UpdatedAt time.Time `json:"updated_at"`
  153. }
  154. type ToggleNewCommentRequest struct {
  155. Disable bool `json:"disable"`
  156. }
  157. type ListEnvironmentsResponse []*Environment
  158. type ValidatePorterYAMLRequest struct {
  159. Branch string `schema:"branch"`
  160. }
  161. type ValidatePorterYAMLResponse struct {
  162. Errors []string `json:"errors"`
  163. }
  164. type UpdateEnvironmentSettingsRequest struct {
  165. Mode string `json:"mode" form:"oneof=auto manual"`
  166. DisableNewComments bool `json:"disable_new_comments"`
  167. GitRepoBranches []string `json:"git_repo_branches"`
  168. NamespaceLabels map[string]string `json:"namespace_labels"`
  169. GitDeployBranches []string `json:"git_deploy_branches"`
  170. }