@@ -13,17 +13,24 @@ import (
1313// ConfigSchemaToProto takes a *configschema.Block and converts it to a
1414// proto.Schema_Block for a grpc response.
1515func ConfigSchemaToProto (b * configschema.Block ) * proto.Schema_Block {
16- block := & proto.Schema_Block {}
16+ block := & proto.Schema_Block {
17+ Description : b .Description ,
18+ DescriptionKind : protoStringKind (b .DescriptionKind ),
19+ Deprecated : b .Deprecated ,
20+ }
1721
1822 for _ , name := range sortedKeys (b .Attributes ) {
1923 a := b .Attributes [name ]
24+
2025 attr := & proto.Schema_Attribute {
21- Name : name ,
22- Description : a .Description ,
23- Optional : a .Optional ,
24- Computed : a .Computed ,
25- Required : a .Required ,
26- Sensitive : a .Sensitive ,
26+ Name : name ,
27+ Description : a .Description ,
28+ DescriptionKind : protoStringKind (a .DescriptionKind ),
29+ Optional : a .Optional ,
30+ Computed : a .Computed ,
31+ Required : a .Required ,
32+ Sensitive : a .Sensitive ,
33+ Deprecated : a .Deprecated ,
2734 }
2835
2936 ty , err := json .Marshal (a .Type )
@@ -44,6 +51,15 @@ func ConfigSchemaToProto(b *configschema.Block) *proto.Schema_Block {
4451 return block
4552}
4653
54+ func protoStringKind (k configschema.StringKind ) proto.StringKind {
55+ switch k {
56+ default :
57+ return proto .StringKind_PLAIN
58+ case configschema .StringMarkdown :
59+ return proto .StringKind_MARKDOWN
60+ }
61+ }
62+
4763func protoSchemaNestedBlock (name string , b * configschema.NestedBlock ) * proto.Schema_NestedBlock {
4864 var nesting proto.Schema_NestedBlock_NestingMode
4965 switch b .Nesting {
@@ -83,15 +99,21 @@ func ProtoToConfigSchema(b *proto.Schema_Block) *configschema.Block {
8399 block := & configschema.Block {
84100 Attributes : make (map [string ]* configschema.Attribute ),
85101 BlockTypes : make (map [string ]* configschema.NestedBlock ),
102+
103+ Description : b .Description ,
104+ DescriptionKind : schemaStringKind (b .DescriptionKind ),
105+ Deprecated : b .Deprecated ,
86106 }
87107
88108 for _ , a := range b .Attributes {
89109 attr := & configschema.Attribute {
90- Description : a .Description ,
91- Required : a .Required ,
92- Optional : a .Optional ,
93- Computed : a .Computed ,
94- Sensitive : a .Sensitive ,
110+ Description : a .Description ,
111+ DescriptionKind : schemaStringKind (a .DescriptionKind ),
112+ Required : a .Required ,
113+ Optional : a .Optional ,
114+ Computed : a .Computed ,
115+ Sensitive : a .Sensitive ,
116+ Deprecated : a .Deprecated ,
95117 }
96118
97119 if err := json .Unmarshal (a .Type , & attr .Type ); err != nil {
@@ -108,6 +130,15 @@ func ProtoToConfigSchema(b *proto.Schema_Block) *configschema.Block {
108130 return block
109131}
110132
133+ func schemaStringKind (k proto.StringKind ) configschema.StringKind {
134+ switch k {
135+ default :
136+ return configschema .StringPlain
137+ case proto .StringKind_MARKDOWN :
138+ return configschema .StringMarkdown
139+ }
140+ }
141+
111142func schemaNestedBlock (b * proto.Schema_NestedBlock ) * configschema.NestedBlock {
112143 var nesting configschema.NestingMode
113144 switch b .Nesting {
0 commit comments