|
9 | 9 | import org.apache.logging.log4j.LogManager;
|
10 | 10 | import org.apache.logging.log4j.Logger;
|
11 | 11 | import org.apache.logging.log4j.message.ParameterizedMessage;
|
| 12 | +import org.elasticsearch.Build; |
12 | 13 | import org.elasticsearch.cluster.metadata.RepositoryMetadata;
|
13 | 14 | import org.elasticsearch.cluster.service.ClusterService;
|
14 | 15 | import org.elasticsearch.common.Strings;
|
|
37 | 38 | import java.util.function.Supplier;
|
38 | 39 |
|
39 | 40 | public class EncryptedRepositoryPlugin extends Plugin implements RepositoryPlugin {
|
| 41 | + |
| 42 | + private static final Boolean ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED; |
| 43 | + static { |
| 44 | + final String property = System.getProperty("es.encrypted_repository_feature_flag_registered"); |
| 45 | + if (Build.CURRENT.isSnapshot() && property != null) { |
| 46 | + throw new IllegalArgumentException("es.encrypted_repository_feature_flag_registered is only supported in non-snapshot builds"); |
| 47 | + } |
| 48 | + if ("true".equals(property)) { |
| 49 | + ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED = true; |
| 50 | + } else if ("false".equals(property)) { |
| 51 | + ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED = false; |
| 52 | + } else if (property == null) { |
| 53 | + ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED = null; |
| 54 | + } else { |
| 55 | + throw new IllegalArgumentException( |
| 56 | + "expected es.encrypted_repository_feature_flag_registered to be unset or [true|false] but was [" + property + "]" |
| 57 | + ); |
| 58 | + } |
| 59 | + } |
| 60 | + |
40 | 61 | static final Logger logger = LogManager.getLogger(EncryptedRepositoryPlugin.class);
|
41 | 62 | static final String REPOSITORY_TYPE_NAME = "encrypted";
|
42 | 63 | // TODO add at least hdfs, and investigate supporting all `BlobStoreRepository` implementations
|
@@ -76,6 +97,11 @@ public Map<String, Repository.Factory> getRepositories(
|
76 | 97 | }
|
77 | 98 | final Map<String, SecureString> repositoryPasswordsMap = Map.copyOf(repositoryPasswordsMapBuilder);
|
78 | 99 |
|
| 100 | + if (false == Build.CURRENT.isSnapshot() |
| 101 | + && (ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED == null || ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED == false)) { |
| 102 | + return Map.of(); |
| 103 | + } |
| 104 | + |
79 | 105 | return Collections.singletonMap(REPOSITORY_TYPE_NAME, new Repository.Factory() {
|
80 | 106 |
|
81 | 107 | @Override
|
|
0 commit comments