Skip to content

Commit

Permalink
Move more.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Sep 25, 2024
1 parent a612e9f commit bc89ef5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 59 deletions.
15 changes: 0 additions & 15 deletions lib/config/bigquery.go

This file was deleted.

20 changes: 20 additions & 0 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ func (c Config) ValidateRedshift() error {
return nil
}

func (c Config) ValidateMSSQL() error {
if c.Output != constants.MSSQL {
return fmt.Errorf("output is not mssql, output: %v", c.Output)
}

if c.MSSQL == nil {
return fmt.Errorf("mssql config is nil")
}

if empty := stringutil.Empty(c.MSSQL.Host, c.MSSQL.Username, c.MSSQL.Password, c.MSSQL.Database); empty {
return fmt.Errorf("one of mssql settings is empty (host, username, password, database)")
}

if c.MSSQL.Port <= 0 {
return fmt.Errorf("invalid mssql port: %d", c.MSSQL.Port)
}

return nil
}

// Validate will check the output source validity
// It will also check if a topic exists + iterate over each topic to make sure it's valid.
// The actual output source (like Snowflake) and CDC parser will be loaded and checked by other funcs.
Expand Down
29 changes: 28 additions & 1 deletion lib/config/snowflake.go → lib/config/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,39 @@ package config

import (
"fmt"
"net/url"

"github.com/artie-labs/transfer/lib/cryptography"
"github.com/artie-labs/transfer/lib/typing"
"github.com/snowflakedb/gosnowflake"
gosnowflake "github.com/snowflakedb/gosnowflake"
)

// DSN - returns the notation for BigQuery following this format: bigquery://projectID/[location/]datasetID?queryString
// If location is passed in, we'll specify it. Else, it'll default to empty and our library will set it to US.
func (b *BigQuery) DSN() string {
dsn := fmt.Sprintf("bigquery://%s/%s", b.ProjectID, b.DefaultDataset)

if b.Location != "" {
dsn = fmt.Sprintf("bigquery://%s/%s/%s", b.ProjectID, b.Location, b.DefaultDataset)
}

return dsn
}

func (m MSSQL) DSN() string {
query := url.Values{}
query.Add("database", m.Database)

u := &url.URL{
Scheme: "sqlserver",
User: url.UserPassword(m.Username, m.Password),
Host: fmt.Sprintf("%s:%d", m.Host, m.Port),
RawQuery: query.Encode(),
}

return u.String()
}

func (s Snowflake) ToConfig() (*gosnowflake.Config, error) {
cfg := &gosnowflake.Config{
Account: s.AccountID,
Expand Down
43 changes: 0 additions & 43 deletions lib/config/mssql.go

This file was deleted.

0 comments on commit bc89ef5

Please sign in to comment.