Skip to content

Commit

Permalink
fix(converge): feature gate for specific images params in werf-conver…
Browse files Browse the repository at this point in the history
…ge (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 <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Oct 3, 2022
1 parent a5fdf4d commit 78c7c28
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions cmd/werf/converge/converge.go
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 78c7c28

Please sign in to comment.