You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: x-kubernetes-preserve-unknown-fields incorrectly applied on List<T> (#850)
### Describe the bug
PreserveUnknownFieldsAttribute can currently only be applied to
properties. If within my CRD I have a List<T> and I set the attribute,
it will render in the CRD at the items level, not within the object
itself.
### To reproduce
```csharp
[KubernetesEntity(Group = "test.io", Kind = "Test", ApiVersion = "v1")]
public partial class TestCrd : CustomKubernetesEntity<TestSpec> { }
public class TestSpec
{
[PreserveUnknownFields]
public List<Item> Items { get; set; } = default!;
}
public class Item
{
public string Name { get; set; } = default!;
}
```
Generates
```yaml
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
items:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-preserve-unknown-fields: true
type: object
type: object
```
### Expected behavior
x-kubernetes-preserve-unknown-fields: true should be applied to the
object within items
```yaml
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
items:
items:
properties:
name:
type: string
type: object
x-kubernetes-preserve-unknown-fields: true
type: array
type: object
type: object
```
To achieve this result, the attribute should be allowed on classes
```csharp
[KubernetesEntity(Group = "test.io", Kind = "Test", ApiVersion = "v1")]
public partial class TestCrd : CustomKubernetesEntity<TestSpec> { }
public class TestSpec
{
public List<Item> Items { get; set; } = default!;
}
[PreserveUnknownFields]
public class Item
{
public string Name { get; set; } = default!;
}
```
---------
Co-authored-by: Razvan Grama <[email protected]>
Co-authored-by: Christoph Bühler <[email protected]>
0 commit comments