Skip to content

Commit

Permalink
refactor: rename "workflow" to "task"
Browse files Browse the repository at this point in the history
And rename WorkflowTask to TaskTask (for now, we'll finish the renaming
later to avoid conflicts with other in-progress branches).
  • Loading branch information
thsig committed Nov 20, 2018
1 parent 9b40291 commit 4c7230a
Show file tree
Hide file tree
Showing 38 changed files with 383 additions and 383 deletions.
34 changes: 17 additions & 17 deletions garden-service/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import chalk from "chalk"
import { Garden } from "./garden"
import { PrimitiveMap } from "./config/common"
import { Module, ModuleMap } from "./types/module"
import { ModuleActions, ServiceActions, PluginActions, WorkflowActions } from "./types/plugin/plugin"
import { ModuleActions, ServiceActions, PluginActions, TaskActions } from "./types/plugin/plugin"
import {
BuildResult,
BuildStatus,
Expand All @@ -28,8 +28,8 @@ import {
TestResult,
PluginActionOutputs,
PublishResult,
RunWorkflowResult,
WorkflowActionOutputs,
RunTaskResult,
TaskActionOutputs,
HotReloadResult,
} from "./types/plugin/outputs"
import {
Expand Down Expand Up @@ -59,9 +59,9 @@ import {
GetEnvironmentStatusParams,
PluginModuleActionParamsBase,
PublishModuleParams,
PluginWorkflowActionParamsBase,
RunWorkflowParams,
WorkflowActionParams,
PluginTaskActionParamsBase,
RunTaskParams,
TaskActionParams,
} from "./types/plugin/params"
import {
Service,
Expand Down Expand Up @@ -105,7 +105,7 @@ type ServiceActionHelperParams<T extends PluginServiceActionParamsBase> =
Omit<T, "module" | "buildDependencies" | "runtimeContext" | keyof PluginActionContextParams>
& { runtimeContext?: RuntimeContext, pluginName?: string }

type WorkflowActionHelperParams<T extends PluginWorkflowActionParamsBase> =
type TaskActionHelperParams<T extends PluginTaskActionParamsBase> =
Omit<T, "module" | "buildDependencies" | keyof PluginActionContextParams>
& { runtimeContext?: RuntimeContext, pluginName?: string }

Expand Down Expand Up @@ -312,11 +312,11 @@ export class ActionHelper implements TypeGuard {
//endregion

//===========================================================================
//region Workflow Methods
//region Task Methods
//===========================================================================

async runWorkflow(params: WorkflowActionHelperParams<RunWorkflowParams>): Promise<RunWorkflowResult> {
return this.callWorkflowHandler({ params, actionType: "runWorkflow" })
async runTask(params: TaskActionHelperParams<RunTaskParams>): Promise<RunTaskResult> {
return this.callTaskHandler({ params, actionType: "runTask" })
}

//endregion
Expand Down Expand Up @@ -452,16 +452,16 @@ export class ActionHelper implements TypeGuard {
return (<Function>handler)(handlerParams)
}

private async callWorkflowHandler<T extends keyof WorkflowActions>(
private async callTaskHandler<T extends keyof TaskActions>(
{ params, actionType, defaultHandler }:
{
params: WorkflowActionHelperParams<WorkflowActionParams[T]>, actionType: T,
defaultHandler?: WorkflowActions[T],
params: TaskActionHelperParams<TaskActionParams[T]>, actionType: T,
defaultHandler?: TaskActions[T],
},
): Promise<WorkflowActionOutputs[T]> {
): Promise<TaskActionOutputs[T]> {

const { workflow } = <any>params
const module = workflow.module
const { task } = <any>params
const module = task.module

const handler = await this.garden.getModuleActionHandler({
moduleType: module.type,
Expand All @@ -476,7 +476,7 @@ export class ActionHelper implements TypeGuard {
...this.commonParams(handler),
...<object>params,
module,
workflow,
task,
buildDependencies,
}

Expand Down
4 changes: 2 additions & 2 deletions garden-service/src/commands/run/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { highlightYaml } from "../../util/util"
import { Command } from "../base"
import { RunModuleCommand } from "./module"
import { RunServiceCommand } from "./service"
import { RunWorkflowCommand } from "./workflow"
import { RunTaskCommand } from "./task"
import { RunTestCommand } from "./test"
import { Garden } from "../../garden"

Expand All @@ -23,7 +23,7 @@ export class RunCommand extends Command {
subCommands = [
RunModuleCommand,
RunServiceCommand,
RunWorkflowCommand,
RunTaskCommand,
RunTestCommand,
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { printRuntimeContext } from "./run"
import dedent = require("dedent")
import { prepareRuntimeContext } from "../../types/service"
import { WorkflowTask } from "../../tasks/workflow"
import { TaskTask } from "../../tasks/task"

const runArgs = {
task: new StringParameter({
Expand All @@ -38,7 +38,7 @@ const runOpts = {
type Args = typeof runArgs
type Opts = typeof runOpts

export class RunWorkflowCommand extends Command<Args, Opts> {
export class RunTaskCommand extends Command<Args, Opts> {
name = "task"
alias = "t"
help = "Run a task (in the context of its parent module)."
Expand All @@ -55,10 +55,10 @@ export class RunWorkflowCommand extends Command<Args, Opts> {
options = runOpts

async action({ garden, args, opts }: CommandParams<Args, Opts>): Promise<CommandResult<RunResult>> {
const workflow = await garden.getWorkflow(args.task)
const module = workflow.module
const task = await garden.getTask(args.task)
const module = task.module

const msg = `Running task ${chalk.white(workflow.name)}`
const msg = `Running task ${chalk.white(task.name)}`

garden.log.header({
emoji: "runner",
Expand All @@ -67,8 +67,8 @@ export class RunWorkflowCommand extends Command<Args, Opts> {

await garden.actions.prepareEnvironment({})

const workflowTask = new WorkflowTask({ garden, workflow, force: true, forceBuild: opts["force-build"] })
for (const depTask of await workflowTask.getDependencies()) {
const taskTask = new TaskTask({ garden, task, force: true, forceBuild: opts["force-build"] })
for (const depTask of await taskTask.getDependencies()) {
await garden.addTask(depTask)
}
await garden.processTasks()
Expand All @@ -83,7 +83,7 @@ export class RunWorkflowCommand extends Command<Args, Opts> {

garden.log.info("")

const result = await garden.actions.runWorkflow({ workflow, runtimeContext, interactive: true })
const result = await garden.actions.runTask({ task, runtimeContext, interactive: true })

garden.log.info(chalk.white(result.output))

Expand Down
4 changes: 2 additions & 2 deletions garden-service/src/commands/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export class ScanCommand extends Command {
const modules = (await garden.getModules())
.map(m => {
m.services.forEach(s => delete s.module)
m.workflows.forEach(w => delete w.module)
m.tasks.forEach(w => delete w.module)
return omit(m, [
"_ConfigType", "cacheContext", "serviceConfigs", "serviceNames", "workflowConfigs", "workflowNames",
"_ConfigType", "cacheContext", "serviceConfigs", "serviceNames", "taskConfigs", "taskNames",
])
})

Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function loadConfig(projectRoot: string, path: string): Promise<Gar
testConfigs: [],
type: moduleConfig.type,
variables: moduleConfig.variables,
workflowConfigs: [],
taskConfigs: [],
}
}

Expand Down
6 changes: 3 additions & 3 deletions garden-service/src/config/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
joiRepositoryUrl,
} from "./common"
import { TestConfig, TestSpec } from "./test"
import { WorkflowConfig, WorkflowSpec } from "./workflow"
import { TaskConfig, TaskSpec } from "./task"

export interface BuildCopySpec {
source: string
Expand Down Expand Up @@ -117,15 +117,15 @@ export interface ModuleConfig
M extends ModuleSpec = any,
S extends ServiceSpec = any,
T extends TestSpec = any,
W extends WorkflowSpec = any,
W extends TaskSpec = any,
>
extends BaseModuleSpec {

plugin?: string // used to identify modules that are bundled as part of a plugin

serviceConfigs: ServiceConfig<S>[]
testConfigs: TestConfig<T>[]
workflowConfigs: WorkflowConfig<W>[]
taskConfigs: TaskConfig<W>[]

// Plugins can add custom fields that are kept here
spec: M
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import {
joiIdentifier,
} from "./common"

export interface WorkflowSpec { }
export interface TaskSpec { }

export interface BaseWorkflowSpec extends WorkflowSpec {
export interface BaseTaskSpec extends TaskSpec {
name: string
dependencies: string[]
timeout: number | null
}

export const baseWorkflowSpecSchema = Joi.object()
export const baseTaskSpecSchema = Joi.object()
.keys({
name: joiIdentifier()
.required()
Expand All @@ -39,26 +39,26 @@ export const baseWorkflowSpecSchema = Joi.object()
})
.description("Required configuration for module tasks.")

export interface WorkflowConfig<T extends WorkflowSpec = WorkflowSpec> extends BaseWorkflowSpec {
export interface TaskConfig<T extends TaskSpec = TaskSpec> extends BaseTaskSpec {
// Plugins can add custom fields that are kept here
spec: T
}

export const workflowConfigSchema = baseWorkflowSpecSchema
export const taskConfigSchema = baseTaskSpecSchema
.keys({
spec: Joi.object()
.meta({ extendable: true })
.description("The task's specification, as defined by its provider plugin."),
})
.description("The configuration for a module's task.")

export const workflowSchema = Joi.object()
export const taskSchema = Joi.object()
.options({ presence: "required" })
.keys({
name: joiIdentifier()
.description("The name of the task."),
module: Joi.object().unknown(true),
config: workflowConfigSchema,
config: taskConfigSchema,
spec: Joi.object()
.meta({ extendable: true })
.description("The configuration of the task (specific to each plugin)."),
Expand Down
Loading

0 comments on commit 4c7230a

Please sign in to comment.