The conversion-gen tool produces wrong conversion code for a pointer to a struct, if source and destination struct have multiple members of the same type, but the member ordering is different.
Here is an example to show the issue for an extended struct from k8s.io/code-generator/examples/apiserver/apis/example:
Type example/v1:
package v1 // "k8s.io/code-generator/examples/apiserver/apis/example/v1"
type TestTypeStatus struct {
Blah string `json:"blah"`
Times *Times `json:"times,omitempty"`
}
type Times struct {
Start *metav1.Time `json:"start,omitempty"`
End *metav1.Time `json:"end,omitempty"`
}
and the internal type:
package example // "k8s.io/code-generator/examples/apiserver/apis/example"
type TestTypeStatus struct {
Blah string
Times *Times
}
type Times struct {
End *metav1.Time
Start *metav1.Time
}
Note, that the ordering of the members Start and End have been changed.
Converting example/v1 to v1 shows that the values have been swapped:
The
conversion-gen
tool produces wrong conversion code for a pointer to a struct, if source and destination struct have multiple members of the same type, but the member ordering is different.Here is an example to show the issue for an extended struct from k8s.io/code-generator/examples/apiserver/apis/example:
Type
example/v1
:and the internal type:
Note, that the ordering of the members
Start
andEnd
have been changed.Converting
example/v1
tov1
shows that the values have been swapped:The complete example code can be found here