From 78c7c286bbf9f873655cfe84a77540a59068645b Mon Sep 17 00:00:00 2001 From: Timofey Kirillov Date: Mon, 3 Oct 2022 17:34:56 +0300 Subject: [PATCH] fix(converge): feature gate for specific images params in werf-converge (due to compatibility issues) By default `werf converge` command does not accept specific images positional params to enable building and verification of only specific images from the `werf.yaml`. When `WERF_CONVERGE_ENABLE_IMAGES_PARAMS=1` is set it is possible to specify either positional images arguments or `--without-images` option: ``` export WERF_CONVERGE_ENABLE_IMAGES_PARAMS=1 werf converge IMAGE_A IMAGE_B [--without-images] [options] ``` This feature gate only needed due to historical compatibility issues with using positional arguments in converge command. Signed-off-by: Timofey Kirillov --- cmd/werf/converge/converge.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cmd/werf/converge/converge.go b/cmd/werf/converge/converge.go index 89e169e131..517e467652 100644 --- a/cmd/werf/converge/converge.go +++ b/cmd/werf/converge/converge.go @@ -51,10 +51,22 @@ var cmdData struct { var commonCmdData common.CmdData +func isSpecificImagesEnabled() bool { + return util.GetBoolEnvironmentDefaultFalse("WERF_CONVERGE_ENABLE_IMAGES_PARAMS") +} + func NewCmd(ctx context.Context) *cobra.Command { ctx = common.NewContextWithCmdData(ctx, &commonCmdData) + + var useMsg string + if isSpecificImagesEnabled() { + useMsg = "converge [IMAGE_NAME ...]" + } else { + useMsg = "converge" + } + cmd := common.SetCommandContext(ctx, &cobra.Command{ - Use: "converge [IMAGE_NAME...]", + Use: useMsg, Short: "Build and push images, then deploy application into Kubernetes", Long: common.GetLongCommandDescription(GetConvergeDocs().Long), Example: `# Build and deploy current application state into production environment @@ -76,12 +88,19 @@ werf converge --repo registry.mydomain.com/web --env production`, common.LogVersion() return common.LogRunningTime(func() error { - return runMain(ctx, common.GetImagesToProcess(args, *commonCmdData.WithoutImages)) + var imagesToProcess build.ImagesToProcess + if isSpecificImagesEnabled() { + imagesToProcess = common.GetImagesToProcess(args, *commonCmdData.WithoutImages) + } + + return runMain(ctx, imagesToProcess) }) }, }) - commonCmdData.SetupWithoutImages(cmd) + if isSpecificImagesEnabled() { + commonCmdData.SetupWithoutImages(cmd) + } common.SetupDir(&commonCmdData, cmd) common.SetupGitWorkTree(&commonCmdData, cmd)