environment.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. WorkflowFilename string `json:"gh_workflow_filename"`
  28. InstallationID uint `json:"gh_installation_id"`
  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. 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 PullRequest 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. }