namespace.go 2.5 KB

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