diff --git a/src/commands/environment/configure.ts b/src/commands/environment/configure.ts index cfd408ae8a..de8afb97e3 100644 --- a/src/commands/environment/configure.ts +++ b/src/commands/environment/configure.ts @@ -8,18 +8,30 @@ import { PluginContext } from "../../plugin-context" import { EnvironmentStatusMap } from "../../types/plugin/outputs" -import { Command } from "../base" +import { + BooleanParameter, + Command, + ParameterValues, +} from "../base" -export class EnvironmentConfigureCommand extends Command { +export const options = { + force: new BooleanParameter({ help: "Force reconfiguration of module(s)" }), +} + +export type Opts = ParameterValues + +export class EnvironmentConfigureCommand extends Command { name = "configure" alias = "config" help = "Configures your environment" - async action(ctx: PluginContext): Promise { + options = options + + async action(ctx: PluginContext, _args, opts: Opts): Promise { const { name } = ctx.getEnvironment() ctx.log.header({ emoji: "gear", command: `Configuring ${name} environment` }) - const result = await ctx.configureEnvironment({}) + const result = await ctx.configureEnvironment({ force: opts.force }) ctx.log.info("") ctx.log.header({ emoji: "heavy_check_mark", command: `Done!` }) diff --git a/src/plugin-context.ts b/src/plugin-context.ts index 0821fd19be..bffb480878 100644 --- a/src/plugin-context.ts +++ b/src/plugin-context.ts @@ -125,7 +125,7 @@ export type WrappedFromGarden = Pick Promise - configureEnvironment: (params: {}) => Promise + configureEnvironment: (params: { force?: boolean }) => Promise destroyEnvironment: (params: {}) => Promise getConfig: (params: PluginContextParams) => Promise setConfig: (params: PluginContextParams) => Promise @@ -273,7 +273,7 @@ export function createPluginContext(garden: Garden): PluginContext { return Bluebird.props(mapValues(handlers, h => h({ ...commonParams(h) }))) }, - configureEnvironment: async () => { + configureEnvironment: async ({ force = false }: { force?: boolean }) => { const handlers = garden.getActionHandlers("configureEnvironment") const statuses = await ctx.getEnvironmentStatus({}) @@ -281,7 +281,7 @@ export function createPluginContext(garden: Garden): PluginContext { await Bluebird.each(toPairs(handlers), async ([name, handler]) => { const status = statuses[name] || { configured: false } - if (status.configured) { + if (status.configured && !force) { return } @@ -291,7 +291,7 @@ export function createPluginContext(garden: Garden): PluginContext { msg: "Configuring...", }) - await handler({ ...commonParams(handler), status, logEntry }) + await handler({ ...commonParams(handler), force, status, logEntry }) logEntry.setSuccess("Configured") }) diff --git a/src/types/plugin/params.ts b/src/types/plugin/params.ts index d099bc6ca3..aeb528f337 100644 --- a/src/types/plugin/params.ts +++ b/src/types/plugin/params.ts @@ -56,6 +56,7 @@ export interface GetEnvironmentStatusParams extends PluginActionParamsBase { export interface ConfigureEnvironmentParams extends PluginActionParamsBase { status: EnvironmentStatus + force: boolean } export interface DestroyEnvironmentParams extends PluginActionParamsBase {