clientset.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. /*
  2. Copyright 2017 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 kubernetes
  14. import (
  15. glog "github.com/golang/glog"
  16. discovery "k8s.io/client-go/discovery"
  17. appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
  18. authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1"
  19. authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
  20. authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
  21. authorizationv1beta1 "k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
  22. autoscalingv1 "k8s.io/client-go/kubernetes/typed/autoscaling/v1"
  23. autoscalingv2alpha1 "k8s.io/client-go/kubernetes/typed/autoscaling/v2alpha1"
  24. batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
  25. batchv2alpha1 "k8s.io/client-go/kubernetes/typed/batch/v2alpha1"
  26. certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
  27. corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
  28. extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
  29. policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1"
  30. rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1"
  31. rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1"
  32. settingsv1alpha1 "k8s.io/client-go/kubernetes/typed/settings/v1alpha1"
  33. storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
  34. storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
  35. rest "k8s.io/client-go/rest"
  36. flowcontrol "k8s.io/client-go/util/flowcontrol"
  37. )
  38. type Interface interface {
  39. Discovery() discovery.DiscoveryInterface
  40. CoreV1() corev1.CoreV1Interface
  41. // Deprecated: please explicitly pick a version if possible.
  42. Core() corev1.CoreV1Interface
  43. AppsV1beta1() appsv1beta1.AppsV1beta1Interface
  44. // Deprecated: please explicitly pick a version if possible.
  45. Apps() appsv1beta1.AppsV1beta1Interface
  46. AuthenticationV1() authenticationv1.AuthenticationV1Interface
  47. // Deprecated: please explicitly pick a version if possible.
  48. Authentication() authenticationv1.AuthenticationV1Interface
  49. AuthenticationV1beta1() authenticationv1beta1.AuthenticationV1beta1Interface
  50. AuthorizationV1() authorizationv1.AuthorizationV1Interface
  51. // Deprecated: please explicitly pick a version if possible.
  52. Authorization() authorizationv1.AuthorizationV1Interface
  53. AuthorizationV1beta1() authorizationv1beta1.AuthorizationV1beta1Interface
  54. AutoscalingV1() autoscalingv1.AutoscalingV1Interface
  55. // Deprecated: please explicitly pick a version if possible.
  56. Autoscaling() autoscalingv1.AutoscalingV1Interface
  57. AutoscalingV2alpha1() autoscalingv2alpha1.AutoscalingV2alpha1Interface
  58. BatchV1() batchv1.BatchV1Interface
  59. // Deprecated: please explicitly pick a version if possible.
  60. Batch() batchv1.BatchV1Interface
  61. BatchV2alpha1() batchv2alpha1.BatchV2alpha1Interface
  62. CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface
  63. // Deprecated: please explicitly pick a version if possible.
  64. Certificates() certificatesv1beta1.CertificatesV1beta1Interface
  65. ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface
  66. // Deprecated: please explicitly pick a version if possible.
  67. Extensions() extensionsv1beta1.ExtensionsV1beta1Interface
  68. PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface
  69. // Deprecated: please explicitly pick a version if possible.
  70. Policy() policyv1beta1.PolicyV1beta1Interface
  71. RbacV1beta1() rbacv1beta1.RbacV1beta1Interface
  72. // Deprecated: please explicitly pick a version if possible.
  73. Rbac() rbacv1beta1.RbacV1beta1Interface
  74. RbacV1alpha1() rbacv1alpha1.RbacV1alpha1Interface
  75. SettingsV1alpha1() settingsv1alpha1.SettingsV1alpha1Interface
  76. // Deprecated: please explicitly pick a version if possible.
  77. Settings() settingsv1alpha1.SettingsV1alpha1Interface
  78. StorageV1beta1() storagev1beta1.StorageV1beta1Interface
  79. StorageV1() storagev1.StorageV1Interface
  80. // Deprecated: please explicitly pick a version if possible.
  81. Storage() storagev1.StorageV1Interface
  82. }
  83. // Clientset contains the clients for groups. Each group has exactly one
  84. // version included in a Clientset.
  85. type Clientset struct {
  86. *discovery.DiscoveryClient
  87. *corev1.CoreV1Client
  88. *appsv1beta1.AppsV1beta1Client
  89. *authenticationv1.AuthenticationV1Client
  90. *authenticationv1beta1.AuthenticationV1beta1Client
  91. *authorizationv1.AuthorizationV1Client
  92. *authorizationv1beta1.AuthorizationV1beta1Client
  93. *autoscalingv1.AutoscalingV1Client
  94. *autoscalingv2alpha1.AutoscalingV2alpha1Client
  95. *batchv1.BatchV1Client
  96. *batchv2alpha1.BatchV2alpha1Client
  97. *certificatesv1beta1.CertificatesV1beta1Client
  98. *extensionsv1beta1.ExtensionsV1beta1Client
  99. *policyv1beta1.PolicyV1beta1Client
  100. *rbacv1beta1.RbacV1beta1Client
  101. *rbacv1alpha1.RbacV1alpha1Client
  102. *settingsv1alpha1.SettingsV1alpha1Client
  103. *storagev1beta1.StorageV1beta1Client
  104. *storagev1.StorageV1Client
  105. }
  106. // CoreV1 retrieves the CoreV1Client
  107. func (c *Clientset) CoreV1() corev1.CoreV1Interface {
  108. if c == nil {
  109. return nil
  110. }
  111. return c.CoreV1Client
  112. }
  113. // Deprecated: Core retrieves the default version of CoreClient.
  114. // Please explicitly pick a version.
  115. func (c *Clientset) Core() corev1.CoreV1Interface {
  116. if c == nil {
  117. return nil
  118. }
  119. return c.CoreV1Client
  120. }
  121. // AppsV1beta1 retrieves the AppsV1beta1Client
  122. func (c *Clientset) AppsV1beta1() appsv1beta1.AppsV1beta1Interface {
  123. if c == nil {
  124. return nil
  125. }
  126. return c.AppsV1beta1Client
  127. }
  128. // Deprecated: Apps retrieves the default version of AppsClient.
  129. // Please explicitly pick a version.
  130. func (c *Clientset) Apps() appsv1beta1.AppsV1beta1Interface {
  131. if c == nil {
  132. return nil
  133. }
  134. return c.AppsV1beta1Client
  135. }
  136. // AuthenticationV1 retrieves the AuthenticationV1Client
  137. func (c *Clientset) AuthenticationV1() authenticationv1.AuthenticationV1Interface {
  138. if c == nil {
  139. return nil
  140. }
  141. return c.AuthenticationV1Client
  142. }
  143. // Deprecated: Authentication retrieves the default version of AuthenticationClient.
  144. // Please explicitly pick a version.
  145. func (c *Clientset) Authentication() authenticationv1.AuthenticationV1Interface {
  146. if c == nil {
  147. return nil
  148. }
  149. return c.AuthenticationV1Client
  150. }
  151. // AuthenticationV1beta1 retrieves the AuthenticationV1beta1Client
  152. func (c *Clientset) AuthenticationV1beta1() authenticationv1beta1.AuthenticationV1beta1Interface {
  153. if c == nil {
  154. return nil
  155. }
  156. return c.AuthenticationV1beta1Client
  157. }
  158. // AuthorizationV1 retrieves the AuthorizationV1Client
  159. func (c *Clientset) AuthorizationV1() authorizationv1.AuthorizationV1Interface {
  160. if c == nil {
  161. return nil
  162. }
  163. return c.AuthorizationV1Client
  164. }
  165. // Deprecated: Authorization retrieves the default version of AuthorizationClient.
  166. // Please explicitly pick a version.
  167. func (c *Clientset) Authorization() authorizationv1.AuthorizationV1Interface {
  168. if c == nil {
  169. return nil
  170. }
  171. return c.AuthorizationV1Client
  172. }
  173. // AuthorizationV1beta1 retrieves the AuthorizationV1beta1Client
  174. func (c *Clientset) AuthorizationV1beta1() authorizationv1beta1.AuthorizationV1beta1Interface {
  175. if c == nil {
  176. return nil
  177. }
  178. return c.AuthorizationV1beta1Client
  179. }
  180. // AutoscalingV1 retrieves the AutoscalingV1Client
  181. func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface {
  182. if c == nil {
  183. return nil
  184. }
  185. return c.AutoscalingV1Client
  186. }
  187. // Deprecated: Autoscaling retrieves the default version of AutoscalingClient.
  188. // Please explicitly pick a version.
  189. func (c *Clientset) Autoscaling() autoscalingv1.AutoscalingV1Interface {
  190. if c == nil {
  191. return nil
  192. }
  193. return c.AutoscalingV1Client
  194. }
  195. // AutoscalingV2alpha1 retrieves the AutoscalingV2alpha1Client
  196. func (c *Clientset) AutoscalingV2alpha1() autoscalingv2alpha1.AutoscalingV2alpha1Interface {
  197. if c == nil {
  198. return nil
  199. }
  200. return c.AutoscalingV2alpha1Client
  201. }
  202. // BatchV1 retrieves the BatchV1Client
  203. func (c *Clientset) BatchV1() batchv1.BatchV1Interface {
  204. if c == nil {
  205. return nil
  206. }
  207. return c.BatchV1Client
  208. }
  209. // Deprecated: Batch retrieves the default version of BatchClient.
  210. // Please explicitly pick a version.
  211. func (c *Clientset) Batch() batchv1.BatchV1Interface {
  212. if c == nil {
  213. return nil
  214. }
  215. return c.BatchV1Client
  216. }
  217. // BatchV2alpha1 retrieves the BatchV2alpha1Client
  218. func (c *Clientset) BatchV2alpha1() batchv2alpha1.BatchV2alpha1Interface {
  219. if c == nil {
  220. return nil
  221. }
  222. return c.BatchV2alpha1Client
  223. }
  224. // CertificatesV1beta1 retrieves the CertificatesV1beta1Client
  225. func (c *Clientset) CertificatesV1beta1() certificatesv1beta1.CertificatesV1beta1Interface {
  226. if c == nil {
  227. return nil
  228. }
  229. return c.CertificatesV1beta1Client
  230. }
  231. // Deprecated: Certificates retrieves the default version of CertificatesClient.
  232. // Please explicitly pick a version.
  233. func (c *Clientset) Certificates() certificatesv1beta1.CertificatesV1beta1Interface {
  234. if c == nil {
  235. return nil
  236. }
  237. return c.CertificatesV1beta1Client
  238. }
  239. // ExtensionsV1beta1 retrieves the ExtensionsV1beta1Client
  240. func (c *Clientset) ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface {
  241. if c == nil {
  242. return nil
  243. }
  244. return c.ExtensionsV1beta1Client
  245. }
  246. // Deprecated: Extensions retrieves the default version of ExtensionsClient.
  247. // Please explicitly pick a version.
  248. func (c *Clientset) Extensions() extensionsv1beta1.ExtensionsV1beta1Interface {
  249. if c == nil {
  250. return nil
  251. }
  252. return c.ExtensionsV1beta1Client
  253. }
  254. // PolicyV1beta1 retrieves the PolicyV1beta1Client
  255. func (c *Clientset) PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface {
  256. if c == nil {
  257. return nil
  258. }
  259. return c.PolicyV1beta1Client
  260. }
  261. // Deprecated: Policy retrieves the default version of PolicyClient.
  262. // Please explicitly pick a version.
  263. func (c *Clientset) Policy() policyv1beta1.PolicyV1beta1Interface {
  264. if c == nil {
  265. return nil
  266. }
  267. return c.PolicyV1beta1Client
  268. }
  269. // RbacV1beta1 retrieves the RbacV1beta1Client
  270. func (c *Clientset) RbacV1beta1() rbacv1beta1.RbacV1beta1Interface {
  271. if c == nil {
  272. return nil
  273. }
  274. return c.RbacV1beta1Client
  275. }
  276. // Deprecated: Rbac retrieves the default version of RbacClient.
  277. // Please explicitly pick a version.
  278. func (c *Clientset) Rbac() rbacv1beta1.RbacV1beta1Interface {
  279. if c == nil {
  280. return nil
  281. }
  282. return c.RbacV1beta1Client
  283. }
  284. // RbacV1alpha1 retrieves the RbacV1alpha1Client
  285. func (c *Clientset) RbacV1alpha1() rbacv1alpha1.RbacV1alpha1Interface {
  286. if c == nil {
  287. return nil
  288. }
  289. return c.RbacV1alpha1Client
  290. }
  291. // SettingsV1alpha1 retrieves the SettingsV1alpha1Client
  292. func (c *Clientset) SettingsV1alpha1() settingsv1alpha1.SettingsV1alpha1Interface {
  293. if c == nil {
  294. return nil
  295. }
  296. return c.SettingsV1alpha1Client
  297. }
  298. // Deprecated: Settings retrieves the default version of SettingsClient.
  299. // Please explicitly pick a version.
  300. func (c *Clientset) Settings() settingsv1alpha1.SettingsV1alpha1Interface {
  301. if c == nil {
  302. return nil
  303. }
  304. return c.SettingsV1alpha1Client
  305. }
  306. // StorageV1beta1 retrieves the StorageV1beta1Client
  307. func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
  308. if c == nil {
  309. return nil
  310. }
  311. return c.StorageV1beta1Client
  312. }
  313. // StorageV1 retrieves the StorageV1Client
  314. func (c *Clientset) StorageV1() storagev1.StorageV1Interface {
  315. if c == nil {
  316. return nil
  317. }
  318. return c.StorageV1Client
  319. }
  320. // Deprecated: Storage retrieves the default version of StorageClient.
  321. // Please explicitly pick a version.
  322. func (c *Clientset) Storage() storagev1.StorageV1Interface {
  323. if c == nil {
  324. return nil
  325. }
  326. return c.StorageV1Client
  327. }
  328. // Discovery retrieves the DiscoveryClient
  329. func (c *Clientset) Discovery() discovery.DiscoveryInterface {
  330. if c == nil {
  331. return nil
  332. }
  333. return c.DiscoveryClient
  334. }
  335. // NewForConfig creates a new Clientset for the given config.
  336. func NewForConfig(c *rest.Config) (*Clientset, error) {
  337. configShallowCopy := *c
  338. if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
  339. configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
  340. }
  341. var cs Clientset
  342. var err error
  343. cs.CoreV1Client, err = corev1.NewForConfig(&configShallowCopy)
  344. if err != nil {
  345. return nil, err
  346. }
  347. cs.AppsV1beta1Client, err = appsv1beta1.NewForConfig(&configShallowCopy)
  348. if err != nil {
  349. return nil, err
  350. }
  351. cs.AuthenticationV1Client, err = authenticationv1.NewForConfig(&configShallowCopy)
  352. if err != nil {
  353. return nil, err
  354. }
  355. cs.AuthenticationV1beta1Client, err = authenticationv1beta1.NewForConfig(&configShallowCopy)
  356. if err != nil {
  357. return nil, err
  358. }
  359. cs.AuthorizationV1Client, err = authorizationv1.NewForConfig(&configShallowCopy)
  360. if err != nil {
  361. return nil, err
  362. }
  363. cs.AuthorizationV1beta1Client, err = authorizationv1beta1.NewForConfig(&configShallowCopy)
  364. if err != nil {
  365. return nil, err
  366. }
  367. cs.AutoscalingV1Client, err = autoscalingv1.NewForConfig(&configShallowCopy)
  368. if err != nil {
  369. return nil, err
  370. }
  371. cs.AutoscalingV2alpha1Client, err = autoscalingv2alpha1.NewForConfig(&configShallowCopy)
  372. if err != nil {
  373. return nil, err
  374. }
  375. cs.BatchV1Client, err = batchv1.NewForConfig(&configShallowCopy)
  376. if err != nil {
  377. return nil, err
  378. }
  379. cs.BatchV2alpha1Client, err = batchv2alpha1.NewForConfig(&configShallowCopy)
  380. if err != nil {
  381. return nil, err
  382. }
  383. cs.CertificatesV1beta1Client, err = certificatesv1beta1.NewForConfig(&configShallowCopy)
  384. if err != nil {
  385. return nil, err
  386. }
  387. cs.ExtensionsV1beta1Client, err = extensionsv1beta1.NewForConfig(&configShallowCopy)
  388. if err != nil {
  389. return nil, err
  390. }
  391. cs.PolicyV1beta1Client, err = policyv1beta1.NewForConfig(&configShallowCopy)
  392. if err != nil {
  393. return nil, err
  394. }
  395. cs.RbacV1beta1Client, err = rbacv1beta1.NewForConfig(&configShallowCopy)
  396. if err != nil {
  397. return nil, err
  398. }
  399. cs.RbacV1alpha1Client, err = rbacv1alpha1.NewForConfig(&configShallowCopy)
  400. if err != nil {
  401. return nil, err
  402. }
  403. cs.SettingsV1alpha1Client, err = settingsv1alpha1.NewForConfig(&configShallowCopy)
  404. if err != nil {
  405. return nil, err
  406. }
  407. cs.StorageV1beta1Client, err = storagev1beta1.NewForConfig(&configShallowCopy)
  408. if err != nil {
  409. return nil, err
  410. }
  411. cs.StorageV1Client, err = storagev1.NewForConfig(&configShallowCopy)
  412. if err != nil {
  413. return nil, err
  414. }
  415. cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
  416. if err != nil {
  417. glog.Errorf("failed to create the DiscoveryClient: %v", err)
  418. return nil, err
  419. }
  420. return &cs, nil
  421. }
  422. // NewForConfigOrDie creates a new Clientset for the given config and
  423. // panics if there is an error in the config.
  424. func NewForConfigOrDie(c *rest.Config) *Clientset {
  425. var cs Clientset
  426. cs.CoreV1Client = corev1.NewForConfigOrDie(c)
  427. cs.AppsV1beta1Client = appsv1beta1.NewForConfigOrDie(c)
  428. cs.AuthenticationV1Client = authenticationv1.NewForConfigOrDie(c)
  429. cs.AuthenticationV1beta1Client = authenticationv1beta1.NewForConfigOrDie(c)
  430. cs.AuthorizationV1Client = authorizationv1.NewForConfigOrDie(c)
  431. cs.AuthorizationV1beta1Client = authorizationv1beta1.NewForConfigOrDie(c)
  432. cs.AutoscalingV1Client = autoscalingv1.NewForConfigOrDie(c)
  433. cs.AutoscalingV2alpha1Client = autoscalingv2alpha1.NewForConfigOrDie(c)
  434. cs.BatchV1Client = batchv1.NewForConfigOrDie(c)
  435. cs.BatchV2alpha1Client = batchv2alpha1.NewForConfigOrDie(c)
  436. cs.CertificatesV1beta1Client = certificatesv1beta1.NewForConfigOrDie(c)
  437. cs.ExtensionsV1beta1Client = extensionsv1beta1.NewForConfigOrDie(c)
  438. cs.PolicyV1beta1Client = policyv1beta1.NewForConfigOrDie(c)
  439. cs.RbacV1beta1Client = rbacv1beta1.NewForConfigOrDie(c)
  440. cs.RbacV1alpha1Client = rbacv1alpha1.NewForConfigOrDie(c)
  441. cs.SettingsV1alpha1Client = settingsv1alpha1.NewForConfigOrDie(c)
  442. cs.StorageV1beta1Client = storagev1beta1.NewForConfigOrDie(c)
  443. cs.StorageV1Client = storagev1.NewForConfigOrDie(c)
  444. cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
  445. return &cs
  446. }
  447. // New creates a new Clientset for the given RESTClient.
  448. func New(c rest.Interface) *Clientset {
  449. var cs Clientset
  450. cs.CoreV1Client = corev1.New(c)
  451. cs.AppsV1beta1Client = appsv1beta1.New(c)
  452. cs.AuthenticationV1Client = authenticationv1.New(c)
  453. cs.AuthenticationV1beta1Client = authenticationv1beta1.New(c)
  454. cs.AuthorizationV1Client = authorizationv1.New(c)
  455. cs.AuthorizationV1beta1Client = authorizationv1beta1.New(c)
  456. cs.AutoscalingV1Client = autoscalingv1.New(c)
  457. cs.AutoscalingV2alpha1Client = autoscalingv2alpha1.New(c)
  458. cs.BatchV1Client = batchv1.New(c)
  459. cs.BatchV2alpha1Client = batchv2alpha1.New(c)
  460. cs.CertificatesV1beta1Client = certificatesv1beta1.New(c)
  461. cs.ExtensionsV1beta1Client = extensionsv1beta1.New(c)
  462. cs.PolicyV1beta1Client = policyv1beta1.New(c)
  463. cs.RbacV1beta1Client = rbacv1beta1.New(c)
  464. cs.RbacV1alpha1Client = rbacv1alpha1.New(c)
  465. cs.SettingsV1alpha1Client = settingsv1alpha1.New(c)
  466. cs.StorageV1beta1Client = storagev1beta1.New(c)
  467. cs.StorageV1Client = storagev1.New(c)
  468. cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
  469. return &cs
  470. }