stacks.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. // A list of env groups which can be synced to an application
  17. EnvGroups []*CreateStackEnvGroupRequest `json:"env_groups,omitempty" form:"required,dive,required"`
  18. }
  19. // swagger:model
  20. type PutStackSourceConfigRequest struct {
  21. SourceConfigs []*CreateStackSourceConfigRequest `json:"source_configs,omitempty" form:"required,dive,required"`
  22. }
  23. const URLParamStackRevisionNumber URLParam = "stack_revision_number"
  24. // swagger:model
  25. type StackRollbackRequest struct {
  26. TargetRevision uint `json:"target_revision"`
  27. }
  28. // swagger:model
  29. type PatchStackSourceConfigRequest struct {
  30. SourceConfig *UpdateStackSourceConfigRequest `json:"source_config,omitempty" form:"required"`
  31. }
  32. type CreateStackAppResourceRequest struct {
  33. // The URL of the Helm registry to pull the template from. If not set, this defaults to `https://charts.getporter.dev`.
  34. TemplateRepoURL string `json:"template_repo_url"`
  35. // The name of the template in the Helm registry, such as `web`
  36. // required: true
  37. TemplateName string `json:"template_name" form:"required"`
  38. // The version of the template in the Helm registry, such as `v0.50.0`
  39. // required: true
  40. TemplateVersion string `json:"template_version" form:"required"`
  41. // The values to pass in to the template.
  42. Values map[string]interface{} `json:"values"`
  43. // The name of the resource.
  44. // required: true
  45. Name string `json:"name" form:"required"`
  46. // The name of the source config (must exist inside `source_configs`).
  47. // required: true
  48. SourceConfigName string `json:"source_config_name" form:"required"`
  49. }
  50. type UpdateStackNameRequest struct {
  51. Name string `json:"name" form:"required"`
  52. }
  53. // swagger:model
  54. type Stack struct {
  55. // The time that the stack was initially created
  56. CreatedAt time.Time `json:"created_at"`
  57. // The time that the stack was last updated
  58. UpdatedAt time.Time `json:"updated_at"`
  59. // The display name of the stack
  60. Name string `json:"name"`
  61. // The namespace that the stack was deployed to
  62. Namespace string `json:"namespace"`
  63. // A unique id for the stack
  64. ID string `json:"id"`
  65. // The latest revision for the stack
  66. LatestRevision *StackRevision `json:"latest_revision,omitempty"`
  67. // The list of revisions deployed for this stack
  68. Revisions []StackRevisionMeta `json:"revisions,omitempty"`
  69. }
  70. // swagger:model
  71. type ListStackRevisionsResponse []StackRevision
  72. // swagger:model
  73. type StackListResponse []Stack
  74. type StackResource struct {
  75. // The time that this resource was initially created
  76. CreatedAt time.Time `json:"created_at"`
  77. // The time that this resource was last updated
  78. UpdatedAt time.Time `json:"updated_at"`
  79. // The stack ID that this resource belongs to
  80. StackID string `json:"stack_id"`
  81. // The numerical revision id that this resource belongs to
  82. StackRevisionID uint `json:"stack_revision_id"`
  83. // The name of the resource
  84. Name string `json:"name"`
  85. // The id for this resource
  86. ID string `json:"id"`
  87. // If this is an app resource, app-specific information for the resource
  88. StackAppData *StackResourceAppData `json:"stack_app_data,omitempty"`
  89. // The source configuration that this resource uses, if this is an application resource
  90. StackSourceConfig *StackSourceConfig `json:"stack_source_config,omitempty"`
  91. }
  92. type StackResourceAppData struct {
  93. // The URL of the Helm registry to pull the template from
  94. TemplateRepoURL string `json:"template_repo_url"`
  95. // The name of the template in the Helm registry, such as `web`
  96. TemplateName string `json:"template_name"`
  97. // The version of the template in the Helm registry, such as `v0.50.0`
  98. TemplateVersion string `json:"template_version"`
  99. }
  100. type StackRevisionStatus string
  101. const (
  102. StackRevisionStatusDeploying StackRevisionStatus = "deploying"
  103. StackRevisionStatusFailed StackRevisionStatus = "failed"
  104. StackRevisionStatusDeployed StackRevisionStatus = "deployed"
  105. )
  106. type StackRevisionMeta struct {
  107. // The time that this revision was created
  108. CreatedAt time.Time `json:"created_at"`
  109. // The id of the revision
  110. ID uint `json:"id"`
  111. // The status of the revision
  112. Status StackRevisionStatus `json:"status"`
  113. // The stack ID that this source config belongs to
  114. StackID string `json:"stack_id"`
  115. }
  116. type StackRevision struct {
  117. *StackRevisionMeta
  118. // The reason for any error or status change
  119. Reason string `json:"reason"`
  120. // The message associated with an error or status change
  121. Message string `json:"message"`
  122. // The list of resources deployed in this revision
  123. Resources []StackResource `json:"resources"`
  124. // The list of source configs deployed in this revision
  125. SourceConfigs []StackSourceConfig `json:"source_configs"`
  126. // The list of env groups scoped to this stack
  127. EnvGroups []StackEnvGroup `json:"env_groups"`
  128. }
  129. type StackEnvGroup struct {
  130. // The time that this resource was initially created
  131. CreatedAt time.Time `json:"created_at"`
  132. // The time that this resource was last updated
  133. UpdatedAt time.Time `json:"updated_at"`
  134. // The stack ID that this resource belongs to
  135. StackID string `json:"stack_id"`
  136. // The numerical revision id that this resource belongs to
  137. StackRevisionID uint `json:"stack_revision_id"`
  138. // The name of the resource
  139. Name string `json:"name"`
  140. // The id for this resource
  141. ID string `json:"id"`
  142. // The version of the env group which is being used
  143. EnvGroupVersion uint `json:"env_group_version"`
  144. }
  145. type StackSourceConfig struct {
  146. // The time that the source configuration was initially created
  147. CreatedAt time.Time `json:"created_at"`
  148. // The time that the source configuration was last updated
  149. UpdatedAt time.Time `json:"updated_at"`
  150. // The stack ID that this source config belongs to
  151. StackID string `json:"stack_id"`
  152. // The numerical revision id that this source config belongs to
  153. StackRevisionID uint `json:"stack_revision_id"`
  154. // The display name of the stack source
  155. Name string `json:"name"`
  156. // The unique id of the stack source config
  157. ID string `json:"id"`
  158. // The complete image repo uri used by the source
  159. ImageRepoURI string `json:"image_repo_uri"`
  160. // The current image tag used by the application
  161. ImageTag string `json:"image_tag"`
  162. // If this field is empty, the resource is deployed directly from the image repo uri
  163. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  164. // Unique ID to identify between revisions
  165. StableSourceConfigID string `json:"source_config_id"`
  166. }
  167. // swagger:model
  168. type CreateStackEnvGroupRequest struct {
  169. // The name of the env group
  170. // required: true
  171. Name string `json:"name" form:"required"`
  172. // The non-secret variables to set in the env group
  173. // required: true
  174. Variables map[string]string `json:"variables,required" form:"required"`
  175. // The secret variables to set in the env group
  176. // required: true
  177. SecretVariables map[string]string `json:"secret_variables,required" form:"required"`
  178. // The list of applications that this env group should be synced to. These applications **must** be present
  179. // in the stack - if an env group is created from a stack, syncing to applications which are not in the stack
  180. // is not supported
  181. LinkedApplications []string `json:"linked_applications"`
  182. }
  183. // swagger:model
  184. type CreateStackSourceConfigRequest struct {
  185. // required: true
  186. Name string `json:"name" form:"required"`
  187. // required: true
  188. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  189. // required: true
  190. ImageTag string `json:"image_tag" form:"required"`
  191. StableSourceConfigID string `json:"source_config_id,omitempty"`
  192. // If this field is empty, the resource is deployed directly from the image repo uri
  193. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  194. }
  195. // swagger:model
  196. type UpdateStackSourceConfigRequest struct {
  197. // required: true
  198. Name string `json:"name" form:"required"`
  199. // required: true
  200. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  201. // required: true
  202. ImageTag string `json:"image_tag" form:"required"`
  203. }
  204. type StackSourceConfigBuild struct {
  205. // The build method to use: can be `docker` (for dockerfiles), or `pack` (for buildpacks)
  206. // required: true
  207. Method string `json:"method" form:"required"`
  208. // The path to the build context (the root folder of the application). For example, `.` or `./app`
  209. // required: true
  210. FolderPath string `json:"folder_path" form:"required"`
  211. // The remote Git configuration to use. If not passed in, this application will not appear to be linked to a
  212. // remote Git repository.
  213. StackSourceConfigBuildGit *StackSourceConfigBuildGit `json:"git,omitempty"`
  214. // The Dockerfile build configuration, if `method` is `docker`
  215. StackSourceConfigBuildDockerfile *StackSourceConfigBuildDockerfile `json:"dockerfile,omitempty"`
  216. // The buildpack configuration, if method is `pack`
  217. StackSourceConfigBuildPack *StackSourceConfigBuildPack `json:"buildpack,omitempty"`
  218. }
  219. type StackSourceConfigBuildGit struct {
  220. // The git integration kind: can be `github` or `gitlab`
  221. GitIntegrationKind string `json:"git_integration_kind"`
  222. // The integration id of the github or gitlab integration
  223. GitIntegrationID uint `json:"git_integration_id"`
  224. // The git repo in ${owner}/${repo} form
  225. GitRepo string `json:"git_repo"`
  226. // The git branch to use
  227. GitBranch string `json:"git_branch"`
  228. }
  229. type StackSourceConfigBuildDockerfile struct {
  230. // The path to the dockerfile from the root directory. Defaults to `./Dockerfile`.
  231. DockerfilePath string `json:"dockerfile_path" form:"required"`
  232. }
  233. type StackSourceConfigBuildPack struct {
  234. // The buildpack builder to use
  235. // required: true
  236. Builder string `json:"builder" form:"required"`
  237. // A list of buildpacks to use
  238. Buildpacks []string `json:"buildpacks"`
  239. }