Sha256: 6660b8944f77946584268ed1686510d480b6932992f179eb9184ea753c29b38b

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Command
  class PsWait < Base
    NAME = "ps:wait"
    OPTIONS = [
      app_option(required: true),
      workload_option,
      location_option
    ].freeze
    DESCRIPTION = "Waits for workloads in app to be ready after re-deployment"
    LONG_DESCRIPTION = <<~DESC
      - Waits for workloads in app to be ready after re-deployment
    DESC
    EXAMPLES = <<~EX
      ```sh
      # Waits for all workloads in app.
      cpflow ps:wait -a $APP_NAME

      # Waits for a specific workload in app.
      cpflow ps:swait -a $APP_NAME -w $WORKLOAD_NAME
      ```
    EX

    def call # rubocop:disable Metrics/MethodLength
      @workloads = [config.options[:workload]] if config.options[:workload]
      @workloads ||= config[:app_workloads] + config[:additional_workloads]

      @workloads.reverse_each do |workload|
        if cp.workload_suspended?(workload)
          progress.puts("Workload '#{workload}' is suspended. Skipping...")
        else
          step("Waiting for workload '#{workload}' to be ready", retry_on_failure: true) do
            cp.workload_deployments_ready?(workload, location: config.location, expected_status: true)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cpflow-4.0.1 lib/command/ps_wait.rb
cpflow-4.0.0 lib/command/ps_wait.rb
cpflow-3.0.1 lib/command/ps_wait.rb
cpflow-3.0.0 lib/command/ps_wait.rb