fix: trimmed preference name

Signed-off-by: xbaran4 <pbaran@redhat.com>
pull/117/head
xbaran4 2021-09-27 15:38:38 +02:00
parent e73266e957
commit a6059bfea5
1 changed files with 4 additions and 1 deletions

View File

@ -42,6 +42,7 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesN
public class UserPreferencesConfigurator implements NamespaceConfigurator {
private static final String USER_PREFERENCES_SECRET_NAME = "user-preferences";
private static final String USER_PREFERENCES_SECRET_MOUNT_PATH = "/config/user/preferences";
private static final int PREFERNCE_NAME_MAX_LENGTH = 253;
private final KubernetesNamespaceFactory namespaceFactory;
private final KubernetesClientFactory clientFactory;
@ -128,6 +129,8 @@ public class UserPreferencesConfigurator implements NamespaceConfigurator {
*/
@VisibleForTesting
String normalizePreferenceName(String name) {
return name.replaceAll("[^-._a-zA-Z0-9]+", "-").replaceAll("-+", "-");
return name.replaceAll("[^-._a-zA-Z0-9]+", "-")
.replaceAll("-+", "-")
.substring(0, Math.min(name.length(), PREFERNCE_NAME_MAX_LENGTH));
}
}