environment.go 5.5 KB

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