Support Table and PartialObjectMetadata on watch

Clean up the code paths that lead to objects being transformed and output with negotiation.
Remove some duplicate code that was not consistent. Now, watch will respond correctly to
Table and PartialObjectMetadata requests. Add unit and integration tests.

When transforming responses to Tables, only the first watch event for a given type will
include the columns. Columns will not change unless the watch is restarted.

Add a volume attachment printer and tighten up table validation error cases.

Disable protobuf from table conversion because Tables don't have protobuf because they
use `interface{}`

Kubernetes-commit: 3230a0b4fd14a6166f8362d4732e199e8779c426
This commit is contained in:
Clayton Coleman 2018-11-28 23:50:12 -05:00 committed by Kubernetes Publisher
parent caa074ae28
commit abaa46c115

View File

@ -36,6 +36,19 @@ type dynamicClient struct {
var _ Interface = &dynamicClient{}
// ConfigFor returns a copy of the provided config with the
// appropriate dynamic client defaults set.
func ConfigFor(inConfig *rest.Config) *rest.Config {
config := rest.CopyConfig(inConfig)
config.AcceptContentTypes = "application/json"
config.ContentType = "application/json"
config.NegotiatedSerializer = basicNegotiatedSerializer{} // this gets used for discovery and error handling types
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return config
}
// NewForConfigOrDie creates a new Interface for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) Interface {
@ -46,17 +59,12 @@ func NewForConfigOrDie(c *rest.Config) Interface {
return ret
}
// NewForConfig creates a new dynamic client or returns an error.
func NewForConfig(inConfig *rest.Config) (Interface, error) {
config := rest.CopyConfig(inConfig)
config := ConfigFor(inConfig)
// for serializing the options
config.GroupVersion = &schema.GroupVersion{}
config.APIPath = "/if-you-see-this-search-for-the-break"
config.AcceptContentTypes = "application/json"
config.ContentType = "application/json"
config.NegotiatedSerializer = basicNegotiatedSerializer{} // this gets used for discovery and error handling types
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
restClient, err := rest.RESTClientFor(config)
if err != nil {