Commit Graph

90 Commits

Author SHA1 Message Date
Tim Hockin
c4339eeca9 Replace uses of ObjectGoPrintDiff with cmp.Diff
ObjectGoPrintDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: 9627c50ef37f3b5274486e6f5ad37b73b1b69bf0
2023-03-23 11:31:25 -07:00
Tim Hockin
7114041b4f Replace uses of diff.ObjectDiff with cmp.Diff
ObjectDiff is already a shim over cmp.Diff, so no actual output or
behavior changes

Kubernetes-commit: 29c0b73d640b6e50c4f2dfeee7b07ca66a530dbd
2023-03-23 11:29:01 -07:00
John Howard
089d04441d client-go: support Shutdown() for metadata and dynamic informers (#114434)
* client-go: support `Shutdown()` for metadata and dynamic informers

Followup to https://github.com/kubernetes/kubernetes/pull/112200,
specifically
https://github.com/kubernetes/kubernetes/pull/112200#issuecomment-1344812038.

* add comments

* Defer lock

Kubernetes-commit: b99fe0d5b9896dd3fe9a2c1bc3b399a18ad080d2
2023-02-28 23:09:17 -08:00
Andy Goldstein
37897aff8d Reflector: support logging Unstructured type
Add an annotation that can be added to the exampleType passed to
NewReflector to indicate the expected type for the Reflector. This is
useful for types such as unstuctured.Unstructured, which, when used with
a dynamic informer, do not have their TypeMeta filled in.

Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>

Kubernetes-commit: 474fc8c5234000bce666a6b02f7ffbb295ef135f
2022-08-17 15:49:26 -04:00
Harsimran Singh Maan
0c269b7a5b remove selflink as per review feedback
Kubernetes-commit: 5da368d012f7635f9718876061bec864b7dcf8e6
2022-10-17 09:19:21 -07:00
Harsimran Singh Maan
fbd8e9aa52 fix failing test assertions
Kubernetes-commit: c8714ebd118760f8d68e9b536d0350129af12d9b
2022-02-22 16:05:40 -08:00
Harsimran Singh Maan
1f10368e31 Preserve metadata for fake dynamic client unstructured lists
Signed-off-by: Harsimran Singh Maan <maan.harry@gmail.com>

Kubernetes-commit: ac904454c24bebd9501ea4701d38f55f25ec9c33
2021-12-31 15:15:18 -08:00
Steve Kuznetsov
34e8a5d862 client-go: factor the dynamic client similarly to others
All other clients:

 - expose a New() method that takes a rest.Interface
 - expose their RESTClient()
 - return pointers to the type, not instances of an interface that the
   type implements

For code that is generic over all Kubernetes clients, and for general
developer experience, it's best to make sure that this client adheres to
these common practices.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Kubernetes-commit: 74af6f1e7d9057bfcb64f4d875063c14041937e5
2022-09-28 08:57:22 -06:00
Antoine Pelisse
a4b84d86ec Validate segments with client-go/dynamic
Kubernetes-commit: 7d64440dd1edf2acb8e71ecd6726904962c6bd02
2022-08-30 16:32:10 -07:00
inosato
27de641f75 Remove ioutil from client-go
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 88dfa51b6003c90e8f0a0508939a1d79950a40df
2022-07-30 20:54:41 +09:00
Abirdcfly
65b1e7d3c0 clean Unreachable code
Signed-off-by: Abirdcfly <fp544037857@gmail.com>

Kubernetes-commit: f71718d6448418d0289b9649905a16bfb1962b68
2022-07-19 00:58:17 +08:00
Kevin Delgado
4eab6be14c Add Apply and ApplyStatus methods to dynamic ResourceInterface
Kubernetes-commit: 581ac7f4465ed97ddc5c62f04376ac427e121601
2022-04-12 20:24:15 +00:00
Antonio Ojea
12956a0d53 expose NewForConfigAndClient for the dynamic client
Kubernetes-commit: b584195e5cc0a1094318ba886a9aecd2f675d59c
2021-10-19 15:58:58 +02:00
scott
61ae14a896 set the content-type Header when the dynamic client sends the request
Kubernetes-commit: 2ad09c6a87b9150598c6119d653acc983c5c7a11
2021-08-12 20:17:07 +08:00
dprotaso
c6c0ca0e1e Simplify use of the fake dynamic client
With the introduction of GVK to the fake dynamic client it made using
the fake much more cumbersome.

Specifically:
- requires manual registration of list types
- mismatch between scheme types and passed in fixtures would result in errors

The PR changes the constructor method NewSimpleDynamicClient to do the following:
- rewire the schemes to unstructured types
- typed fixtures are converted to unstructured types
- automatically register fixture gvks with the scheme

This should make the dynamic client 'flexible' with it's inputs like it was
before

Kubernetes-commit: 418fa71b6b1d1fba930daaba1f8ecf55070b4bdf
2021-06-16 14:51:00 -04:00
Markus Thömmes
3579fb3012 Implement a FakeClient interface
Kubernetes-commit: cf26825e3d9b89526e13bb53f74354593477205c
2021-03-15 14:47:24 +01:00
Markus Thömmes
57471dea7c Add Tracker() function to fake dynamic client
Kubernetes-commit: 4c4c78fd398899b4349c486063be6f4935cd92ce
2021-03-10 14:16:51 +01:00
David Eads
20c034c178 add GVK to fake dynamic client to match actual behavior
Kubernetes-commit: f4383458432cd67714e9ce0acde56a2ed5c24a21
2020-10-29 15:53:34 -04:00
Andrew Sy Kim
1db2969ba9 fake dynamic client: support *List kinds
Today the dynamic fake client is not aware of *List kinds, so List calls return UnstructuredList
objects without TypeMeta. This patch updates client-go's fake object tracker to store a map of
GVR to list GVKs. In this way, the list GVK can be set for UnstructuredList objects.

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

Kubernetes-commit: 0845b863e89912e0d6c4380f8bc362646326386a
2020-10-27 23:08:46 -04:00
Andrew Sy Kim
f45d9426eb fake dynamic client: document that List does not preserve TypeMeta in UnstructuredList
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

Kubernetes-commit: deb1bb8bfff012e03ccc80fd85ee4fc2f9fceb6d
2020-09-28 09:29:06 -04:00
Martin Schimandl
3450a048bc Fix staticchecks in vendor/k8s.io/client-go
Kubernetes-commit: 13c017056c924e148113e42786a511ed2fee7594
2020-10-01 12:40:32 +02:00
Quan Tian
faf5681d1c Improve fake clientset performance
The fake clientset used a slice to store each kind of objects, it's
quite slow to init the clientset with massive objects because it checked
existence of an object by traversing all objects before adding it, which
leads to O(n^2) time complexity. Also, the Create, Update, Get, Delete
methods needs to traverse all objects, which affects the time statistic
of code that calls them.

This patch changed to use a map to store each kind of objects, reduced
the time complexity of initializing clientset to O(n) and the Create,
Update, Get, Delete to O(1).

For example:
Before this patch, it took ~29s to init a clientset with 30000 Pods,
and 2~4ms to create and get an Pod.
After this patch, it took ~50ms to init a clientset with 30000 Pods,
and tens of µs to create and get an Pod.

Kubernetes-commit: 7e15e31e11e48a6db855e30ca9b07dbce3047577
2020-03-27 18:39:20 +08:00
Wayne Witzel III
4562e6a9dd add tests for NewFilteredDynamicSharedInformerFactory namespace
Signed-off-by: Wayne Witzel III <witzelw@vmware.com>

Kubernetes-commit: 2064d90e92430f96e440cfc4fc03a69b4243bc6c
2019-06-20 13:04:36 -04:00
Jordan Liggitt
1faf9e8d03 client-go dynamic context
Kubernetes-commit: 6fa54d715fbc992afb483e71d450d5dbd66990eb
2020-03-06 01:27:11 -05:00
Jordan Liggitt
2c6476911c client-go dynamic client: pass DeleteOptions by value
Kubernetes-commit: 161b7513f73185745f8c17db5a56b7229157f876
2020-03-06 10:20:27 -05:00
Mike Danese
b136e9eb2b refactor
Kubernetes-commit: d55d6175f8e2cfdab0b79aac72046a652c2eb515
2020-01-27 18:19:44 -08:00
Clayton Coleman
881cd219a8 dynamic: The dynamic client no longer needs a special cased watch
By correctly handling content type negotiation, we can avoid the
need for a special version of watch and use the same code path as
typed clients.

Kubernetes-commit: 3f94f80b0a79293e54d7080aaf7a64d7df8b1d4a
2019-11-03 15:10:12 -05:00
Michael FIG
c80077227f Honour NewFilteredDynamicSharedInformerFactory namespace argument
Kubernetes-commit: 2ed3272a5e428690c066a7c09e5c6a2fad3d74b6
2019-05-15 11:48:17 -06:00
Clayton Coleman
33b8c3799f Unify runtime.SerializerInfo with negotiate.AcceptedMediaTypes
There was no reason to have two types and this avoids ~10% of allocations
on the GET code path.

```
BenchmarkGet-12          	  100000	    109045 ns/op	   17608 B/op	     146 allocs/op

BenchmarkGet-12          	  100000	    108850 ns/op	   15942 B/op	     132 allocs/op
```

Kubernetes-commit: 0489d0b1cf139253b82f73b072578073bc5616d6
2019-03-21 21:00:55 -04:00
Levi Blackstone
5691acfeec Check for required name parameter in dynamic client
The Create, Delete, Get, Patch, Update and UpdateStatus
methods in the dynamic client all expect the name
parameter to be non-empty, but did not validate this
requirement, which could lead to a panic. Add explicit
checks to these methods.

Kubernetes-commit: a9cba032dedbed9d04828c917a79a8371305d058
2019-03-06 16:21:33 -07:00
Clayton Coleman
abaa46c115 Support Table and PartialObjectMetadata on watch
Clean up the code paths that lead to objects being transformed and output with negotiation.
Remove some duplicate code that was not consistent. Now, watch will respond correctly to
Table and PartialObjectMetadata requests. Add unit and integration tests.

When transforming responses to Tables, only the first watch event for a given type will
include the columns. Columns will not change unless the watch is restarted.

Add a volume attachment printer and tighten up table validation error cases.

Disable protobuf from table conversion because Tables don't have protobuf because they
use `interface{}`

Kubernetes-commit: 3230a0b4fd14a6166f8362d4732e199e8779c426
2018-11-28 23:50:12 -05:00
Steve Kriss
f0c6576981 client-fake object tracker: support merge patch
Signed-off-by: Steve Kriss <krisss@vmware.com>

Kubernetes-commit: d425fe29bd808db54c59e3e0ecdedbe735b8f68b
2019-02-21 13:47:16 -07:00
luhualin
7f4dae86e2 fix dynamic informer tweakListOptions
Kubernetes-commit: 94b0bd897d04e1668d96db8d9b5e353b15f2f2da
2019-02-21 19:33:04 +08:00
Antoine Pelisse
35efedd302 API Machinery, Kubectl and tests
Kubernetes-commit: 0e1d50e70fdc9ed838d75a7a1abbe5fa607d22a1
2019-01-16 21:14:42 -08:00
Jordan Liggitt
4f3f813d72 Find current resourceVersion for waiting for deletion/conditions
Kubernetes-commit: c12d8a56f8397b6d1dfcb853eb36de0fc06cbd9f
2019-01-11 10:38:18 -05:00
Ville Aikas
41406bf985 Add support for JSON patch in fake client
Kubernetes-commit: a363b153851326ece7f81f4c1ae0a1ab8700a209
2018-10-02 13:30:52 +00:00
p0lyn0mial
bfcfd82283 adds dynamic informer factory
Kubernetes-commit: 4d479aff37edfcdb17ac5a5f89b1e3f95d118f30
2018-09-17 19:07:00 +02:00
Chao Xu
97dc22a90a Populates the fake dynamic client scheme
Kubernetes-commit: db20e16b87b38ace132c375f9ae414a98b451d7b
2018-09-26 18:32:49 -07:00
p0lyn0mial
cf575eb079 adds dynamic lister
Kubernetes-commit: 8b43a0005a5bd3c2e415d55efb6c9d77c1c655b1
2018-09-17 19:07:00 +02:00
Antoine Pelisse
29424b90cb dry-run: Update DynamicClient to pass Create/Update options
Kubernetes-commit: 71970d6475f6570d933fa9f22be2ebc20a9ace6f
2018-08-01 10:35:43 -07:00
David Eads
875f881c7c add missing OrDie variant for dynamic client construction
Kubernetes-commit: 75e28b0dd48a3a2d90d1bbb8133114134c6d0528
2018-07-23 16:29:35 -04:00
David Eads
4b43750b96 fix dynamic client listing bug
Kubernetes-commit: 60afd0ba81aeccb04169716c815348ceb424730d
2018-07-11 13:05:54 -04:00
David Eads
f6af22edb3 fix dynamic client name
Kubernetes-commit: fd044d152ee13a6cb812e4c3e7504ee8e24b5b8c
2018-05-09 12:58:12 -04:00
David Eads
1c46f3b96c move old dynamic client to deprecated-client
Kubernetes-commit: d8924bc1c914c63fd7e93f7e562edfddd911d9d7
2018-05-09 12:54:24 -04:00
David Eads
77541e5cb7 add subresource support for the dynamic client
Kubernetes-commit: 82e32d2a3260807237a69bc40fb371db640d26fc
2018-05-09 12:52:12 -04:00
David Eads
1f41b75933 add fake dynamic client
Kubernetes-commit: 121b698492fcf546c9264b27d086b18d915c607f
2018-04-26 15:36:07 -04:00
David Eads
7757aaeb14 make dynamic client slightly easier to use
Kubernetes-commit: 5ff923c7f931a34632df1f5a5400adbec33d49bf
2018-04-27 11:29:05 -04:00
David Eads
7205c0679a remove versioning interface
Kubernetes-commit: e2fc5cf259463f896213afdef15d58ef9a91eb35
2018-04-25 10:55:17 -04:00
xuzhonghu
2b0acf6f5a fix bug in dynamicResourceClient.UpdateStatus should encode
Kubernetes-commit: 9e8ce9535d9ce46791304e4ea3d1694e09b9ae9f
2018-04-27 14:07:11 +08:00
David Eads
2e1683e1a1 add easy to use dynamic client
Kubernetes-commit: 3632037e600d82a954c05ecd4f9cb6f1ca93d41c
2018-04-24 13:41:40 -04:00