13
vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/gen.go
generated
vendored
13
vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/gen.go
generated
vendored
@@ -84,6 +84,9 @@ type Generator struct {
|
||||
// n indicates limit the description to at most n characters and truncate the description to
|
||||
// closest sentence boundary if it exceeds n characters.
|
||||
MaxDescLen *int `marker:",optional"`
|
||||
|
||||
// GenerateEmbeddedObjectMeta specifies if any embedded ObjectMeta in the CRD should be generated
|
||||
GenerateEmbeddedObjectMeta *bool `marker:",optional"`
|
||||
}
|
||||
|
||||
var _ genall.Generator = &Generator{}
|
||||
@@ -100,6 +103,8 @@ func (g Generator) Generate(ctx *genall.GenerationContext) (result error) {
|
||||
parser := &crdgen.Parser{
|
||||
Collector: ctx.Collector,
|
||||
Checker: ctx.Checker,
|
||||
// Indicates the parser on whether to register the ObjectMeta type or not
|
||||
GenerateEmbeddedObjectMeta: g.GenerateEmbeddedObjectMeta != nil && *g.GenerateEmbeddedObjectMeta == true,
|
||||
}
|
||||
|
||||
crdgen.AddKnownTypes(parser)
|
||||
@@ -142,6 +147,12 @@ func (g Generator) Generate(ctx *genall.GenerationContext) (result error) {
|
||||
fullSchema = *fullSchema.DeepCopy()
|
||||
crdgen.TruncateDescription(&fullSchema, *g.MaxDescLen)
|
||||
}
|
||||
|
||||
// Fix top level ObjectMeta regardless of the settings.
|
||||
if _, ok := fullSchema.Properties["metadata"]; ok {
|
||||
fullSchema.Properties["metadata"] = apiext.JSONSchemaProps{Type: "object"}
|
||||
}
|
||||
|
||||
existingSet.NewSchemata[gv.Version] = fullSchema
|
||||
}
|
||||
}
|
||||
@@ -434,7 +445,7 @@ func crdsFromDirectory(ctx *genall.GenerationContext, dir string) (map[schema.Gr
|
||||
groupKind := schema.GroupKind{Group: actualCRD.Spec.Group, Kind: actualCRD.Spec.Names.Kind}
|
||||
var versions map[string]struct{}
|
||||
if len(actualCRD.Spec.Versions) == 0 {
|
||||
versions = map[string]struct{}{actualCRD.Spec.Version: struct{}{}}
|
||||
versions = map[string]struct{}{actualCRD.Spec.Version: {}}
|
||||
} else {
|
||||
versions = make(map[string]struct{}, len(actualCRD.Spec.Versions))
|
||||
for _, ver := range actualCRD.Spec.Versions {
|
||||
|
||||
4
vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/zz_generated.markerhelp.go
generated
vendored
4
vendor/sigs.k8s.io/controller-tools/pkg/schemapatcher/zz_generated.markerhelp.go
generated
vendored
@@ -32,11 +32,11 @@ func (Generator) Help() *markers.DefinitionHelp {
|
||||
Details: "For legacy (v1beta1) single-version CRDs, it will simply replace the global schema. \n For legacy (v1beta1) multi-version CRDs, and any v1 CRDs, it will replace schemata of existing versions and *clear the schema* from any versions not specified in the Go code. It will *not* add new versions, or remove old ones. \n For legacy multi-version CRDs with identical schemata, it will take care of lifting the per-version schema up to the global schema. \n It will generate output for each \"CRD Version\" (API version of the CRD type itself) , e.g. apiextensions/v1beta1 and apiextensions/v1) available.",
|
||||
},
|
||||
FieldHelp: map[string]markers.DetailedHelp{
|
||||
"ManifestsPath": markers.DetailedHelp{
|
||||
"ManifestsPath": {
|
||||
Summary: "contains the CustomResourceDefinition YAML files.",
|
||||
Details: "",
|
||||
},
|
||||
"MaxDescLen": markers.DetailedHelp{
|
||||
"MaxDescLen": {
|
||||
Summary: "specifies the maximum description length for fields in CRD's OpenAPI schema. ",
|
||||
Details: "0 indicates drop the description for all fields completely. n indicates limit the description to at most n characters and truncate the description to closest sentence boundary if it exceeds n characters.",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user