Skip to content

Commit

Permalink
fix(server): re-use Garden instance when running commands for API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Aug 9, 2019
1 parent 4e5fd15 commit 5d873a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions garden-service/src/server/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ export async function resolveRequest(
// Prepare arguments for command action.
const command = commandSpec.command

// TODO: Creating a new Garden instance is not ideal,
// need to revisit once we've refactored the TaskGraph and config resolution.
const cmdGarden = await Garden.factory(garden.projectRoot, garden.opts)

// We generally don't want actions to log anything in the server.
const cmdLog = log.placeholder(LogLevel.silly, { childEntriesInheritLevel: true })

Expand All @@ -78,7 +74,7 @@ export async function resolveRequest(
const cmdOpts = mapParams(ctx, request.parameters, optParams)

return command.action({
garden: cmdGarden,
garden,
log: cmdLog,
headerLog: cmdLog,
footerLog: cmdLog,
Expand Down
4 changes: 4 additions & 0 deletions garden-service/test/unit/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ describe("startServer", () => {
it("should correctly map arguments and options to commands", (done) => {
const id = uuid.v4()
onMessage((req) => {
// Ignore other events such as taskPending and taskProcessing and wait for the command result
if ((<any>req).type !== "commandResult") {
return
}
const taskResult = taskResultOutputs((<any>req).result)
const result = {
...req,
Expand Down

0 comments on commit 5d873a0

Please sign in to comment.