mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 08:35:10 +00:00
Add custom error struct for Group/Version not found
Kubernetes-commit: dc83af0b44bd6432dea3ccd29a77ca3a0b6122a2
This commit is contained in:
committed by
Kubernetes Publisher
parent
3f4372de09
commit
4c5eaaf0d7
@@ -125,7 +125,7 @@ func (r *root) retrieveGVBytes(gv schema.GroupVersion) ([]byte, error) {
|
||||
apiPath := gvToAPIPath(gv)
|
||||
gvOpenAPI, found := paths[apiPath]
|
||||
if !found {
|
||||
return nil, fmt.Errorf("GroupVersion (%s) not found in OpenAPI V3 root document", gv)
|
||||
return nil, &GroupVersionNotFoundError{gv: gv}
|
||||
}
|
||||
return gvOpenAPI.Schema(runtime.ContentTypeJSON)
|
||||
}
|
||||
@@ -170,3 +170,13 @@ func pathToGroupVersion(path string) (schema.GroupVersion, error) {
|
||||
}
|
||||
return gv, nil
|
||||
}
|
||||
|
||||
// Encapsulates GroupVersion not found as one of the paths
|
||||
// at OpenAPI V3 endpoint.
|
||||
type GroupVersionNotFoundError struct {
|
||||
gv schema.GroupVersion
|
||||
}
|
||||
|
||||
func (r *GroupVersionNotFoundError) Error() string {
|
||||
return fmt.Sprintf("GroupVersion (%v) not found as OpenAPI V3 path", r.gv)
|
||||
}
|
||||
|
Reference in New Issue
Block a user