Skip to content

Add simple ResourceVersion tracking in fake.Clientset #1385

Open
@stippi2

Description

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?

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions