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

[bug]: KubeOps.Cli runs into an error when a generic class is inherited from ValidationWebhook #817

Closed
dsempi opened this issue Sep 30, 2024 · 0 comments · Fixed by #816
Closed
Labels
bug Something isn't working

Comments

@dsempi
Copy link
Contributor

dsempi commented Sep 30, 2024

Describe the bug

If there is a generic class inherited from ValidationWebhook class which contains some shared functionality for multiple entities, it's being processed by the AssemblyLoader as if it was the final webhook. When resolving the entity type, it runs into an error "Value cannot be null. (Parameter 'name')".

To reproduce

  1. Let's have a class like:
public class V1EntityValidator<TEntity> : ValidationWebhook<TEntity> where TEntity : CustomKubernetesEntity<V1Spec>
{
    protected V1EntityValidator()
    {
    }

    public override ValidationResult Create(TEntity entity, bool dryRun)
    {
      // do some basic validation
    }
    ...
}
  1. Let's have an inherited class like:
[ValidationWebhook(typeof(V1MyResource))]
public class V1MyResourceValidator : V1EntityValidator<V1MyResource>
{
}
  1. Compile the project. The GenerateOperatorResources target fails with the following error:
An error occurred whiled executing Command: operator
Value cannot be null. (Parameter 'name')

Expected behavior

Compilation runs without an error and the operator resources get generated.

Screenshots

No response

Additional Context

I've prepared a Pull Request that fixes the issue, please see #816.

@dsempi dsempi added the bug Something isn't working label Sep 30, 2024
@buehler buehler linked a pull request Oct 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant