From 09a005d79ee0f52c038e92ee6d992b84554c009c Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Tue, 18 Sep 2018 14:39:30 +1000 Subject: [PATCH] Populate the env with dry run status Updates the `applyEnvironmentVariables` function to populate whether or not the current execution context is running as a dry run or not which can then be used in hooks. --- doc/hooks.md | 1 + go/logic/hooks.go | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/hooks.md b/doc/hooks.md index 43ddb7e..1b1958f 100644 --- a/doc/hooks.md +++ b/doc/hooks.md @@ -69,6 +69,7 @@ The following variables are available on all hooks: - `GH_OST_INSPECTED_HOST` - `GH_OST_EXECUTING_HOST` - `GH_OST_HOOKS_HINT` - copy of `--hooks-hint` value +- `GH_OST_DRY_RUN` - whether or not the `gh-ost` run is a dry run The following variable are available on particular hooks: diff --git a/go/logic/hooks.go b/go/logic/hooks.go index 1fdfd5c..6515d7f 100644 --- a/go/logic/hooks.go +++ b/go/logic/hooks.go @@ -64,6 +64,7 @@ func (this *HooksExecutor) applyEnvironmentVariables(extraVariables ...string) [ env = append(env, fmt.Sprintf("GH_OST_INSPECTED_HOST=%s", this.migrationContext.GetInspectorHostname())) env = append(env, fmt.Sprintf("GH_OST_EXECUTING_HOST=%s", this.migrationContext.Hostname)) env = append(env, fmt.Sprintf("GH_OST_HOOKS_HINT=%s", this.migrationContext.HooksHintMessage)) + env = append(env, fmt.Sprintf("GH_OST_DRY_RUN=%t", this.migrationContext.Noop)) for _, variable := range extraVariables { env = append(env, variable)