mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Make RESTClient more generic to API version, simplify version handling
RESTClient is an abstraction on top of arbitrary HTTP endpoints that follow the Kubernetes API conventions. Refactored RESTClientFor so that assumptions that are Kube specific happen outside of that method (so others can reuse the RESTClient). Added more validation to client.New to ensure clients give good input. Exposed APIVersion on RESTClient as a method so that wrapper code (code that adds typed / structured methods over rest endpoints like client.Client) can more easily make decisions about what APIVersion it is running under.
This commit is contained in:
@@ -44,7 +44,7 @@ func (c *Client) ReplicationControllers(namespace string) ReplicationControllerI
|
||||
}
|
||||
|
||||
func (c *Client) Nodes() NodeInterface {
|
||||
return newNodes(c, c.preV1Beta3)
|
||||
return newNodes(c)
|
||||
}
|
||||
|
||||
func (c *Client) Events(namespace string) EventInterface {
|
||||
@@ -78,9 +78,6 @@ type APIStatus interface {
|
||||
// Client is the implementation of a Kubernetes client.
|
||||
type Client struct {
|
||||
*RESTClient
|
||||
|
||||
// preV1Beta3 is true for v1beta1 and v1beta2
|
||||
preV1Beta3 bool
|
||||
}
|
||||
|
||||
// ServerVersion retrieves and parses the server's version.
|
||||
@@ -132,3 +129,8 @@ func IsTimeout(err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// preV1Beta3 returns true if the provided API version is an API introduced before v1beta3.
|
||||
func preV1Beta3(version string) bool {
|
||||
return version == "v1beta1" || version == "v1beta2"
|
||||
}
|
||||
|
Reference in New Issue
Block a user