@@ -112,7 +112,7 @@ impl S3Fdw {
112
112
}
113
113
114
114
impl ForeignDataWrapper < S3FdwError > for S3Fdw {
115
- fn new ( options : & HashMap < String , String > ) -> S3FdwResult < Self > {
115
+ fn new ( server : ForeignServer ) -> S3FdwResult < Self > {
116
116
// cannot use create_async_runtime() as the runtime needs to be created
117
117
// for multiple threads
118
118
let rt = tokio:: runtime:: Runtime :: new ( )
@@ -128,27 +128,27 @@ impl ForeignDataWrapper<S3FdwError> for S3Fdw {
128
128
} ;
129
129
130
130
// get is_mock flag
131
- let is_mock: bool = options. get ( "is_mock" ) == Some ( & "true" . to_string ( ) ) ;
131
+ let is_mock: bool = server . options . get ( "is_mock" ) == Some ( & "true" . to_string ( ) ) ;
132
132
133
133
// get credentials
134
134
let creds = if is_mock {
135
135
// LocalStack uses hardcoded credentials
136
136
Some ( ( "test" . to_string ( ) , "test" . to_string ( ) ) )
137
137
} else {
138
- match options. get ( "vault_access_key_id" ) {
138
+ match server . options . get ( "vault_access_key_id" ) {
139
139
Some ( vault_access_key_id) => {
140
140
// if using credentials stored in Vault
141
141
let vault_secret_access_key =
142
- require_option ( "vault_secret_access_key" , options) ?;
142
+ require_option ( "vault_secret_access_key" , & server . options ) ?;
143
143
get_vault_secret ( vault_access_key_id)
144
144
. zip ( get_vault_secret ( vault_secret_access_key) )
145
145
}
146
146
None => {
147
147
// if using credentials directly specified
148
148
let aws_access_key_id =
149
- require_option ( "aws_access_key_id" , options) ?. to_string ( ) ;
149
+ require_option ( "aws_access_key_id" , & server . options ) ?. to_string ( ) ;
150
150
let aws_secret_access_key =
151
- require_option ( "aws_secret_access_key" , options) ?. to_string ( ) ;
151
+ require_option ( "aws_secret_access_key" , & server . options ) ?. to_string ( ) ;
152
152
Some ( ( aws_access_key_id, aws_secret_access_key) )
153
153
}
154
154
}
@@ -163,7 +163,8 @@ impl ForeignDataWrapper<S3FdwError> for S3Fdw {
163
163
let region = if is_mock {
164
164
default_region
165
165
} else {
166
- options
166
+ server
167
+ . options
167
168
. get ( "aws_region" )
168
169
. map ( |t| t. to_owned ( ) )
169
170
. unwrap_or ( default_region)
@@ -177,7 +178,7 @@ impl ForeignDataWrapper<S3FdwError> for S3Fdw {
177
178
let mut config_loader = aws_config:: defaults ( BehaviorVersion :: latest ( ) ) ;
178
179
179
180
// endpoint_url not supported as env var in rust https://github.com/awslabs/aws-sdk-rust/issues/932
180
- if let Some ( endpoint_url) = options. get ( "endpoint_url" ) {
181
+ if let Some ( endpoint_url) = server . options . get ( "endpoint_url" ) {
181
182
config_loader = config_loader. endpoint_url ( endpoint_url) ;
182
183
}
183
184
0 commit comments