Commit Graph

23 Commits

Author SHA1 Message Date
Arda Güçlü
57d597c1d6 Add shortname ambiguity warning in shortcut expander (#117668)
* Add warning handler callback function in shortcut expander

Currently, errors in client-go are propagated back to the callers via
function returns. However, there is no elegant way for just warning users.
For example, when user wants to get a resource with it's short name format
and if there are multiple resources belonging to this short name, we need to
warn user about this ambugity which one is picked and which ones are discarded.

Not only to overcome this particular case mentioned above, but also propose a
way for the possible warnings in the future, this commit adds a warningHandler
callback function in shortcutExpander.

* Add warningPrinter functionality in ConfigFlags

ConfigFlags has neither warning user in a standardized
format functionality nor passing warning callback functions to other upper level
libraries such as client-go.

This commit adds an ability that user can set warningPrinters
according to their IOStreams and this warningPrinters will be used
to raise possible warnings happening not only in cli-runtime but
also in client-go.

* Pass warning callback function in ConfigFlags to shortcutExpander

This commit passes warning callback function to print possible
warnings happened in shortcut expander to warn user in a
standardized format.

* Add integration test for CRDs having ambiguous short names

This commit adds integration test to assure that warning message
related to this ambiguity is printed when resources are being retrieved via their short name
representations in cases where multiple resources have same
short names.

This integration test also ensures that the logic behind which resource
will be selected hasn't been changed which may cause disperancies in
clusters.

* Remove defaultConfigFlag global variable

* Move default config flags initialization into function

* Skip warning for versions of same group/resource

* Run update-vendor

* Warn only once when there are multiple versions registered for ambiguous resource

* Apply gocritic review

* Add multi-resource multi-version ambiguity unit test

Kubernetes-commit: a504aed54d028dbc8ea2508142c94d309f5f1ec6
2023-10-11 18:04:11 +03:00
Jefftree
2bd3f49236 Update gnostic references
Kubernetes-commit: 2111e79f56acdfa6a8dab56780c52e3abc608758
2023-06-01 18:25:39 +00:00
Hao Ruan
ef522cc423 replace spew methods with dump methods
Kubernetes-commit: c4e1b01416ec05e6a520a181d4ce3b4333adb4e4
2023-04-13 09:41:07 +08:00
Sean Sullivan
3ac73ea2c8 Adds bool to force non-aggregated discovery
Kubernetes-commit: a84d877310ba5cf9237c8e8e3218229c202d3a1e
2022-11-09 12:30:05 -08:00
Maciej Szulik
e2598a43a3 restmapper: re-try shortcut expander after not-found error
Kubernetes-commit: f7d1eb7726fa511b6439b7f8162138742ac639ab
2020-11-21 00:10:47 +01:00
Alexander Zielenski
018cf8ace6 add fetching into discovery client for OpenAPI v3
reflect latest struct changes

use correct discovery openapi test data layout

make the OpenAPIv3 interface less blue

field grouping

add copyrights

implement cached discovery client

add cached discovery tests

address review feedback

Kubernetes-commit: 075866b3e3ea029c243d82d8d6eb99e96d9c49d3
2022-03-22 10:40:56 -07:00
Arda Güçlü
7e062f8fa4 Remove deprecated discovery/ServerResources function
ServerResources function was deprecated and instead ServerGroupsAndResources
function is suggested.

This PR removes ServerResources function and move every place to use ServerGroupsAndResources.

Kubernetes-commit: ef39a8914291ba200bd5486c88a7575ffd4b7d1d
2021-12-22 11:14:09 +03:00
Jefftree
186c332c7b googleapis/gnostic -> google/gnostic
Kubernetes-commit: 8a1d5947ad34ba275192341baa4e5fef8e6c7f24
2022-03-15 20:36:21 -07:00
Mikhail Mazurskiy
c5a1393028 ResettableRESTMapper to make it possible to reset wrapped mappers
Kubernetes-commit: de4598d0db5e2babe89dd334407b2ba8024ec9a1
2021-10-13 16:15:24 +11:00
Mikhail Mazurskiy
0ae31f68fd Cache rest mapper and discovery client
They are both stateful so it is beneficial for performance to cache them.

Kubernetes-commit: 037ed11f649f356efc4363db32b9f85ef02ca106
2021-07-25 19:31:58 +10:00
Martin Schimandl
3450a048bc Fix staticchecks in vendor/k8s.io/client-go
Kubernetes-commit: 13c017056c924e148113e42786a511ed2fee7594
2020-10-01 12:40:32 +02:00
Davanum Srinivas
75fea27a27 switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Jordan Liggitt
d847b4c964 github.com/googleapis/gnostic v0.4.1
Kubernetes-commit: 93c7b24562d80959f45c308e7412456a410b9b25
2020-03-31 17:18:56 -04:00
Nguyen Hai Truong
666c7b3f0c trivial fix typo: resouce -> resource
Although it is spelling mistakes, it might make an affects while reading.

Signed-off-by: Nguyen Hai Truong <truongnh@vn.fujitsu.com>

Kubernetes-commit: 34961dc16c91f530b84957c50be5ebdbb914380b
2019-02-15 02:05:28 -08:00
Dr. Stefan Schimanski
42ebdc32c2 discovery: speedup cache miss by a two digit factor
Kubernetes-commit: 2cdddd8d4ec0c16df9b3667a11dfc07fa7bf49e2
2019-02-05 13:17:47 +01:00
Dr. Stefan Schimanski
2cc261d78b client-go: extend discovery intf with ServerGroupsAndResources
Kubernetes-commit: 618050e35dd617032e81dfe61084a676d3e10757
2019-02-05 11:35:36 +01:00
Dr. Stefan Schimanski
643eaf2115 restmapper: add GetAPIGroupResources tests
Kubernetes-commit: 57d0f9d9720a824b27d7ae0b464d1e171804baf4
2019-02-11 17:22:29 +01:00
Davanum Srinivas
74cd8bbeee Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
David Eads
7aab051039 fill in normal restmapping info with the legacy guess
Kubernetes-commit: 0aa13d75021bcc80af73b3edaa3209ecd6ebe687
2018-07-16 13:38:43 -04:00
David Eads
3fb1070233 construct resource.Builder from kubeconfig flags
Kubernetes-commit: 1f5357034b4a8ef4ed68f0c2415e280601968e91
2018-05-09 13:53:07 -04:00
David Eads
37c8d52754 category expansion can only come from the server
Kubernetes-commit: ad87219b2cba1d22ac2a808568da7322775972ae
2018-05-09 11:12:32 -04:00
David Eads
0c30aacc9d move category expansion types to restmapper package
Kubernetes-commit: 37f6cb723017edb46117d64d70c827a2d8c93b59
2018-05-09 11:01:49 -04:00
David Eads
1c9ae1b2ac move client based restmappers to client-go
Kubernetes-commit: dd97a7bc59c913c71730dba8b8de274820466417
2018-05-07 15:41:13 -04:00