environment.go 3.7 KB

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