stacks.go 11 KB

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