environment.go 5.3 KB

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