Skip to content

Commit d80f0e5

Browse files
committed
app_id可不传,已包含在bucket里面
1 parent 80594d4 commit d80f0e5

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/org/elasticsearch/repositories/cos/COSClientSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class COSClientSettings {
1717
public static final Setting<String> ACCESS_KEY_SECRET = Setting
1818
.simpleString("access_key_secret", Setting.Property.NodeScope, Setting.Property.Dynamic);
1919
public static final Setting<String> APP_ID = Setting
20-
.simpleString("app_id", Setting.Property.NodeScope, Setting.Property.Dynamic);
20+
.simpleString("app_id", "", Setting.Property.NodeScope, Setting.Property.Dynamic);
2121
public static final Setting<String> BUCKET =
2222
simpleString("bucket", Setting.Property.NodeScope, Setting.Property.Dynamic);
2323
public static final Setting<String> BASE_PATH =

src/main/java/org/elasticsearch/repositories/cos/COSRepository.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ public class COSRepository extends BlobStoreRepository {
3838
this.service = cos;
3939
String bucket = getSetting(COSClientSettings.BUCKET, metadata);
4040
String basePath = getSetting(COSClientSettings.BASE_PATH, metadata);
41-
String app_id = COSRepository.getSetting(COSClientSettings.APP_ID, metadata);
41+
String app_id = COSClientSettings.APP_ID.get(metadata.settings());
4242
// qcloud-sdk-v5 app_id directly joined with bucket name
43-
// TODO: 考虑不要在让用户传appid的参数,因为现在bucket name直接就是带着appid了,考虑两个做兼容,并写deprecation log
44-
this.bucket = bucket+"-"+app_id;
43+
if (Strings.hasLength(app_id)) {
44+
this.bucket = bucket + "-" + app_id;
45+
deprecationLogger.deprecated("cos repository bucket already contain app_id, and app_id will not be supported for the cos repository in future releases");
46+
} else {
47+
this.bucket = bucket;
48+
}
4549

4650
if (Strings.hasLength(basePath)) {
4751
if (basePath.startsWith("/")) {
4852
basePath = basePath.substring(1);
49-
deprecationLogger.deprecated("cos repository base_path trimming the leading `/`, and leading `/` whill not be supported for the cos repository in future releases");
53+
deprecationLogger.deprecated("cos repository base_path trimming the leading `/`, and leading `/` will not be supported for the cos repository in future releases");
5054
}
5155
this.basePath = new BlobPath().add(basePath);
5256
} else {

0 commit comments

Comments
 (0)