Skip to content

Commit

Permalink
fix(Networking): fix unable to edit Host Aliases configuration of a w…
Browse files Browse the repository at this point in the history
…orkload pod
  • Loading branch information
ly5156 committed Jan 7, 2025
1 parent 7632c51 commit f409dba
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions shell/components/form/Networking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
data() {
const t = this.$store.getters['i18n/t'];
const hostAliases = (this.value.hostAliases || []).map((entry) => {
const tmpHostAliases = (this.value.hostAliases || []).map((entry) => {
return {
ip: entry.ip,
hostnames: entry.hostnames.join(', ')
Expand All @@ -41,12 +41,12 @@ export default {
const out = {
dnsPolicy: this.value.dnsPolicy || 'ClusterFirst',
networkMode: this.value.hostNetwork ? { label: t('workload.networking.networkMode.options.hostNetwork'), value: true } : { label: t('workload.networking.networkMode.options.normal'), value: false },
hostAliases,
nameservers,
searches,
hostname,
subdomain,
options
options,
tmpHostAliases
};
return out;
Expand Down Expand Up @@ -81,6 +81,15 @@ export default {
];
},
hostAliases() {
return (this.value.hostAliases || []).map((entry) => {
return {
ip: entry.ip,
hostnames: entry.hostnames?.join(', ') ?? ''
};
});
},
...mapGetters({ t: 'i18n/t' })
},
Expand Down Expand Up @@ -113,12 +122,12 @@ export default {
methods: {
updateHostAliases(neu) {
this.hostAliases = neu.map((entry) => {
this.tmpHostAliases = neu.map((entry) => {
const ip = entry.ip.trim();
const hostnames = entry.hostnames.trim().split(/[\s,]+/).filter((x) => !!x);
return { ip, hostnames };
}).filter((entry) => entry.ip && entry.hostnames.length);
});
this.update();
},
Expand All @@ -134,7 +143,7 @@ export default {
dnsConfig,
dnsPolicy: this.dnsPolicy,
hostname: this.hostname,
hostAliases: this.hostAliases,
hostAliases: this.tmpHostAliases,
subdomain: this.subdomain,
hostNetwork: this.networkMode.value
};
Expand Down Expand Up @@ -248,7 +257,7 @@ export default {
<div class="col span-12">
<KeyValue
key="hostAliases"
v-model:value="hostAliases"
:value="hostAliases"
:mode="mode"
:title="t('workload.networking.hostAliases.label')"
:protip="t('workload.networking.hostAliases.tip')"
Expand Down

0 comments on commit f409dba

Please sign in to comment.