charts.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package k8s
  15. import (
  16. "yunion.io/x/jsonutils"
  17. )
  18. type ChartListOptions struct {
  19. BaseListOptions
  20. Repo string `help:"Repository name"`
  21. RepoUrl string `help:"Repository url"`
  22. AllVersion bool `help:"Get Chart all history versions"`
  23. Keyword string `help:"Chart keyword"`
  24. Version string `help:"Chart semver version filter"`
  25. Type string `help:"Chart type" choices:"internal|external"`
  26. }
  27. func (o ChartListOptions) Params() (*jsonutils.JSONDict, error) {
  28. params, err := o.BaseListOptions.Params()
  29. if err != nil {
  30. return nil, err
  31. }
  32. if len(o.Name) != 0 {
  33. params.Add(jsonutils.NewString(o.Name), "name")
  34. }
  35. if len(o.Repo) != 0 {
  36. params.Add(jsonutils.NewString(o.Repo), "repo")
  37. }
  38. if len(o.RepoUrl) != 0 {
  39. params.Add(jsonutils.NewString(o.RepoUrl), "repo_url")
  40. }
  41. if o.AllVersion {
  42. params.Add(jsonutils.JSONTrue, "all_version")
  43. }
  44. if len(o.Version) != 0 {
  45. params.Add(jsonutils.NewString(o.Version), "version")
  46. }
  47. if len(o.Keyword) != 0 {
  48. params.Add(jsonutils.NewString(o.Keyword), "keyword")
  49. }
  50. if o.Type != "" {
  51. params.Add(jsonutils.NewString(o.Type), "type")
  52. }
  53. return params, nil
  54. }
  55. type ChartGetOptions struct {
  56. REPO string `help:"Repo of the chart"`
  57. NAME string `help:"Chart name"`
  58. Version string `help:"Chart version"`
  59. }
  60. func (o ChartGetOptions) Params() *jsonutils.JSONDict {
  61. params := jsonutils.NewDict()
  62. params.Add(jsonutils.NewString(o.REPO), "repo")
  63. if o.Version != "" {
  64. params.Add(jsonutils.NewString(o.Version), "version")
  65. }
  66. return params
  67. }