diff --git a/garden-service/src/actions.ts b/garden-service/src/actions.ts index 5356c67d08..8a30c43397 100644 --- a/garden-service/src/actions.ts +++ b/garden-service/src/actions.ts @@ -136,7 +136,7 @@ export class ActionHelper implements TypeGuard { /** * Checks environment status and calls prepareEnvironment for each provider that isn't flagged as ready. * - * If any of the getEnvironmentStatus handlers returns needUserInput=true, this throws and guides the user to + * If any of the getEnvironmentStatus handlers returns needManualInit=true, this throws and guides the user to * run `garden init` */ async prepareEnvironment( @@ -151,13 +151,13 @@ export class ActionHelper implements TypeGuard { const entry = log.info({ section: "providers", msg: "Getting status...", status: "active" }) const statuses = await this.getEnvironmentStatus({ pluginName, log: entry }) - const needUserInput = Object.entries(statuses) + const needManualInit = Object.entries(statuses) .map(([name, status]) => ({ ...status, name })) - .filter(status => status.needUserInput === true) + .filter(status => status.needManualInit === true) - if (!allowUserInput && needUserInput.length > 0) { - const names = needUserInput.map(s => s.name).join(", ") - const msgPrefix = needUserInput.length === 1 + if (!allowUserInput && needManualInit.length > 0) { + const names = needManualInit.map(s => s.name).join(", ") + const msgPrefix = needManualInit.length === 1 ? `Plugin ${names} has been updated or hasn't been configured, and requires user input.` : `Plugins ${names} have been updated or haven't been configured, and require user input.` diff --git a/garden-service/src/plugins/kubernetes/init.ts b/garden-service/src/plugins/kubernetes/init.ts index 320633f680..d8d62597be 100644 --- a/garden-service/src/plugins/kubernetes/init.ts +++ b/garden-service/src/plugins/kubernetes/init.ts @@ -56,6 +56,7 @@ export async function getEnvironmentStatus( } const systemServiceNames = k8sCtx.provider.config._systemServices + let needManualInit = false if (systemServiceNames.length > 0) { // Check Tiller status in system namespace @@ -80,6 +81,10 @@ export async function getEnvironmentStatus( systemReady = systemTillerReady && systemServiceStatuses.ready && sysNamespaceUpToDate dashboardPages = systemServiceStatuses.dashboardPages + + // We always require manual init if we're installing any system services to remote clusters, to avoid conflicts + // between users or unnecessary work. + needManualInit = true } const detail = { systemReady, projectReady } @@ -88,6 +93,7 @@ export async function getEnvironmentStatus( ready: projectReady && systemReady, detail, dashboardPages, + needManualInit, } } diff --git a/garden-service/src/types/plugin/provider/getEnvironmentStatus.ts b/garden-service/src/types/plugin/provider/getEnvironmentStatus.ts index 0291596f42..b1b7cc9f9d 100644 --- a/garden-service/src/types/plugin/provider/getEnvironmentStatus.ts +++ b/garden-service/src/types/plugin/provider/getEnvironmentStatus.ts @@ -16,7 +16,7 @@ export interface GetEnvironmentStatusParams extends PluginActionParamsBase { } export interface EnvironmentStatus { ready: boolean - needUserInput?: boolean + needManualInit?: boolean dashboardPages?: DashboardPage[] detail?: any } @@ -30,7 +30,7 @@ export const environmentStatusSchema = Joi.object() ready: Joi.boolean() .required() .description("Set to true if the environment is fully configured for a provider."), - needUserInput: Joi.boolean() + needManualInit: Joi.boolean() .description( "Set to true if the environment needs user input to be initialized, " + "and thus needs to be initialized via `garden init`.", @@ -50,10 +50,9 @@ export const getEnvironmentStatus = { Called before \`prepareEnvironment\`. If this returns \`ready: true\`, the \`prepareEnvironment\` action is not called. - If this returns \`needUserInput: true\`, the process may throw an error and guide the user to - run \`garden init\`, so that \`prepareEnvironment\` can safely ask for user input. Otherwise the - \`prepareEnvironment\` handler may be run implicitly ahead of actions like \`deployService\`, - \`runModule\` etc. + If this returns \`needManualInit: true\`, the process may throw an error and guide the user to + run \`garden init\`. Otherwise the \`prepareEnvironment\` handler may be run implicitly ahead of + actions like \`deployService\`, \`runModule\` etc. `, paramsSchema: actionParamsSchema, resultSchema: environmentStatusSchema, diff --git a/garden-service/src/types/plugin/provider/prepareEnvironment.ts b/garden-service/src/types/plugin/provider/prepareEnvironment.ts index b6a9511eab..881251919a 100644 --- a/garden-service/src/types/plugin/provider/prepareEnvironment.ts +++ b/garden-service/src/types/plugin/provider/prepareEnvironment.ts @@ -25,10 +25,10 @@ export const prepareEnvironment = { Called ahead of any service runtime actions (such as \`deployService\`, \`runModule\` and \`testModule\`), unless \`getEnvironmentStatus\` returns \`ready: true\` or - \`needUserInput: true\`. + \`needManualInit: true\`. Important: If your handler does require user input, please be sure to indicate that via the - \`getEnvironmentStatus\` handler. If this provider's \`getEnvironmentStatus\` returns \`needUserInput: true\`, + \`getEnvironmentStatus\` handler. If this provider's \`getEnvironmentStatus\` returns \`needManualInit: true\`, this is only called via the \`garden init\` command, so that the handler can safely request user input via the CLI. `,