stacks.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. }
  17. type CreateStackAppResourceRequest struct {
  18. // The URL of the Helm registry to pull the template from
  19. // required: true
  20. TemplateRepoURL string `json:"template_repo_url" form:"required"`
  21. // The name of the template in the Helm registry, such as `web`
  22. // required: true
  23. TemplateName string `json:"template_name" form:"required"`
  24. // The version of the template in the Helm registry, such as `v0.50.0`
  25. // required: true
  26. TemplateVersion string `json:"template_version" form:"required"`
  27. // The values to pass in to the template.
  28. Values map[string]interface{} `json:"values"`
  29. // The name of the resource.
  30. // required: true
  31. Name string `json:"name" form:"required"`
  32. // The name of the source config (must exist inside `source_configs`).
  33. // required: true
  34. SourceConfigName string `json:"source_config_name" form:"required"`
  35. }
  36. // swagger:model
  37. type Stack struct {
  38. // The time that the stack was initially created
  39. CreatedAt time.Time `json:"created_at"`
  40. // The time that the stack was last updated
  41. UpdatedAt time.Time `json:"updated_at"`
  42. // The display name of the stack
  43. Name string `json:"name"`
  44. // A unique id for the stack
  45. ID string `json:"id"`
  46. // The latest revision for the stack
  47. LatestRevision *StackRevision `json:"latest_revision,omitempty"`
  48. // The list of revisions deployed for this stack
  49. Revisions []StackRevisionMeta `json:"revisions"`
  50. }
  51. type StackResource struct {
  52. // The time that this resource was initially created
  53. CreatedAt time.Time `json:"created_at"`
  54. // The time that this resource was last updated
  55. UpdatedAt time.Time `json:"updated_at"`
  56. // The stack ID that this resource belongs to
  57. StackID string `json:"stack_id"`
  58. // The numerical revision id that this resource belongs to
  59. StackRevisionID uint `json:"stack_revision_id"`
  60. // The name of the resource
  61. Name string `json:"name"`
  62. // The id for this resource
  63. ID string `json:"id"`
  64. // If this is an app resource, app-specific information for the resource
  65. StackAppData *StackResourceAppData `json:"stack_app_data,omitempty"`
  66. // The source configuration for this stack
  67. StackSourceConfig *StackSourceConfig `json:"stack_source_config,omitempty"`
  68. }
  69. type StackResourceAppData struct {
  70. // The URL of the Helm registry to pull the template from
  71. TemplateRepoURL string `json:"template_repo_url"`
  72. // The name of the template in the Helm registry, such as `web`
  73. TemplateName string `json:"template_name"`
  74. // The version of the template in the Helm registry, such as `v0.50.0`
  75. TemplateVersion string `json:"template_version"`
  76. }
  77. type StackRevisionStatus string
  78. const (
  79. StackRevisionStatusDeploying StackRevisionStatus = "deploying"
  80. StackRevisionStatusFailed StackRevisionStatus = "failed"
  81. StackRevisionStatusDeployed StackRevisionStatus = "deployed"
  82. )
  83. type StackRevisionMeta struct {
  84. // The time that this revision was created
  85. CreatedAt time.Time `json:"created_at"`
  86. // The id of the revision
  87. ID uint `json:"id"`
  88. // The status of the revision
  89. Status StackRevisionStatus `json:"status"`
  90. // The stack ID that this source config belongs to
  91. StackID string `json:"stack_id"`
  92. }
  93. type StackRevision struct {
  94. *StackRevisionMeta
  95. // The list of resources deployed in this revision
  96. Resources []StackResource `json:"resources"`
  97. SourceConfigs []StackSourceConfig `json:"source_configs"`
  98. }
  99. type StackSourceConfig struct {
  100. // The time that the source configuration was initially created
  101. CreatedAt time.Time `json:"created_at"`
  102. // The time that the source configuration was last updated
  103. UpdatedAt time.Time `json:"updated_at"`
  104. // The stack ID that this source config belongs to
  105. StackID string `json:"stack_id"`
  106. // The numerical revision id that this source config belongs to
  107. StackRevisionID uint `json:"stack_revision_id"`
  108. // The display name of the stack source
  109. Name string `json:"name"`
  110. // The unique id of the stack source config
  111. ID string `json:"id"`
  112. // The complete image repo uri used by the source
  113. ImageRepoURI string `json:"image_repo_uri"`
  114. // The current image tag used by the application
  115. ImageTag string `json:"image_tag"`
  116. // If this field is empty, the resource is deployed directly from the image repo uri
  117. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  118. }
  119. // swagger:model
  120. type CreateStackSourceConfigRequest struct {
  121. // required: true
  122. Name string `json:"name"`
  123. // required: true
  124. ImageRepoURI string `json:"image_repo_uri"`
  125. // required: true
  126. ImageTag string `json:"image_tag"`
  127. // If this field is empty, the resource is deployed directly from the image repo uri
  128. StackSourceConfigBuild *StackSourceConfigBuild `json:"build,omitempty"`
  129. }
  130. type StackSourceConfigBuild struct {
  131. // The build method to use: can be `docker` (for dockerfiles), or `pack` (for buildpacks)
  132. // required: true
  133. Method string `json:"method" form:"required"`
  134. // The path to the build context (the root folder of the application). For example, `.` or `./app`
  135. // required: true
  136. FolderPath string `json:"folder_path" form:"required"`
  137. // The remote Git configuration to use. If not passed in, this application will not appear to be linked to a
  138. // remote Git repository.
  139. StackSourceConfigBuildGit *StackSourceConfigBuildGit `json:"git,omitempty"`
  140. // The Dockerfile build configuration, if `method` is `docker`
  141. StackSourceConfigBuildDockerfile *StackSourceConfigBuildDockerfile `json:"dockerfile,omitempty"`
  142. // The buildpack configuration, if method is `pack`
  143. StackSourceConfigBuildPack *StackSourceConfigBuildPack `json:"buildpack,omitempty"`
  144. }
  145. type StackSourceConfigBuildGit struct {
  146. // The git integration kind: can be `github` or `gitlab`
  147. GitIntegrationKind string `json:"git_integration_kind"`
  148. // The integration id of the github or gitlab integration
  149. GitIntegrationID uint `json:"git_integration_id"`
  150. // The git repo in ${owner}/${repo} form
  151. GitRepo string `json:"git_repo"`
  152. // The git branch to use
  153. GitBranch string `json:"git_branch"`
  154. }
  155. type StackSourceConfigBuildDockerfile struct {
  156. // The path to the dockerfile from the root directory. Defaults to `./Dockerfile`.
  157. DockerfilePath string `json:"dockerfile_path" form:"required"`
  158. }
  159. type StackSourceConfigBuildPack struct {
  160. // The buildpack builder to use
  161. // required: true
  162. Builder string `json:"builder" form:"required"`
  163. // A list of buildpacks to use
  164. Buildpacks []string `json:"buildpacks"`
  165. }