fix build with latest core changes
`Terminal.println(..)` doesn't support varargs arguments anymore Original commit: elastic/x-pack-elasticsearch@533a4f7919
This commit is contained in:
parent
e039ef412f
commit
ffab6da42d
|
@ -160,7 +160,7 @@ public class ESUsersTool extends CliTool {
|
||||||
Path file = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
Path file = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
||||||
Map<String, char[]> users = new HashMap<>(FileUserPasswdStore.parseFile(file, null));
|
Map<String, char[]> users = new HashMap<>(FileUserPasswdStore.parseFile(file, null));
|
||||||
if (users.containsKey(username)) {
|
if (users.containsKey(username)) {
|
||||||
terminal.println("User [%s] already exists", username);
|
terminal.println(String.format("User [%s] already exists", username));
|
||||||
return ExitStatus.CODE_ERROR;
|
return ExitStatus.CODE_ERROR;
|
||||||
}
|
}
|
||||||
Hasher hasher = Hasher.BCRYPT;
|
Hasher hasher = Hasher.BCRYPT;
|
||||||
|
@ -228,7 +228,7 @@ public class ESUsersTool extends CliTool {
|
||||||
Path file = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
Path file = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
||||||
Map<String, char[]> users = new HashMap<>(FileUserPasswdStore.parseFile(file, null));
|
Map<String, char[]> users = new HashMap<>(FileUserPasswdStore.parseFile(file, null));
|
||||||
if (!users.containsKey(username)) {
|
if (!users.containsKey(username)) {
|
||||||
terminal.println("User [%s] doesn't exist", username);
|
terminal.println(String.format("User [%s] doesn't exist", username));
|
||||||
return ExitStatus.NO_USER;
|
return ExitStatus.NO_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ public class ESUsersTool extends CliTool {
|
||||||
Path file = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
Path file = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
||||||
Map<String, char[]> users = new HashMap<>(FileUserPasswdStore.parseFile(file, null));
|
Map<String, char[]> users = new HashMap<>(FileUserPasswdStore.parseFile(file, null));
|
||||||
if (!users.containsKey(username)) {
|
if (!users.containsKey(username)) {
|
||||||
terminal.println("User [%s] doesn't exist", username);
|
terminal.println(String.format("User [%s] doesn't exist", username));
|
||||||
return ExitStatus.NO_USER;
|
return ExitStatus.NO_USER;
|
||||||
}
|
}
|
||||||
Hasher hasher = Hasher.BCRYPT;
|
Hasher hasher = Hasher.BCRYPT;
|
||||||
|
@ -378,7 +378,7 @@ public class ESUsersTool extends CliTool {
|
||||||
String[] allRoles = ArrayUtils.concat(addRoles, removeRoles, String.class);
|
String[] allRoles = ArrayUtils.concat(addRoles, removeRoles, String.class);
|
||||||
for (String role : allRoles) {
|
for (String role : allRoles) {
|
||||||
if (!ROLE_PATTERN.matcher(role).matches()) {
|
if (!ROLE_PATTERN.matcher(role).matches()) {
|
||||||
terminal.println("Role name [%s] is not valid. Please use lowercase and numbers only", role);
|
terminal.println(String.format("Role name [%s] is not valid. Please use lowercase and numbers only", role));
|
||||||
return ExitStatus.DATA_ERROR;
|
return ExitStatus.DATA_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ public class ESUsersTool extends CliTool {
|
||||||
Path path = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
Path path = FileUserPasswdStore.resolveFile(esusersSettings, env);
|
||||||
Map<String, char[]> usersMap = FileUserPasswdStore.parseFile(path, null);
|
Map<String, char[]> usersMap = FileUserPasswdStore.parseFile(path, null);
|
||||||
if (!usersMap.containsKey(username)) {
|
if (!usersMap.containsKey(username)) {
|
||||||
terminal.println("User [%s] doesn't exist", username);
|
terminal.println(String.format("User [%s] doesn't exist", username));
|
||||||
return ExitStatus.NO_USER;
|
return ExitStatus.NO_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ public class ESUsersTool extends CliTool {
|
||||||
|
|
||||||
if (username != null) {
|
if (username != null) {
|
||||||
if (!users.contains(username)) {
|
if (!users.contains(username)) {
|
||||||
terminal.println("User [%s] doesn't exist", username);
|
terminal.println(String.format("User [%s] doesn't exist", username));
|
||||||
return ExitStatus.NO_USER;
|
return ExitStatus.NO_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,15 +459,15 @@ public class ESUsersTool extends CliTool {
|
||||||
String[] roles = userRoles.get(username);
|
String[] roles = userRoles.get(username);
|
||||||
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
||||||
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
||||||
terminal.println("%-15s: %s", username, Arrays.stream(markedRoles).map(s -> s == null ? "-" : s).collect(Collectors.joining(",")));
|
terminal.println(String.format("%-15s: %s", username, Arrays.stream(markedRoles).map(s -> s == null ? "-" : s).collect(Collectors.joining(","))));
|
||||||
if (!unknownRoles.isEmpty()) {
|
if (!unknownRoles.isEmpty()) {
|
||||||
// at least one role is marked... so printing the legend
|
// at least one role is marked... so printing the legend
|
||||||
Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath();
|
Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath();
|
||||||
terminal.println();
|
terminal.println();
|
||||||
terminal.println(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath());
|
terminal.println(String.format(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
terminal.println("%-15s: -", username);
|
terminal.println(String.format("%-15s: -", username));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean unknownRolesFound = false;
|
boolean unknownRolesFound = false;
|
||||||
|
@ -476,7 +476,7 @@ public class ESUsersTool extends CliTool {
|
||||||
String[] roles = entry.getValue();
|
String[] roles = entry.getValue();
|
||||||
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
||||||
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
||||||
terminal.println("%-15s: %s", entry.getKey(), String.join(",", markedRoles));
|
terminal.println(String.format("%-15s: %s", entry.getKey(), String.join(",", markedRoles)));
|
||||||
unknownRolesFound = unknownRolesFound || !unknownRoles.isEmpty();
|
unknownRolesFound = unknownRolesFound || !unknownRoles.isEmpty();
|
||||||
usersExist = true;
|
usersExist = true;
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ public class ESUsersTool extends CliTool {
|
||||||
Set<String> usersWithoutRoles = Sets.newHashSet(users);
|
Set<String> usersWithoutRoles = Sets.newHashSet(users);
|
||||||
usersWithoutRoles.removeAll(userRoles.keySet());
|
usersWithoutRoles.removeAll(userRoles.keySet());
|
||||||
for (String user : usersWithoutRoles) {
|
for (String user : usersWithoutRoles) {
|
||||||
terminal.println("%-15s: -", user);
|
terminal.println(String.format("%-15s: -", user));
|
||||||
usersExist = true;
|
usersExist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ public class ESUsersTool extends CliTool {
|
||||||
// at least one role is marked... so printing the legend
|
// at least one role is marked... so printing the legend
|
||||||
Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath();
|
Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath();
|
||||||
terminal.println();
|
terminal.println();
|
||||||
terminal.println(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath());
|
terminal.println(String.format(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ public class ESUsersTool extends CliTool {
|
||||||
return FileRolesStore.parseFileForRoleNames(rolesFile, null);
|
return FileRolesStore.parseFileForRoleNames(rolesFile, null);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// if for some reason, parsing fails (malformatted perhaps) we just warn
|
// if for some reason, parsing fails (malformatted perhaps) we just warn
|
||||||
terminal.println("Warning: Could not parse [%s] for roles verification. Please revise and fix it. Nonetheless, the user will still be associated with all specified roles", rolesFile.toAbsolutePath());
|
terminal.println(String.format("Warning: Could not parse [%s] for roles verification. Please revise and fix it. Nonetheless, the user will still be associated with all specified roles", rolesFile.toAbsolutePath()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -536,9 +536,9 @@ public class ESUsersTool extends CliTool {
|
||||||
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
||||||
if (!unknownRoles.isEmpty()) {
|
if (!unknownRoles.isEmpty()) {
|
||||||
Path rolesFile = FileRolesStore.resolveFile(settings, env);
|
Path rolesFile = FileRolesStore.resolveFile(settings, env);
|
||||||
terminal.println("Warning: The following roles [%s] are unknown. Make sure to add them to the [%s] file. " +
|
terminal.println(String.format("Warning: The following roles [%s] are unknown. Make sure to add them to the [%s] file. " +
|
||||||
"Nonetheless the user will still be associated with all specified roles",
|
"Nonetheless the user will still be associated with all specified roles",
|
||||||
Strings.collectionToCommaDelimitedString(unknownRoles), rolesFile.toAbsolutePath());
|
Strings.collectionToCommaDelimitedString(unknownRoles), rolesFile.toAbsolutePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,10 @@ public class SystemKeyTool extends CliTool {
|
||||||
}
|
}
|
||||||
terminal.println(Terminal.Verbosity.VERBOSE, "generating...");
|
terminal.println(Terminal.Verbosity.VERBOSE, "generating...");
|
||||||
byte[] key = InternalCryptoService.generateKey();
|
byte[] key = InternalCryptoService.generateKey();
|
||||||
terminal.println("Storing generated key in [%s]...", path.toAbsolutePath());
|
terminal.println(String.format("Storing generated key in [%s]...", path.toAbsolutePath()));
|
||||||
Files.write(path, key, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
Files.write(path, key, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
terminal.printError("Cannot generate and save system key file [%s]", path.toAbsolutePath());
|
terminal.printError(String.format("Cannot generate and save system key file [%s]", path.toAbsolutePath()));
|
||||||
return ExitStatus.IO_ERROR;
|
return ExitStatus.IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class SystemKeyTool extends CliTool {
|
||||||
try {
|
try {
|
||||||
Files.setPosixFilePermissions(path, PERMISSION_OWNER_READ_WRITE);
|
Files.setPosixFilePermissions(path, PERMISSION_OWNER_READ_WRITE);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
terminal.printError("Cannot set owner read/write permissions to generated system key file [%s]", path.toAbsolutePath());
|
terminal.printError(String.format("Cannot set owner read/write permissions to generated system key file [%s]", path.toAbsolutePath()));
|
||||||
return ExitStatus.IO_ERROR;
|
return ExitStatus.IO_ERROR;
|
||||||
}
|
}
|
||||||
terminal.println("Ensure the generated key can be read by the user that Elasticsearch runs as, permissions are set to owner read/write only");
|
terminal.println("Ensure the generated key can be read by the user that Elasticsearch runs as, permissions are set to owner read/write only");
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class ManualPublicSmtpServersTester {
|
||||||
|
|
||||||
EmailService.EmailSent sent = service.send(email, null, profile);
|
EmailService.EmailSent sent = service.send(email, null, profile);
|
||||||
|
|
||||||
terminal.println("email sent via account [%s]", sent.account());
|
terminal.println(String.format("email sent via account [%s]", sent.account()));
|
||||||
} finally {
|
} finally {
|
||||||
service.stop();
|
service.stop();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue