-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify construction of the fake dynamic client #102928
Simplify construction of the fake dynamic client #102928
Conversation
/kind cleanup |
/assign @lavalamp |
I debated whether to move the logic to I wonder if that method is still necessary and could be marked deprecated |
/assign @deads2k related to kubernetes/client-go#914 specifically kubernetes/client-go#949 (comment) |
cc @n3wscott |
Interesting this PR won't fix #914 because in that example there's no scheme or resources being supplied during construction. |
/triage accepted |
Does a priority need to be assigned prior to review? |
unstructuredScheme.AddKnownTypeWithName(gvk, &unstructured.Unstructured{}) | ||
} | ||
|
||
objects, err := convertObjectsToUnstructured(scheme, objects) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
|
||
// This test ensures list works when the fake dynamic client is seeded with a typed scheme and | ||
// unstructured type fixtures | ||
func TestListWithUnstructuredObjectsAndTypedScheme(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a test case where the list isn't seeded at all and the response needs to be fully constructed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TestListWithNoFixturesAndTypedScheme
I'm testing with a typed scheme - otherwise I'd expect consumers to use the other constructor that requires a mapping of gvrs to list kinds
/lgtm holding for squash. ping me on slack for a re-lgtm. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, dprotaso The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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
cfbd3ff
to
418fa71
Compare
Ok squashed |
/lgtm |
/retest |
1 similar comment
/retest |
/cherrypick release-1.21 |
…2928-upstream-release-1.20 Automated cherry pick of #102928: Simplify use of the fake dynamic client
…2928-upstream-release-1.21 Automated cherry pick of #102928: Simplify use of the fake dynamic client
The new `ko` build option to produce SBOM is disabled until we have a design for how this should work across Skaffold builders. Additional transitive dependencies (mainly authentication libraries for various image registries) means that the Skaffold binary grows by about 4.8MB. The change to labels_test.go works around the tests failing due to this change in `client-go` between `v0.21.3` and `v0.21.4`: kubernetes/client-go@c6c0ca0 That commit came from this k/k PR: kubernetes/kubernetes#102928 Related: GoogleContainerTools#7193 Tracking: GoogleContainerTools#7131
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
With the introduction of GVK to the fake dynamic client it made using
the fake much more cumbersome.
Specifically:
The PR changes the constructor method NewSimpleDynamicClient to do the following:
This should make the dynamic client 'flexible' with it's inputs like it was
before
Which issue(s) this PR fixes:
Fixes N/A
Special notes for your reviewer:
Thanks!
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: