namespace.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. )
  12. // ReleaseListFilter is a struct that represents the various filter options used for
  13. // retrieving the releases
  14. type ReleaseListFilter struct {
  15. // swagger:ignore
  16. Namespace string `json:"namespace"`
  17. // the pagination limit
  18. //
  19. // in: query
  20. // example: 50
  21. Limit int `json:"limit"`
  22. // how many items to skip
  23. //
  24. // in: query
  25. // example: 10
  26. Skip int `json:"skip"`
  27. // whether to sort by date
  28. //
  29. // in: query
  30. // example: false
  31. ByDate bool `json:"byDate"`
  32. // which helm statuses to filter by
  33. //
  34. // in: query
  35. StatusFilter []string `json:"statusFilter"`
  36. }
  37. // listStatesFromNames accepts the following list of names:
  38. //
  39. // "deployed", "uninstalled", "uninstalling", "pending-install", "pending-upgrade",
  40. // "pending-rollback", "superseded", "failed"
  41. //
  42. // It returns an action.ListStates to be used in an action.List as filters for
  43. // releases in a certain state.
  44. func (h *ReleaseListFilter) listStatesFromNames() action.ListStates {
  45. var res action.ListStates = 0
  46. for _, name := range h.StatusFilter {
  47. res = res | res.FromName(name)
  48. }
  49. return res
  50. }
  51. // Apply sets the ReleaseListFilter options for an action.List
  52. func (h *ReleaseListFilter) Apply(list *action.List) {
  53. if h.Namespace == "" {
  54. list.AllNamespaces = true
  55. }
  56. list.Limit = h.Limit
  57. list.Offset = h.Skip
  58. list.StateMask = h.listStatesFromNames()
  59. if h.ByDate {
  60. list.ByDate = true
  61. }
  62. }
  63. type ListReleasesRequest struct {
  64. *ReleaseListFilter
  65. }
  66. // swagger:model
  67. type ListReleasesResponse []*release.Release
  68. type GetConfigMapRequest struct {
  69. Name string `schema:"name,required"`
  70. }
  71. type GetConfigMapResponse struct {
  72. *v1.ConfigMap
  73. }
  74. type ListConfigMapsResponse struct {
  75. *v1.ConfigMapList
  76. }
  77. type ConfigMapInput struct {
  78. Name string
  79. Namespace string
  80. Variables map[string]string
  81. SecretVariables map[string]string
  82. }
  83. type CreateConfigMapRequest struct {
  84. Name string `json:"name,required"`
  85. Variables map[string]string `json:"variables,required"`
  86. SecretVariables map[string]string `json:"secret_variables,required"`
  87. }
  88. type EnvGroup struct {
  89. MetaVersion uint `json:"meta_version"`
  90. CreatedAt time.Time `json:"created_at"`
  91. Version uint `json:"version"`
  92. Name string `json:"name"`
  93. Namespace string `json:"namespace"`
  94. Applications []string `json:"applications"`
  95. Variables map[string]string `json:"variables"`
  96. }
  97. type EnvGroupMeta struct {
  98. MetaVersion uint `json:"meta_version"`
  99. CreatedAt time.Time `json:"created_at"`
  100. Version uint `json:"version"`
  101. Name string `json:"name"`
  102. Namespace string `json:"namespace"`
  103. }
  104. type GetEnvGroupRequest struct {
  105. Name string `schema:"name,required"`
  106. Version uint `schema:"version"`
  107. }
  108. type CloneEnvGroupRequest struct {
  109. Namespace string `json:"namespace" form:"required"`
  110. Name string `json:"name" form:"required"`
  111. CloneName string `json:"clone_name"`
  112. Version uint `json:"version"`
  113. }
  114. type GetEnvGroupAllRequest struct {
  115. Name string `schema:"name,required"`
  116. }
  117. type DeleteEnvGroupRequest struct {
  118. Name string `json:"name,required"`
  119. }
  120. type AddEnvGroupApplicationRequest struct {
  121. Name string `json:"name" form:"required"`
  122. ApplicationName string `json:"app_name" form:"required"`
  123. }
  124. type ListEnvGroupsResponse []*EnvGroupMeta
  125. type CreateEnvGroupRequest struct {
  126. Name string `json:"name,required"`
  127. Variables map[string]string `json:"variables,required"`
  128. SecretVariables map[string]string `json:"secret_variables,required"`
  129. }
  130. type CreateConfigMapResponse struct {
  131. *v1.ConfigMap
  132. }
  133. type UpdateConfigMapRequest struct {
  134. Name string `json:"name,required"`
  135. Variables map[string]string `json:"variables,required"`
  136. SecretVariables map[string]string `json:"secret_variables,required"`
  137. }
  138. type UpdateConfigMapResponse struct {
  139. *v1.ConfigMap
  140. }
  141. type RenameConfigMapRequest struct {
  142. Name string `json:"name,required"`
  143. NewName string `json:"new_name,required"`
  144. }
  145. type RenameConfigMapResponse struct {
  146. *v1.ConfigMap
  147. }
  148. type DeleteConfigMapRequest struct {
  149. Name string `schema:"name,required"`
  150. }
  151. type GetPodLogsRequest struct {
  152. Container string `schema:"container_name"`
  153. }
  154. type GetPreviousPodLogsRequest struct {
  155. Container string `schema:"container_name"`
  156. }
  157. type GetPreviousPodLogsResponse struct {
  158. PrevLogs []string `json:"previous_logs"`
  159. }
  160. type GetJobsRequest struct {
  161. Revision uint `schema:"revision"`
  162. }
  163. type GetJobRunsRequest struct {
  164. Status string `schema:"status"`
  165. Sort string `schema:"sort"`
  166. }
  167. type StreamJobRunsRequest struct {
  168. Name string `schema:"name"`
  169. }