Skip to content

Commit

Permalink
fix: label sanitation (#193)
Browse files Browse the repository at this point in the history
* fix: label sanitation

* fix: use right group

* fix: prettier formating
  • Loading branch information
DekusDenial authored Mar 28, 2024
1 parent cbf8418 commit 4b43edb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const CONTAINER_WAITING_REASON_PATH = 'status.containerStatuses.0.state.waiting.
const PR_JOBNAME_REGEX_PATTERN = /^PR-([0-9]+)(?::[\w-]+)?$/gi;
const MATCH_LABEL_REGEX_PATTERN = /(?:^[-_.]*)([\w-.]*?)(?:[-_.]*$)/g;
const DISALLOWED_LABEL_CHAR_REGEX_PATTERN = /[^\w-.]+/g;
const ALPHANUMERIC_START_END_REGEX_PATTERN = /^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g;
const TERMINATION_GRACE_PERIOD_SECONDS = 'terminationGracePeriodSeconds';
const POD_STATUSQUERY_RETRYDELAY_MS = 500;

Expand Down Expand Up @@ -72,7 +73,9 @@ function setLabels(podConfig, podLabels, config) {
..._.toString(label)
.replaceAll(DISALLOWED_LABEL_CHAR_REGEX_PATTERN, '.')
.matchAll(MATCH_LABEL_REGEX_PATTERN)
][0][1].slice(0, 63);
][0][1]
.slice(0, 63)
.replace(ALPHANUMERIC_START_END_REGEX_PATTERN, '');
};

const { buildContainerName, jobName, templateFullName, templateVersion, pipelineName, prNum, cpu, memory, disk } =
Expand Down

0 comments on commit 4b43edb

Please sign in to comment.