mirror of https://github.com/portainer/portainer
fix(k8s/ns): validate ingress ctrl host pattern (#5662)
* fix(k8s/ns): validate ingress ctrl host pattern * feat(kube/ns): validate ingress hostnamepull/5782/head
parent
d14c7b0309
commit
9c279e7fae
|
@ -269,6 +269,7 @@
|
||||||
ng-model="item.Host"
|
ng-model="item.Host"
|
||||||
ng-change="$ctrl.onChangeIngressHostname()"
|
ng-change="$ctrl.onChangeIngressHostname()"
|
||||||
placeholder="foo"
|
placeholder="foo"
|
||||||
|
pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -288,6 +289,10 @@
|
||||||
>
|
>
|
||||||
<ng-messages for="resourcePoolCreationForm['hostname_' + ic.IngressClass.Name + '_' + $index].$error">
|
<ng-messages for="resourcePoolCreationForm['hostname_' + ic.IngressClass.Name + '_' + $index].$error">
|
||||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Hostname is required.</p>
|
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Hostname is required.</p>
|
||||||
|
<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 with an alphanumeric character (e.g. 'example.com').
|
||||||
|
</p>
|
||||||
</ng-messages>
|
</ng-messages>
|
||||||
<p ng-if="$ctrl.state.duplicates.ingressHosts.refs[ic.IngressClass.Name][$index] !== undefined">
|
<p ng-if="$ctrl.state.duplicates.ingressHosts.refs[ic.IngressClass.Name][$index] !== undefined">
|
||||||
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This hostname is already used.
|
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This hostname is already used.
|
||||||
|
|
|
@ -34,7 +34,7 @@ class KubernetesCreateResourcePoolController {
|
||||||
onChangeIngressHostname() {
|
onChangeIngressHostname() {
|
||||||
const state = this.state.duplicates.ingressHosts;
|
const state = this.state.duplicates.ingressHosts;
|
||||||
const hosts = _.flatMap(this.formValues.IngressClasses, 'Hosts');
|
const hosts = _.flatMap(this.formValues.IngressClasses, 'Hosts');
|
||||||
const hostnames = _.map(hosts, 'Host');
|
const hostnames = _.compact(hosts.map((h) => h.Host));
|
||||||
const hostnamesWithoutRemoved = _.filter(hostnames, (h) => !h.NeedsDeletion);
|
const hostnamesWithoutRemoved = _.filter(hostnames, (h) => !h.NeedsDeletion);
|
||||||
const allHosts = _.flatMap(this.allIngresses, 'Hosts');
|
const allHosts = _.flatMap(this.allIngresses, 'Hosts');
|
||||||
const formDuplicates = KubernetesFormValidationHelper.getDuplicates(hostnamesWithoutRemoved);
|
const formDuplicates = KubernetesFormValidationHelper.getDuplicates(hostnamesWithoutRemoved);
|
||||||
|
|
|
@ -221,6 +221,7 @@
|
||||||
ng-model="item.Host"
|
ng-model="item.Host"
|
||||||
ng-change="ctrl.onChangeIngressHostname()"
|
ng-change="ctrl.onChangeIngressHostname()"
|
||||||
placeholder="foo"
|
placeholder="foo"
|
||||||
|
pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -240,6 +241,11 @@
|
||||||
>
|
>
|
||||||
<ng-messages for="resourcePoolEditForm['hostname_' + ic.IngressClass.Name + '_' + $index].$error">
|
<ng-messages for="resourcePoolEditForm['hostname_' + ic.IngressClass.Name + '_' + $index].$error">
|
||||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Hostname is required.</p>
|
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Hostname is required.</p>
|
||||||
|
<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 with an alphanumeric character (e.g.
|
||||||
|
'example.com').
|
||||||
|
</p>
|
||||||
</ng-messages>
|
</ng-messages>
|
||||||
<p ng-if="item.Duplicate">
|
<p ng-if="item.Duplicate">
|
||||||
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
|
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
|
||||||
|
|
Loading…
Reference in New Issue