From f46a68de475af9eb1b819726a568a5e53038553d Mon Sep 17 00:00:00 2001 From: Lionel Villard Date: Tue, 16 Aug 2022 11:52:12 -0400 Subject: [PATCH] generate defaults for known types --- pkg/crdpuller/discovery.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/crdpuller/discovery.go b/pkg/crdpuller/discovery.go index 646ec2d2912..02cc0b4c677 100644 --- a/pkg/crdpuller/discovery.go +++ b/pkg/crdpuller/discovery.go @@ -455,6 +455,10 @@ func (sc *SchemaConverter) VisitPrimitive(p *proto.Primitive) { sc.setupDescription(p) sc.schemaProps.Type = p.Type sc.schemaProps.Format = p.Format + + if defaults, ok := knownDefaults[p.Path.String()]; ok { + sc.schemaProps.Default = defaults + } } func (sc *SchemaConverter) VisitKind(k *proto.Kind) { @@ -627,3 +631,7 @@ func init() { } } } + +var knownDefaults map[string]*apiextensionsv1.JSON = map[string]*apiextensionsv1.JSON{ + "io.k8s.api.core.v1.ContainerPort.protocol": {Raw: []byte(`"TCP"`)}, +}