Skip to content

Commit

Permalink
fix(compose): fix arg handling for Runs/Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thsig committed Jul 11, 2023
1 parent 35c7a23 commit 3209af8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions plugins/docker-compose/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import chalk from "chalk"
import AsyncLock from "async-lock"
import { sdk } from "@garden-io/sdk"
import { DockerComposeDeploySpec, DockerComposeProjectSpec } from "./schemas"
Expand Down Expand Up @@ -73,6 +74,7 @@ export async function runToolWithArgs(tool: PluginTool, params: ExecParams) {
state = "ready"
} catch (err) {
state = "failed"
params.log.error(chalk.red(err.message))
success = false
}

Expand Down
17 changes: 11 additions & 6 deletions plugins/docker-compose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ composeExecTest.addHandler("run", makeComposeExecHandler())
function getRunOpts(spec: sdk.types.infer<typeof dockerComposeRunSchemaBase>) {
const opts: string[] = []

if (spec.command) {
opts.push("--entrypoint", spec.command.join(" "))
}
if (spec.name) {
opts.push("--name", spec.name)
}
Expand Down Expand Up @@ -520,7 +523,7 @@ const makeDockerFreshHandler = () => {
cwd: action.basePath(),
args: [...opts, spec.image],
log,
streamLogs: { ctx },
streamLogs: { ctx, print: true },
})

return {
Expand Down Expand Up @@ -567,11 +570,13 @@ const makeDockerComposeFreshHandler = () => {
return async ({ ctx, log, action }) => {
const spec = action.getSpec()

const opts = [
const args = [
"run",
// "--build", // TODO: consider making this configurable?
...spec.command || [],
"--build", // TODO: consider making this configurable?
"--remove-orphans",
"--no-deps",
...getRunOpts(spec),
spec.service,
]

// TODO: add env var flags
Expand All @@ -584,9 +589,9 @@ const makeDockerComposeFreshHandler = () => {
output,
} = await runToolWithArgs(compose(ctx), {
cwd: action.basePath(),
args: [...opts, spec.service],
args,
log,
streamLogs: { ctx },
streamLogs: { ctx, print: true },
})

return {
Expand Down

0 comments on commit 3209af8

Please sign in to comment.