Skip to content

Commit

Permalink
Add plural in list function name
Browse files Browse the repository at this point in the history
  • Loading branch information
emeric-martineau committed Aug 3, 2023
1 parent 34b4b40 commit fdaab33
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions metabase/table_metabase_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func tableMetabaseDb() *plugin.Table {
Name: "metabase_db",
Description: "List databases created in Metabase.",
List: &plugin.ListConfig{
Hydrate: listDatabase,
Hydrate: listDatabases,
},
Get: &plugin.GetConfig{
KeyColumns: plugin.AllColumns([]string{"id"}),
Expand All @@ -37,19 +37,19 @@ func tableMetabaseDb() *plugin.Table {
}
}

func listDatabase(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
func listDatabases(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
client, err := connect(d)

if err != nil {
plugin.Logger(ctx).Error("metabase_db.listDatabase", "connection_error", err)
plugin.Logger(ctx).Error("metabase_db.listDatabases", "connection_error", err)
return nil, err
}

request := client.DatabaseApi.ListDatabases(context.Background())

dbList, resp, err := client.DatabaseApi.ListDatabasesExecute(request)

err = manageError("metabase_db.listDatabase", ctx, resp, err)
err = manageError("metabase_db.listDatabases", ctx, resp, err)

if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions metabase/table_metabase_db_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func tableMetabaseDbFeature() *plugin.Table {
Description: "Features of one database.",
List: &plugin.ListConfig{
KeyColumns: plugin.AllColumns([]string{"db_id"}),
Hydrate: listDatabaseFeature,
Hydrate: listDatabaseFeatures,
},

Columns: []*plugin.Column{
Expand All @@ -29,11 +29,11 @@ func tableMetabaseDbFeature() *plugin.Table {
}
}

func listDatabaseFeature(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
func listDatabaseFeatures(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
client, err := connect(d)

if err != nil {
plugin.Logger(ctx).Error("metabase_db_feature.listDatabaseFeature", "connection_error", err)
plugin.Logger(ctx).Error("metabase_db_feature.listDatabaseFeatures", "connection_error", err)
return nil, err
}

Expand All @@ -44,7 +44,7 @@ func listDatabaseFeature(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd

db, resp, err := client.DatabaseApi.GetDatabaseExecute(request)

err = manageError("metabase_db_feature.listDatabaseFeature", ctx, resp, err)
err = manageError("metabase_db_feature.listDatabaseFeatures", ctx, resp, err)

if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions metabase/table_metabase_db_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func tableMetabaseDbTable() *plugin.Table {
Description: "List of tables of databases created in Metabase.",
List: &plugin.ListConfig{
KeyColumns: plugin.AllColumns([]string{"db_id"}),
Hydrate: listDatabaseTable,
Hydrate: listDatabaseTables,
},
Get: &plugin.GetConfig{
KeyColumns: plugin.AllColumns([]string{"id", "db_id"}),
Expand All @@ -38,11 +38,11 @@ func tableMetabaseDbTable() *plugin.Table {
}
}

func listDatabaseTable(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
func listDatabaseTables(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
client, err := connect(d)

if err != nil {
plugin.Logger(ctx).Error("metabase_db_table.listDatabaseTable", "connection_error", err)
plugin.Logger(ctx).Error("metabase_db_table.listDatabaseTables", "connection_error", err)
return nil, err
}

Expand All @@ -54,7 +54,7 @@ func listDatabaseTable(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydra

db, resp, err := client.DatabaseApi.GetDatabaseExecute(request)

err = manageError("metabase_db_table.listDatabaseTable", ctx, resp, err)
err = manageError("metabase_db_table.listDatabaseTables", ctx, resp, err)

if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions metabase/table_metabase_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func tableMetabaseGroup() *plugin.Table {
Name: "metabase_permission_group",
Description: "List of group created in Metabase.",
List: &plugin.ListConfig{
Hydrate: listPermissionGroup,
Hydrate: listPermissionsGroup,
},
Get: &plugin.GetConfig{
KeyColumns: plugin.AllColumns([]string{"id"}),
Expand All @@ -28,19 +28,19 @@ func tableMetabaseGroup() *plugin.Table {
}
}

func listPermissionGroup(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
func listPermissionsGroup(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
client, err := connect(d)

if err != nil {
plugin.Logger(ctx).Error("metabase_permission_group.listPermissionGroup", "connection_error", err)
plugin.Logger(ctx).Error("metabase_permission_group.listPermissionsGroup", "connection_error", err)
return nil, err
}

request := client.PermissionsApi.GetPermissionsGroup(context.Background())

permissions, resp, err := client.PermissionsApi.GetPermissionsGroupExecute(request)

err = manageError("metabase_permission_group.listPermissionGroup", ctx, resp, err)
err = manageError("metabase_permission_group.listPermissionsGroup", ctx, resp, err)

if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions metabase/table_metabase_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func tableMetabasePermission() *plugin.Table {
Name: "metabase_permission",
Description: "List of permissions in Metabase.",
List: &plugin.ListConfig{
Hydrate: listPermission,
Hydrate: listPermissions,
},
Columns: []*plugin.Column{
{Name: "group_id", Type: proto.ColumnType_INT, Description: "ID of the group."},
Expand All @@ -38,25 +38,25 @@ func tableMetabasePermission() *plugin.Table {
}
}

func listPermission(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
func listPermissions(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
client, err := connect(d)

if err != nil {
plugin.Logger(ctx).Error("metabase_permission.listPermission", "connection_error", err)
plugin.Logger(ctx).Error("metabase_permission.listPermissions", "connection_error", err)
return nil, err
}

request := client.PermissionsApi.GetPermissionsGraph(context.Background())

permission, resp, err := client.PermissionsApi.GetPermissionsGraphExecute(request)

err = manageError("metabase_permission.listPermission", ctx, resp, err)
err = manageError("metabase_permission.listPermissions", ctx, resp, err)

if err != nil {
return nil, err
}

permissions, err := createPermission("metabase_permission.listPermission", ctx, permission.Groups)
permissions, err := createPermission("metabase_permission.listPermissions", ctx, permission.Groups)

if err == nil {
for _, perm := range permissions {
Expand Down
10 changes: 5 additions & 5 deletions metabase/table_metabase_permission_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ func tableMetabasePermissionData() *plugin.Table {
Name: "metabase_permission_data",
Description: "List of permissions for data in Metabase.",
List: &plugin.ListConfig{
Hydrate: listPermissionData,
Hydrate: listPermissionsData,
},
Columns: SubPermissionColum,
}
}

func listPermissionData(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
return listSubPermission("listPermissionData", ctx, d, PermissionData)
func listPermissionsData(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
return listSubPermissions("listPermissionsData", ctx, d, PermissionData)
}

func listSubPermission(methodCallStack string, ctx context.Context, d *plugin.QueryData, permissionType PermissionType) (interface{}, error) {
func listSubPermissions(methodCallStack string, ctx context.Context, d *plugin.QueryData, permissionType PermissionType) (interface{}, error) {
client, err := connect(d)
methodCallStack = fmt.Sprintf("%s.listSubPermission", methodCallStack)
methodCallStack = fmt.Sprintf("%s.listSubPermissions", methodCallStack)

if err != nil {
plugin.Logger(ctx).Error(methodCallStack, "connection_error", err)
Expand Down
6 changes: 3 additions & 3 deletions metabase/table_metabase_permission_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ func tableMetabasePermissionDownload() *plugin.Table {
Name: "metabase_permission_download",
Description: "List of permissions for download in Metabase.",
List: &plugin.ListConfig{
Hydrate: listPermissionDownload,
Hydrate: listPermissionsDownload,
},
Columns: SubPermissionColum,
}
}

func listPermissionDownload(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
return listSubPermission("listPermissionDownload", ctx, d, PermissionDownload)
func listPermissionsDownload(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
return listSubPermissions("listPermissionsDownload", ctx, d, PermissionDownload)
}

0 comments on commit fdaab33

Please sign in to comment.