diff --git a/garden-service/src/plugins/kubernetes/actions.ts b/garden-service/src/plugins/kubernetes/actions.ts index e0b0e1e925..2db11a5cd9 100644 --- a/garden-service/src/plugins/kubernetes/actions.ts +++ b/garden-service/src/plugins/kubernetes/actions.ts @@ -121,7 +121,13 @@ export async function execInService(params: ExecInServiceParams } // exec in the pod via kubectl - const kubecmd = ["exec", "-i", pod.metadata.name, "--", ...command] + const opts: string[] = [] + + if (interactive) { + opts.push("-it") + } + + const kubecmd = ["exec", ...opts, pod.metadata.name, "--", ...command] const res = await kubectl(api.context, namespace).call(kubecmd, { ignoreError: true, timeout: 999999, @@ -185,10 +191,13 @@ export async function runModule( "--restart=Never", "--command", "--rm", - "-i", "--quiet", ] + if (interactive) { + opts.push("-it") + } + const kubecmd = [ "run", `run-${module.name}-${Math.round(new Date().getTime())}`, ...opts, diff --git a/garden-service/src/plugins/kubernetes/kubectl.ts b/garden-service/src/plugins/kubernetes/kubectl.ts index a2d39771de..682e1c8bf5 100644 --- a/garden-service/src/plugins/kubernetes/kubectl.ts +++ b/garden-service/src/plugins/kubernetes/kubectl.ts @@ -32,9 +32,9 @@ export class Kubectl { } async call(args: string[], opts: SpawnOpts = {}) { - const { data, ignoreError = false, timeout = KUBECTL_DEFAULT_TIMEOUT } = opts - const preparedArgs = this.prepareArgs(args, opts) - return spawn("kubectl", preparedArgs, { ignoreError, data, timeout }) + const { data, ignoreError = false, timeout = KUBECTL_DEFAULT_TIMEOUT, tty } = opts + const preparedArgs = this.prepareArgs(args) + return spawn("kubectl", preparedArgs, { ignoreError, data, timeout, tty }) } async json(args: string[], opts: SpawnOpts = {}): Promise { @@ -48,10 +48,10 @@ export class Kubectl { } spawn(args: string[]): ChildProcess { - return _spawn("kubectl", this.prepareArgs(args, {})) + return _spawn("kubectl", this.prepareArgs(args)) } - private prepareArgs(args: string[], { tty }: SpawnOpts) { + private prepareArgs(args: string[]) { const opts: string[] = [] if (this.namespace) { @@ -66,10 +66,6 @@ export class Kubectl { opts.push(`--kubeconfig=${this.configPath}`) } - if (tty) { - opts.push("--tty") - } - return opts.concat(args) } } diff --git a/garden-service/src/types/plugin/outputs.ts b/garden-service/src/types/plugin/outputs.ts index a30af0d7ff..968ec026b4 100644 --- a/garden-service/src/types/plugin/outputs.ts +++ b/garden-service/src/types/plugin/outputs.ts @@ -87,11 +87,14 @@ export const execInServiceResultSchema = Joi.object() .required() .description("The exit code of the command executed in the service container."), output: Joi.string() + .allow("") .required() .description("The output of the executed command."), stdout: Joi.string() + .allow("") .description("The stdout output of the executed command (if available)."), stderr: Joi.string() + .allow("") .description("The stderr output of the executed command (if available)."), })