-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
59 lines (45 loc) · 1.72 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package redshift
import (
"encoding/json"
"time"
"github.com/tidwall/sjson"
"github.com/rudderlabs/sqlconnect-go/sqlconnect/internal/postgres"
)
const RedshiftDataConfigType = "redshift-data"
// PostgresConfig is the configuration for a redshift database when using the postgres driver
type PostgresConfig = postgres.Config
// Config is the configuration for a redshift database when using the redshift data api driver
type Config struct {
ClusterIdentifier string `json:"clusterIdentifier"`
Database string `json:"database"`
User string `json:"user"`
Region string `json:"region"`
WorkgroupName string `json:"workgroupName"`
SecretsARN string `json:"secretsARN"`
SharedConfigProfile string `json:"sharedConfigProfile"`
AccessKeyID string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey"`
SessionToken string `json:"sessionToken"`
RoleARN string `json:"roleARN"`
ExternalID string `json:"externalID"`
RoleARNExpiry time.Duration `json:"roleARNExpiry"` // default: 15m
Timeout time.Duration `json:"timeout"` // default: no timeout
MinPolling time.Duration `json:"minPolling"` // default: 10ms
MaxPolling time.Duration `json:"maxPolling"` // default: 5s
RetryMaxAttempts int `json:"retryMaxAttempts"` // default: 20
UseLegacyMappings bool `json:"useLegacyMappings"`
}
func (c *Config) MarshalJSON() ([]byte, error) {
bytes, err := json.Marshal(*c)
if err != nil {
return nil, err
}
return sjson.SetBytes(bytes, "type", RedshiftDataConfigType)
}
func (c *Config) Parse(input json.RawMessage) error {
err := json.Unmarshal(input, c)
if err != nil {
return err
}
return nil
}