Skip to content
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

Add mock handling for implicit generic support #3960

Closed
shawkins opened this issue Mar 10, 2022 · 4 comments
Closed

Add mock handling for implicit generic support #3960

shawkins opened this issue Mar 10, 2022 · 4 comments
Labels
component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly status/never-stale
Milestone

Comments

@shawkins
Copy link
Contributor

Is your task related to a problem? Please describe

When using the built-in mock server the metadata will be missing for a generic resource.

Describe the solution you'd like

There should be a way either against the client or the mock server to register a ResourceDefinitionContext for testing purposes.

Currently when you use the entry point client.genericKubernetesResources(context) - that context is not cached / saved, it is only used locally for that operation.

Describe alternatives you've considered

No response

Additional context

No response

@shawkins
Copy link
Contributor Author

Based upon #3941 (reply in thread) a quick implementation would be something like KubernetesMockServer.defineType(ResourceDefinitionContext) - and it would automatically setup the needed expectations.

Based upon #3941 (reply in thread) you could also consider a more crud based approach to the api resources.

Or there is existing CRD aware logic in the mock server - that is already inferring the plurals so we could actually extend this to return the full api endpoint metadata as well.

This is also making me think we should just remove the proposed EnableKubernetesMockClient.unsupported - and instead let that be driven off of methods on the KubernetesMockClient.

@shawkins shawkins added this to the 6.x milestone Mar 28, 2022
@stale
Copy link

stale bot commented Jun 26, 2022

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@manusa
Copy link
Member

manusa commented Jul 22, 2022

I've missed this issue. Last month I spent some time refactoring the Mock Server CRUD mode and I was thinking that we were missing something related to what's requested here.

Please check the following list of properties for the CRUD mode to see if we're aligned and can we establish some sort of spec to implement the missing features:

  1. ✔️ Mock server supports Custom Resources (CR)
  2. ❓ Custom Resource Definitions (CRD) can be "installed" and allow the usage of custom APIs just like any other resource (IIRC this should be implemented too)
  3. ✖️ Mock Server can be preset with a set of custom resources or custom APIs
    • The workaround is to add create/install the CRDs in a setup/before method
  4. ❓ Mock server should fail when handling CRs or custom APIs which have not been previously installed

@shawkins
Copy link
Contributor Author

  1. Limited support exists. See the handling in KubernetesAttributesExtractor. Currently the crd information is only used to determine if the resource has a status sub-resource and to determine the plural from the resource (I can't remember why that's needed).
  2. Limited support exists in KubernetesServer, but not KuberenetesMockServer - you can pass a list of CustomResourceDefinitionContext.
  3. In crud mode it currently does not fail.

@manusa manusa added the component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly label Jul 22, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 15, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 15, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 16, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 16, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 23, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 23, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Aug 26, 2022
@manusa manusa closed this as completed in f3078b5 Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly status/never-stale
Projects
None yet
Development

No branches or pull requests

2 participants