cluster_resource.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. "yunion.io/x/onecloud/pkg/apis"
  18. )
  19. type ClusterResourceCreateOptions struct {
  20. CLUSTER string `default:"$K8S_CLUSTER" help:"Kubernetes cluster name"`
  21. NAME string `help:"Name of resource"`
  22. }
  23. func (o ClusterResourceCreateOptions) Params() (jsonutils.JSONObject, error) {
  24. params := jsonutils.NewDict()
  25. params.Add(jsonutils.NewString(o.CLUSTER), "cluster_id")
  26. params.Add(jsonutils.NewString(o.NAME), "name")
  27. return params, nil
  28. }
  29. type NamespaceResourceCreateOptions struct {
  30. apis.DomainLevelResourceCreateInput
  31. CLUSTER string `default:"$K8S_CLUSTER" help:"Kubernetes cluster name"`
  32. NAMESPACE string `help:"Namespace of resource"`
  33. }
  34. func (o NamespaceResourceCreateOptions) Params() (jsonutils.JSONObject, error) {
  35. params := jsonutils.Marshal(o.DomainLevelResourceCreateInput).(*jsonutils.JSONDict)
  36. params.Add(jsonutils.NewString(o.CLUSTER), "cluster_id")
  37. params.Add(jsonutils.NewString(o.NAMESPACE), "namespace_id")
  38. return params, nil
  39. }
  40. type ClusterResourceUpdateOptions struct {
  41. ID string `help:"Id of resource"`
  42. }
  43. func (o ClusterResourceUpdateOptions) GetId() string {
  44. return o.ID
  45. }
  46. type NamespaceResourceUpdateOptions struct {
  47. ClusterResourceUpdateOptions
  48. }