environment.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. GitRepoBranches []string `json:"git_repo_branches"`
  11. Name string `json:"name"`
  12. Mode string `json:"mode"`
  13. DeploymentCount uint `json:"deployment_count"`
  14. LastDeploymentStatus string `json:"last_deployment_status"`
  15. NewCommentsDisabled bool `json:"new_comments_disabled"`
  16. }
  17. type CreateEnvironmentRequest struct {
  18. Name string `json:"name" form:"required"`
  19. Mode string `json:"mode" form:"oneof=auto manual" default:"manual"`
  20. DisableNewComments bool `json:"disable_new_comments"`
  21. GitRepoBranches []string `json:"git_repo_branches"`
  22. }
  23. type GitHubMetadata struct {
  24. DeploymentID int64 `json:"gh_deployment_id"`
  25. PRName string `json:"gh_pr_name"`
  26. RepoName string `json:"gh_repo_name"`
  27. RepoOwner string `json:"gh_repo_owner"`
  28. CommitSHA string `json:"gh_commit_sha"`
  29. PRBranchFrom string `json:"gh_pr_branch_from"`
  30. PRBranchInto string `json:"gh_pr_branch_into"`
  31. }
  32. type DeploymentStatus string
  33. const (
  34. DeploymentStatusCreated DeploymentStatus = "created"
  35. DeploymentStatusCreating DeploymentStatus = "creating"
  36. DeploymentStatusUpdating DeploymentStatus = "updating"
  37. DeploymentStatusInactive DeploymentStatus = "inactive"
  38. DeploymentStatusTimedOut DeploymentStatus = "timed_out"
  39. DeploymentStatusFailed DeploymentStatus = "failed"
  40. )
  41. type Deployment struct {
  42. *GitHubMetadata
  43. ID uint `json:"id"`
  44. CreatedAt time.Time `json:"created_at"`
  45. UpdatedAt time.Time `json:"updated_at"`
  46. EnvironmentID uint `json:"environment_id"`
  47. Namespace string `json:"namespace"`
  48. Status DeploymentStatus `json:"status"`
  49. Subdomain string `json:"subdomain"`
  50. PullRequestID uint `json:"pull_request_id"`
  51. InstallationID uint `json:"gh_installation_id"`
  52. LastWorkflowRunURL string `json:"last_workflow_run_url"`
  53. }
  54. type CreateGHDeploymentRequest struct {
  55. ActionID uint `json:"action_id" form:"required"`
  56. }
  57. type CreateDeploymentRequest struct {
  58. *CreateGHDeploymentRequest
  59. *GitHubMetadata
  60. Namespace string `json:"namespace" form:"required"`
  61. PullRequestID uint `json:"pull_request_id" form:"required"`
  62. }
  63. type SuccessfullyDeployedResource struct {
  64. ReleaseName string `json:"release_name" form:"required"`
  65. ReleaseType string `json:"release_type"`
  66. }
  67. type FinalizeDeploymentRequest struct {
  68. Namespace string `json:"namespace" form:"required"`
  69. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  70. Subdomain string `json:"subdomain"`
  71. }
  72. type FinalizeDeploymentWithErrorsRequest struct {
  73. Namespace string `json:"namespace" form:"required"`
  74. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  75. Errors map[string]string `json:"errors" form:"required"`
  76. }
  77. type UpdateDeploymentRequest struct {
  78. *CreateGHDeploymentRequest
  79. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  80. CommitSHA string `json:"commit_sha" form:"required"`
  81. Namespace string `json:"namespace" form:"required"`
  82. }
  83. type ListDeploymentRequest struct {
  84. EnvironmentID uint `schema:"environment_id"`
  85. }
  86. type UpdateDeploymentStatusRequest struct {
  87. *CreateGHDeploymentRequest
  88. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  89. Status string `json:"status" form:"required,oneof=created creating inactive failed"`
  90. Namespace string `json:"namespace" form:"required"`
  91. }
  92. type DeleteDeploymentRequest struct {
  93. Namespace string `json:"namespace" form:"required"`
  94. }
  95. type GetDeploymentRequest struct {
  96. Namespace string `schema:"namespace" form:"required"`
  97. }
  98. type PullRequest struct {
  99. Title string `json:"pr_title"`
  100. Number uint `json:"pr_number"`
  101. RepoOwner string `json:"repo_owner"`
  102. RepoName string `json:"repo_name"`
  103. BranchFrom string `json:"branch_from"`
  104. BranchInto string `json:"branch_into"`
  105. }
  106. type ToggleNewCommentRequest struct {
  107. Disable bool `json:"disable"`
  108. }
  109. type ListEnvironmentsResponse []*Environment
  110. type UpdateEnvironmentSettingsRequest struct {
  111. Mode string `json:"mode" form:"oneof=auto manual"`
  112. DisableNewComments bool `json:"disable_new_comments"`
  113. GitRepoBranches []string `json:"git_repo_branches"`
  114. }