namespace.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. //
  92. MetaVersion uint `json:"meta_version"`
  93. CreatedAt time.Time `json:"created_at"`
  94. Version uint `json:"version"`
  95. Name string `json:"name"`
  96. Namespace string `json:"namespace"`
  97. Applications []string `json:"applications"`
  98. Variables map[string]string `json:"variables"`
  99. }
  100. type EnvGroupMeta struct {
  101. MetaVersion uint `json:"meta_version"`
  102. CreatedAt time.Time `json:"created_at"`
  103. Version uint `json:"version"`
  104. Name string `json:"name"`
  105. Namespace string `json:"namespace"`
  106. }
  107. type GetEnvGroupRequest struct {
  108. Name string `schema:"name,required"`
  109. Version uint `schema:"version"`
  110. }
  111. type CloneEnvGroupRequest struct {
  112. Namespace string `json:"namespace" form:"required"`
  113. Name string `json:"name" form:"required"`
  114. CloneName string `json:"clone_name"`
  115. Version uint `json:"version"`
  116. }
  117. type GetEnvGroupAllRequest struct {
  118. Name string `schema:"name,required"`
  119. }
  120. type DeleteEnvGroupRequest struct {
  121. Name string `json:"name,required"`
  122. }
  123. type AddEnvGroupApplicationRequest struct {
  124. Name string `json:"name" form:"required"`
  125. ApplicationName string `json:"app_name" form:"required"`
  126. }
  127. type ListEnvGroupsResponse []*EnvGroupMeta
  128. // CreateEnvGroupRequest represents the request body to create or update an env group
  129. //
  130. // swagger:model
  131. type CreateEnvGroupRequest struct {
  132. // the name of the env group to create or update
  133. // example: prod-env-group
  134. Name string `json:"name" form:"required"`
  135. // the variables to include in the env group
  136. Variables map[string]string `json:"variables" form:"required"`
  137. // the secret variables to include in the env group
  138. SecretVariables map[string]string `json:"secret_variables"`
  139. }
  140. type CreateConfigMapResponse struct {
  141. *v1.ConfigMap
  142. }
  143. type UpdateConfigMapRequest struct {
  144. Name string `json:"name,required"`
  145. Variables map[string]string `json:"variables,required"`
  146. SecretVariables map[string]string `json:"secret_variables,required"`
  147. }
  148. type UpdateConfigMapResponse struct {
  149. *v1.ConfigMap
  150. }
  151. type RenameConfigMapRequest struct {
  152. Name string `json:"name,required"`
  153. NewName string `json:"new_name,required"`
  154. }
  155. type RenameConfigMapResponse struct {
  156. *v1.ConfigMap
  157. }
  158. type DeleteConfigMapRequest struct {
  159. Name string `schema:"name,required"`
  160. }
  161. type GetPodLogsRequest struct {
  162. Container string `schema:"container_name"`
  163. }
  164. type GetPreviousPodLogsRequest struct {
  165. Container string `schema:"container_name"`
  166. }
  167. type GetPreviousPodLogsResponse struct {
  168. PrevLogs []string `json:"previous_logs"`
  169. }
  170. type GetJobsRequest struct {
  171. Revision uint `schema:"revision"`
  172. }
  173. type GetJobRunsRequest struct {
  174. Status string `schema:"status"`
  175. Sort string `schema:"sort"`
  176. }
  177. type StreamJobRunsRequest struct {
  178. Name string `schema:"name"`
  179. }
  180. // GetEnvGroupResponse represents the response body containing an env group
  181. //
  182. // swagger: model
  183. type GetEnvGroupResponse struct {
  184. *EnvGroup
  185. // the stack ID of the stack containing this env group (if any)
  186. StackID string `json:"stack_id,omitempty"`
  187. }
  188. // CreateEnvGroupRequest represents the request body to create or update an env group
  189. //
  190. // swagger:model
  191. type EnvGroupReleaseRequest struct {
  192. ReleaseName string `json:"release_name" form:"required"`
  193. }