Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Commit 16df078

Browse files
committed
*: document Client.Namespace
Because we already use the empty string "" to indicate AllNamespaces it's unclear if the following statement is attempting to list all namespaces or have the namespace value defaulted: client.List(ctx, "", &deployments) Alternatives such as creating another special variable: client.List(ctx, k8s.DefaultNamespace, &deployments) Seem clunckier than just doing: cleint.List(ctx, client.Namespace, &deployments)
1 parent f2ca415 commit 16df078

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

client.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,27 @@ type Client struct {
8080
// The URL of the API server.
8181
Endpoint string
8282

83-
// Default namespaces for objects that don't supply a namespace in
84-
// their object metadata.
83+
// Namespace is the name fo the default reconciled from the client's config.
84+
// It is set when constructing a client using NewClient(), and defaults to
85+
// the value "default".
86+
//
87+
// This value should be used to access the client's default namespace. For
88+
// example, to create a configmap in the default namespace, use client.Namespace
89+
// when to fill the ObjectMeta:
90+
//
91+
// client, err := k8s.NewClient(config)
92+
// if err != nil {
93+
// // handle error
94+
// }
95+
// cm := v1.ConfigMap{
96+
// Metadata: &metav1.ObjectMeta{
97+
// Name: &k8s.String("my-configmap"),
98+
// Namespace: &client.Namespace,
99+
// },
100+
// Data: map[string]string{"foo": "bar", "spam": "eggs"},
101+
// }
102+
// err := client.Create(ctx, cm)
103+
//
85104
Namespace string
86105

87106
// SetHeaders provides a hook for modifying the HTTP headers of all requests.

0 commit comments

Comments
 (0)