From 45dd09595f7d9fc57c341b12d482b2262b023c59 Mon Sep 17 00:00:00 2001 From: Jon Udell Date: Fri, 22 Sep 2023 10:40:53 -0700 Subject: [PATCH] cleanup --- ...{{csv_filename}.md => {odbc_tablename}.md} | 0 go.mod | 2 +- odbc/connection_config.go | 12 ----------- odbc/table_code_odbc.go | 8 ++------ odbc/utils.go | 20 +++++++++---------- 5 files changed, 12 insertions(+), 30 deletions(-) rename docs/tables/{{csv_filename}.md => {odbc_tablename}.md} (100%) diff --git a/docs/tables/{csv_filename}.md b/docs/tables/{odbc_tablename}.md similarity index 100% rename from docs/tables/{csv_filename}.md rename to docs/tables/{odbc_tablename}.md diff --git a/go.mod b/go.mod index b694f17..3816b76 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( github.com/alexbrainman/odbc v0.0.0-20230814102256-1421b829acc9 + github.com/turbot/go-kit v0.6.0 github.com/turbot/steampipe-plugin-sdk/v5 v5.5.0 ) @@ -79,7 +80,6 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/stevenle/topsort v0.2.0 // indirect github.com/tkrajina/go-reflector v0.5.6 // indirect - github.com/turbot/go-kit v0.6.0 // indirect github.com/ulikunitz/xz v0.5.10 // indirect github.com/zclconf/go-cty v1.12.1 // indirect go.opencensus.io v0.23.0 // indirect diff --git a/odbc/connection_config.go b/odbc/connection_config.go index eff5392..fb873b9 100644 --- a/odbc/connection_config.go +++ b/odbc/connection_config.go @@ -1,8 +1,6 @@ package odbc import ( - "strings" - "github.com/turbot/steampipe-plugin-sdk/v5/plugin" "github.com/turbot/steampipe-plugin-sdk/v5/plugin/schema" ) @@ -30,13 +28,3 @@ func GetConfig(connection *plugin.Connection) odbcConfig { config, _ := connection.Config.(odbcConfig) return config } - -// Additional helper function to split data source and table from a string -func splitDataSourceAndTable(s string) (string, string) { - parts := strings.SplitN(s, ":", 2) - if len(parts) != 2 { - // Handle this case, maybe return an error or default values - return "", "" - } - return parts[0], parts[1] -} diff --git a/odbc/table_code_odbc.go b/odbc/table_code_odbc.go index 6535dcd..a2b0a71 100644 --- a/odbc/table_code_odbc.go +++ b/odbc/table_code_odbc.go @@ -3,17 +3,13 @@ package odbc import ( "context" - //"encoding/json" "fmt" - //"os" "strings" "database/sql" + _ "github.com/alexbrainman/odbc" "github.com/turbot/go-kit/helpers" - - //"fmt" - _ "github.com/alexbrainman/odbc" "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/v5/plugin" "github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" @@ -65,7 +61,7 @@ func tableODBC(ctx context.Context, connection *plugin.Connection) (*plugin.Tabl return &plugin.Table{ Name: strings.ToLower(dsn) + "_" + tablename, - Description: dsn, + Description: dsn + ":" + tablename, List: &plugin.ListConfig{ Hydrate: listODBC, }, diff --git a/odbc/utils.go b/odbc/utils.go index 453c71f..4759362 100644 --- a/odbc/utils.go +++ b/odbc/utils.go @@ -1,15 +1,13 @@ package odbc -// Convert column index number to corresponding letter -// For example, 1:a, 2:b, 27:aa, 55:bc -func intToLetters(colIndex int) (letter string) { - colIndex-- - if firstLetter := colIndex / 26; firstLetter > 0 { - letter += intToLetters(firstLetter) - letter += string(rune('a' + colIndex%26)) - } else { - letter += string(rune('a' + colIndex)) - } +import ( + "strings" +) - return +func splitDataSourceAndTable(s string) (string, string) { + parts := strings.SplitN(s, ":", 2) + if len(parts) != 2 { + return "", "" + } + return parts[0], parts[1] }