I have a use case where I am reading the custom resources. Below is a sample code for that
type Image Struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ImageSpec `json:"spec,omitempty"`
Status ImageStatus `json:"status,omitempty"`
}
list := v1alpha1.ImageList{}
err := srv.restClient.
Get().
Resource("images").
Do(ctx).
Into(&list)
How can I mock these images CR for testing the function? I am using fake clientSet for creating a fake RestClient. I went through documentation of ClientSet and explored a couple of Interfaces but was not able to find any API which I can use for creating fake resources.
Documentation link: https://pkg.go.dev/k8s.io/client-go/kubernetes/fake
Does anyone know how can I achieve this?
I explored a couple of ClientSet APIs but was not able to find one using which I can create.
you could initialize fakeclient like: