-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support docker compose v2 plugin version
- Loading branch information
1 parent
ce3ff7d
commit 81e72e9
Showing
19 changed files
with
1,540 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,4 +184,4 @@ module.exports = { | |
|
||
// Whether to use watchman for file crawling | ||
// watchman: true, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const mapPorts = ( | ||
ports: string | ||
): Array<{ | ||
mapped?: { address: string; port: number } | ||
exposed: { port: number; protocol: string } | ||
}> => { | ||
if (!ports) { | ||
return [] | ||
} | ||
|
||
return ports.split(',').map((untypedPort) => { | ||
const exposedFragments = untypedPort.trim().split('->') | ||
|
||
const [port, protocol] = | ||
exposedFragments.length === 1 | ||
? exposedFragments[0].split('/') | ||
: exposedFragments[1].split('/') | ||
|
||
const mapped = exposedFragments[0] | ||
const lastDoubleColon = mapped.lastIndexOf(':') | ||
|
||
if (lastDoubleColon === -1) { | ||
return { | ||
exposed: { port: Number(port), protocol } | ||
} | ||
} | ||
|
||
const address = mapped.substr(0, lastDoubleColon) | ||
const mappedPort = mapped.substr(lastDoubleColon + 1) | ||
|
||
return { | ||
exposed: { port: Number(port), protocol }, | ||
mapped: { port: Number(mappedPort), address } | ||
} | ||
}) | ||
} | ||
|
||
export default mapPorts |
Oops, something went wrong.