environment.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. CustomNamespace bool `json:"custom_namespace"`
  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. }
  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. Namespace string `json:"namespace" form:"required"`
  68. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  69. Subdomain string `json:"subdomain"`
  70. }
  71. type FinalizeDeploymentWithErrorsRequest struct {
  72. Namespace string `json:"namespace" form:"required"`
  73. SuccessfulResources []*SuccessfullyDeployedResource `json:"successful_resources"`
  74. Errors map[string]string `json:"errors" form:"required"`
  75. }
  76. type UpdateDeploymentRequest struct {
  77. *CreateGHDeploymentRequest
  78. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  79. CommitSHA string `json:"commit_sha" form:"required"`
  80. Namespace string `json:"namespace" form:"required"`
  81. }
  82. type ListDeploymentRequest struct {
  83. EnvironmentID uint `schema:"environment_id"`
  84. }
  85. type UpdateDeploymentStatusRequest struct {
  86. *CreateGHDeploymentRequest
  87. PRBranchFrom string `json:"gh_pr_branch_from" form:"required"`
  88. Status string `json:"status" form:"required,oneof=created creating inactive failed"`
  89. Namespace string `json:"namespace" form:"required"`
  90. }
  91. type DeleteDeploymentRequest struct {
  92. Namespace string `json:"namespace" form:"required"`
  93. }
  94. type GetDeploymentRequest struct {
  95. Namespace string `schema:"namespace" form:"required"`
  96. }
  97. type PullRequest struct {
  98. Title string `json:"pr_title"`
  99. Number uint `json:"pr_number"`
  100. RepoOwner string `json:"repo_owner"`
  101. RepoName string `json:"repo_name"`
  102. BranchFrom string `json:"branch_from"`
  103. BranchInto string `json:"branch_into"`
  104. }
  105. type ToggleNewCommentRequest struct {
  106. Disable bool `json:"disable"`
  107. }
  108. type ListEnvironmentsResponse []*Environment
  109. type ValidatePorterYAMLRequest struct {
  110. Branch string `schema:"branch"`
  111. }
  112. type ValidatePorterYAMLResponse struct {
  113. Errors []string `json:"errors"`
  114. }