@@ -84,6 +84,9 @@ type Generator struct {
84
84
// n indicates limit the description to at most n characters and truncate the description to
85
85
// closest sentence boundary if it exceeds n characters.
86
86
MaxDescLen * int `marker:",optional"`
87
+
88
+ // GenerateEmbeddedObjectMeta specifies if any embedded ObjectMeta in the CRD should be generated
89
+ GenerateEmbeddedObjectMeta * bool `marker:",optional"`
87
90
}
88
91
89
92
var _ genall.Generator = & Generator {}
@@ -100,6 +103,8 @@ func (g Generator) Generate(ctx *genall.GenerationContext) (result error) {
100
103
parser := & crdgen.Parser {
101
104
Collector : ctx .Collector ,
102
105
Checker : ctx .Checker ,
106
+ // Indicates the parser on whether to register the ObjectMeta type or not
107
+ GenerateEmbeddedObjectMeta : g .GenerateEmbeddedObjectMeta != nil && * g .GenerateEmbeddedObjectMeta == true ,
103
108
}
104
109
105
110
crdgen .AddKnownTypes (parser )
@@ -142,6 +147,12 @@ func (g Generator) Generate(ctx *genall.GenerationContext) (result error) {
142
147
fullSchema = * fullSchema .DeepCopy ()
143
148
crdgen .TruncateDescription (& fullSchema , * g .MaxDescLen )
144
149
}
150
+
151
+ // Fix top level ObjectMeta regardless of the settings.
152
+ if _ , ok := fullSchema .Properties ["metadata" ]; ok {
153
+ fullSchema .Properties ["metadata" ] = apiext.JSONSchemaProps {Type : "object" }
154
+ }
155
+
145
156
existingSet .NewSchemata [gv .Version ] = fullSchema
146
157
}
147
158
}
0 commit comments