in src/invoker.js [116:181]
async prepare() {
const action = this.action;
// this must run after initial build was kicked off in Debugger so that built files are present
// kind and image - precedence:
// 1. arguments (this.image)
// 2. action (action.exec.image)
// 3. defaults (kinds.images[kind])
const kind = this.kind || action.exec.kind;
if (kind === "blackbox") {
throw new Error("Action is of kind 'blackbox', must specify kind using `--kind` argument.");
}
this.image = this.image || action.exec.image || await this.getImageForKind(kind);
if (!this.image) {
throw new Error(`Unknown kind: ${kind}. You might want to specify --image.`);
}
// debugging instructions
this.debugKind = kinds.debugKinds[kind] || kind.split(":")[0];
try {
this.debug = require(`${__dirname}/kinds/${this.debugKind}/${this.debugKind}`);
} catch (e) {
log.warn(`Cannot find debug info for kind ${this.debugKind}:`, e.message);
this.debug = {};
}
this.debug.internalPort = this.internalPort || resolveValue(this.debug.port, this);
this.debug.port = this.port || this.internalPort || resolveValue(this.debug.port, this);
// ------------------------
this.debug.command = this.command || resolveValue(this.debug.command, this);
if (!this.debug.port) {
throw new Error(`No debug port known for kind: ${kind}. Please specify --port.`);
}
if (!this.debug.internalPort) {
throw new Error(`No debug port known for kind: ${kind}. Please specify --internal-port.`);
}
if (!this.debug.command) {
throw new Error(`No debug command known for kind: ${kind}. Please specify --command.`);
}
// limits
this.memory = (action.limits.memory || OPENWHISK_DEFAULTS.memory) * 1024 * 1024;
// source mounting
if (this.sourcePath) {
if (!this.debug.mountAction) {
log.warn(`Warning: Sorry, mounting sources not yet supported for: ${kind}.`);
this.sourcePath = undefined;
}
}
this.dockerArgsFromKind = resolveValue(this.debug.dockerArgs, this) || "";
this.dockerArgsFromUser = this.dockerArgs || "";
if (this.sourcePath && this.debug.mountAction) {
this.sourceMountAction = resolveValue(this.debug.mountAction, this);
}
}