releaseapp.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 AppBaseCreateOptions struct {
  19. NamespaceWithClusterOptions
  20. ReleaseCreateUpdateOptions
  21. Name string `help:"Release name, If unspecified, it will autogenerate one for you"`
  22. }
  23. func (o AppBaseCreateOptions) Params() (*jsonutils.JSONDict, error) {
  24. params, err := o.ReleaseCreateUpdateOptions.Params()
  25. if err != nil {
  26. return nil, err
  27. }
  28. params.Update(o.NamespaceWithClusterOptions.Params())
  29. if o.Name != "" {
  30. params.Add(jsonutils.NewString(o.Name), "release_name")
  31. }
  32. return params, nil
  33. }
  34. type AppCreateOptions struct {
  35. AppBaseCreateOptions
  36. ChartName string `help:"Helm release app chart name, e.g yunion/meter, yunion/monitor-stack"`
  37. }
  38. func (o AppCreateOptions) Params() (*jsonutils.JSONDict, error) {
  39. params, err := o.AppBaseCreateOptions.Params()
  40. if err != nil {
  41. return nil, err
  42. }
  43. if o.ChartName != "" {
  44. params.Add(jsonutils.NewString(o.ChartName), "chart_name")
  45. }
  46. return params, nil
  47. }