Repository: mrsked/mrsk
File: lib/kamal/cli/traefik.rb (Ruby)

Code before:
class Kamal::Cli::Traefik < Kamal::Cli::Base
  desc "boot", "Boot Traefik on servers"
  def boot
    mutating do
      on(KAMAL.traefik_hosts) do
        execute *KAMAL.registry.login
        execute *KAMAL.traefik.start_or_run
      end
    end
  end

  desc "reboot", "Reboot Traefik on servers (stop container, remove container, start new container)"
  option :rolling, type: :boolean, default: false, desc: "Reboot traefik on hosts in sequence, rather than in parallel"
  option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
  def reboot
    confirming "Reboot Traefik on hosts? (stop container, remove container, start new container). This will cause a brief outage." do
      mutating do
        host_groups = options[:rolling] ? KAMAL.traefik_hosts : [ KAMAL.traefik_hosts ]
        host_groups.each do |hosts|
          host_list = Array(hosts).join(",")
          run_hook "pre-traefik-reboot", hosts: host_list
          on(hosts) do
            execute *KAMAL.auditor.record("Rebooted traefik"), verbosity: :debug
            execute *KAMAL.registry.login
            execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false
            execute *KAMAL.traefik.remove_container
            execute *KAMAL.traefik.run
          end
          run_hook "post-traefik-reboot", hosts: host_list
        end
      end
    end
  end

  desc "start", "Start existing Traefik container on servers"
  def start
    mutating do
      on(KAMAL.traefik_hosts) do
        execute *KAMAL.auditor.record("Started traefik"), verbosity: :debug
        execute *KAMAL.traefik.start
      end

Review comment (suggestion):
I was missing a question here (same as in other two places)

```suggestion
    confirming "Reboot Traefik on hosts? (stop container, remove container, start new container). This will cause a brief outage. Are you sure?" do
```


Code after:
class Kamal::Cli::Traefik < Kamal::Cli::Base
  desc "boot", "Boot Traefik on servers"
  def boot
    mutating do
      on(KAMAL.traefik_hosts) do
        execute *KAMAL.registry.login
        execute *KAMAL.traefik.start_or_run
      end
    end
  end

  desc "reboot", "Reboot Traefik on servers (stop container, remove container, start new container)"
  option :rolling, type: :boolean, default: false, desc: "Reboot traefik on hosts in sequence, rather than in parallel"
  option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
  def reboot
    confirming "This will cause a brief outage on each host. Are you sure?" do
      mutating do
        host_groups = options[:rolling] ? KAMAL.traefik_hosts : [ KAMAL.traefik_hosts ]
        host_groups.each do |hosts|
          host_list = Array(hosts).join(",")
          run_hook "pre-traefik-reboot", hosts: host_list
          on(hosts) do
            execute *KAMAL.auditor.record("Rebooted traefik"), verbosity: :debug
            execute *KAMAL.registry.login
            execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false
            execute *KAMAL.traefik.remove_container
            execute *KAMAL.traefik.run
          end
          run_hook "post-traefik-reboot", hosts: host_list
        end
      end
    end
  end

  desc "start", "Start existing Traefik container on servers"
  def start
    mutating do
      on(KAMAL.traefik_hosts) do
        execute *KAMAL.auditor.record("Started traefik"), verbosity: :debug
        execute *KAMAL.traefik.start
      end