2
0

namespace.go 6.7 KB

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