SOLR-14108: Handle missing verify commands or missing default params in Package Manager

This commit is contained in:
Ishan Chattopadhyaya 2019-12-19 10:38:34 +05:30
parent 7490bfd828
commit cbfa781fe3
2 changed files with 24 additions and 20 deletions

View File

@ -289,9 +289,10 @@ public class PackageManager implements Closeable {
public boolean verify(SolrPackageInstance pkg, List<String> collections) {
boolean success = true;
for (Plugin plugin: pkg.plugins) {
Command cmd = plugin.verifyCommand;
if (plugin.verifyCommand != null && !Strings.isNullOrEmpty(cmd.path)) {
for (String collection: collections) {
Map<String, String> collectionParameterOverrides = getPackageParams(pkg.name, collection);
Command cmd = plugin.verifyCommand;
Map<String, String> systemParams = Map.of("collection", collection, "package-name", pkg.name, "package-version", pkg.version);
String url = solrBaseUrl + PackageUtils.resolve(cmd.path, pkg.parameterDefaults, collectionParameterOverrides, systemParams);
@ -313,6 +314,7 @@ public class PackageManager implements Closeable {
}
}
}
}
return success;
}

View File

@ -171,9 +171,11 @@ public class PackageUtils {
// TODO: Should perhaps use Matchers etc. instead of this clumsy replaceAll().
if (str == null) return null;
if (defaults != null) {
for (String param: defaults.keySet()) {
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.containsKey(param)? overrides.get(param): defaults.get(param));
}
}
for (String param: overrides.keySet()) {
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.get(param));
}