environment.go 4.8 KB

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