1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

Can't create kubernetes resources with a username longer than 63 characters (#4672)

* fix(kubernetes): truncate username when we create resource

* fix(k8s): remove forbidden characters in owner label
This commit is contained in:
Maxime Bajeux 2021-01-12 02:35:59 +01:00 committed by GitHub
parent cbd7fdc62e
commit 4cd468ce21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 6 deletions

View file

@ -10,7 +10,11 @@ class KubernetesCommonHelper {
}
static ownerToLabel(owner) {
return _.replace(owner, /[^-A-Za-z0-9_.]/g, '.');
let label = _.replace(owner, /[^-A-Za-z0-9_.]/g, '.');
label = _.truncate(label, { length: 63, omission: '' });
label = _.replace(label, /^[-_.]*/g, '');
label = _.replace(label, /[-_.]*$/g, '');
return label;
}
}
export default KubernetesCommonHelper;