extensions.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/extensions"
  16. "k8s.io/kubernetes/pkg/client/restclient"
  17. )
  18. // Interface holds the experimental methods for clients of Kubernetes
  19. // to allow mock testing.
  20. // Features of Extensions group are not supported and may be changed or removed in
  21. // incompatible ways at any time.
  22. type ExtensionsInterface interface {
  23. ScaleNamespacer
  24. DaemonSetsNamespacer
  25. DeploymentsNamespacer
  26. JobsNamespacer
  27. IngressNamespacer
  28. NetworkPolicyNamespacer
  29. ThirdPartyResourceNamespacer
  30. ReplicaSetsNamespacer
  31. PodSecurityPoliciesInterface
  32. StorageClassesInterface
  33. }
  34. // ExtensionsClient is used to interact with experimental Kubernetes features.
  35. // Features of Extensions group are not supported and may be changed or removed in
  36. // incompatible ways at any time.
  37. type ExtensionsClient struct {
  38. *restclient.RESTClient
  39. }
  40. func (c *ExtensionsClient) PodSecurityPolicies() PodSecurityPolicyInterface {
  41. return newPodSecurityPolicy(c)
  42. }
  43. func (c *ExtensionsClient) Scales(namespace string) ScaleInterface {
  44. return newScales(c, namespace)
  45. }
  46. func (c *ExtensionsClient) DaemonSets(namespace string) DaemonSetInterface {
  47. return newDaemonSets(c, namespace)
  48. }
  49. func (c *ExtensionsClient) Deployments(namespace string) DeploymentInterface {
  50. return newDeployments(c, namespace)
  51. }
  52. func (c *ExtensionsClient) Jobs(namespace string) JobInterface {
  53. return newJobs(c, namespace)
  54. }
  55. func (c *ExtensionsClient) Ingress(namespace string) IngressInterface {
  56. return newIngress(c, namespace)
  57. }
  58. func (c *ExtensionsClient) NetworkPolicies(namespace string) NetworkPolicyInterface {
  59. return newNetworkPolicies(c, namespace)
  60. }
  61. func (c *ExtensionsClient) ThirdPartyResources() ThirdPartyResourceInterface {
  62. return newThirdPartyResources(c)
  63. }
  64. func (c *ExtensionsClient) ReplicaSets(namespace string) ReplicaSetInterface {
  65. return newReplicaSets(c, namespace)
  66. }
  67. func (c *ExtensionsClient) StorageClasses() StorageClassInterface {
  68. return newStorageClasses(c)
  69. }
  70. // NewExtensions creates a new ExtensionsClient for the given config. This client
  71. // provides access to experimental Kubernetes features.
  72. // Features of Extensions group are not supported and may be changed or removed in
  73. // incompatible ways at any time.
  74. func NewExtensions(c *restclient.Config) (*ExtensionsClient, error) {
  75. config := *c
  76. if err := setGroupDefaults(extensions.GroupName, &config); err != nil {
  77. return nil, err
  78. }
  79. client, err := restclient.RESTClientFor(&config)
  80. if err != nil {
  81. return nil, err
  82. }
  83. return &ExtensionsClient{client}, nil
  84. }
  85. // NewExtensionsOrDie creates a new ExtensionsClient for the given config and
  86. // panics if there is an error in the config.
  87. // Features of Extensions group are not supported and may be changed or removed in
  88. // incompatible ways at any time.
  89. func NewExtensionsOrDie(c *restclient.Config) *ExtensionsClient {
  90. client, err := NewExtensions(c)
  91. if err != nil {
  92. panic(err)
  93. }
  94. return client
  95. }