...
1
16
17 package explain
18
19 import "k8s.io/kube-openapi/pkg/util/proto"
20
21
22 const indentDesc = 2
23
24
25 type regularFieldsPrinter struct {
26 Writer *Formatter
27 Error error
28 }
29
30 var _ proto.SchemaVisitor = ®ularFieldsPrinter{}
31 var _ fieldsPrinter = ®ularFieldsPrinter{}
32
33
34 func (f *regularFieldsPrinter) VisitArray(a *proto.Array) {
35 a.SubType.Accept(f)
36 }
37
38
39
40 func (f *regularFieldsPrinter) VisitKind(k *proto.Kind) {
41 for _, key := range k.Keys() {
42 v := k.Fields[key]
43 required := ""
44 if k.IsRequired(key) {
45 required = " -required-"
46 }
47
48 if err := f.Writer.Write("%s\t<%s>%s", key, GetTypeName(v), required); err != nil {
49 f.Error = err
50 return
51 }
52 if err := f.Writer.Indent(indentDesc).WriteWrapped("%s", v.GetDescription()); err != nil {
53 f.Error = err
54 return
55 }
56 if err := f.Writer.Write(""); err != nil {
57 f.Error = err
58 return
59 }
60 }
61 }
62
63
64 func (f *regularFieldsPrinter) VisitMap(m *proto.Map) {
65 m.SubType.Accept(f)
66 }
67
68
69 func (f *regularFieldsPrinter) VisitPrimitive(p *proto.Primitive) {
70
71 }
72
73
74 func (f *regularFieldsPrinter) VisitReference(r proto.Reference) {
75 r.SubSchema().Accept(f)
76 }
77
78
79 func (f *regularFieldsPrinter) PrintFields(schema proto.Schema) error {
80 schema.Accept(f)
81 return f.Error
82 }
83
View as plain text