mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 13:25:26 +02:00
fix(k8s/ingress): ensure new ports are only added to ingress only if app is published via ingress (#6153)
* fix(k8s/ingress): ensure new ports are only added to ingress only if app is published via ingress * refactor(k8s/ingress): removed deleted ports of ingress in a single pass
This commit is contained in:
parent
69c17986d9
commit
b6fbf8eecc
6 changed files with 53 additions and 32 deletions
|
@ -1246,7 +1246,13 @@
|
|||
Enable publishing for this application
|
||||
</label>
|
||||
<label class="switch" style="margin-left: 20px;">
|
||||
<input type="checkbox" class="form-control" name="enable_port_publishing" ng-model="ctrl.formValues.IsPublishingService" />
|
||||
<input
|
||||
type="checkbox"
|
||||
class="form-control"
|
||||
name="enable_port_publishing"
|
||||
ng-model="ctrl.formValues.IsPublishingService"
|
||||
ng-change="ctrl.onServicePublishChange()"
|
||||
/>
|
||||
<i></i>
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
@ -144,8 +144,6 @@ class KubernetesCreateApplicationController {
|
|||
this.setPullImageValidity = this.setPullImageValidity.bind(this);
|
||||
this.onChangeFileContent = this.onChangeFileContent.bind(this);
|
||||
this.onServicePublishChange = this.onServicePublishChange.bind(this);
|
||||
|
||||
this.$scope.$watch(() => this.formValues.IsPublishingService, this.onServicePublishChange);
|
||||
}
|
||||
/* #endregion */
|
||||
|
||||
|
@ -426,34 +424,31 @@ class KubernetesCreateApplicationController {
|
|||
|
||||
/* #endregion */
|
||||
|
||||
/* #region PUBLISHED PORTS UI MANAGEMENT */
|
||||
onServicePublishChange() {
|
||||
// service creation
|
||||
if (this.formValues.PublishedPorts.length === 0) {
|
||||
if (this.formValues.IsPublishingService) {
|
||||
// toggle enabled
|
||||
this.addPublishedPort();
|
||||
}
|
||||
// enable publishing with no previous ports exposed
|
||||
if (this.formValues.IsPublishingService && !this.formValues.PublishedPorts.length) {
|
||||
this.addPublishedPort();
|
||||
return;
|
||||
}
|
||||
|
||||
// service update
|
||||
if (this.formValues.IsPublishingService) {
|
||||
// toggle enabled
|
||||
this.formValues.PublishedPorts.forEach((port) => (port.NeedsDeletion = false));
|
||||
} else {
|
||||
// toggle disabled
|
||||
// all new ports need to be deleted, existing ports need to be marked as needing deletion
|
||||
// delete new ports, mark old ports to be deleted
|
||||
this.formValues.PublishedPorts = this.formValues.PublishedPorts.filter((port) => !port.IsNew).map((port) => ({ ...port, NeedsDeletion: true }));
|
||||
}
|
||||
}
|
||||
|
||||
/* #region PUBLISHED PORTS UI MANAGEMENT */
|
||||
addPublishedPort() {
|
||||
const p = new KubernetesApplicationPublishedPortFormValue();
|
||||
const ingresses = this.ingresses;
|
||||
p.IngressName = ingresses && ingresses.length ? ingresses[0].Name : undefined;
|
||||
p.IngressHost = ingresses && ingresses.length ? ingresses[0].Hosts[0] : undefined;
|
||||
p.IngressHosts = ingresses && ingresses.length ? ingresses[0].Hosts : undefined;
|
||||
if (this.formValues.PublishingType === KubernetesApplicationPublishingTypes.INGRESS) {
|
||||
p.IngressName = ingresses && ingresses.length ? ingresses[0].Name : undefined;
|
||||
p.IngressHost = ingresses && ingresses.length ? ingresses[0].Hosts[0] : undefined;
|
||||
p.IngressHosts = ingresses && ingresses.length ? ingresses[0].Hosts : undefined;
|
||||
}
|
||||
if (this.formValues.PublishedPorts.length) {
|
||||
p.Protocol = this.formValues.PublishedPorts[0].Protocol;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue