Skip to content

Commit

Permalink
return schema from http server (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
brennanjl authored Apr 26, 2024
1 parent 4863d69 commit 1e4abb3
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions internal/services/grpc/txsvc/v1/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,35 @@ func convertSchemaFromEngine(schema *common.Schema) (*txpb.Schema, error) {
return nil, err
}
return &txpb.Schema{
Owner: schema.Owner,
Name: schema.Name,
Tables: convertTablesFromEngine(schema.Tables),
Actions: actions,
Owner: schema.Owner,
Name: schema.Name,
Tables: convertTablesFromEngine(schema.Tables),
Extensions: convertExtensionsFromEngine(schema.Extensions),
Actions: actions,
}, nil
}

func convertExtensionsFromEngine(extensions []*common.Extension) []*txpb.Extensions {
convExtensions := make([]*txpb.Extensions, len(extensions))
for i, extension := range extensions {
initialization := make([]*txpb.Extensions_ExtensionConfig, len(extension.Initialization))
for j, init := range extension.Initialization {
initialization[j] = &txpb.Extensions_ExtensionConfig{
Argument: init.Key,
Value: init.Value,
}
}

convExtensions[i] = &txpb.Extensions{
Name: extension.Name,
Alias: extension.Alias,
Initialization: initialization,
}
}

return convExtensions
}

func convertTablesFromEngine(tables []*common.Table) []*txpb.Table {
convTables := make([]*txpb.Table, len(tables))
for i, table := range tables {
Expand Down

0 comments on commit 1e4abb3

Please sign in to comment.