environment.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. Name string `json:"name"`
  11. Mode string `json:"mode"`
  12. DeploymentCount uint `json:"deployment_count"`
  13. LastDeploymentStatus string `json:"last_deployment_status"`
  14. EnableNewComment bool `json:"enable_new_comment"`
  15. }
  16. type CreateEnvironmentRequest struct {
  17. Name string `json:"name" form:"required"`
  18. Mode string `json:"mode" form:"oneof=auto manual" default:"manual"`
  19. }
  20. type GitHubMetadata struct {
  21. DeploymentID int64 `json:"gh_deployment_id"`
  22. PRName string `json:"gh_pr_name"`
  23. RepoName string `json:"gh_repo_name"`
  24. RepoOwner string `json:"gh_repo_owner"`
  25. CommitSHA string `json:"gh_commit_sha"`
  26. PRBranchFrom string `json:"gh_pr_branch_from"`
  27. PRBranchInto string `json:"gh_pr_branch_into"`
  28. }
  29. type DeploymentStatus string
  30. const (
  31. DeploymentStatusCreated DeploymentStatus = "created"
  32. DeploymentStatusCreating DeploymentStatus = "creating"
  33. DeploymentStatusUpdating DeploymentStatus = "updating"
  34. DeploymentStatusInactive DeploymentStatus = "inactive"
  35. DeploymentStatusTimedOut DeploymentStatus = "timed_out"
  36. DeploymentStatusFailed DeploymentStatus = "failed"
  37. )
  38. type Deployment struct {
  39. *GitHubMetadata
  40. ID uint `json:"id"`
  41. CreatedAt time.Time `json:"created_at"`
  42. UpdatedAt time.Time `json:"updated_at"`
  43. EnvironmentID uint `json:"environment_id"`
  44. Namespace string `json:"namespace"`
  45. Status DeploymentStatus `json:"status"`
  46. Subdomain string `json:"subdomain"`
  47. PullRequestID uint `json:"pull_request_id"`
  48. InstallationID uint `json:"gh_installation_id"`
  49. LastWorkflowRunURL string `json:"last_workflow_run_url"`
  50. }
  51. type CreateGHDeploymentRequest struct {
  52. ActionID uint `json:"action_id" form:"required"`
  53. }
  54. type CreateDeploymentRequest struct {
  55. *CreateGHDeploymentRequest
  56. *GitHubMetadata
  57. Namespace string `json:"namespace" form:"required"`
  58. PullRequestID uint `json:"pull_request_id" form:"required"`
  59. }
  60. type FinalizeDeploymentRequest struct {
  61. Namespace string `json:"namespace" form:"required"`
  62. Subdomain string `json:"subdomain" form:"required"`
  63. }
  64. type UpdateDeploymentRequest struct {
  65. *CreateGHDeploymentRequest
  66. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  67. CommitSHA string `json:"commit_sha" form:"required"`
  68. Namespace string `json:"namespace" form:"required"`
  69. }
  70. type ListDeploymentRequest struct {
  71. EnvironmentID uint `schema:"environment_id"`
  72. }
  73. type UpdateDeploymentStatusRequest struct {
  74. *CreateGHDeploymentRequest
  75. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  76. Status string `json:"status" form:"required,oneof=created creating inactive failed"`
  77. Namespace string `json:"namespace" form:"required"`
  78. }
  79. type DeleteDeploymentRequest struct {
  80. Namespace string `json:"namespace" form:"required"`
  81. }
  82. type GetDeploymentRequest struct {
  83. Namespace string `schema:"namespace" form:"required"`
  84. }
  85. type EnablePullRequestRequest struct {
  86. Title string `json:"pr_title"`
  87. Number uint `json:"pr_number"`
  88. RepoOwner string `json:"repo_owner"`
  89. RepoName string `json:"repo_name"`
  90. BranchFrom string `json:"branch_from"`
  91. BranchInto string `json:"branch_into"`
  92. }
  93. type ToggleNewCommentRequest struct {
  94. Enable bool `json:"enable" form:"required"`
  95. }