mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-02 01:42:19 +00:00
address feedback
Kubernetes-commit: 32d834a88673614080bc37727f8cc94b9b85bc86
This commit is contained in:
parent
12cafe2b1b
commit
624929cd3f
@ -594,7 +594,9 @@ func TestGetOpenAPISchemaV3(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected := testV3Specs[k]
|
expected := testV3Specs[k]
|
||||||
if contentType == runtime.ContentTypeJSON {
|
switch contentType {
|
||||||
|
|
||||||
|
case runtime.ContentTypeJSON:
|
||||||
var actualSpec spec3.OpenAPI
|
var actualSpec spec3.OpenAPI
|
||||||
|
|
||||||
if err := json.Unmarshal(actual, &actualSpec); err != nil {
|
if err := json.Unmarshal(actual, &actualSpec); err != nil {
|
||||||
@ -606,7 +608,7 @@ func TestGetOpenAPISchemaV3(t *testing.T) {
|
|||||||
// Our test server parses the files in directly as gnostic
|
// Our test server parses the files in directly as gnostic
|
||||||
// which retains empty maps/lists, etc.
|
// which retains empty maps/lists, etc.
|
||||||
require.EqualValues(t, expected, &actualSpec)
|
require.EqualValues(t, expected, &actualSpec)
|
||||||
} else {
|
case openapi.ContentTypeOpenAPIV3PB:
|
||||||
// Convert to JSON then to gnostic then to PB for comparison
|
// Convert to JSON then to gnostic then to PB for comparison
|
||||||
expectedJSON, err := json.Marshal(expected)
|
expectedJSON, err := json.Marshal(expected)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -625,6 +627,8 @@ func TestGetOpenAPISchemaV3(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(expectedPB, actual) {
|
if !reflect.DeepEqual(expectedPB, actual) {
|
||||||
t.Fatalf("expected equal values: %v", cmp.Diff(expectedPB, actual))
|
t.Fatalf("expected equal values: %v", cmp.Diff(expectedPB, actual))
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
panic(fmt.Errorf("unrecognized content type: %v", contentType))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that fetching schema once again does not return same instance
|
// Ensure that fetching schema once again does not return same instance
|
||||||
|
@ -38,14 +38,9 @@ func newGroupVersion(client *client, item handler3.OpenAPIV3DiscoveryGroupVersio
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupversion) Schema(contentType string) ([]byte, error) {
|
func (g *groupversion) Schema(contentType string) ([]byte, error) {
|
||||||
data, err := g.client.restClient.Get().
|
return g.client.restClient.Get().
|
||||||
RequestURI(g.item.ServerRelativeURL).
|
RequestURI(g.item.ServerRelativeURL).
|
||||||
SetHeader("Accept", contentType).
|
SetHeader("Accept", contentType).
|
||||||
Do(context.TODO()).
|
Do(context.TODO()).
|
||||||
Raw()
|
Raw()
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return data, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user