mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
Provide more helpful error when using unsupported api version
This commit is contained in:
parent
712f303350
commit
878a72228f
@ -29,6 +29,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"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/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
|
||||
@ -267,6 +268,9 @@ func (c *clientSwaggerSchema) ValidateBytes(data []byte) error {
|
||||
if err != nil {
|
||||
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().
|
||||
AbsPath("/swaggerapi/api", version).
|
||||
Do().
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"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/util/yaml"
|
||||
)
|
||||
@ -46,6 +47,9 @@ func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
|
||||
if err != nil {
|
||||
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 == "" {
|
||||
return nil, fmt.Errorf("kind not set in %q", source)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user