From 62ad2af51a419c18c3db5592bbc6ea9075291caa Mon Sep 17 00:00:00 2001 From: Luca Maltagliati Date: Tue, 27 Aug 2024 18:08:03 +0200 Subject: [PATCH 1/4] fix: max length to kubernetes names --- packages/console-types/src/strings/en.json | 2 +- packages/console-types/src/types/services.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/console-types/src/strings/en.json b/packages/console-types/src/strings/en.json index df3679d5..60406b13 100644 --- a/packages/console-types/src/strings/en.json +++ b/packages/console-types/src/strings/en.json @@ -1,7 +1,7 @@ { "endpoint.basePath.patternError": "Must start with \"/\" and can contain alphanumeric characters and the symbols \"_\", \"-\", and \".\", optionally preceded by \":\"", "configMountPath.patternError": "Can contain alphanumeric characters, parentheses, spaces and the symbols - , _ , . , | , \\ , / , ! , \" , £, $ , % , & , = , ? , ^ ,* , +, @", - "resourceName.patternError": "Must start with a lowercase character and can contain lowercase letters, numbers and the symbol \"-\". Cannot end with \"-\"", + "resourceName.patternError": "Must start with a lowercase character and can contain lowercase letters, numbers and the symbol \"-\". Cannot end with \"-\". Cannot exceed 253 characters in length.", "dockerImage.patternError": "Must respect the format host/imagename:tag, where host and tag are optional. Image name and tag can be interpolated", "configMapFileName.patternError": "Can contain alphanumeric characters and the symbols \"_\", \"-\" and \".\"", "swaggerPath.patternError": "Must start with \"/\". Can contain alphanumeric characters and the symbols \"_\", \"-\" and \".\"", diff --git a/packages/console-types/src/types/services.ts b/packages/console-types/src/types/services.ts index 55e89448..6b7f47ec 100644 --- a/packages/console-types/src/types/services.ts +++ b/packages/console-types/src/types/services.ts @@ -30,6 +30,7 @@ import { ownersSchema } from './collections' export const serviceName = { type: 'string', minLength: 1, + maxLength: 253, pattern: '^[a-z]([-a-z0-9]*[a-z0-9])?$', [VALIDATION_ERROR_ID]: 'resourceName.patternError', } as const @@ -63,6 +64,8 @@ export const swaggerPath = { export const serviceSecretName = { type: 'string', + minLength: 1, + maxLength: 253, pattern: '^[a-z][a-z0-9]*(-[a-z0-9]+)*$', [VALIDATION_ERROR_ID]: 'resourceName.patternError', } as const @@ -75,6 +78,8 @@ export const serviceSecretKey = { export const configMapName = { type: 'string', + minLength: 1, + maxLength: 253, pattern: '^[a-z][a-z0-9]*(-[a-z0-9]+)*$', [VALIDATION_ERROR_ID]: 'resourceName.patternError', } as const From 052aa473b13a6243f4985cca1202397283f4e8b5 Mon Sep 17 00:00:00 2001 From: Luca Maltagliati Date: Tue, 27 Aug 2024 18:09:09 +0200 Subject: [PATCH 2/4] i18n --- packages/console-types/src/strings/en.json | 2 +- packages/console-types/src/strings/it.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/console-types/src/strings/en.json b/packages/console-types/src/strings/en.json index 60406b13..bda8b3b5 100644 --- a/packages/console-types/src/strings/en.json +++ b/packages/console-types/src/strings/en.json @@ -1,7 +1,7 @@ { "endpoint.basePath.patternError": "Must start with \"/\" and can contain alphanumeric characters and the symbols \"_\", \"-\", and \".\", optionally preceded by \":\"", "configMountPath.patternError": "Can contain alphanumeric characters, parentheses, spaces and the symbols - , _ , . , | , \\ , / , ! , \" , £, $ , % , & , = , ? , ^ ,* , +, @", - "resourceName.patternError": "Must start with a lowercase character and can contain lowercase letters, numbers and the symbol \"-\". Cannot end with \"-\". Cannot exceed 253 characters in length.", + "resourceName.patternError": "Must start with a lowercase character and can contain lowercase letters, numbers and the symbol \"-\". Cannot end with \"-\". Cannot exceed 253 characters in length", "dockerImage.patternError": "Must respect the format host/imagename:tag, where host and tag are optional. Image name and tag can be interpolated", "configMapFileName.patternError": "Can contain alphanumeric characters and the symbols \"_\", \"-\" and \".\"", "swaggerPath.patternError": "Must start with \"/\". Can contain alphanumeric characters and the symbols \"_\", \"-\" and \".\"", diff --git a/packages/console-types/src/strings/it.json b/packages/console-types/src/strings/it.json index 1a274364..939c177e 100644 --- a/packages/console-types/src/strings/it.json +++ b/packages/console-types/src/strings/it.json @@ -1,7 +1,7 @@ { "endpoint.basePath.patternError": "Deve iniziare con \"/\" e può contenere caratteri alfanumerici e i simboli \"_\", \"-\" e \".\", eventualmente preceduti da \":\"", "configMountPath.patternError": "Può contenere caratteri alfanumerici, parentesi, spazi e i simboli - , _ , . , | , \\ , / , ! , \" , £, $ , % , & , = , ? , ^ ,* , +, @", - "resourceName.patternError": "Deve iniziare con una lettera minuscola e può contenere lettere minuscole, numeri e il simbolo \"-\". Non può terminare con \"-\"", + "resourceName.patternError": "Deve iniziare con una lettera minuscola e può contenere lettere minuscole, numeri e il simbolo \"-\". Non può terminare con \"-\". Non può superare i 253 caratteri di lunghezza", "dockerImage.patternError": "Deve rispettare il formato host/imagename:tag, con host e tag opzionali. I valori di imagename e tag possono essere interpolati", "configMapFileName.patternError": "Può contenere caratteri alfanumerici e i simboli \"_\", \"-\" e \".\"", "swaggerPath.patternError": "Deve iniziare con \"/\". Può contenere caratteri alfanumerici e i simboli \"_\", \"-\" e \".\"", From b860abc804b0d63ca64f9abe0f7caccdbead1982 Mon Sep 17 00:00:00 2001 From: Luca Maltagliati Date: Tue, 27 Aug 2024 18:13:13 +0200 Subject: [PATCH 3/4] snaps --- .../src/types/config.test.ts.test.cjs | 33 +++++++++++++++++++ .../src/types/endpoints.test.ts.test.cjs | 1 + 2 files changed, 34 insertions(+) diff --git a/packages/console-types/tap-snapshots/src/types/config.test.ts.test.cjs b/packages/console-types/tap-snapshots/src/types/config.test.ts.test.cjs index 8125e549..06bf3618 100644 --- a/packages/console-types/tap-snapshots/src/types/config.test.ts.test.cjs +++ b/packages/console-types/tap-snapshots/src/types/config.test.ts.test.cjs @@ -1599,6 +1599,8 @@ Object { "type": "string", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -3304,6 +3306,7 @@ Object { "type": "boolean", }, "service": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4076,6 +4079,7 @@ Object { "type": "object", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4156,6 +4160,8 @@ Object { "x-validation-error-id": "configMountPath.patternError", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -4216,6 +4222,7 @@ Object { "type": "array", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4231,6 +4238,8 @@ Object { "x-validation-error-id": "configMountPath.patternError", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -4269,6 +4278,7 @@ Object { "type": "string", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4360,6 +4370,7 @@ Object { "type": "string", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4416,6 +4427,7 @@ Object { "type": "array", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4510,6 +4522,7 @@ Object { "type": "array", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -4640,6 +4653,8 @@ Object { "x-validation-error-id": "configMountPath.patternError", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -4777,6 +4792,8 @@ Object { "x-validation-error-id": "serviceSecretKey.patternError", }, "secretName": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -4803,6 +4820,8 @@ Object { "x-validation-error-id": "configMapFileName.patternError", }, "configMapName": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -5070,6 +5089,7 @@ Object { "type": "object", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -5243,6 +5263,8 @@ Object { "x-validation-error-id": "configMountPath.patternError", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -5355,6 +5377,8 @@ Object { "x-validation-error-id": "configMountPath.patternError", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -5507,6 +5531,8 @@ Object { "x-validation-error-id": "serviceSecretKey.patternError", }, "secretName": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -5533,6 +5559,8 @@ Object { "x-validation-error-id": "configMapFileName.patternError", }, "configMapName": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -5803,6 +5831,7 @@ Object { "type": "object", }, "name": Object { + "maxLength": 253, "minLength": 1, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "type": "string", @@ -6010,6 +6039,8 @@ Object { "x-validation-error-id": "configMountPath.patternError", }, "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", @@ -6082,6 +6113,8 @@ Object { "additionalProperties": false, "properties": Object { "name": Object { + "maxLength": 253, + "minLength": 1, "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", "type": "string", "x-validation-error-id": "resourceName.patternError", diff --git a/packages/console-types/tap-snapshots/src/types/endpoints.test.ts.test.cjs b/packages/console-types/tap-snapshots/src/types/endpoints.test.ts.test.cjs index f5d41306..d383fed1 100644 --- a/packages/console-types/tap-snapshots/src/types/endpoints.test.ts.test.cjs +++ b/packages/console-types/tap-snapshots/src/types/endpoints.test.ts.test.cjs @@ -1087,6 +1087,7 @@ exports[`src/types/endpoints.test.ts TAP endpoints schema > must match snapshot "service": { "type": "string", "minLength": 1, + "maxLength": 253, "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", "x-validation-error-id": "resourceName.patternError" } From a82f1784a3999a6efda70b52333dce9837b17889 Mon Sep 17 00:00:00 2001 From: Luca Maltagliati Date: Tue, 27 Aug 2024 18:16:33 +0200 Subject: [PATCH 4/4] changeset --- .changeset/afraid-geese-tease.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/afraid-geese-tease.md diff --git a/.changeset/afraid-geese-tease.md b/.changeset/afraid-geese-tease.md new file mode 100644 index 00000000..8ad89092 --- /dev/null +++ b/.changeset/afraid-geese-tease.md @@ -0,0 +1,5 @@ +--- +"@mia-platform/console-types": patch +--- + +fix: max length to k8s resource names