Skip to content

Commit 7a42e65

Browse files
authored
Add missing godocs and provide default for HTTPClient (#6)
* Add missing godocs and provide default for HTTPClient
1 parent dde7624 commit 7a42e65

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

pkg/cache/cache.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ type Options struct {
109109
// So that all informers will not send list requests simultaneously.
110110
Resync *time.Duration
111111

112+
// KeyFunction is the cache.KeyFunc that the informers will be configured to use.
113+
// Defaults to cache.MetaNamespaceKeyFunc from client-go
112114
KeyFunction cache.KeyFunc
113115

114116
// Namespace restricts the cache's ListWatch to the desired namespace

pkg/cache/internal/informers_map.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ type specificInformersMap struct {
139139
// disableDeepCopy indicates not to deep copy objects during get or list objects.
140140
disableDeepCopy DisableDeepCopyByGVK
141141

142+
// keyFunction is the cache.KeyFunc informers will be configured to use
142143
keyFunction cache.KeyFunc
143144
}
144145

pkg/client/apiutil/apimachinery.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ func RESTClientForGVK(gvk schema.GroupVersionKind, isUnstructured bool, baseConf
123123
return rest.RESTClientFor(createRestConfig(gvk, isUnstructured, baseConfig, codecs))
124124
}
125125

126+
// RESTClientForGVKAndClient constructs a new rest.Interface capable of accessing the resource associated
127+
// wwith the give GroupVersionKind. The REST client will be configured to use provided http.Client, and the
128+
// negotiated serializer from baseConfig, if set.
126129
func RESTClientForGVKAndClient(gvk schema.GroupVersionKind, client *http.Client, isUnstructured bool, baseConfig *rest.Config, codecs serializer.CodecFactory) (rest.Interface, error) {
127130
return rest.RESTClientForConfigAndClient(createRestConfig(gvk, isUnstructured, baseConfig, codecs), client)
128131
}

pkg/client/client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type Options struct {
5858
// Mapper, if provided, will be used to map GroupVersionKinds to Resources
5959
Mapper meta.RESTMapper
6060

61+
// HTTPClient, if provided, will be used by all constructed clients to talk to the apiserver
6162
HTTPClient *http.Client
6263

6364
// Opts is used to configure the warning handler responsible for
@@ -84,6 +85,14 @@ func newClient(config *rest.Config, options Options) (*client, error) {
8485
return nil, fmt.Errorf("must provide non-nil rest.Config to client.New")
8586
}
8687

88+
if options.HTTPClient == nil {
89+
httpClient, err := rest.HTTPClientFor(config)
90+
if err != nil {
91+
return nil, fmt.Errorf("Could not create HTTPClient from config")
92+
}
93+
opts.HTTPClient = httpClient
94+
}
95+
8796
if !options.Opts.SuppressWarnings {
8897
// surface warnings
8998
logger := log.Log.WithName("KubeAPIWarningLogger")

pkg/client/client_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type clientCache struct {
3636
// config is the rest.Config to talk to an apiserver
3737
config *rest.Config
3838

39-
// httpclient is the httpClient to talk to an apiserver
39+
// httpClient is the http.Client to talk to an apiserver
4040
httpClient *http.Client
4141

4242
// scheme maps go structs to GroupVersionKinds

pkg/reconcile/reconcile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (r *Result) IsZero() bool {
4545
// information to uniquely identify the object - its Name and Namespace. It does NOT contain information about
4646
// any specific Event or the object contents itself.
4747
type Request struct {
48-
// NamespacedName is the name and namespace of the object to reconcile.
48+
// ObjectKey is the name, namespace, and cluster of the object to reconcile.
4949
client.ObjectKey
5050
}
5151

0 commit comments

Comments
 (0)