From 24893573aa3a0b320f9128c22cf1dbc984cdc97c Mon Sep 17 00:00:00 2001 From: sunportainer <93502624+sunportainer@users.noreply.github.com> Date: Tue, 25 Jan 2022 18:59:09 +0800 Subject: [PATCH] feat/ee-1991/validate-k8s-workload (#6302) --- .../views/applications/create/createApplication.html | 8 +++----- .../configurations/create/createConfiguration.html | 6 +++--- .../resource-pools/create/createResourcePool.html | 8 ++++---- .../create/createResourcePoolController.js | 10 +++++++++- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index 9714a5b50..fb78d8ed0 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -110,7 +110,7 @@ ng-model="ctrl.formValues.Name" ng-change="ctrl.onChangeName()" placeholder="my-app" - ng-pattern="/^[a-z]([-a-z0-9]*[a-z0-9])?$/" + ng-pattern="/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/" auto-focus required ng-disabled="ctrl.state.isEdit" @@ -122,10 +122,8 @@

This field is required.

-

This field must consist of lower case alphanumeric characters or '-', start with an - alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123').

+

This field must consist of lower case alphanumeric characters or '-', and contain at most 63 + characters, and must start and end with an alphanumeric character (e.g. 'my-name', or 'abc-123').

An application with the same name already exists inside the selected namespace.

This field is required.

This field must consist of lower case alphanumeric characters, '-' or '.', and must start and end - with an alphanumeric character.

This field must consist of lower case alphanumeric characters, '-' or '.', and contain at most 63 + characters, and must start and end with an alphanumeric character.

-

+

This field is required.

This field must consist of lower case alphanumeric characters, '-' or '.', and must start and end - with an alphanumeric character.

This field must consist of lower case alphanumeric characters or '-', and contain at most 63 + characters, and must start and end with an alphanumeric character.

-

A namespace with the same name already exists.

+

Prefix "kube-" is reserved for Kubernetes system namespaces.

diff --git a/app/kubernetes/views/resource-pools/create/createResourcePoolController.js b/app/kubernetes/views/resource-pools/create/createResourcePoolController.js index b767d09a8..f925a7daa 100644 --- a/app/kubernetes/views/resource-pools/create/createResourcePoolController.js +++ b/app/kubernetes/views/resource-pools/create/createResourcePoolController.js @@ -102,11 +102,18 @@ class KubernetesCreateResourcePoolController { /* #endregion */ isCreateButtonDisabled() { - return this.state.actionInProgress || (this.formValues.HasQuota && !this.isQuotaValid()) || this.state.isAlreadyExist || this.state.duplicates.ingressHosts.hasRefs; + return ( + this.state.actionInProgress || + (this.formValues.HasQuota && !this.isQuotaValid()) || + this.state.isAlreadyExist || + this.state.hasPrefixKube || + this.state.duplicates.ingressHosts.hasRefs + ); } onChangeName() { this.state.isAlreadyExist = _.find(this.resourcePools, (resourcePool) => resourcePool.Namespace.Name === this.formValues.Name) !== undefined; + this.state.hasPrefixKube = /^kube-/.test(this.formValues.Name); } isQuotaValid() { @@ -200,6 +207,7 @@ class KubernetesCreateResourcePoolController { sliderMaxCpu: 0, viewReady: false, isAlreadyExist: false, + hasPrefixKube: false, canUseIngress: endpoint.Kubernetes.Configuration.IngressClasses.length, duplicates: { ingressHosts: new KubernetesFormValidationReferences(),