stacks.go 11 KB

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