stacks.go 9.9 KB

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