namespace.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package types
  2. import (
  3. "helm.sh/helm/v3/pkg/action"
  4. "helm.sh/helm/v3/pkg/release"
  5. v1 "k8s.io/api/core/v1"
  6. )
  7. const (
  8. URLParamPodName URLParam = "name"
  9. URLParamIngressName URLParam = "name"
  10. )
  11. // ReleaseListFilter is a struct that represents the various filter options used for
  12. // retrieving the releases
  13. type ReleaseListFilter struct {
  14. Namespace string `json:"namespace"`
  15. Limit int `json:"limit"`
  16. Skip int `json:"skip"`
  17. ByDate bool `json:"byDate"`
  18. StatusFilter []string `json:"statusFilter"`
  19. }
  20. // listStatesFromNames accepts the following list of names:
  21. //
  22. // "deployed", "uninstalled", "uninstalling", "pending-install", "pending-upgrade",
  23. // "pending-rollback", "superseded", "failed"
  24. //
  25. // It returns an action.ListStates to be used in an action.List as filters for
  26. // releases in a certain state.
  27. func (h *ReleaseListFilter) listStatesFromNames() action.ListStates {
  28. var res action.ListStates = 0
  29. for _, name := range h.StatusFilter {
  30. res = res | res.FromName(name)
  31. }
  32. return res
  33. }
  34. // Apply sets the ReleaseListFilter options for an action.List
  35. func (h *ReleaseListFilter) Apply(list *action.List) {
  36. if h.Namespace == "" {
  37. list.AllNamespaces = true
  38. }
  39. list.Limit = h.Limit
  40. list.Offset = h.Skip
  41. list.StateMask = h.listStatesFromNames()
  42. if h.ByDate {
  43. list.ByDate = true
  44. }
  45. }
  46. type ListReleasesRequest struct {
  47. *ReleaseListFilter
  48. }
  49. type ListReleasesResponse []*release.Release
  50. type GetConfigMapRequest struct {
  51. Name string `schema:"name,required"`
  52. }
  53. type GetConfigMapResponse struct {
  54. *v1.ConfigMap
  55. }
  56. type ListConfigMapsResponse struct {
  57. *v1.ConfigMapList
  58. }
  59. type ConfigMapInput struct {
  60. Name string
  61. Namespace string
  62. Variables map[string]string
  63. SecretVariables map[string]string
  64. }
  65. type CreateConfigMapRequest struct {
  66. Name string `json:"name,required"`
  67. Variables map[string]string `json:"variables,required"`
  68. SecretVariables map[string]string `json:"secret_variables,required"`
  69. }
  70. type CreateConfigMapResponse struct {
  71. *v1.ConfigMap
  72. }
  73. type UpdateConfigMapRequest struct {
  74. Name string `json:"name,required"`
  75. Variables map[string]string `json:"variables,required"`
  76. SecretVariables map[string]string `json:"secret_variables,required"`
  77. }
  78. type UpdateConfigMapResponse struct {
  79. *v1.ConfigMap
  80. }
  81. type RenameConfigMapRequest struct {
  82. Name string `json:"name,required"`
  83. NewName string `json:"new_name,required"`
  84. }
  85. type RenameConfigMapResponse struct {
  86. *v1.ConfigMap
  87. }
  88. type DeleteConfigMapRequest struct {
  89. Name string `schema:"name,required"`
  90. }