fix(ingress): fixed hostname field when having multiple ingresses EE-1072 (#5273)

pull/5216/head
fhanportainer 2021-07-05 18:17:20 +12:00 committed by GitHub
parent 340805f880
commit d48f6bd02c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

View File

@ -261,7 +261,7 @@ class KubernetesApplicationConverter {
return res; return res;
} }
static applicationToFormValues(app, resourcePools, configurations, persistentVolumeClaims, nodesLabels) { static applicationToFormValues(app, resourcePools, configurations, persistentVolumeClaims, nodesLabels, ingresses) {
const res = new KubernetesApplicationFormValues(); const res = new KubernetesApplicationFormValues();
res.ApplicationType = app.ApplicationType; res.ApplicationType = app.ApplicationType;
res.ResourcePool = _.find(resourcePools, ['Namespace.Name', app.ResourcePool]); res.ResourcePool = _.find(resourcePools, ['Namespace.Name', app.ResourcePool]);
@ -278,7 +278,7 @@ class KubernetesApplicationConverter {
res.PersistedFolders = KubernetesApplicationHelper.generatePersistedFoldersFormValuesFromPersistedFolders(app.PersistedFolders, persistentVolumeClaims); // generate from PVC and app.PersistedFolders res.PersistedFolders = KubernetesApplicationHelper.generatePersistedFoldersFormValuesFromPersistedFolders(app.PersistedFolders, persistentVolumeClaims); // generate from PVC and app.PersistedFolders
res.Configurations = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(app.Env, app.ConfigurationVolumes, configurations); res.Configurations = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(app.Env, app.ConfigurationVolumes, configurations);
res.AutoScaler = KubernetesApplicationHelper.generateAutoScalerFormValueFromHorizontalPodAutoScaler(app.AutoScaler, res.ReplicaCount); res.AutoScaler = KubernetesApplicationHelper.generateAutoScalerFormValueFromHorizontalPodAutoScaler(app.AutoScaler, res.ReplicaCount);
res.PublishedPorts = KubernetesApplicationHelper.generatePublishedPortsFormValuesFromPublishedPorts(app.ServiceType, app.PublishedPorts); res.PublishedPorts = KubernetesApplicationHelper.generatePublishedPortsFormValuesFromPublishedPorts(app.ServiceType, app.PublishedPorts, ingresses);
res.Containers = app.Containers; res.Containers = app.Containers;
const isIngress = _.filter(res.PublishedPorts, (p) => p.IngressName).length; const isIngress = _.filter(res.PublishedPorts, (p) => p.IngressName).length;

View File

@ -274,7 +274,7 @@ class KubernetesApplicationHelper {
/* #endregion */ /* #endregion */
/* #region PUBLISHED PORTS FV <> PUBLISHED PORTS */ /* #region PUBLISHED PORTS FV <> PUBLISHED PORTS */
static generatePublishedPortsFormValuesFromPublishedPorts(serviceType, publishedPorts) { static generatePublishedPortsFormValuesFromPublishedPorts(serviceType, publishedPorts, ingress) {
const generatePort = (port, rule) => { const generatePort = (port, rule) => {
const res = new KubernetesApplicationPublishedPortFormValue(); const res = new KubernetesApplicationPublishedPortFormValue();
res.IsNew = false; res.IsNew = false;
@ -282,6 +282,7 @@ class KubernetesApplicationHelper {
res.IngressName = rule.IngressName; res.IngressName = rule.IngressName;
res.IngressRoute = rule.Path; res.IngressRoute = rule.Path;
res.IngressHost = rule.Host; res.IngressHost = rule.Host;
res.IngressHosts = ingress.find((i) => i.Name === rule.IngressName).Hosts;
} }
res.Protocol = port.Protocol; res.Protocol = port.Protocol;
res.ContainerPort = port.TargetPort; res.ContainerPort = port.TargetPort;

View File

@ -124,6 +124,7 @@ export function KubernetesApplicationPublishedPortFormValue() {
IngressName: undefined, IngressName: undefined,
IngressRoute: undefined, IngressRoute: undefined,
IngressHost: undefined, IngressHost: undefined,
IngressHosts: [],
}; };
} }

View File

@ -1368,7 +1368,7 @@
class="form-control" class="form-control"
name="ingress_hostname_{{ $index }}" name="ingress_hostname_{{ $index }}"
ng-model="publishedPort.IngressHost" ng-model="publishedPort.IngressHost"
ng-options="host as (host | kubernetesApplicationIngressEmptyHostname) for host in ctrl.ingressHostnames" ng-options="host as (host | kubernetesApplicationIngressEmptyHostname) for host in publishedPort.IngressHosts"
ng-change="ctrl.onChangePublishedPorts()" ng-change="ctrl.onChangePublishedPorts()"
ng-disabled="ctrl.disableLoadBalancerEdit() || ctrl.isEditAndNotNewPublishedPort($index)" ng-disabled="ctrl.disableLoadBalancerEdit() || ctrl.isEditAndNotNewPublishedPort($index)"
> >

View File

@ -321,6 +321,7 @@ class KubernetesCreateApplicationController {
const ingresses = this.filteredIngresses; const ingresses = this.filteredIngresses;
p.IngressName = ingresses && ingresses.length ? ingresses[0].Name : undefined; p.IngressName = ingresses && ingresses.length ? ingresses[0].Name : undefined;
p.IngressHost = ingresses && ingresses.length ? ingresses[0].Hosts[0] : 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) { if (this.formValues.PublishedPorts.length) {
p.Protocol = this.formValues.PublishedPorts[0].Protocol; p.Protocol = this.formValues.PublishedPorts[0].Protocol;
} }
@ -388,6 +389,7 @@ class KubernetesCreateApplicationController {
onChangePortMappingIngress(index) { onChangePortMappingIngress(index) {
const publishedPort = this.formValues.PublishedPorts[index]; const publishedPort = this.formValues.PublishedPorts[index];
const ingress = _.find(this.filteredIngresses, { Name: publishedPort.IngressName }); const ingress = _.find(this.filteredIngresses, { Name: publishedPort.IngressName });
publishedPort.IngressHosts = ingress.Hosts;
this.ingressHostnames = ingress.Hosts; this.ingressHostnames = ingress.Hosts;
publishedPort.IngressHost = this.ingressHostnames.length ? this.ingressHostnames[0] : []; publishedPort.IngressHost = this.ingressHostnames.length ? this.ingressHostnames[0] : [];
this.onChangePublishedPorts(); this.onChangePublishedPorts();
@ -972,7 +974,8 @@ class KubernetesCreateApplicationController {
this.resourcePools, this.resourcePools,
this.configurations, this.configurations,
this.persistentVolumeClaims, this.persistentVolumeClaims,
this.nodesLabels this.nodesLabels,
this.filteredIngresses
); );
this.formValues.OriginalIngresses = this.filteredIngresses; this.formValues.OriginalIngresses = this.filteredIngresses;
this.savedFormValues = angular.copy(this.formValues); this.savedFormValues = angular.copy(this.formValues);