environment.go 4.2 KB

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