mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
Co-authored-by: enisdenjo <badurinadenis@gmail.com> Co-authored-by: Denis Badurina <denis@domonda.com>
58 lines
3.3 KiB
Diff
58 lines
3.3 KiB
Diff
diff --git a/dist/run/bootstrap/getParsedComposeFile.js b/dist/run/bootstrap/getParsedComposeFile.js
|
|
index 9734743..ae3c5c8 100644
|
|
--- a/dist/run/bootstrap/getParsedComposeFile.js
|
|
+++ b/dist/run/bootstrap/getParsedComposeFile.js
|
|
@@ -18,6 +18,22 @@ const PortBinding = io.type({
|
|
published: io.number,
|
|
target: io.number,
|
|
});
|
|
+const PortBindingComposeObject = io.type({
|
|
+ published: io.union([io.number, io.string]),
|
|
+ target: io.number,
|
|
+ })
|
|
+ const PortBindingFromComposeObject = new io.Type(
|
|
+ 'PortBindingFromComposeObject',
|
|
+ PortBinding.is,
|
|
+ (input, context) =>
|
|
+ Either.either.chain(PortBindingComposeObject.validate(input, context), ports =>
|
|
+ io.success({
|
|
+ ...ports,
|
|
+ published: io.string.is(ports.published) ? parseInt(ports.published) : ports.published,
|
|
+ }),
|
|
+ ),
|
|
+ function_1.identity,
|
|
+ )
|
|
const PortBindingFromString = new io.Type('PortBindingFromComposeString', PortBinding.is, (input, context) => {
|
|
const match = input.match(/(\d*):(\d*)\/\w*/);
|
|
return match
|
|
@@ -27,7 +43,7 @@ const PortBindingFromString = new io.Type('PortBindingFromComposeString', PortBi
|
|
})
|
|
: io.failure(input, context, 'String did not match expected format.');
|
|
}, function_1.identity);
|
|
-const PortBindingFromComposeFile = new io.Type('PortBindingFromComposeFile', PortBinding.is, (input, context) => function_1.pipe(io.string.is(input) ? PortBindingFromString.validate(input, context) : PortBinding.validate(input, context), Either.fold(err => io.failure(input, context, 'Could not decode the port mappings. This is most likely related to a breaking change in the docker-compose format.\n' +
|
|
+const PortBindingFromComposeFile = new io.Type('PortBindingFromComposeFile', PortBinding.is, (input, context) => function_1.pipe(io.string.is(input) ? PortBindingFromString.validate(input, context): PortBindingFromComposeObject.validate(input, context), Either.fold(err => io.failure(input, context, 'Could not decode the port mappings. This is most likely related to a breaking change in the docker-compose format.\n' +
|
|
`Received: ${JSON.stringify(input)}\n` +
|
|
err
|
|
.filter(err => err.message)
|
|
@@ -38,7 +54,6 @@ const DockerComposeService = io.partial({
|
|
ports: io.array(PortBindingFromComposeFile),
|
|
});
|
|
const ComposeFile = io.type({
|
|
- version: io.string,
|
|
services: io.record(io.string, DockerComposeService),
|
|
});
|
|
const handleDecodeError = (err) => {
|
|
@@ -49,12 +64,7 @@ const decodeComposeFile = function_1.flow(ComposeFile.decode, Either.fold(handle
|
|
const DOCKEST_COMPOSE_FILE_VERSION = '3.8';
|
|
exports.getParsedComposeFile = (mergedComposeFiles) => {
|
|
const dockerComposeFile = function_1.pipe(mergedComposeFiles, js_yaml_1.safeLoad, decodeComposeFile);
|
|
- const versionNumber = parseFloat(dockerComposeFile.version);
|
|
- if (Math.trunc(versionNumber) < 3) {
|
|
- throw new Errors_1.DockestError(`Incompatible docker-compose file version. Please use version '3.x'`);
|
|
- }
|
|
- else if (dockerComposeFile.version !== DOCKEST_COMPOSE_FILE_VERSION) {
|
|
- Logger_1.Logger.warn(`You should upgrade to docker-compose file version '${DOCKEST_COMPOSE_FILE_VERSION}'. Dockest automatically uses that version.`);
|
|
+ if (dockerComposeFile.version !== DOCKEST_COMPOSE_FILE_VERSION) {
|
|
dockerComposeFile.version = DOCKEST_COMPOSE_FILE_VERSION;
|
|
}
|
|
return {
|