[client-go] avoid Registry in fake REST client

Previously, the fake RESTClient in client-go required a Registry.  It
used the Registry to fetch the GroupVersion for the fake client.
However, the way it did so was dubious in some cases (it hard-coded the
default API group in places), and not strictly necssary.

This updates the fake client to just recieve the GroupVersion and
internal group name directly, instead of requiring a Registry, so that
it can be consumed in unit tests where a Registry isn't necessarily
readily available (e.g. elsewhere in client-go).
This commit is contained in:
Solly Ross
2017-10-04 18:42:54 -04:00
parent 1bea47aaca
commit eac2049fc9
46 changed files with 155 additions and 150 deletions

View File

@@ -163,7 +163,7 @@ func Example_printReplicationControllerWithNamespace() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -216,7 +216,7 @@ func Example_printMultiContainersReplicationControllerWithWide() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -270,7 +270,7 @@ func Example_printReplicationController() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -325,7 +325,7 @@ func Example_printPodWithWideFormat() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -368,7 +368,7 @@ func Example_printPodWithShowLabels() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -505,7 +505,7 @@ func Example_printPodHideTerminated() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -541,7 +541,7 @@ func Example_printPodShowAll() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}
@@ -570,7 +570,7 @@ func Example_printServiceWithNamespacesAndLabels() {
printersinternal.AddHandlers(p)
tf.Printer = p
tf.Client = &fake.RESTClient{
APIRegistry: legacyscheme.Registry,
GroupVersion: legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion,
NegotiatedSerializer: ns,
Client: nil,
}