mirror of
https://github.com/portainer/portainer.git
synced 2025-08-01 11:55:21 +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,118 @@
|
|||
import { toRequest } from './toRequest';
|
||||
|
||||
test('should handle empty portBindings', () => {
|
||||
const result = toRequest([]);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
test('should handle single port binding', () => {
|
||||
const result = toRequest([
|
||||
{
|
||||
hostPort: 80,
|
||||
protocol: 'tcp',
|
||||
containerPort: 80,
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
PublishedPort: 80,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should handle port range', () => {
|
||||
const result = toRequest([
|
||||
{
|
||||
hostPort: { start: 80, end: 82 },
|
||||
protocol: 'tcp',
|
||||
containerPort: { start: 80, end: 82 },
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
PublishedPort: 80,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
PublishedPort: 81,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 81,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
PublishedPort: 82,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 82,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should throw error for unequal port ranges', () => {
|
||||
expect(() =>
|
||||
toRequest([
|
||||
{
|
||||
hostPort: { start: 80, end: 82 },
|
||||
protocol: 'tcp',
|
||||
containerPort: { start: 80, end: 81 },
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
])
|
||||
).toThrow(
|
||||
'Invalid port specification: host port range must be equal to container port range'
|
||||
);
|
||||
});
|
||||
|
||||
test('should handle host port range with single container port', () => {
|
||||
const result = toRequest([
|
||||
{
|
||||
hostPort: { start: 80, end: 82 },
|
||||
protocol: 'tcp',
|
||||
containerPort: 80,
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
PublishedPort: 80,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
PublishedPort: 81,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
{
|
||||
PublishedPort: 82,
|
||||
Protocol: 'tcp',
|
||||
TargetPort: 80,
|
||||
PublishMode: 'ingress',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should throw error for container port range with single host port', () => {
|
||||
expect(() =>
|
||||
toRequest([
|
||||
// @ts-expect-error test invalid input
|
||||
{
|
||||
hostPort: 80,
|
||||
protocol: 'tcp',
|
||||
containerPort: { start: 80, end: 82 },
|
||||
publishMode: 'ingress',
|
||||
},
|
||||
])
|
||||
).toThrow(
|
||||
'Invalid port specification: host port must be a range when container port is a range'
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue