Sha256: 12272d0381549d3f8de6dd13250b480a938cd26ddc9a17da6466605b952895f7

Contents?: true

Size: 1.32 KB

Versions: 21

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Command
  class MaintenanceSetPage < Base
    NAME = "maintenance:set-page"
    USAGE = "maintenance:set-page PAGE_URL"
    REQUIRES_ARGS = true
    OPTIONS = [
      app_option(required: true)
    ].freeze
    DESCRIPTION = "Sets the page for maintenance mode"
    LONG_DESCRIPTION = <<~DESC
      - Sets the page for maintenance mode
      - Only works if the maintenance workload uses the `shakacode/maintenance-mode` image
      - Will set the URL as an env var `PAGE_URL` on the maintenance workload
      - Optionally specify the maintenance workload through `maintenance_workload` in the `.controlplane/controlplane.yml` file (defaults to 'maintenance')
    DESC

    def call
      maintenance_workload = config.current[:maintenance_workload] || "maintenance"

      maintenance_workload_data = cp.fetch_workload!(maintenance_workload)
      maintenance_workload_data.dig("spec", "containers").each do |container|
        next unless container["image"].match?(%r{^shakacode/maintenance-mode})

        container_name = container["name"]
        page_url = config.args.first
        step("Setting '#{page_url}' as the page for maintenance mode") do
          cp.set_workload_env_var(maintenance_workload, container: container_name, name: "PAGE_URL", value: page_url)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
cpflow-4.0.1 lib/command/maintenance_set_page.rb
cpflow-4.0.0 lib/command/maintenance_set_page.rb
cpflow-3.0.1 lib/command/maintenance_set_page.rb
cpflow-3.0.0 lib/command/maintenance_set_page.rb
cpl-2.2.4 lib/command/maintenance_set_page.rb
cpl-2.2.2 lib/command/maintenance_set_page.rb
cpl-2.2.1 lib/command/maintenance_set_page.rb
cpl-2.2.0 lib/command/maintenance_set_page.rb
cpl-1.4.0 lib/command/maintenance_set_page.rb
cpl-1.3.0 lib/command/maintenance_set_page.rb
cpl-1.2.0 lib/command/maintenance_set_page.rb
cpl-1.1.2 lib/command/maintenance_set_page.rb
cpl-1.1.2.rc.0 lib/command/maintenance_set_page.rb
cpl-1.1.1 lib/command/maintenance_set_page.rb
cpl-1.1.0 lib/command/maintenance_set_page.rb
cpl-1.0.4 lib/command/maintenance_set_page.rb
cpl-1.0.3 lib/command/maintenance_set_page.rb
cpl-1.0.2 lib/command/maintenance_set_page.rb
cpl-1.0.1 lib/command/maintenance_set_page.rb
cpl-1.0.0 lib/command/maintenance_set_page.rb