namespace.go 2.5 KB

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