Skip to content

Commit

Permalink
Feat: use separate config for s3 bucket configuration for result down…
Browse files Browse the repository at this point in the history
…load from s3
  • Loading branch information
jan.kaifer authored and jankaifer committed Oct 15, 2024
1 parent 35e374b commit b0f1f85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ func (c *Config) GetS3ResultPrefix() string {
return GetFromEnvVal(s3ResultPrefixEnvKey)
}

// SetS3OutputBucket is setter for S3 output bucket
func (c *Config) SetS3OutputBucket(o string) error {
if len(o) == 0 {
return ErrConfigS3OutputBucket
}
c.values.Set("s3_output_bucket", o)
return nil
}

// GetS3OutputBucket is getter of s3 output bucket
func (c *Config) GetS3OutputBucket() string {
if val := c.values.Get("s3_output_bucket"); val != "" {
return val
}
return ""
}

// SetUser is a setter of User.
func (c *Config) SetUser(o string) {
c.dsn.User = url.UserPassword(o, "")
Expand Down
1 change: 1 addition & 0 deletions go/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
ErrConfigOutputLocation = errors.New("output location must starts with s3")
ErrConfigRegion = errors.New("region is required")
ErrConfigS3ResultPrefix = errors.New("S3 result prefix is required")
ErrConfigS3OutputBucket = errors.New("S3 output bucket is required")
ErrConfigWGPointer = errors.New("workgroup pointer is nil")
ErrConfigAccessIDRequired = errors.New("AWS access ID is required")
ErrConfigAccessKeyRequired = errors.New("AWS access Key is required")
Expand Down
2 changes: 1 addition & 1 deletion go/rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (r *Rows) DownloadResultFromS3() (*csv.Reader, error) {

client := s3.NewFromConfig(cfg)

bucket := r.config.GetOutputBucket()
bucket := r.config.GetS3OutputBucket()
path := fmt.Sprintf("%s/%s.csv", r.config.GetS3ResultPrefix(), r.queryID)

output, err := client.GetObject(context.TODO(), &s3.GetObjectInput{
Expand Down

0 comments on commit b0f1f85

Please sign in to comment.