mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-29 05:22:37 +00:00
Merge pull request #28931 from smarterclayton/fix_conversions
Automatic merge from submit-queue genconversion=false should skip fields during conversion generation Currently it only skips if the fields don't match, but that leaves no way for callers to say "no really, ignore this field". @wojtek-t @thockin *must* be able to ignore a non-convertible field (if the types are different but we still want the autogeneration of everything else)
This commit is contained in:
commit
6558b30f11
@ -352,16 +352,13 @@ func isDirectlyConvertible(in, out *types.Type, manualConversions conversionFunc
|
|||||||
case types.Struct:
|
case types.Struct:
|
||||||
convertible := true
|
convertible := true
|
||||||
for _, inMember := range in.Members {
|
for _, inMember := range in.Members {
|
||||||
|
// Check if this member is excluded from conversion
|
||||||
|
if tagvals := extractTag(inMember.CommentLines); tagvals != nil && tagvals[0] == "false" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Check if there is an out member with that name.
|
// Check if there is an out member with that name.
|
||||||
outMember, found := findMember(out, inMember.Name)
|
outMember, found := findMember(out, inMember.Name)
|
||||||
if !found {
|
if !found {
|
||||||
// Check if the member has opted out with:
|
|
||||||
// "+k8s:conversion-gen=false"
|
|
||||||
// TODO: Switch to SecondClosestCommentLines.
|
|
||||||
if tagvals := extractTag(inMember.CommentLines); tagvals != nil && tagvals[0] == "false" {
|
|
||||||
glog.V(5).Infof("field %v.%s requests no conversion generation, skipping", in, inMember.Name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
convertible = convertible && isConvertible(inMember.Type, outMember.Type, manualConversions)
|
convertible = convertible && isConvertible(inMember.Type, outMember.Type, manualConversions)
|
||||||
@ -727,6 +724,10 @@ func (g *genConversion) doSlice(inType, outType *types.Type, sw *generator.Snipp
|
|||||||
|
|
||||||
func (g *genConversion) doStruct(inType, outType *types.Type, sw *generator.SnippetWriter) {
|
func (g *genConversion) doStruct(inType, outType *types.Type, sw *generator.SnippetWriter) {
|
||||||
for _, m := range inType.Members {
|
for _, m := range inType.Members {
|
||||||
|
// Check if this member is excluded from conversion
|
||||||
|
if tagvals := extractTag(m.CommentLines); tagvals != nil && tagvals[0] == "false" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
outMember, isOutMember := findMember(outType, m.Name)
|
outMember, isOutMember := findMember(outType, m.Name)
|
||||||
if !isOutMember {
|
if !isOutMember {
|
||||||
// Since this object wasn't filtered out, this means that
|
// Since this object wasn't filtered out, this means that
|
||||||
|
Loading…
Reference in New Issue
Block a user