policy.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package unversioned
  14. import (
  15. "k8s.io/kubernetes/pkg/apis/policy"
  16. "k8s.io/kubernetes/pkg/client/restclient"
  17. )
  18. type PolicyInterface interface {
  19. PodDisruptionBudgetNamespacer
  20. }
  21. // PolicyClient is used to interact with Kubernetes batch features.
  22. type PolicyClient struct {
  23. *restclient.RESTClient
  24. }
  25. func (c *PolicyClient) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface {
  26. return newPodDisruptionBudget(c, namespace)
  27. }
  28. func NewPolicy(c *restclient.Config) (*PolicyClient, error) {
  29. config := *c
  30. if err := setGroupDefaults(policy.GroupName, &config); err != nil {
  31. return nil, err
  32. }
  33. client, err := restclient.RESTClientFor(&config)
  34. if err != nil {
  35. return nil, err
  36. }
  37. return &PolicyClient{client}, nil
  38. }
  39. func NewPolicyOrDie(c *restclient.Config) *PolicyClient {
  40. client, err := NewPolicy(c)
  41. if err != nil {
  42. panic(err)
  43. }
  44. return client
  45. }