environment.go 3.5 KB

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