environment.go 5.0 KB

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