Commit 68bbf6c1 authored by Alex Robinson's avatar Alex Robinson

Merge pull request #10447 from feihujiang/helpfulErrorForUnsupportedVersion

Provide more helpful error when using unsupported api version
parents fb9c126f 878a7222
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
...@@ -267,6 +268,9 @@ func (c *clientSwaggerSchema) ValidateBytes(data []byte) error { ...@@ -267,6 +268,9 @@ func (c *clientSwaggerSchema) ValidateBytes(data []byte) error {
if err != nil { if err != nil {
return err return err
} }
if ok := registered.IsRegisteredAPIVersion(version); !ok {
return fmt.Errorf("API version %q isn't supported, only supports API versions %q", version, registered.RegisteredVersions)
}
schemaData, err := c.c.RESTClient.Get(). schemaData, err := c.c.RESTClient.Get().
AbsPath("/swaggerapi/api", version). AbsPath("/swaggerapi/api", version).
Do(). Do().
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/yaml" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/yaml"
) )
...@@ -47,6 +48,9 @@ func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) { ...@@ -47,6 +48,9 @@ func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to get type info from %q: %v", source, err) return nil, fmt.Errorf("unable to get type info from %q: %v", source, err)
} }
if ok := registered.IsRegisteredAPIVersion(version); !ok {
return nil, fmt.Errorf("API version %q in %q isn't supported, only supports API versions %q", version, source, registered.RegisteredVersions)
}
if kind == "" { if kind == "" {
return nil, fmt.Errorf("kind not set in %q", source) return nil, fmt.Errorf("kind not set in %q", source)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment