Sha256: e87ac53588b0af3dbd9d3b1e80e1497e935f3597ab4be3bdd621b61f59fae86a

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Command
  class Maintenance < Base
    NAME = "maintenance"
    OPTIONS = [
      app_option(required: true)
    ].freeze
    DESCRIPTION = "Checks if maintenance mode is on or off for an app"
    LONG_DESCRIPTION = <<~DESC
      - Checks if maintenance mode is on or off for an app
      - Outputs 'on' or 'off'
      - Specify the one-off workload through `one_off_workload` in the `.controlplane/controlplane.yml` file
      - Optionally specify the maintenance workload through `maintenance_workload` in the `.controlplane/controlplane.yml` file (defaults to 'maintenance')
      - Maintenance mode is only supported for domains that use path based routing mode and have a route configured for the prefix '/' on either port 80 or 443
    DESC

    def call # rubocop:disable Metrics/MethodLength
      one_off_workload = config[:one_off_workload]
      maintenance_workload = config.current[:maintenance_workload] || "maintenance"

      domain_data = cp.find_domain_for([one_off_workload, maintenance_workload])
      unless domain_data
        raise "Can't find domain. " \
              "Maintenance mode is only supported for domains that use path based routing mode " \
              "and have a route configured for the prefix '/' on either port 80 or 443."
      end

      domain_workload = cp.get_domain_workload(domain_data)
      if domain_workload == maintenance_workload
        puts "on"
      else
        puts "off"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cpl-1.1.2 lib/command/maintenance.rb
cpl-1.1.2.rc.0 lib/command/maintenance.rb
cpl-1.1.1 lib/command/maintenance.rb
cpl-1.1.0 lib/command/maintenance.rb
cpl-1.0.4 lib/command/maintenance.rb
cpl-1.0.3 lib/command/maintenance.rb
cpl-1.0.2 lib/command/maintenance.rb
cpl-1.0.1 lib/command/maintenance.rb
cpl-1.0.0 lib/command/maintenance.rb
cpl-0.7.0 lib/command/maintenance.rb