stacks.go 11 KB

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