mirror of
https://github.com/rancher/steve.git
synced 2025-09-20 19:08:46 +00:00
Adjust output to match request in issue, update tests to match reality
This commit is contained in:
@@ -305,11 +305,11 @@ func Test_byID(t *testing.T) {
|
|||||||
Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata",
|
Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata",
|
||||||
},
|
},
|
||||||
"binaryData": {
|
"binaryData": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "BinaryData contains the binary data. Each key must consist of alphanumeric characters, '-', '_' or '.'. BinaryData can contain byte sequences that are not in the UTF-8 range. The keys stored in BinaryData must not overlap with the ones in the Data field, this is enforced during validation process. Using this field will require 1.10+ apiserver and kubelet.",
|
Description: "BinaryData contains the binary data. Each key must consist of alphanumeric characters, '-', '_' or '.'. BinaryData can contain byte sequences that are not in the UTF-8 range. The keys stored in BinaryData must not overlap with the ones in the Data field, this is enforced during validation process. Using this field will require 1.10+ apiserver and kubelet.",
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "Data contains the configuration data. Each key must consist of alphanumeric characters, '-', '_' or '.'. Values with non-UTF-8 byte sequences must use the BinaryData field. The keys stored in Data must not overlap with the keys in the BinaryData field, this is enforced during validation process.",
|
Description: "Data contains the configuration data. Each key must consist of alphanumeric characters, '-', '_' or '.'. Values with non-UTF-8 byte sequences must use the BinaryData field. The keys stored in Data must not overlap with the keys in the BinaryData field, this is enforced during validation process.",
|
||||||
},
|
},
|
||||||
"immutable": {
|
"immutable": {
|
||||||
@@ -321,7 +321,7 @@ func Test_byID(t *testing.T) {
|
|||||||
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
||||||
ResourceFields: map[string]definitionField{
|
ResourceFields: map[string]definitionField{
|
||||||
"annotations": {
|
"annotations": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "annotations of the resource",
|
Description: "annotations of the resource",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -390,7 +390,7 @@ func Test_byID(t *testing.T) {
|
|||||||
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
||||||
ResourceFields: map[string]definitionField{
|
ResourceFields: map[string]definitionField{
|
||||||
"annotations": {
|
"annotations": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "annotations of the resource",
|
Description: "annotations of the resource",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -439,7 +439,7 @@ func Test_byID(t *testing.T) {
|
|||||||
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
||||||
ResourceFields: map[string]definitionField{
|
ResourceFields: map[string]definitionField{
|
||||||
"annotations": {
|
"annotations": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "annotations of the resource",
|
Description: "annotations of the resource",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -512,7 +512,7 @@ func Test_byID(t *testing.T) {
|
|||||||
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
||||||
ResourceFields: map[string]definitionField{
|
ResourceFields: map[string]definitionField{
|
||||||
"annotations": {
|
"annotations": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "annotations of the resource",
|
Description: "annotations of the resource",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -560,7 +560,7 @@ func Test_byID(t *testing.T) {
|
|||||||
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
|
||||||
ResourceFields: map[string]definitionField{
|
ResourceFields: map[string]definitionField{
|
||||||
"annotations": {
|
"annotations": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: "annotations of the resource",
|
Description: "annotations of the resource",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package definitions
|
package definitions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"k8s.io/kube-openapi/pkg/util/proto"
|
"k8s.io/kube-openapi/pkg/util/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ func (s *schemaFieldVisitor) VisitArray(array *proto.Array) {
|
|||||||
array.SubType.Accept(subVisitor)
|
array.SubType.Accept(subVisitor)
|
||||||
subField := subVisitor.field
|
subField := subVisitor.field
|
||||||
// Represent the map as "array[<value_type>]"
|
// Represent the map as "array[<value_type>]"
|
||||||
field.Type = "array[" + subField.Type + "]"
|
field.Type = fmt.Sprintf("array[%s]", subField.Type)
|
||||||
s.field = field
|
s.field = field
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,8 +36,8 @@ func (s *schemaFieldVisitor) VisitMap(protoMap *proto.Map) {
|
|||||||
subVisitor := &schemaFieldVisitor{definitions: s.definitions}
|
subVisitor := &schemaFieldVisitor{definitions: s.definitions}
|
||||||
protoMap.SubType.Accept(subVisitor)
|
protoMap.SubType.Accept(subVisitor)
|
||||||
subField := subVisitor.field
|
subField := subVisitor.field
|
||||||
// Represent the map as "map[string]<value_type>"
|
// Represent the map as "map[<value_type>]"
|
||||||
field.Type = "map[string]" + subField.Type
|
field.Type = fmt.Sprintf("map[%s]", subField.Type)
|
||||||
s.field = field
|
s.field = field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,7 @@ func TestSchemaFieldVisitor(t *testing.T) {
|
|||||||
inputSchema: &protoMap,
|
inputSchema: &protoMap,
|
||||||
wantDefinitions: map[string]definition{},
|
wantDefinitions: map[string]definition{},
|
||||||
wantField: definitionField{
|
wantField: definitionField{
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: protoMap.Description,
|
Description: protoMap.Description,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -151,7 +151,7 @@ func TestSchemaFieldVisitor(t *testing.T) {
|
|||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"protoMap": {
|
"protoMap": {
|
||||||
Type: "map[" + protoPrimitive.Type + "]string",
|
Type: "map[" + protoPrimitive.Type + "]",
|
||||||
Description: protoMap.Description,
|
Description: protoMap.Description,
|
||||||
},
|
},
|
||||||
"protoPrimitive": {
|
"protoPrimitive": {
|
||||||
@@ -194,7 +194,7 @@ func TestSchemaFieldVisitor(t *testing.T) {
|
|||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"protoMap": {
|
"protoMap": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: protoMap.Description,
|
Description: protoMap.Description,
|
||||||
},
|
},
|
||||||
"protoPrimitive": {
|
"protoPrimitive": {
|
||||||
@@ -237,7 +237,7 @@ func TestSchemaFieldVisitor(t *testing.T) {
|
|||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"protoMap": {
|
"protoMap": {
|
||||||
Type: "map[string]string",
|
Type: "map[string]",
|
||||||
Description: protoMap.Description,
|
Description: protoMap.Description,
|
||||||
},
|
},
|
||||||
"protoPrimitive": {
|
"protoPrimitive": {
|
||||||
@@ -255,7 +255,7 @@ func TestSchemaFieldVisitor(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantField: definitionField{
|
wantField: definitionField{
|
||||||
Type: "map[string]io.cattle.test",
|
Type: "map[io.cattle.test]",
|
||||||
Description: protoNestedMap.Description,
|
Description: protoNestedMap.Description,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -279,7 +279,7 @@ func TestSchemaFieldVisitor(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantDefinitions: map[string]definition{},
|
wantDefinitions: map[string]definition{},
|
||||||
wantField: definitionField{
|
wantField: definitionField{
|
||||||
Type: "map[string]array[map[string]string]",
|
Type: "map[array[map[string]]]",
|
||||||
Description: "multi-level nested structure",
|
Description: "multi-level nested structure",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user