mirror of https://github.com/portainer/portainer
feat/ee-1991/validate-k8s-workload (#6302)
parent
118809a9c0
commit
24893573aa
|
@ -110,7 +110,7 @@
|
||||||
ng-model="ctrl.formValues.Name"
|
ng-model="ctrl.formValues.Name"
|
||||||
ng-change="ctrl.onChangeName()"
|
ng-change="ctrl.onChangeName()"
|
||||||
placeholder="my-app"
|
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
|
auto-focus
|
||||||
required
|
required
|
||||||
ng-disabled="ctrl.state.isEdit"
|
ng-disabled="ctrl.state.isEdit"
|
||||||
|
@ -122,10 +122,8 @@
|
||||||
<div class="col-sm-12 small text-warning">
|
<div class="col-sm-12 small text-warning">
|
||||||
<div ng-messages="kubernetesApplicationCreationForm.application_name.$error">
|
<div ng-messages="kubernetesApplicationCreationForm.application_name.$error">
|
||||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
||||||
<p ng-message="pattern"
|
<p ng-message="pattern"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field must consist of lower case alphanumeric characters or '-', and contain at most 63
|
||||||
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field must consist of lower case alphanumeric characters or '-', start with an
|
characters, and must start and end with an alphanumeric character (e.g. 'my-name', or 'abc-123').</p>
|
||||||
alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123').</p
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<p ng-if="ctrl.state.alreadyExists"
|
<p ng-if="ctrl.state.alreadyExists"
|
||||||
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> An application with the same name already exists inside the selected namespace.</p
|
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> An application with the same name already exists inside the selected namespace.</p
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
class="form-control"
|
class="form-control"
|
||||||
name="configuration_name"
|
name="configuration_name"
|
||||||
ng-model="ctrl.formValues.Name"
|
ng-model="ctrl.formValues.Name"
|
||||||
ng-pattern="/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/"
|
ng-pattern="/^[a-z0-9]([a-z0-9-.]{0,61}[a-z0-9])?$/"
|
||||||
ng-change="ctrl.onChangeName()"
|
ng-change="ctrl.onChangeName()"
|
||||||
placeholder="my-configuration"
|
placeholder="my-configuration"
|
||||||
auto-focus
|
auto-focus
|
||||||
|
@ -33,8 +33,8 @@
|
||||||
<div ng-messages="kubernetesConfigurationCreationForm.configuration_name.$error">
|
<div ng-messages="kubernetesConfigurationCreationForm.configuration_name.$error">
|
||||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
||||||
<p ng-message="pattern"
|
<p ng-message="pattern"
|
||||||
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field must consist of lower case alphanumeric characters, '-' or '.', and must start and end
|
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field must consist of lower case alphanumeric characters, '-' or '.', and contain at most 63
|
||||||
with an alphanumeric character.</p
|
characters, and must start and end with an alphanumeric character.</p
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<p ng-if="ctrl.state.alreadyExist"
|
<p ng-if="ctrl.state.alreadyExist"
|
||||||
|
|
|
@ -28,16 +28,16 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" ng-show="resourcePoolCreationForm.pool_name.$invalid || $ctrl.state.isAlreadyExist">
|
<div class="form-group" ng-show="resourcePoolCreationForm.pool_name.$invalid || $ctrl.state.isAlreadyExist || $ctrl.state.hasPrefixKube">
|
||||||
<div class="col-sm-12 small text-warning">
|
<div class="col-sm-12 small text-warning">
|
||||||
<div ng-messages="resourcePoolCreationForm.pool_name.$error">
|
<div ng-messages="resourcePoolCreationForm.pool_name.$error">
|
||||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
||||||
<p ng-message="pattern"
|
<p ng-message="pattern"
|
||||||
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field must consist of lower case alphanumeric characters, '-' or '.', and must start and end
|
><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field must consist of lower case alphanumeric characters or '-', and contain at most 63
|
||||||
with an alphanumeric character.</p
|
characters, and must start and end with an alphanumeric character.</p
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<p ng-if="$ctrl.state.isAlreadyExist"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> A namespace with the same name already exists.</p>
|
<p ng-if="$ctrl.state.hasPrefixKube"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Prefix "kube-" is reserved for Kubernetes system namespaces.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- #endregion -->
|
<!-- #endregion -->
|
||||||
|
|
|
@ -102,11 +102,18 @@ class KubernetesCreateResourcePoolController {
|
||||||
/* #endregion */
|
/* #endregion */
|
||||||
|
|
||||||
isCreateButtonDisabled() {
|
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() {
|
onChangeName() {
|
||||||
this.state.isAlreadyExist = _.find(this.resourcePools, (resourcePool) => resourcePool.Namespace.Name === this.formValues.Name) !== undefined;
|
this.state.isAlreadyExist = _.find(this.resourcePools, (resourcePool) => resourcePool.Namespace.Name === this.formValues.Name) !== undefined;
|
||||||
|
this.state.hasPrefixKube = /^kube-/.test(this.formValues.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
isQuotaValid() {
|
isQuotaValid() {
|
||||||
|
@ -200,6 +207,7 @@ class KubernetesCreateResourcePoolController {
|
||||||
sliderMaxCpu: 0,
|
sliderMaxCpu: 0,
|
||||||
viewReady: false,
|
viewReady: false,
|
||||||
isAlreadyExist: false,
|
isAlreadyExist: false,
|
||||||
|
hasPrefixKube: false,
|
||||||
canUseIngress: endpoint.Kubernetes.Configuration.IngressClasses.length,
|
canUseIngress: endpoint.Kubernetes.Configuration.IngressClasses.length,
|
||||||
duplicates: {
|
duplicates: {
|
||||||
ingressHosts: new KubernetesFormValidationReferences(),
|
ingressHosts: new KubernetesFormValidationReferences(),
|
||||||
|
|
Loading…
Reference in New Issue