mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #43247 from mbohlool/extensions_fix
Automatic merge from submit-queue (batch tested with PRs 42617, 43247, 43509, 43644, 43820) Bugfix: OpenAPI-gen was not generating extensions correctly Fixes a bug in openapi-gen that generated invalid code if x-kubernetes extensions defined in types.go. The location of VendorExtensions was wrong.
This commit is contained in:
commit
fa98c5fed4
@ -336,7 +336,11 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
|||||||
if len(required) > 0 {
|
if len(required) > 0 {
|
||||||
g.Do("Required: []string{\"$.$\"},\n", strings.Join(required, "\",\""))
|
g.Do("Required: []string{\"$.$\"},\n", strings.Join(required, "\",\""))
|
||||||
}
|
}
|
||||||
g.Do("},\n},\n", nil)
|
g.Do("},\n", nil)
|
||||||
|
if err := g.generateExtensions(t.CommentLines); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
g.Do("},\n", nil)
|
||||||
g.Do("Dependencies: []string{\n", args)
|
g.Do("Dependencies: []string{\n", args)
|
||||||
// Map order is undefined, sort them or we may get a different file generated each time.
|
// Map order is undefined, sort them or we may get a different file generated each time.
|
||||||
keys := []string{}
|
keys := []string{}
|
||||||
@ -353,11 +357,7 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
|||||||
}
|
}
|
||||||
g.Do("\"$.$\",", k)
|
g.Do("\"$.$\",", k)
|
||||||
}
|
}
|
||||||
g.Do("},\n", nil)
|
g.Do("},\n},\n", nil)
|
||||||
if err := g.generateExtensions(t.CommentLines); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g.Do("},\n", nil)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ func (g openAPITypeWriter) generateExtensions(CommentLines []string) error {
|
|||||||
for _, val := range tagValues {
|
for _, val := range tagValues {
|
||||||
if strings.HasPrefix(val, tagExtensionPrefix) {
|
if strings.HasPrefix(val, tagExtensionPrefix) {
|
||||||
if !anyExtension {
|
if !anyExtension {
|
||||||
g.Do("spec.VendorExtensible: {\nExtensions: spec.Extensions{\n", nil)
|
g.Do("VendorExtensible: spec.VendorExtensible{\nExtensions: spec.Extensions{\n", nil)
|
||||||
anyExtension = true
|
anyExtension = true
|
||||||
}
|
}
|
||||||
parts := strings.SplitN(val, ":", 2)
|
parts := strings.SplitN(val, ":", 2)
|
||||||
|
@ -227,7 +227,7 @@ Format: "byte",
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"WithExtension": {
|
"WithExtension": {
|
||||||
spec.VendorExtensible: {
|
VendorExtensible: spec.VendorExtensible{
|
||||||
Extensions: spec.Extensions{
|
Extensions: spec.Extensions{
|
||||||
"x-kubernetes-member-tag": "member_test",
|
"x-kubernetes-member-tag": "member_test",
|
||||||
},
|
},
|
||||||
@ -241,15 +241,15 @@ Format: "",
|
|||||||
},
|
},
|
||||||
Required: []string{"String","Int64","Int32","Int16","Int8","Uint","Uint64","Uint32","Uint16","Uint8","Byte","Bool","Float64","Float32","ByteArray","WithExtension"},
|
Required: []string{"String","Int64","Int32","Int16","Int8","Uint","Uint64","Uint32","Uint16","Uint8","Byte","Bool","Float64","Float32","ByteArray","WithExtension"},
|
||||||
},
|
},
|
||||||
},
|
VendorExtensible: spec.VendorExtensible{
|
||||||
Dependencies: []string{
|
|
||||||
},
|
|
||||||
spec.VendorExtensible: {
|
|
||||||
Extensions: spec.Extensions{
|
Extensions: spec.Extensions{
|
||||||
"x-kubernetes-type-tag": "type_test",
|
"x-kubernetes-type-tag": "type_test",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Dependencies: []string{
|
||||||
|
},
|
||||||
|
},
|
||||||
`, buffer.String())
|
`, buffer.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user