Commit Graph

107 Commits

Author SHA1 Message Date
Lukasz Szaszkiewicz
6708db95c9 client-go/dynamic: rm watchlist
Kubernetes-commit: 3038f3530d1b35d896826673acdae0bd55bd769c
2025-06-11 09:45:09 +02:00
Jordan Liggitt
5be379c517 Drop null creationTimestamp from test fixtures
Kubernetes-commit: 6bb6c9934294d8265197c9dfc4c9dd3adaca147a
2025-03-24 09:37:26 -04:00
Jordan Liggitt
ebd18c5e7c Make ToUnstructured match stdlib omitempty and anonymous behavior
Kubernetes-commit: 09912f3521932db99fe19f993db240fd43f3240e
2025-03-24 11:52:44 -04:00
Patrick Ohly
e8a7cb0e18 client-go informers: provide ListWatch *WithContext variants
For compatibility reasons, the old functions without the ctx parameter still
get generated, now with context.Background instead of context.TODO. In practice
that code won't be used by the client-go reflector code because it prefers
the *WithContext functions, but it cannot be ruled out that some other code
only supports the old fields.

Kubernetes-commit: 8cc74e8a266e1042be1c60adfa3091852036f48a
2024-12-09 16:04:52 +01:00
Ben Luddy
8cb21671f4 Add CBOR feature gates.
For alpha, there is one apiserver feature gate and two client-go feature gates controlling
CBOR. They were initially wired to separate test-only feature gate instances in order to prevent
them from being configurable at runtime via command-line flags or environment variables (for
client-go feature gates outside of Kubernetes components). All of the integration tests required by
the KEP as alpha criteria have been implemented. This adds the feature gates to the usual feature
gate instances and removes the temporary code to support separate test-only feature gate instances.

Kubernetes-commit: 072dfcb416fd4e1ddab0a89ac4faf519e268bc96
2024-11-04 10:40:19 -05:00
Ben Luddy
cff56219d9 Support application/apply-patch+cbor in patch requests.
Kubernetes-commit: 37ed906a33211c7d578cab2d681941ebfd2f2f23
2024-10-22 16:08:24 -04:00
Ben Luddy
1cca19dc02 Add test-only client feature gates for CBOR.
As with the apiserver feature gate for CBOR as a serving and storage encoding, the client feature
gates for CBOR are being initially added through a test-only feature gate instance that is not wired
to environment variables or to command-line flags and is intended only to be enabled
programmatically from integration tests. The test-only instance will be removed as part of alpha
graduation and replaced by conventional client feature gating.

Kubernetes-commit: ea13190d8bd3a4bb3e82055b529aa7599ae5c6e1
2024-10-23 16:36:37 -04:00
Ben Luddy
ee51eaf9d0 Use content negotiation in the dynamic client.
Kubernetes-commit: 97958d96a2911c8b1df324868f4730b1c622c798
2024-02-15 17:47:19 -05:00
Lukasz Szaszkiewicz
d274c7ba36 client-go/rest/request: decodes initialEventsListBlueprint for watchlist requests
Kubernetes-commit: 7be192ae0bd5d9628c5ee37c2e8b843d602c0fa3
2024-10-02 15:03:39 +02:00
Joe Betz
1d3f0e5617 Add dynamic informers tests for field and label selectors
Kubernetes-commit: 6ba426c0c09c30411a7c6121044d7b1db1722776
2024-09-03 12:12:30 -04:00
Ben Luddy
08c6c3148c Add test for unintended changes to dynamic client response handling.
The goal is to increase confidence that a change to the dynamic client does not unintentionally
introduce subtle changes to objects returned by dynamic clients in existing programs.

Kubernetes-commit: c8b1037a58ab6ddc3a8b237938eca2f6336abb73
2024-09-16 10:10:49 -04:00
liyuerich
68d318f3aa drop deprecated json/yaml newSerializers, use json.NewSerializerWithOptions instead
Signed-off-by: liyuerich <yue.li@daocloud.io>

Kubernetes-commit: 3c9309db463679c348934429d8487d190ed5e64a
2024-05-29 19:00:00 +08:00
Ryan McKinley
fae3dcdbf6 avoid panic when subresource is a list
Kubernetes-commit: 2e3b937dcdb02cab74213a5608cc4dac39c6423e
2024-09-09 09:40:38 +03:00
Lukasz Szaszkiewicz
732dd289a0 dynamic client: add support for API streaming
Kubernetes-commit: d778356bc6a057ae41bee4577e568293a25fce9b
2024-07-11 13:49:29 +02:00
Lukasz Szaszkiewicz
5d84e91dbf client-go/dynamic: use CheckListFromCacheDataConsistencyIfRequested
Kubernetes-commit: 79370c6d676814758c60bbc1b71a882583be2214
2024-06-04 10:23:19 +02:00
Ben Luddy
4cd6b756be Generate HTTP request fixtures for dynamic client tests.
Kubernetes-commit: e335b8e81b467c70f0f8a485f69e5664adbbc687
2024-04-16 12:49:15 -04:00
Ben Luddy
b17c363481 Add test to detect unintentional changes in dynamic client requests.
Kubernetes-commit: a803c8034d60a81b0da71ea8631e27888a607476
2024-04-16 12:48:12 -04:00
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