tiller.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 TillerCreateOptions struct {
  19. ClusterBaseOptions
  20. KubeContext string `json:"kube_context"`
  21. Namespace string `json:"namespace" default:"kube-system"`
  22. // Upgrade if Tiller is already installed
  23. Upgrade bool `json:"upgrade"`
  24. // Name of service account
  25. ServiceAccount string `json:"service_account" default:"tiller"`
  26. // Use the canary Tiller image
  27. Canary bool `json:"canary_image"`
  28. // Override Tiller image
  29. Image string `json:"tiller_image" default:"yunion/tiller:v2.9.1"`
  30. // Limit the maximum number of revisions saved per release. Use 0 for no limit.
  31. MaxHistory int `json:"history_max"`
  32. }
  33. func (o TillerCreateOptions) Params() *jsonutils.JSONDict {
  34. params := o.ClusterBaseOptions.Params()
  35. if len(o.KubeContext) > 0 {
  36. params.Add(jsonutils.NewString(o.KubeContext), "kube_context")
  37. }
  38. params.Add(jsonutils.NewString(o.Namespace), "namespace")
  39. params.Add(jsonutils.NewString(o.ServiceAccount), "service_account")
  40. if o.Canary {
  41. params.Add(jsonutils.JSONTrue, "canary_image")
  42. }
  43. if o.Upgrade {
  44. params.Add(jsonutils.JSONTrue, "upgrade")
  45. }
  46. if len(o.Image) > 0 {
  47. params.Add(jsonutils.NewString(o.Image), "tiller_image")
  48. }
  49. if o.MaxHistory > 0 {
  50. params.Add(jsonutils.NewInt(int64(o.MaxHistory)), "history_max")
  51. }
  52. return params
  53. }