Skip to content

Commit 2149bf0

Browse files
committed
backward compatibility
1 parent f413681 commit 2149bf0

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,62 @@
2525
- **tmp_path**: temporary file directory. If null, it is associated with the default FileSystem. (string, default: null)
2626
- **tmp_path_prefix**: prefix of temporary files (string, default: 'embulk-output-s3-')
2727
- **canned_acl**: canned access control list for created objects ([enum](#cannedaccesscontrollist), default: null)
28-
- **proxy_host**: proxy host to use when accessing AWS S3 via proxy. (string, default: null )
29-
- **proxy_port**: proxy port to use when accessing AWS S3 via proxy. (string, default: null )
28+
- [Deprecated] **proxy_host**: proxy host to use when accessing AWS S3 via proxy. (string, default: null )
29+
- [Deprecated] **proxy_port**: proxy port to use when accessing AWS S3 via proxy. (string, default: null )
30+
- **http_proxy** http proxy configuration to use when accessing AWS S3 via http proxy. (optional)
31+
- **host** proxy host (string, required)
32+
- **port** proxy port (int, optional)
33+
- **https** use https or not (boolean, default true)
34+
- **user** proxy user (string, optional)
35+
- **password** proxy password (string, optional)
36+
37+
- **auth_method**: name of mechanism to authenticate requests (basic, env, instance, profile, properties, anonymous, or session. default: basic)
38+
39+
- "basic": uses access_key_id and secret_access_key to authenticate.
40+
41+
- **access_key_id**: AWS access key ID (string, required)
42+
43+
- **secret_access_key**: AWS secret access key (string, required)
44+
45+
- "env": uses AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY) environment variables.
46+
47+
- "instance": uses EC2 instance profile.
48+
49+
- "profile": uses credentials written in a file. Format of the file is as following, where `[...]` is a name of profile.
50+
51+
- **profile_file**: path to a profiles file. (string, default: given by AWS_CREDENTIAL_PROFILES_FILE environment varialbe, or ~/.aws/credentials).
52+
53+
- **profile_name**: name of a profile. (string, default: `"default"`)
54+
55+
```
56+
[default]
57+
aws_access_key_id=YOUR_ACCESS_KEY_ID
58+
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
59+
60+
[profile2]
61+
...
62+
```
63+
64+
- "properties": uses aws.accessKeyId and aws.secretKey Java system properties.
65+
66+
- "anonymous": uses anonymous access. This auth method can access only public files.
67+
68+
- "session": uses temporary-generated access_key_id, secret_access_key and session_token.
69+
70+
- **access_key_id**: AWS access key ID (string, required)
71+
72+
- **secret_access_key**: AWS secret access key (string, required)
73+
74+
- **session_token**: session token (string, required)
75+
76+
- "default": uses AWS SDK's default strategy to look up available credentials from runtime environment. This method behaves like the combination of the following methods.
77+
78+
1. "env"
79+
1. "properties"
80+
1. "profile"
81+
1. "instance"
82+
83+
3084
3185
### CannedAccessControlList
3286
you can choose one of the below list.

src/main/java/org/embulk/output/s3/HttpProxy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public interface HttpProxy
1818
{
1919
@Config("host")
2020
String getHost();
21+
void setHost(String host);
2122

2223
@Config("port")
2324
@ConfigDefault("null")
2425
Optional<Integer> getPort();
26+
void setPort(Optional<Integer> host);
2527

2628
@Config("https")
2729
@ConfigDefault("true")

src/main/java/org/embulk/output/s3/S3FileOutputPlugin.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,41 @@ private ClientConfiguration getClientConfiguration(PluginTask task)
191191
clientConfig.setMaxConnections(50); // SDK default: 50
192192
clientConfig.setSocketTimeout(8 * 60 * 1000); // SDK default: 50*1000
193193
clientConfig.setRetryPolicy(PredefinedRetryPolicies.NO_RETRY_POLICY);
194+
194195
// set http proxy
196+
// backward compatibility
197+
if (task.getProxyHost().isPresent() || task.getProxyPort().isPresent()){
198+
if (!task.getHttpProxy().isPresent()){
199+
TaskMapper taskMapper = CONFIG_MAPPER_FACTORY.createTaskMapper();
200+
HttpProxy httpProxy = taskMapper.map(CONFIG_MAPPER_FACTORY.newTaskSource(), HttpProxy.class);
201+
task.setHttpProxy(Optional.of(httpProxy));
202+
}
203+
}
204+
205+
if (task.getProxyHost().isPresent()){
206+
HttpProxy httpProxy = task.getHttpProxy().get();
207+
if (httpProxy.getHost().isEmpty()){
208+
httpProxy.setHost(task.getProxyHost().get());
209+
task.setHttpProxy(Optional.of(httpProxy));
210+
}
211+
}
212+
213+
if (task.getProxyPort().isPresent()){
214+
HttpProxy httpProxy = task.getHttpProxy().get();
215+
if (!httpProxy.getPort().isPresent()){
216+
httpProxy.setPort(task.getProxyPort());
217+
task.setHttpProxy(Optional.of(httpProxy));
218+
}
219+
}
220+
195221
if (task.getHttpProxy().isPresent()) {
196222
setHttpProxyInAwsClient(clientConfig, task.getHttpProxy().get());
197223
}
198224

199225
return clientConfig;
200226
}
201227

228+
202229
private void setHttpProxyInAwsClient(ClientConfiguration clientConfig, HttpProxy httpProxy)
203230
{
204231
// host

0 commit comments

Comments
 (0)