From b94199415f7e5f002aa45fb0ddcc43c5a0521fd6 Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Thu, 7 Mar 2024 09:10:49 +0000 Subject: [PATCH] Convert combine by: '||' to any --- lib/kamal/commands/base.rb | 4 ++++ lib/kamal/commands/builder/base.rb | 5 ++++- lib/kamal/commands/traefik.rb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/kamal/commands/base.rb b/lib/kamal/commands/base.rb index 3ce9b325..f51f01c1 100644 --- a/lib/kamal/commands/base.rb +++ b/lib/kamal/commands/base.rb @@ -62,6 +62,10 @@ module Kamal::Commands combine *commands, by: ">" end + def any(*commands) + combine *commands, by: "||" + end + def xargs(command) [ :xargs, command ].flatten end diff --git a/lib/kamal/commands/builder/base.rb b/lib/kamal/commands/builder/base.rb index 582adf9a..a39b3247 100644 --- a/lib/kamal/commands/builder/base.rb +++ b/lib/kamal/commands/builder/base.rb @@ -24,7 +24,10 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base def validate_image pipe \ docker(:inspect, "-f", "'{{ .Config.Labels.service }}'", config.absolute_image), - [:grep, "-x", config.service, "||", "(echo \"Image #{config.absolute_image} is missing the 'service' label\" && exit 1)"] + any( + [:grep, "-x", config.service], + "(echo \"Image #{config.absolute_image} is missing the 'service' label\" && exit 1)" + ) end diff --git a/lib/kamal/commands/traefik.rb b/lib/kamal/commands/traefik.rb index bb8f048b..14405bdb 100644 --- a/lib/kamal/commands/traefik.rb +++ b/lib/kamal/commands/traefik.rb @@ -39,7 +39,7 @@ class Kamal::Commands::Traefik < Kamal::Commands::Base end def start_or_run - combine start, run, by: "||" + any start, run end def info