namespace.go 4.3 KB

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