Merge pull request #33 from CraigMChen/feature/k8s1.16-

feat: support k8s version less than 1.16
This commit is contained in:
Darren Shepherd 2022-01-07 13:37:03 -07:00 committed by GitHub
commit 9d72af0469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -35,7 +35,7 @@ func (a *addQuery) RoundTrip(req *http.Request) (*http.Response, error) {
for k, v := range a.values {
q.Set(k, v)
}
req.Header.Set("Accept", "application/json;as=Table;v=v1;g=meta.k8s.io")
req.Header.Set("Accept", "application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io")
req.URL.RawQuery = q.Encode()
return a.next.RoundTrip(req)
}
@ -59,10 +59,10 @@ func NewFactory(cfg *rest.Config, impersonate bool) (*Factory, error) {
tableClientCfg := rest.CopyConfig(clientCfg)
tableClientCfg.Wrap(setTable)
tableClientCfg.AcceptContentTypes = "application/json;as=Table;v=v1;g=meta.k8s.io"
tableClientCfg.AcceptContentTypes = "application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io"
tableWatchClientCfg := rest.CopyConfig(watchClientCfg)
tableWatchClientCfg.Wrap(setTable)
tableWatchClientCfg.AcceptContentTypes = "application/json;as=Table;v=v1;g=meta.k8s.io"
tableWatchClientCfg.AcceptContentTypes = "application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io"
md, err := metadata.NewForConfig(cfg)
if err != nil {

View File

@ -96,7 +96,7 @@ func newClient(config *rest.Config) (*rest.RESTClient, error) {
config = rest.CopyConfig(config)
config.RateLimiter = ratelimit.None
config.UserAgent = rest.DefaultKubernetesUserAgent()
config.AcceptContentTypes = "application/json;as=Table;v=v1;g=meta.k8s.io"
config.AcceptContentTypes = "application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io"
config.GroupVersion = &schema.GroupVersion{}
config.NegotiatedSerializer = serializer.NewCodecFactory(scheme)
config.APIPath = "/"

View File

@ -169,7 +169,8 @@ func rowToObject(obj *unstructured.Unstructured) {
return
}
if obj.Object["kind"] != "Table" ||
obj.Object["apiVersion"] != "meta.k8s.io/v1" {
(obj.Object["apiVersion"] != "meta.k8s.io/v1" &&
obj.Object["apiVersion"] != "meta.k8s.io/v1beta1") {
return
}
@ -181,7 +182,8 @@ func rowToObject(obj *unstructured.Unstructured) {
func tableToList(obj *unstructured.UnstructuredList) {
if obj.Object["kind"] != "Table" ||
obj.Object["apiVersion"] != "meta.k8s.io/v1" {
(obj.Object["apiVersion"] != "meta.k8s.io/v1" &&
obj.Object["apiVersion"] != "meta.k8s.io/v1beta1") {
return
}