better host-process support
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
a7d5b53fd3
commit
82961ac36f
|
|
@ -10,7 +10,7 @@ require("../src/utils/polyfills");
|
|||
const yaml = require("js-yaml");
|
||||
const fs = require("fs");
|
||||
const { grpc } = require("../src/utils/grpc");
|
||||
const { stringify } = require("../src/utils/general");
|
||||
const { stringify, stripWindowsDriveLetter } = require("../src/utils/general");
|
||||
|
||||
let options;
|
||||
const args = require("yargs")
|
||||
|
|
@ -21,6 +21,15 @@ const args = require("yargs")
|
|||
describe: "provide a path to driver config file",
|
||||
config: true,
|
||||
configParser: (path) => {
|
||||
// normalize path for host-process containers
|
||||
// CONTAINER_SANDBOX_MOUNT_POINT C:\C\0eac9a8da76f6d7119c5d9f86c8b3106d67dbbf01dbeb22fdc0192476b7e31cb\
|
||||
// path is injected as C:\config\driver-config-file.yaml
|
||||
if (process.env.CONTAINER_SANDBOX_MOUNT_POINT) {
|
||||
path = `${
|
||||
process.env.CONTAINER_SANDBOX_MOUNT_POINT
|
||||
}${stripWindowsDriveLetter(path)}`;
|
||||
}
|
||||
|
||||
try {
|
||||
options = JSON.parse(fs.readFileSync(path, "utf-8"));
|
||||
return true;
|
||||
|
|
@ -31,29 +40,6 @@ const args = require("yargs")
|
|||
return true;
|
||||
} catch (e) {}
|
||||
|
||||
// CONTAINER_SANDBOX_MOUNT_POINT C:\C\0eac9a8da76f6d7119c5d9f86c8b3106d67dbbf01dbeb22fdc0192476b7e31cb\
|
||||
if (process.env.CONTAINER_SANDBOX_MOUNTPOINT) {
|
||||
try {
|
||||
options = JSON.parse(
|
||||
fs.readFileSync(
|
||||
`${process.env.CONTAINER_SANDBOX_MOUNTPOINT}${path}`,
|
||||
"utf-8"
|
||||
)
|
||||
);
|
||||
return true;
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
options = yaml.load(
|
||||
fs.readFileSync(
|
||||
`${process.env.CONTAINER_SANDBOX_MOUNTPOINT}${path}`,
|
||||
"utf8"
|
||||
)
|
||||
);
|
||||
return true;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
throw new Error("failed parsing config file: " + path);
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ function getLargestNumber() {
|
|||
return number;
|
||||
}
|
||||
|
||||
function stripWindowsDriveLetter(path) {
|
||||
return path.replace(/^[a-zA-Z]:/, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* transition function to replicate `request` style requests using axios
|
||||
*
|
||||
|
|
@ -248,6 +252,7 @@ module.exports.crc16 = crc16;
|
|||
module.exports.lockKeysFromRequest = lockKeysFromRequest;
|
||||
module.exports.getLargestNumber = getLargestNumber;
|
||||
module.exports.stringify = stringify;
|
||||
module.exports.stripWindowsDriveLetter = stripWindowsDriveLetter;
|
||||
module.exports.axios_request = axios_request;
|
||||
module.exports.default_supported_block_filesystems =
|
||||
default_supported_block_filesystems;
|
||||
|
|
|
|||
Loading…
Reference in New Issue