namespace.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. package types
  2. import (
  3. "time"
  4. "helm.sh/helm/v3/pkg/action"
  5. "helm.sh/helm/v3/pkg/release"
  6. v1 "k8s.io/api/core/v1"
  7. )
  8. const (
  9. URLParamPodName URLParam = "name"
  10. URLParamIngressName URLParam = "name"
  11. URLParamEnvGroupName URLParam = "name"
  12. URLParamEnvGroupVersion URLParam = "version"
  13. )
  14. // ReleaseListFilter is a struct that represents the various filter options used for
  15. // retrieving the releases
  16. type ReleaseListFilter struct {
  17. // swagger:ignore
  18. Namespace string `json:"namespace"`
  19. // the pagination limit
  20. //
  21. // in: query
  22. // example: 50
  23. Limit int `json:"limit"`
  24. // how many items to skip
  25. //
  26. // in: query
  27. // example: 10
  28. Skip int `json:"skip"`
  29. // whether to sort by date
  30. //
  31. // in: query
  32. // example: false
  33. ByDate bool `json:"byDate"`
  34. // which helm statuses to filter by
  35. //
  36. // in: query
  37. StatusFilter []string `json:"statusFilter"`
  38. }
  39. // listStatesFromNames accepts the following list of names:
  40. //
  41. // "deployed", "uninstalled", "uninstalling", "pending-install", "pending-upgrade",
  42. // "pending-rollback", "superseded", "failed"
  43. //
  44. // It returns an action.ListStates to be used in an action.List as filters for
  45. // releases in a certain state.
  46. func (h *ReleaseListFilter) listStatesFromNames() action.ListStates {
  47. var res action.ListStates = 0
  48. for _, name := range h.StatusFilter {
  49. res = res | res.FromName(name)
  50. }
  51. return res
  52. }
  53. // Apply sets the ReleaseListFilter options for an action.List
  54. func (h *ReleaseListFilter) Apply(list *action.List) {
  55. if h.Namespace == "" {
  56. list.AllNamespaces = true
  57. }
  58. list.Limit = h.Limit
  59. list.Offset = h.Skip
  60. list.StateMask = h.listStatesFromNames()
  61. if h.ByDate {
  62. list.ByDate = true
  63. }
  64. }
  65. type ListReleasesRequest struct {
  66. *ReleaseListFilter
  67. }
  68. // swagger:model
  69. type ListReleasesResponse []*release.Release
  70. type GetConfigMapRequest struct {
  71. Name string `schema:"name,required"`
  72. }
  73. type GetConfigMapResponse struct {
  74. *v1.ConfigMap
  75. }
  76. type ListConfigMapsResponse struct {
  77. *v1.ConfigMapList
  78. }
  79. type ConfigMapInput struct {
  80. Name string
  81. Namespace string
  82. Variables map[string]string
  83. SecretVariables map[string]string
  84. }
  85. type CreateConfigMapRequest struct {
  86. Name string `json:"name,required"`
  87. Variables map[string]string `json:"variables,required"`
  88. SecretVariables map[string]string `json:"secret_variables,required"`
  89. }
  90. type EnvGroup struct {
  91. MetaVersion uint `json:"meta_version"`
  92. CreatedAt time.Time `json:"created_at"`
  93. Version uint `json:"version"`
  94. Name string `json:"name"`
  95. Namespace string `json:"namespace"`
  96. Applications []string `json:"applications"`
  97. Variables map[string]string `json:"variables"`
  98. }
  99. type EnvGroupMeta struct {
  100. MetaVersion uint `json:"meta_version"`
  101. CreatedAt time.Time `json:"created_at"`
  102. Version uint `json:"version"`
  103. Name string `json:"name"`
  104. Namespace string `json:"namespace"`
  105. }
  106. type GetEnvGroupRequest struct {
  107. Name string `schema:"name,required"`
  108. Version uint `schema:"version"`
  109. }
  110. type CloneEnvGroupRequest struct {
  111. Namespace string `json:"namespace" form:"required"`
  112. Name string `json:"name" form:"required,dns1123"`
  113. CloneName string `json:"clone_name,dns1123"`
  114. Version uint `json:"version"`
  115. }
  116. type GetEnvGroupAllRequest struct {
  117. Name string `schema:"name,required"`
  118. }
  119. type DeleteEnvGroupRequest struct {
  120. Name string `json:"name,required"`
  121. }
  122. type AddEnvGroupApplicationRequest struct {
  123. Name string `json:"name" form:"required,dns1123"`
  124. ApplicationName string `json:"app_name" form:"required"`
  125. }
  126. type ListEnvGroupsResponse []*EnvGroupMeta
  127. // CreateEnvGroupRequest represents the request body to create or update an env group
  128. //
  129. // swagger:model
  130. type CreateEnvGroupRequest struct {
  131. // the name of the env group to create or update
  132. // example: prod-env-group
  133. Name string `json:"name" form:"required,dns1123"`
  134. // the variables to include in the env group
  135. Variables map[string]string `json:"variables" form:"required"`
  136. // the secret variables to include in the env group
  137. SecretVariables map[string]string `json:"secret_variables"`
  138. }
  139. type CreateConfigMapResponse struct {
  140. *v1.ConfigMap
  141. }
  142. type UpdateConfigMapRequest struct {
  143. Name string `json:"name,required"`
  144. Variables map[string]string `json:"variables,required"`
  145. SecretVariables map[string]string `json:"secret_variables,required"`
  146. }
  147. type UpdateConfigMapResponse struct {
  148. *v1.ConfigMap
  149. }
  150. type RenameConfigMapRequest struct {
  151. Name string `json:"name,required"`
  152. NewName string `json:"new_name,required"`
  153. }
  154. type RenameConfigMapResponse struct {
  155. *v1.ConfigMap
  156. }
  157. type DeleteConfigMapRequest struct {
  158. Name string `schema:"name,required"`
  159. }
  160. type GetPodLogsRequest struct {
  161. Container string `schema:"container_name"`
  162. }
  163. type GetPreviousPodLogsRequest struct {
  164. Container string `schema:"container_name"`
  165. }
  166. type GetPreviousPodLogsResponse struct {
  167. PrevLogs []string `json:"previous_logs"`
  168. }
  169. type GetJobsRequest struct {
  170. Revision uint `schema:"revision"`
  171. }
  172. type GetJobRunsRequest struct {
  173. Status string `schema:"status"`
  174. Sort string `schema:"sort"`
  175. }
  176. type StreamJobRunsRequest struct {
  177. Name string `schema:"name"`
  178. }
  179. type GetEnvGroupResponse struct {
  180. *EnvGroup
  181. StackID string `json:"stack_id,omitempty"`
  182. }
  183. // V1EnvGroupReleaseRequest represents the request body to add or remove a release in an env group
  184. //
  185. // swagger:model
  186. type V1EnvGroupReleaseRequest struct {
  187. ReleaseName string `json:"release_name" form:"required,dns1123"`
  188. }
  189. // V1EnvGroupResponse defines an env group
  190. //
  191. // swagger:model
  192. type V1EnvGroupResponse struct {
  193. // the UTC timestamp in RFC 3339 format indicating the creation time of the env group
  194. CreatedAt time.Time `json:"created_at"`
  195. // the version of the env group
  196. Version uint `json:"version"`
  197. // the name of the env group
  198. Name string `json:"name"`
  199. // the list of releases linked to this env group
  200. Releases []string `json:"releases"`
  201. // the variables contained in this env group
  202. Variables map[string]string `json:"variables"`
  203. // the ID of the stack containing this env group (if any)
  204. StackID string `json:"stack_id,omitempty"`
  205. }
  206. // V1EnvGroupsAllVersionsResponse represents the response body containing all versions of an env group
  207. //
  208. // swagger:model
  209. type V1EnvGroupsAllVersionsResponse []*V1EnvGroupResponse
  210. type V1EnvGroupMeta struct {
  211. // the UTC timestamp in RFC 3339 format indicating the creation time of the env group
  212. CreatedAt time.Time `json:"created_at"`
  213. // the name of the env group
  214. Name string `json:"name"`
  215. // the ID of the stack containing this env group (if any)
  216. StackID string `json:"stack_id,omitempty"`
  217. }
  218. // V1ListAllEnvGroupsResponse represents the response body containing the list of env groups
  219. //
  220. // swagger:model
  221. type V1ListAllEnvGroupsResponse []*V1EnvGroupMeta