Bump to latest kube-openapi and SMD to pick up structType=atomic support

This commit is contained in:
Joe Betz
2020-09-30 11:49:13 -07:00
parent aa1f912868
commit f298d549f6
41 changed files with 469 additions and 73 deletions

View File

@@ -282,6 +282,9 @@ func typeShortName(t *types.Type) string {
func (g openAPITypeWriter) generateMembers(t *types.Type, required []string) ([]string, error) {
var err error
for t.Kind == types.Pointer { // fast-forward to effective type containing members
t = t.Elem
}
for _, m := range t.Members {
if hasOpenAPITagValue(m.CommentLines, tagValueFalse) {
continue
@@ -534,7 +537,7 @@ func (g openAPITypeWriter) generateDescription(CommentLines []string) {
default:
if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") {
delPrevChar()
line = "\n" + line + "\n" // Replace it with newline. This is useful when we have a line with: "Example:\n\tJSON-someting..."
line = "\n" + line + "\n" // Replace it with newline. This is useful when we have a line with: "Example:\n\tJSON-something..."
} else {
line += " "
}

View File

@@ -155,7 +155,7 @@ func namesMatch(goName, jsonName string) bool {
return true
}
// isCaptical returns true if one character is capital
// isCapital returns true if one character is capital
func isCapital(b byte) bool {
return b >= 'A' && b <= 'Z'
}

View File

@@ -312,6 +312,18 @@ func (c *convert) VisitKind(k *proto.Kind) {
NamedType: &deducedName,
}
}
ext := k.GetExtensions()
if val, ok := ext["x-kubernetes-map-type"]; ok {
switch val {
case "atomic":
a.Map.ElementRelationship = schema.Atomic
case "granular":
a.Map.ElementRelationship = schema.Separable
default:
c.reportError("unknown map type %v", val)
}
}
}
func toStringSlice(o interface{}) (out []string, ok bool) {
@@ -384,8 +396,17 @@ func (c *convert) VisitMap(m *proto.Map) {
a.Map = &schema.Map{}
a.Map.ElementType = c.makeRef(m.SubType, c.preserveUnknownFields)
// TODO: Get element relationship when we start putting it into the
// spec.
ext := m.GetExtensions()
if val, ok := ext["x-kubernetes-map-type"]; ok {
switch val {
case "atomic":
a.Map.ElementRelationship = schema.Atomic
case "granular":
a.Map.ElementRelationship = schema.Separable
default:
c.reportError("unknown map type %v", val)
}
}
}
func ptr(s schema.Scalar) *schema.Scalar { return &s }