MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / tablesV3

Function tablesV3

cli/cmd/tables_v3.go:35–75  ·  view source on GitHub ↗
(ctx context.Context, sourceClient *managedplugin.Client, sourceSpec *specs.Source, path, format, filter string)

Source from the content-addressed store, hash-verified

33}
34
35func tablesV3(ctx context.Context, sourceClient *managedplugin.Client, sourceSpec *specs.Source, path, format, filter string) error {
36 err := registerOnce()
37 if err != nil {
38 return err
39 }
40 sourcePbClient := pluginPb.NewPluginClient(sourceClient.Conn)
41 if err := initPlugin(ctx, sourcePbClient, sourceSpec.Spec, true, invocationUUID.String()); err != nil {
42 return fmt.Errorf("failed to init source: %w", err)
43 }
44
45 name, err := sourcePbClient.GetName(ctx, &pluginPb.GetName_Request{})
46 if err != nil {
47 return fmt.Errorf("failed to get source name: %w", err)
48 }
49
50 req := &pluginPb.GetTables_Request{
51 Tables: []string{"*"},
52 }
53
54 if filter == "spec" {
55 req.Tables = sourceSpec.Tables
56 req.SkipTables = sourceSpec.SkipTables
57 req.SkipDependentTables = *sourceSpec.SkipDependentTables
58 }
59
60 tables, err := getTables(ctx, sourcePbClient, req)
61 if err != nil {
62 return fmt.Errorf("failed to convert schemas to tables: %w", err)
63 }
64 topLevelTables, err := tables.UnflattenTables()
65 if err != nil {
66 return fmt.Errorf("failed to unflatten tables: %w", err)
67 }
68
69 g := docs.NewGenerator(name.Name, topLevelTables)
70 f := docs.FormatMarkdown
71 if format == "json" {
72 f = docs.FormatJSON
73 }
74 return g.Generate(path, f)
75}

Callers 1

tablesFunction · 0.85

Calls 5

GenerateMethod · 0.95
ErrorfMethod · 0.80
initPluginFunction · 0.70
getTablesFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected