Skip to content

Commit

Permalink
chore: add struct tags and update docs (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chief-Rishab authored Mar 22, 2023
1 parent 905cc68 commit 4c18210
Show file tree
Hide file tree
Showing 32 changed files with 89 additions and 93 deletions.
26 changes: 13 additions & 13 deletions plugins/extractors/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ var summary string

// Config holds the set of configuration for the bigquery extractor
type Config struct {
ProjectID string `mapstructure:"project_id" validate:"required"`
ProjectID string `json:"project_id" yaml:"project_id" mapstructure:"project_id" validate:"required"`
// ServiceAccountBase64 takes precedence over ServiceAccountJSON field
ServiceAccountBase64 string `mapstructure:"service_account_base64"`
ServiceAccountJSON string `mapstructure:"service_account_json"`
MaxPageSize int `mapstructure:"max_page_size"`
TablePattern string `mapstructure:"table_pattern"`
Exclude Exclude `mapstructure:"exclude"`
IncludeColumnProfile bool `mapstructure:"include_column_profile"`
MaxPreviewRows int `mapstructure:"max_preview_rows" default:"30"`
IsCollectTableUsage bool `mapstructure:"collect_table_usage" default:"false"`
UsagePeriodInDay int64 `mapstructure:"usage_period_in_day" default:"7"`
UsageProjectIDs []string `mapstructure:"usage_project_ids"`
ServiceAccountBase64 string `json:"service_account_base64" yaml:"service_account_base64" mapstructure:"service_account_base64"`
ServiceAccountJSON string `json:"service_account_json" yaml:"service_account_json" mapstructure:"service_account_json"`
MaxPageSize int `json:"max_page_size" yaml:"max_page_size" mapstructure:"max_page_size"`
TablePattern string `json:"table_pattern" yaml:"table_pattern" mapstructure:"table_pattern"`
Exclude Exclude `json:"exclude" yaml:"exclude" mapstructure:"exclude"`
IncludeColumnProfile bool `json:"include_column_profile" yaml:"include_column_profile" mapstructure:"include_column_profile"`
MaxPreviewRows int `json:"max_preview_rows" yaml:"max_preview_rows" mapstructure:"max_preview_rows" default:"30"`
IsCollectTableUsage bool `json:"collect_table_usage" yaml:"collect_table_usage" mapstructure:"collect_table_usage" default:"false"`
UsagePeriodInDay int64 `json:"usage_period_in_day" yaml:"usage_period_in_day" mapstructure:"usage_period_in_day" default:"7"`
UsageProjectIDs []string `json:"usage_project_ids" yaml:"usage_project_ids" mapstructure:"usage_project_ids"`
}

type Exclude struct {
// list of datasetIDs
Datasets []string `mapstructure:"datasets"`
Datasets []string `json:"datasets" yaml:"datasets" mapstructure:"datasets"`
// list of tableNames in format - datasetID.tableID
Tables []string `mapstructure:"tables"`
Tables []string `json:"tables" yaml:"tables" mapstructure:"tables"`
}

const (
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/bigtable/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (

// Config holds the configurations for the bigtable extractor
type Config struct {
ProjectID string `mapstructure:"project_id" validate:"required"`
ProjectID string `json:"project_id" yaml:"project_id" mapstructure:"project_id" validate:"required"`
}

var info = plugins.Info{
Expand Down
6 changes: 3 additions & 3 deletions plugins/extractors/caramlstore/caramlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ var summary string

// Config holds the set of configuration for the CaraML Store extractor
type Config struct {
URL string `mapstructure:"url" validate:"required"`
MaxSizeInMB int `mapstructure:"max_size_in_mb"`
RequestTimeout time.Duration `mapstructure:"request_timeout" validate:"min=1ms" default:"10s"`
URL string `json:"url" yaml:"url" mapstructure:"url" validate:"required"`
MaxSizeInMB int `json:"max_size_in_mb" yaml:"max_size_in_mb" mapstructure:"max_size_in_mb"`
RequestTimeout time.Duration `json:"request_timeout" yaml:"request_timeout" mapstructure:"request_timeout" validate:"min=1ms" default:"10s"`
}

var sampleConfig = `url: caraml-store.com:80`
Expand Down
8 changes: 4 additions & 4 deletions plugins/extractors/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const (

// Config holds the set of configuration for the cassandra extractor
type Config struct {
UserID string `mapstructure:"user_id" validate:"required"`
Password string `mapstructure:"password" validate:"required"`
Host string `mapstructure:"host" validate:"required"`
Port int `mapstructure:"port" validate:"required"`
UserID string `json:"user_id" yaml:"user_id" mapstructure:"user_id" validate:"required"`
Password string `json:"password" yaml:"password" mapstructure:"password" validate:"required"`
Host string `json:"host" yaml:"host" mapstructure:"host" validate:"required"`
Port int `json:"port" yaml:"port" mapstructure:"port" validate:"required"`
}

var sampleConfig = `
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var summary string

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: "tcp://localhost:3306?username=admin&password=pass123&debug=true"`
Expand Down
8 changes: 4 additions & 4 deletions plugins/extractors/couchdb/couchdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var defaultDBList = []string{

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: http://admin:pass123@localhost:3306/`
Expand Down Expand Up @@ -139,10 +139,10 @@ func (e *Extractor) processTable(ctx context.Context, dbName string, docID strin
// push table to channel
e.emit(models.NewRecord(&v1beta2.Asset{
Urn: models.NewURN("couchdb", e.UrnScope, "table", fmt.Sprintf("%s.%s", dbName, docID)),
Name: docID,
Type: "table",
Name: docID,
Type: "table",
Service: "couchdb",
Data: table,
Data: table,
}))

return
Expand Down
6 changes: 3 additions & 3 deletions plugins/extractors/elastic/elastic.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
var summary string

type Config struct {
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
Host string `mapstructure:"host" validate:"required"`
User string `json:"user" yaml:"user" mapstructure:"user"`
Password string `json:"password" yaml:"password" mapstructure:"password"`
Host string `json:"host" yaml:"host" mapstructure:"host" validate:"required"`
}

var sampleConfig = `
Expand Down
6 changes: 3 additions & 3 deletions plugins/extractors/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var summary string

// Config holds the set of configuration for the extractor
type Config struct {
ProjectID string `mapstructure:"project_id" validate:"required"`
ServiceAccountJSON string `mapstructure:"service_account_json"`
ExtractBlob bool `mapstructure:"extract_blob"`
ProjectID string `json:"project_id" yaml:"project_id" mapstructure:"project_id" validate:"required"`
ServiceAccountJSON string `json:"service_account_json" yaml:"service_account_json" mapstructure:"service_account_json"`
ExtractBlob bool `json:"extract_blob" yaml:"extract_blob" mapstructure:"extract_blob"`
}

var sampleConfig = `
Expand Down
8 changes: 4 additions & 4 deletions plugins/extractors/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var summary string

// Config holds the set of configuration for the extractor
type Config struct {
Org string `mapstructure:"org" validate:"required"`
Token string `mapstructure:"token" validate:"required"`
Org string `json:"org" yaml:"org" mapstructure:"org" validate:"required"`
Token string `json:"token" yaml:"token" mapstructure:"token" validate:"required"`
}

var sampleConfig = `
Expand Down Expand Up @@ -96,8 +96,8 @@ func (e *Extractor) Extract(ctx context.Context, emit plugins.Emit) (err error)
emit(models.NewRecord(&v1beta2.Asset{
Urn: models.NewURN("github", e.UrnScope, "user", usr.GetNodeID()),
Service: "github",
Type: "user",
Data: u,
Type: "user",
Data: u,
}))
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/grafana/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var summary string

// Config holds the set of configuration for the grafana extractor
type Config struct {
BaseURL string `mapstructure:"base_url" validate:"required"`
APIKey string `mapstructure:"api_key" validate:"required"`
BaseURL string `json:"base_url" yaml:"base_url" mapstructure:"base_url" validate:"required"`
APIKey string `json:"api_key" yaml:"api_key" mapstructure:"api_key" validate:"required"`
}

var sampleConfig = `
Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/gsuite/gsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
var summary string

type Config struct {
ServiceAccountJSON string `mapstructure:"service_account_json" validate:"required"`
UserEmail string `mapstructure:"user_email" validate:"required"`
ServiceAccountJSON string `json:"service_account_json" yaml:"service_account_json" mapstructure:"service_account_json" validate:"required"`
UserEmail string `json:"user_email" yaml:"user_email" mapstructure:"user_email" validate:"required"`
}

var sampleConfig = `
Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var defaultTopics = map[string]byte{

// Config holds the set of configuration for the kafka extractor
type Config struct {
Broker string `mapstructure:"broker" validate:"required"`
Auth AuthConfig `mapstructure:"auth_config"`
Broker string `json:"broker" yaml:"broker" mapstructure:"broker" validate:"required"`
Auth AuthConfig `json:"auth_config" yaml:"auth_config" mapstructure:"auth_config"`
}

type AuthConfig struct {
Expand Down
8 changes: 4 additions & 4 deletions plugins/extractors/mariadb/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var defaultDBList = []string{

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: "admin:pass123@tcp(localhost:3306)/"`
Expand Down Expand Up @@ -139,10 +139,10 @@ func (e *Extractor) processTable(database string, tableName string) (err error)
// push table to channel
e.emit(models.NewRecord(&v1beta2.Asset{
Urn: models.NewURN("mariadb", e.UrnScope, "table", fmt.Sprintf("%s.%s", database, tableName)),
Name: tableName,
Type: "table",
Name: tableName,
Type: "table",
Service: "mariadb",
Data: data,
Data: data,
}))
return
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/extractors/merlin/merlin.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ var summary string

// Config holds the set of configuration for the Merlin extractor.
type Config struct {
URL string `mapstructure:"url" validate:"required"`
ServiceAccountBase64 string `mapstructure:"service_account_base64"`
RequestTimeout time.Duration `mapstructure:"request_timeout" validate:"min=1ms" default:"10s"`
WorkerCount int `mapstructure:"worker_count" validate:"min=1" default:"5"`
URL string `json:"url" yaml:"url" mapstructure:"url" validate:"required"`
ServiceAccountBase64 string `json:"service_account_base64" yaml:"service_account_base64" mapstructure:"service_account_base64"`
RequestTimeout time.Duration `json:"request_timeout" yaml:"request_timeout" mapstructure:"request_timeout" validate:"min=1ms" default:"10s"`
WorkerCount int `json:"worker_count" yaml:"worker_count" mapstructure:"worker_count" validate:"min=1" default:"5"`
}

var sampleConfig = heredoc.Doc(`
Expand Down
10 changes: 5 additions & 5 deletions plugins/extractors/metabase/metabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ var info = plugins.Info{

// Config holds the set of configuration for the metabase extractor
type Config struct {
Host string `mapstructure:"host" validate:"required"`
InstanceLabel string `mapstructure:"instance_label" validate:"required"`
Username string `mapstructure:"username" validate:"required_without=SessionID"`
Password string `mapstructure:"password"`
SessionID string `mapstructure:"session_id"`
Host string `json:"host" yaml:"host" mapstructure:"host" validate:"required"`
InstanceLabel string `json:"instance_label" yaml:"instance_label" mapstructure:"instance_label" validate:"required"`
Username string `json:"username" yaml:"username" mapstructure:"username" validate:"required_without=SessionID"`
Password string `json:"password" yaml:"password" mapstructure:"password"`
SessionID string `json:"session_id" yaml:"session_id" mapstructure:"session_id"`
}

// Extractor manages the extraction of data
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var defaultCollections = []string{

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: "mongodb://admin:pass123@localhost:3306"`
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/mssql/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var defaultDBList = []string{

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: "sqlserver://admin:pass123@localhost:3306/"`
Expand Down
1 change: 0 additions & 1 deletion plugins/extractors/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ source:
name: mysql
config:
connection_url: admin:pass123@tcp(localhost:3306)/
identifier: my-mysql
```
## Inputs
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var defaultDBList = []string{

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: "admin:pass123@tcp(localhost:3306)/"`
Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/optimus/optimus.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var summary string

// Config holds the set of configuration for the bigquery extractor
type Config struct {
Host string `mapstructure:"host" validate:"required"`
MaxSizeInMB int `mapstructure:"max_size_in_mb"`
Host string `json:"host" yaml:"host" mapstructure:"host" validate:"required"`
MaxSizeInMB int `json:"max_size_in_mb" yaml:"max_size_in_mb" mapstructure:"max_size_in_mb"`
}

var sampleConfig = `host: optimus.com:80`
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var summary string

// Config holds the set of configuration options for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: oracle://username:passwd@localhost:1521/xe`
Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var defaultDBList = []string{"information_schema", "root", "postgres"}

// Config holds the set of configuration options for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
Exclude string `mapstructure:"exclude"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
Exclude string `json:"exclude" yaml:"exclude" mapstructure:"exclude"`
}

var sampleConfig = `
Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/presto/presto.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var summary string

// Config holds the set of configuration options for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
Exclude string `mapstructure:"exclude_catalog"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
Exclude string `json:"exclude_catalog" yaml:"exclude_catalog" mapstructure:"exclude_catalog"`
}

var sampleConfig = `
Expand Down
4 changes: 2 additions & 2 deletions plugins/extractors/redash/redash.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var summary string

// Config holds the set of configuration for the redash extractor
type Config struct {
BaseURL string `mapstructure:"base_url" validate:"required"`
ApiKey string `mapstructure:"api_key" validate:"required"`
BaseURL string `json:"base_url" yaml:"base_url" mapstructure:"base_url" validate:"required"`
ApiKey string `json:"api_key" yaml:"api_key" mapstructure:"api_key" validate:"required"`
}

var sampleConfig = `
Expand Down
10 changes: 5 additions & 5 deletions plugins/extractors/redshift/redshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var summary string

// Config holds the set of configuration for the metabase extractor
type Config struct {
ClusterID string `mapstructure:"cluster_id" validate:"required"`
DBName string `mapstructure:"db_name" validate:"required"`
DBUser string `mapstructure:"db_user" validate:"required"`
AWSRegion string `mapstructure:"aws_region" validate:"required"`
Exclude string `mapstructure:"exclude"`
ClusterID string `json:"cluster_id" yaml:"cluster_id" mapstructure:"cluster_id" validate:"required"`
DBName string `json:"db_name" yaml:"db_name" mapstructure:"db_name" validate:"required"`
DBUser string `json:"db_user" yaml:"db_user" mapstructure:"db_user" validate:"required"`
AWSRegion string `json:"aws_region" yaml:"aws_region" mapstructure:"aws_region" validate:"required"`
Exclude string `json:"exclude" yaml:"exclude" mapstructure:"exclude"`
}

var sampleConfig = `
Expand Down
2 changes: 1 addition & 1 deletion plugins/extractors/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var summary string

// Config holds the connection URL for the extractor
type Config struct {
ConnectionURL string `mapstructure:"connection_url" validate:"required"`
ConnectionURL string `json:"connection_url" yaml:"connection_url" mapstructure:"connection_url" validate:"required"`
}

var sampleConfig = `connection_url: "user:password@my_organization-my_account/mydb"`
Expand Down
8 changes: 4 additions & 4 deletions plugins/extractors/superset/superset.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ var summary string

// Config holds the set of configuration for the superset extractor
type Config struct {
Username string `mapstructure:"username" validate:"required"`
Password string `mapstructure:"password" validate:"required"`
Host string `mapstructure:"host" validate:"required"`
Provider string `mapstructure:"provider" validate:"required"`
Username string `json:"username" yaml:"username" mapstructure:"username" validate:"required"`
Password string `json:"password" yaml:"password" mapstructure:"password" validate:"required"`
Host string `json:"host" yaml:"host" mapstructure:"host" validate:"required"`
Provider string `json:"provider" yaml:"provider" mapstructure:"provider" validate:"required"`
}

var sampleConfig = `
Expand Down
1 change: 0 additions & 1 deletion plugins/extractors/tableau/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ source:
config:
host: http://server.tableau.com
version: 3.12
identifier: my-tableau
username: meteor_user
password: xxxxxxxxxx
```
Expand Down
Loading

0 comments on commit 4c18210

Please sign in to comment.