mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 14:29:40 +02:00
feat(docker/containers): migrate network tab to react [EE-5210] (#10344)
This commit is contained in:
parent
e92f067e42
commit
2b47b84e5e
13 changed files with 413 additions and 246 deletions
|
@ -0,0 +1,42 @@
|
|||
import { CreateContainerRequest } from '../types';
|
||||
|
||||
import { CONTAINER_MODE, Values } from './types';
|
||||
|
||||
export function toRequest(
|
||||
oldConfig: CreateContainerRequest,
|
||||
values: Values,
|
||||
fromContainerId: string
|
||||
): CreateContainerRequest {
|
||||
let mode = values.networkMode;
|
||||
let hostName = values.hostname;
|
||||
if (mode === CONTAINER_MODE && values.container) {
|
||||
mode += `:${values.container}`;
|
||||
hostName = '';
|
||||
}
|
||||
|
||||
return {
|
||||
...oldConfig,
|
||||
Hostname: hostName,
|
||||
MacAddress: values.macAddress,
|
||||
HostConfig: {
|
||||
...oldConfig.HostConfig,
|
||||
NetworkMode: mode,
|
||||
Dns: [values.primaryDns, values.secondaryDns].filter((d) => d),
|
||||
ExtraHosts: values.hostsFileEntries,
|
||||
},
|
||||
NetworkingConfig: {
|
||||
...oldConfig.NetworkingConfig,
|
||||
EndpointsConfig: {
|
||||
[mode]: {
|
||||
IPAMConfig: {
|
||||
IPv4Address: values.ipv4Address,
|
||||
IPv6Address: values.ipv6Address,
|
||||
},
|
||||
Aliases: oldConfig.NetworkingConfig.EndpointsConfig?.[
|
||||
mode
|
||||
]?.Aliases?.filter((al) => !fromContainerId.startsWith(al)),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue