stacks.go 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. package types
  2. import "time"
  3. // swagger:model
  4. type CreateStackRequest struct {
  5. // The display name of the stack
  6. // required: true
  7. Name string `json:"name" form:"required"`
  8. // A list of app resources to create. An app resource is an application helm chart, such as a `web` or `worker` template.
  9. // required: true
  10. AppResources []*CreateStackAppResourceRequest `json:"app_resources,omitempty" form:"required,dive,required"`
  11. // A list of configurations which can build an application. Each application resource must use at least one
  12. // source config in order to build application from source. The source config can be specified as a Docker image
  13. // registry or linked to a remote Git repository.
  14. // required: true
  15. SourceConfigs []*CreateStackSourceConfigRequest `json:"source_configs,omitempty" form:"required,dive,required"`
  16. }
  17. // swagger:model
  18. type PutStackSourceConfigRequest struct {
  19. SourceConfigs []*CreateStackSourceConfigRequest `json:"source_configs,omitempty" form:"required,dive,required"`
  20. }
  21. const URLParamStackRevisionNumber URLParam = "stack_revision_number"
  22. // swagger:model
  23. type StackRollbackRequest struct {
  24. TargetRevision uint `json:"target_revision"`
  25. }
  26. // swagger:model
  27. type PatchStackSourceConfigRequest struct {
  28. SourceConfig *UpdateStackSourceConfigRequest `json:"source_config,omitempty" form:"required"`
  29. }
  30. type CreateStackAppResourceRequest struct {
  31. // The URL of the Helm registry to pull the template from. If not set, this defaults to `https://charts.getporter.dev`.
  32. TemplateRepoURL string `json:"template_repo_url"`
  33. // The name of the template in the Helm registry, such as `web`
  34. // required: true
  35. TemplateName string `json:"template_name" form:"required"`
  36. // The version of the template in the Helm registry, such as `v0.50.0`
  37. // required: true
  38. TemplateVersion string `json:"template_version" form:"required"`
  39. // The values to pass in to the template.
  40. Values map[string]interface{} `json:"values"`
  41. // The name of the resource.
  42. // required: true
  43. Name string `json:"name" form:"required"`
  44. // The name of the source config (must exist inside `source_configs`).
  45. // required: true
  46. SourceConfigName string `json:"source_config_name" form:"required"`
  47. }
  48. // swagger:model
  49. type Stack struct {
  50. // The time that the stack was initially created
  51. CreatedAt time.Time `json:"created_at"`
  52. // The time that the stack was last updated
  53. UpdatedAt time.Time `json:"updated_at"`
  54. // The display name of the stack
  55. Name string `json:"name"`
  56. // The namespace that the stack was deployed to
  57. Namespace string `json:"namespace"`
  58. // A unique id for the stack
  59. ID string `json:"id"`
  60. // The latest revision for the stack
  61. LatestRevision *StackRevision `json:"latest_revision,omitempty"`
  62. // The list of revisions deployed for this stack
  63. Revisions []StackRevisionMeta `json:"revisions,omitempty"`
  64. }
  65. // swagger:model
  66. type StackListResponse []Stack
  67. type StackResource struct {
  68. // The time that this resource was initially created
  69. CreatedAt time.Time `json:"created_at"`
  70. // The time that this resource was last updated
  71. UpdatedAt time.Time `json:"updated_at"`
  72. // The stack ID that this resource belongs to
  73. StackID string `json:"stack_id"`
  74. // The numerical revision id that this resource belongs to
  75. StackRevisionID uint `json:"stack_revision_id"`
  76. // The name of the resource
  77. Name string `json:"name"`
  78. // The id for this resource
  79. ID string `json:"id"`
  80. // If this is an app resource, app-specific information for the resource
  81. StackAppData *StackResourceAppData `json:"stack_app_data,omitempty"`
  82. // The source configuration for this stack
  83. StackSourceConfig *StackSourceConfig `json:"stack_source_config,omitempty"`
  84. }
  85. type StackResourceAppData struct {
  86. // The URL of the Helm registry to pull the template from
  87. TemplateRepoURL string `json:"template_repo_url"`
  88. // The name of the template in the Helm registry, such as `web`
  89. TemplateName string `json:"template_name"`
  90. // The version of the template in the Helm registry, such as `v0.50.0`
  91. TemplateVersion string `json:"template_version"`
  92. }
  93. type StackRevisionStatus string
  94. const (
  95. StackRevisionStatusDeploying StackRevisionStatus = "deploying"
  96. StackRevisionStatusFailed StackRevisionStatus = "failed"
  97. StackRevisionStatusDeployed StackRevisionStatus = "deployed"
  98. )
  99. type StackRevisionMeta struct {
  100. // The time that this revision was created
  101. CreatedAt time.Time `json:"created_at"`
  102. // The id of the revision
  103. ID uint `json:"id"`
  104. // The status of the revision
  105. Status StackRevisionStatus `json:"status"`
  106. // The stack ID that this source config belongs to
  107. StackID string `json:"stack_id"`
  108. }
  109. type StackRevision struct {
  110. *StackRevisionMeta
  111. // The reason for any error or status change
  112. Reason string `json:"reason"`
  113. // The message associated with an error or status change
  114. Message string `json:"message"`
  115. // The list of resources deployed in this revision
  116. Resources []StackResource `json:"resources"`
  117. SourceConfigs []StackSourceConfig `json:"source_configs"`
  118. }
  119. type StackSourceConfig struct {
  120. // The time that the source configuration was initially created
  121. CreatedAt time.Time `json:"created_at"`
  122. // The time that the source configuration was last updated
  123. UpdatedAt time.Time `json:"updated_at"`
  124. // The stack ID that this source config belongs to
  125. StackID string `json:"stack_id"`
  126. // The numerical revision id that this source config belongs to
  127. StackRevisionID uint `json:"stack_revision_id"`
  128. // The display name of the stack source
  129. Name string `json:"name"`
  130. // The unique id of the stack source config
  131. ID string `json:"id"`
  132. // The complete image repo uri used by the source
  133. ImageRepoURI string `json:"image_repo_uri"`
  134. // The current image tag used by the application
  135. ImageTag string `json:"image_tag"`
  136. // If this field is empty, the resource is deployed directly from the image repo uri
  137. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  138. }
  139. // swagger:model
  140. type CreateStackSourceConfigRequest struct {
  141. // required: true
  142. Name string `json:"name" form:"required"`
  143. // required: true
  144. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  145. // required: true
  146. ImageTag string `json:"image_tag" form:"required"`
  147. // If this field is empty, the resource is deployed directly from the image repo uri
  148. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  149. }
  150. // swagger:model
  151. type UpdateStackSourceConfigRequest struct {
  152. // required: true
  153. Name string `json:"name" form:"required"`
  154. // required: true
  155. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  156. // required: true
  157. ImageTag string `json:"image_tag" form:"required"`
  158. }
  159. type StackSourceConfigBuild struct {
  160. // The build method to use: can be `docker` (for dockerfiles), or `pack` (for buildpacks)
  161. // required: true
  162. Method string `json:"method" form:"required"`
  163. // The path to the build context (the root folder of the application). For example, `.` or `./app`
  164. // required: true
  165. FolderPath string `json:"folder_path" form:"required"`
  166. // The remote Git configuration to use. If not passed in, this application will not appear to be linked to a
  167. // remote Git repository.
  168. StackSourceConfigBuildGit *StackSourceConfigBuildGit `json:"git,omitempty"`
  169. // The Dockerfile build configuration, if `method` is `docker`
  170. StackSourceConfigBuildDockerfile *StackSourceConfigBuildDockerfile `json:"dockerfile,omitempty"`
  171. // The buildpack configuration, if method is `pack`
  172. StackSourceConfigBuildPack *StackSourceConfigBuildPack `json:"buildpack,omitempty"`
  173. }
  174. type StackSourceConfigBuildGit struct {
  175. // The git integration kind: can be `github` or `gitlab`
  176. GitIntegrationKind string `json:"git_integration_kind"`
  177. // The integration id of the github or gitlab integration
  178. GitIntegrationID uint `json:"git_integration_id"`
  179. // The git repo in ${owner}/${repo} form
  180. GitRepo string `json:"git_repo"`
  181. // The git branch to use
  182. GitBranch string `json:"git_branch"`
  183. }
  184. type StackSourceConfigBuildDockerfile struct {
  185. // The path to the dockerfile from the root directory. Defaults to `./Dockerfile`.
  186. DockerfilePath string `json:"dockerfile_path" form:"required"`
  187. }
  188. type StackSourceConfigBuildPack struct {
  189. // The buildpack builder to use
  190. // required: true
  191. Builder string `json:"builder" form:"required"`
  192. // A list of buildpacks to use
  193. Buildpacks []string `json:"buildpacks"`
  194. }