mirror of
https://github.com/portainer/portainer.git
synced 2025-07-27 17:29:39 +02:00
feat(docker/services): show port ranges [EE-4012] (#10657)
Some checks failed
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
Some checks failed
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
This commit is contained in:
parent
4ca6292805
commit
d336a14e50
37 changed files with 1406 additions and 148 deletions
|
@ -0,0 +1,280 @@
|
|||
import { toViewModel } from './toViewModel';
|
||||
|
||||
test('basic', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 22,
|
||||
PublishedPort: 222,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 3000,
|
||||
PublishedPort: 3000,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
hostPort: 222,
|
||||
containerPort: 22,
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
hostPort: 3000,
|
||||
containerPort: 3000,
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('already combined', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishedPort: 7000,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishedPort: 7001,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishedPort: 7002,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishedPort: 7003,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishedPort: 7004,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishedPort: 7005,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
hostPort: {
|
||||
start: 7000,
|
||||
end: 7005,
|
||||
},
|
||||
containerPort: 80,
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('simple combine ports', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 74,
|
||||
PublishedPort: 81,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 75,
|
||||
PublishedPort: 82,
|
||||
},
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
hostPort: {
|
||||
start: 81,
|
||||
end: 82,
|
||||
},
|
||||
containerPort: {
|
||||
start: 74,
|
||||
end: 75,
|
||||
},
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('combine and sort', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{ Protocol: 'tcp', TargetPort: 3244, PublishedPort: 105 },
|
||||
{ Protocol: 'tcp', TargetPort: 3245, PublishedPort: 106 },
|
||||
{ Protocol: 'tcp', TargetPort: 81, PublishedPort: 81 },
|
||||
{ Protocol: 'tcp', TargetPort: 82, PublishedPort: 82 },
|
||||
{ Protocol: 'tcp', TargetPort: 83 },
|
||||
{ Protocol: 'tcp', TargetPort: 84 },
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
hostPort: { start: 81, end: 82 },
|
||||
containerPort: { start: 81, end: 82 },
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
hostPort: undefined,
|
||||
containerPort: {
|
||||
start: 83,
|
||||
end: 84,
|
||||
},
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
hostPort: { start: 105, end: 106 },
|
||||
containerPort: { start: 3244, end: 3245 },
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('empty input', () => {
|
||||
expect(toViewModel([])).toStrictEqual([]);
|
||||
});
|
||||
|
||||
test('invalid input', () => {
|
||||
expect(() =>
|
||||
toViewModel(
|
||||
// @ts-expect-error testing invalid input
|
||||
{ Name: 'invalid', Protocol: 'tcp', TargetPort: 22, PublishedPort: 222 }
|
||||
)
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
test('mixed protocols', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{ Protocol: 'tcp', TargetPort: 22, PublishedPort: 222 },
|
||||
{ Protocol: 'udp', TargetPort: 23, PublishedPort: 223 },
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
containerPort: 22,
|
||||
hostPort: 222,
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
containerPort: 23,
|
||||
hostPort: 223,
|
||||
protocol: 'udp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('non-sequential ports', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{ Protocol: 'tcp', TargetPort: 22, PublishedPort: 222 },
|
||||
{ Protocol: 'tcp', TargetPort: 24, PublishedPort: 224 },
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
containerPort: 22,
|
||||
hostPort: 222,
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
containerPort: 24,
|
||||
hostPort: 224,
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('without host', () => {
|
||||
expect(
|
||||
toViewModel([
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39003,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39010,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39007,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39008,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39000,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39001,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39002,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39004,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39005,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39006,
|
||||
},
|
||||
{
|
||||
Protocol: 'tcp',
|
||||
PublishMode: 'ingress',
|
||||
TargetPort: 39009,
|
||||
},
|
||||
])
|
||||
).toStrictEqual([
|
||||
{
|
||||
protocol: 'tcp',
|
||||
publishMode: 'ingress',
|
||||
containerPort: {
|
||||
start: 39000,
|
||||
end: 39010,
|
||||
},
|
||||
hostPort: undefined,
|
||||
},
|
||||
]);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue