<p>Im trying to get <code>RAW</code> data from operator CR and im getting an <strong>empty object</strong> . (all others value are working as expected )
I’ve created a <strong>minimal example</strong> for the issue, in the example im trying to read the <code>infrastructureConfig</code> object</p>
<p><strong>The tricky part here that my struct is reference to another struct which have a property type rawdata</strong></p>
<p><a href="https://github.com/JennyMet/gardner_test" rel="nofollow noreferrer">https://github.com/JennyMet/gardner_test</a></p>
<p>Here the simple CR</p>
<p><code>https://github.com/JennyMet/gardner_test/blob/main/config/samples/mygroup_v1alpha1_rawtest.yaml#L11</code></p>
<p>Here im tying to read the data and get an empty object, any idea?</p>
<p><a href="https://github.com/JennyMet/gardner_test/blob/main/controllers/rawtest_controller.go#L70" rel="nofollow noreferrer">https://github.com/JennyMet/gardner_test/blob/main/controllers/rawtest_controller.go#L70</a></p>
<p>this is the reference of the type which im using
<a href="https://github.com/gardener/gardener/blob/5522be0e17ccf38aae36efb9fdb6463c66d6e4f1/pkg/apis/core/v1beta1/types_shoot.go#L1184" rel="nofollow noreferrer">https://github.com/gardener/gardener/blob/5522be0e17ccf38aae36efb9fdb6463c66d6e4f1/pkg/apis/core/v1beta1/types_shoot.go#L1184</a></p>
<p><strong>I think its related to fields</strong></p>
<p><code>x-kubernetes-preserve-unknown-fields: true</code>
<a href="https://book.kubebuilder.io/reference/markers/crd-processing.html" rel="nofollow noreferrer">https://book.kubebuilder.io/reference/markers/crd-processing.html</a>
which is not existing
How can I add it to the schema here ?</p>
<p><a href="https://github.com/JennyMet/gardner_test/blob/main/api/v1alpha1/rawtest_types.go#L32" rel="nofollow noreferrer">https://github.com/JennyMet/gardner_test/blob/main/api/v1alpha1/rawtest_types.go#L32</a> as under the hood it uses</p>
<p><a href="https://github.com/gardener/gardener/blob/5522be0e17ccf38aae36efb9fdb6463c66d6e4f1/pkg/apis/core/v1beta1/types_shoot.go#L1184" rel="nofollow noreferrer">https://github.com/gardener/gardener/blob/5522be0e17ccf38aae36efb9fdb6463c66d6e4f1/pkg/apis/core/v1beta1/types_shoot.go#L1184</a></p>
<p>I mean I tried and it doesnt work as the <code>InfrastructureConfig</code> which is RAW is under the</p>
<pre><code>type System struct {
    Type     system           `json:&quot;type,omitempty&quot;`
    // +kubebuilder:pruning:PreserveUnknownFields
    Provider v1beta1.Provider `json:&quot;provider,omitempty&quot;`
}
</code></pre>
<p>But the rawData is under <code>Provider</code> which is not my struct, <strong>im just using it.</strong></p>
<p>which is like this , see the  <code>InfrastructureConfig</code> type...</p>
<pre><code>type Provider struct {

    Type string `json:&quot;type&quot; protobuf:&quot;bytes,1,opt,name=type&quot;`
    ControlPlaneConfig *runtime.RawExtension `json:&quot;controlPlaneConfig,omitempty&quot; protobuf:&quot;bytes,2,opt,name=controlPlaneConfig&quot;`
    InfrastructureConfig *runtime.RawExtension `json:&quot;infrastructureConfig,omitempty&quot; protobuf:&quot;bytes,3,opt,name=infrastructureConfig&quot;`

}
</code></pre>

<p>Currently, you can only put the <code>// +kubebuilder:pruning:PreserveUnknownFields</code> on the <code>Provider v1beta1.Provider</code>, which means all sub fields in it will be allowed with additional unknown fields.</p>
<p>The good news is, your problem will be solved after <a href="https://github.com/kubernetes-sigs/controller-tools/pull/683" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/controller-tools/pull/683</a> merged. After that, you have not to use <code>// +kubebuilder:pruning:PreserveUnknownFields</code> and controller-tools would automatically add <code>x-kubernetes-preserve-unknown-fields: true</code> for all <code>RawExtension</code> fields.</p>
