mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-23 01:28:51 +00:00
Merge pull request #898 from balena-io/897-normalise-compose-ports
fix: Normalize ports from compose file on instantiation
This commit is contained in:
@ -140,10 +140,7 @@ export class PortMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static fromComposePorts(ports: string[]): PortMap[] {
|
public static fromComposePorts(ports: string[]): PortMap[] {
|
||||||
return _(ports)
|
return PortMap.normalisePortMaps(ports.map(p => new PortMap(p)));
|
||||||
.map(p => new PortMap(p))
|
|
||||||
.sortBy(p => p.ports.internalStart)
|
|
||||||
.value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private parsePortString(portStr: string): void {
|
private parsePortString(portStr: string): void {
|
||||||
|
@ -252,6 +252,15 @@ describe 'Ports', ->
|
|||||||
|
|
||||||
expect(portMapsTarget).to.deep.equal(portMapsCurrent)
|
expect(portMapsTarget).to.deep.equal(portMapsCurrent)
|
||||||
|
|
||||||
|
describe 'fromComposePorts', ->
|
||||||
|
it 'should normalise compose ports', ->
|
||||||
|
expect(PortMap.fromComposePorts([
|
||||||
|
'80:80',
|
||||||
|
'81:81',
|
||||||
|
'82:82',
|
||||||
|
])).to.deep.equal([
|
||||||
|
new PortMap('80-82')
|
||||||
|
])
|
||||||
|
|
||||||
describe 'normalisePortMaps', ->
|
describe 'normalisePortMaps', ->
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user