We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main import ( "context" "fmt" v1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic/fake" ) var d1 = &v1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "nginx-deployment", Namespace: "default", }, Spec: v1.DeploymentSpec{}, } var d2 = &v1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "nginx2-deployment", Namespace: "default", }, Spec: v1.DeploymentSpec{}, } func main() { var f5scheme = runtime.NewScheme() f5scheme.AddKnownTypes(v1.SchemeGroupVersion, &v1.Deployment{}, &v1.DeploymentList{}, ) dynamicClient := fake.NewSimpleDynamicClient(f5scheme, d1, d2) DeploymentList, _ := dynamicClient.Resource(schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}). Namespace("default").List(context.TODO(), metav1.ListOptions{ FieldSelector: "metadata.name=nginx-deployment", }) for _, d := range DeploymentList.Items { fmt.Println(d.GetName()) } }
output
nginx-deployment nginx2-deployment
from debug. only filter by namespace
The text was updated successfully, but these errors were encountered:
For anyone digging into this, alsoFakeLister discards field selectors before building the list.
alsoFakeLister
client-go/gentype/fake.go
Line 162 in ea791f2
Update: we were able to replicate the real client functionality by prepending a reactor to the fake client set. See #500
Sorry, something went wrong.
No branches or pull requests
example code
output
from debug. only filter by namespace
The text was updated successfully, but these errors were encountered: