environment.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 SuccessfullyDeployedResource struct {
  62. ReleaseName string `json:"release_name" form:"required"`
  63. ReleaseType string `json:"release_type"`
  64. }
  65. type FinalizeDeploymentRequest struct {
  66. Namespace string `json:"namespace" form:"required"`
  67. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  68. Subdomain string `json:"subdomain"`
  69. }
  70. type FinalizeDeploymentWithErrorsRequest struct {
  71. Namespace string `json:"namespace" form:"required"`
  72. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  73. Errors map[string]string `json:"errors" form:"required"`
  74. }
  75. type UpdateDeploymentRequest struct {
  76. *CreateGHDeploymentRequest
  77. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  78. CommitSHA string `json:"commit_sha" form:"required"`
  79. Namespace string `json:"namespace" form:"required"`
  80. }
  81. type ListDeploymentRequest struct {
  82. EnvironmentID uint `schema:"environment_id"`
  83. }
  84. type UpdateDeploymentStatusRequest struct {
  85. *CreateGHDeploymentRequest
  86. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  87. Status string `json:"status" form:"required,oneof=created creating inactive failed"`
  88. Namespace string `json:"namespace" form:"required"`
  89. }
  90. type DeleteDeploymentRequest struct {
  91. Namespace string `json:"namespace" form:"required"`
  92. }
  93. type GetDeploymentRequest struct {
  94. Namespace string `schema:"namespace" form:"required"`
  95. }
  96. type PullRequest struct {
  97. Title string `json:"pr_title"`
  98. Number uint `json:"pr_number"`
  99. RepoOwner string `json:"repo_owner"`
  100. RepoName string `json:"repo_name"`
  101. BranchFrom string `json:"branch_from"`
  102. BranchInto string `json:"branch_into"`
  103. }
  104. type ToggleNewCommentRequest struct {
  105. Enable bool `json:"enable" form:"required"`
  106. }
  107. type ListEnvironmentsResponse []*Environment