environment.go 5.1 KB

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