Skip to content

Commit b0f1f85

Browse files
jan.kaiferjankaifer
jan.kaifer
authored andcommitted
Feat: use separate config for s3 bucket configuration for result download from s3
1 parent 35e374b commit b0f1f85

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

go/config.go

+17
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,23 @@ func (c *Config) GetS3ResultPrefix() string {
213213
return GetFromEnvVal(s3ResultPrefixEnvKey)
214214
}
215215

216+
// SetS3OutputBucket is setter for S3 output bucket
217+
func (c *Config) SetS3OutputBucket(o string) error {
218+
if len(o) == 0 {
219+
return ErrConfigS3OutputBucket
220+
}
221+
c.values.Set("s3_output_bucket", o)
222+
return nil
223+
}
224+
225+
// GetS3OutputBucket is getter of s3 output bucket
226+
func (c *Config) GetS3OutputBucket() string {
227+
if val := c.values.Get("s3_output_bucket"); val != "" {
228+
return val
229+
}
230+
return ""
231+
}
232+
216233
// SetUser is a setter of User.
217234
func (c *Config) SetUser(o string) {
218235
c.dsn.User = url.UserPassword(o, "")

go/errors.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var (
3232
ErrConfigOutputLocation = errors.New("output location must starts with s3")
3333
ErrConfigRegion = errors.New("region is required")
3434
ErrConfigS3ResultPrefix = errors.New("S3 result prefix is required")
35+
ErrConfigS3OutputBucket = errors.New("S3 output bucket is required")
3536
ErrConfigWGPointer = errors.New("workgroup pointer is nil")
3637
ErrConfigAccessIDRequired = errors.New("AWS access ID is required")
3738
ErrConfigAccessKeyRequired = errors.New("AWS access Key is required")

go/rows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (r *Rows) DownloadResultFromS3() (*csv.Reader, error) {
109109

110110
client := s3.NewFromConfig(cfg)
111111

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

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

0 commit comments

Comments
 (0)