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
The generation of additionalProperties out of a CRD is not creating the access methods as expected. If there is an object in the CRD defined with configuration:
type: object
x-kubernetes-preserve-unknown-fields: true
It will generate a java class for that configuration, but the mapper will not fill the Map. Therefore the object will not contain any data.
Fabric8 Kubernetes Client version
6.2.0
Steps to reproduce
Create a CRD having type object and x-kubernetes-preserve-unknown-fields: true
generate the java code
read a CR with additionalAttributes like
- configuration:
description: "Map does not contain this content"
enabled: true
name: "Erronious content"
Use a mapper to read that yaml into you generated Java Object
All the addtionalAttributes are not present in the Map
Expected behavior
Every unknown field should be accessible with in that additionalAttributes map via the "key"; i.E. "description".
Proposal, instead of generating:
@com.fasterxml.jackson.annotation.JsonAnyGetter()
public java.util.Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}
@com.fasterxml.jackson.annotation.JsonAnySetter()
public void setAdditionalProperties(java.util.Map<String, Object> additionalProperties) {
this.additionalProperties = additionalProperties;
}
we may need to generate
@com.fasterxml.jackson.annotation.JsonAnyGetter()
public java.util.Map<String, Object> any() {
return additionalProperties;
}
@com.fasterxml.jackson.annotation.JsonAnySetter()
public void setAdditionalProperties(String name, Object value) {
additionalProperties.put(name, value);
}
public Object getAdditionalProperties(String name) {
return additionalProperties.get(name);
}
It definetly works for String objects as unknown entities. I don't know what happends with complex objects.
Runtime
Kubernetes (vanilla), other (please specify in additional context)
Kubernetes API Server version
1.25.3@latest
Environment
Windows
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
mteubner
changed the title
Additional Attributes are generated to be ignored, because of wrong setting of JsonAnyGetter annotation
Additional Attributes are generated to be ignored, because of wrong setting of JsonAnySetter annotation
Oct 31, 2022
yup, looking into it, I'm 100% sure I tested this manually when implementing the support.
Now that we have proper integration tests we can fix it properly.
Apparently, some serialization/deserialization behaviors have been slightly changed.
Describe the bug
Component : java-generator
The generation of additionalProperties out of a CRD is not creating the access methods as expected. If there is an object in the CRD defined with configuration:
type: object
x-kubernetes-preserve-unknown-fields: true
It will generate a java class for that configuration, but the mapper will not fill the Map. Therefore the object will not contain any data.
Fabric8 Kubernetes Client version
6.2.0
Steps to reproduce
- configuration:
description: "Map does not contain this content"
enabled: true
name: "Erronious content"
All the addtionalAttributes are not present in the Map
Expected behavior
Every unknown field should be accessible with in that additionalAttributes map via the "key"; i.E. "description".
Proposal, instead of generating:
we may need to generate
It definetly works for String objects as unknown entities. I don't know what happends with complex objects.
Runtime
Kubernetes (vanilla), other (please specify in additional context)
Kubernetes API Server version
1.25.3@latest
Environment
Windows
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: