MCPcopy
hub / github.com/kubernetes-sigs/controller-runtime / ExampleClient_get

Function ExampleClient_get

pkg/client/example_test.go:80–100  ·  view source on GitHub ↗

This example shows how to use the client with typed and unstructured objects to retrieve an object.

()

Source from the content-addressed store, hash-verified

78
79// This example shows how to use the client with typed and unstructured objects to retrieve an object.
80func ExampleClient_get() {
81 // Using a typed object.
82 pod := &corev1.Pod{}
83 // c is a created client.
84 _ = c.Get(context.Background(), client.ObjectKey{
85 Namespace: "namespace",
86 Name: "name",
87 }, pod)
88
89 // Using a unstructured object.
90 u := &unstructured.Unstructured{}
91 u.SetGroupVersionKind(schema.GroupVersionKind{
92 Group: "apps",
93 Kind: "Deployment",
94 Version: "v1",
95 })
96 _ = c.Get(context.Background(), client.ObjectKey{
97 Namespace: "namespace",
98 Name: "name",
99 }, u)
100}
101
102// This example shows how to use the client with typed and unstructured objects to create objects.
103func ExampleClient_create() {

Callers

nothing calls this directly

Calls 2

GetMethod · 0.65
SetGroupVersionKindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…