stacks.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. // A unique id for the stack
  57. ID string `json:"id"`
  58. // The latest revision for the stack
  59. LatestRevision *StackRevision `json:"latest_revision,omitempty"`
  60. // The list of revisions deployed for this stack
  61. Revisions []StackRevisionMeta `json:"revisions,omitempty"`
  62. }
  63. // swagger:model
  64. type StackListResponse []Stack
  65. type StackResource struct {
  66. // The time that this resource was initially created
  67. CreatedAt time.Time `json:"created_at"`
  68. // The time that this resource was last updated
  69. UpdatedAt time.Time `json:"updated_at"`
  70. // The stack ID that this resource belongs to
  71. StackID string `json:"stack_id"`
  72. // The numerical revision id that this resource belongs to
  73. StackRevisionID uint `json:"stack_revision_id"`
  74. // The name of the resource
  75. Name string `json:"name"`
  76. // The id for this resource
  77. ID string `json:"id"`
  78. // If this is an app resource, app-specific information for the resource
  79. StackAppData *StackResourceAppData `json:"stack_app_data,omitempty"`
  80. // The source configuration for this stack
  81. StackSourceConfig *StackSourceConfig `json:"stack_source_config,omitempty"`
  82. }
  83. type StackResourceAppData struct {
  84. // The URL of the Helm registry to pull the template from
  85. TemplateRepoURL string `json:"template_repo_url"`
  86. // The name of the template in the Helm registry, such as `web`
  87. TemplateName string `json:"template_name"`
  88. // The version of the template in the Helm registry, such as `v0.50.0`
  89. TemplateVersion string `json:"template_version"`
  90. }
  91. type StackRevisionStatus string
  92. const (
  93. StackRevisionStatusDeploying StackRevisionStatus = "deploying"
  94. StackRevisionStatusFailed StackRevisionStatus = "failed"
  95. StackRevisionStatusDeployed StackRevisionStatus = "deployed"
  96. )
  97. type StackRevisionMeta struct {
  98. // The time that this revision was created
  99. CreatedAt time.Time `json:"created_at"`
  100. // The id of the revision
  101. ID uint `json:"id"`
  102. // The status of the revision
  103. Status StackRevisionStatus `json:"status"`
  104. // The stack ID that this source config belongs to
  105. StackID string `json:"stack_id"`
  106. }
  107. type StackRevision struct {
  108. *StackRevisionMeta
  109. // The reason for any error or status change
  110. Reason string `json:"reason"`
  111. // The message associated with an error or status change
  112. Message string `json:"message"`
  113. // The list of resources deployed in this revision
  114. Resources []StackResource `json:"resources"`
  115. SourceConfigs []StackSourceConfig `json:"source_configs"`
  116. }
  117. type StackSourceConfig struct {
  118. // The time that the source configuration was initially created
  119. CreatedAt time.Time `json:"created_at"`
  120. // The time that the source configuration was last updated
  121. UpdatedAt time.Time `json:"updated_at"`
  122. // The stack ID that this source config belongs to
  123. StackID string `json:"stack_id"`
  124. // The numerical revision id that this source config belongs to
  125. StackRevisionID uint `json:"stack_revision_id"`
  126. // The display name of the stack source
  127. Name string `json:"name"`
  128. // The unique id of the stack source config
  129. ID string `json:"id"`
  130. // The complete image repo uri used by the source
  131. ImageRepoURI string `json:"image_repo_uri"`
  132. // The current image tag used by the application
  133. ImageTag string `json:"image_tag"`
  134. // If this field is empty, the resource is deployed directly from the image repo uri
  135. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  136. }
  137. // swagger:model
  138. type CreateStackSourceConfigRequest struct {
  139. // required: true
  140. Name string `json:"name"`
  141. // required: true
  142. ImageRepoURI string `json:"image_repo_uri"`
  143. // required: true
  144. ImageTag string `json:"image_tag"`
  145. // If this field is empty, the resource is deployed directly from the image repo uri
  146. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  147. }
  148. // swagger:model
  149. type UpdateStackSourceConfigRequest struct {
  150. // required: true
  151. Name string `json:"name"`
  152. // required: true
  153. ImageRepoURI string `json:"image_repo_uri"`
  154. // required: true
  155. ImageTag string `json:"image_tag"`
  156. }
  157. type StackSourceConfigBuild struct {
  158. // The build method to use: can be `docker` (for dockerfiles), or `pack` (for buildpacks)
  159. // required: true
  160. Method string `json:"method" form:"required"`
  161. // The path to the build context (the root folder of the application). For example, `.` or `./app`
  162. // required: true
  163. FolderPath string `json:"folder_path" form:"required"`
  164. // The remote Git configuration to use. If not passed in, this application will not appear to be linked to a
  165. // remote Git repository.
  166. StackSourceConfigBuildGit *StackSourceConfigBuildGit `json:"git,omitempty"`
  167. // The Dockerfile build configuration, if `method` is `docker`
  168. StackSourceConfigBuildDockerfile *StackSourceConfigBuildDockerfile `json:"dockerfile,omitempty"`
  169. // The buildpack configuration, if method is `pack`
  170. StackSourceConfigBuildPack *StackSourceConfigBuildPack `json:"buildpack,omitempty"`
  171. }
  172. type StackSourceConfigBuildGit struct {
  173. // The git integration kind: can be `github` or `gitlab`
  174. GitIntegrationKind string `json:"git_integration_kind"`
  175. // The integration id of the github or gitlab integration
  176. GitIntegrationID uint `json:"git_integration_id"`
  177. // The git repo in ${owner}/${repo} form
  178. GitRepo string `json:"git_repo"`
  179. // The git branch to use
  180. GitBranch string `json:"git_branch"`
  181. }
  182. type StackSourceConfigBuildDockerfile struct {
  183. // The path to the dockerfile from the root directory. Defaults to `./Dockerfile`.
  184. DockerfilePath string `json:"dockerfile_path" form:"required"`
  185. }
  186. type StackSourceConfigBuildPack struct {
  187. // The buildpack builder to use
  188. // required: true
  189. Builder string `json:"builder" form:"required"`
  190. // A list of buildpacks to use
  191. Buildpacks []string `json:"buildpacks"`
  192. }