-
Notifications
You must be signed in to change notification settings - Fork 362
/
Copy pathserde.go
30 lines (25 loc) · 861 Bytes
/
serde.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package graveler
import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"
)
const (
EntityTypeKey = "entity"
EntityTypeCommit = "commit"
EntityTypeBranch = "branch"
EntityTypeTag = "tag"
EntitySchemaKey = "schema_name"
EntitySchemaCommit = "io.treeverse.lakefs.graveler.CommitData"
EntitySchemaBranch = "io.treeverse.lakefs.graveler.BranchData"
EntitySchemaTag = "io.treeverse.lakefs.graveler.TagData"
EntitySchemaDefinitionKey = "schema_definition"
)
func serializeSchemaDefinition(msg protoreflect.ProtoMessage) (string, error) {
descriptorProto := protodesc.ToDescriptorProto(msg.ProtoReflect().Descriptor())
jsonData, err := protojson.Marshal(descriptorProto)
if err != nil {
return "", err
}
return string(jsonData), nil
}