Currently, the fake.Clientset does not maintain any ResourceVersions on the objects that are added via it's API functions. For example:
client := fake.NewClientset()
namespaces := clientset.CoreV1().Namespaces()
// Create a namespace via the API:
ns := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
},
}
_, _ := namespaces.Create(ctx, ns, metav1.CreateOptions{})
// Retrieve the namespace by name
ns, _ = namespaces.Get(context.TODO(), "test-namespace", metav1.GetOptions{})
// ns.ResourceVersion == ""
In the above example, the ResourceVersion of the object is not maintained by the fake client. For some type of tests, it would be a great benefit to update the resource version in the fake client.
We open this issue to get feedback whether this feature is considered valuable. If so, we offer to implement it. We saw there was already an earlier issue that got closed due to lack of activity.
We have successfully implemented the resource version updates by registering a Reactor that watches the Create, Update and Patch actions. But it feels like it would not hurt to have this functionality directly in client-go. What do you think?
Currently, the
fake.Clientset
does not maintain any ResourceVersions on the objects that are added via it's API functions. For example:In the above example, the
ResourceVersion
of the object is not maintained by the fake client. For some type of tests, it would be a great benefit to update the resource version in the fake client.We open this issue to get feedback whether this feature is considered valuable. If so, we offer to implement it. We saw there was already an earlier issue that got closed due to lack of activity.
We have successfully implemented the resource version updates by registering a Reactor that watches the Create, Update and Patch actions. But it feels like it would not hurt to have this functionality directly in client-go. What do you think?