Sha256: ee009fb2219e4507cdd50732b964fad0124af413b599911f833ee13a4821a65d

Contents?: true

Size: 1.3 KB

Versions: 22

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Krane
  module CLI
    class RestartCommand
      DEFAULT_RESTART_TIMEOUT = '300s'
      OPTIONS = {
        "deployments" => { type: :array, banner: "list of deployments",
                           desc: "List of workload names to restart" },
        "global-timeout" => { type: :string, banner: "duration", default: DEFAULT_RESTART_TIMEOUT,
                              desc: "Max duration to monitor workloads correctly restarted" },
        "selector" => { type: :string, banner: "'label=value'",
                        desc: "Select workloads by selector(s)" },
        "verify-result" => { type: :boolean, default: true,
                             desc: "Verify workloads correctly restarted" },
      }

      def self.from_options(namespace, context, options)
        require 'krane/restart_task'
        selector = ::Krane::LabelSelector.parse(options[:selector]) if options[:selector]
        restart = ::Krane::RestartTask.new(
          namespace: namespace,
          context: context,
          global_timeout: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
        )
        restart.run!(
          deployments: options[:deployments],
          selector: selector,
          verify_result: options["verify-result"]
        )
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
krane-2.2.0 lib/krane/cli/restart_command.rb
krane-2.1.10 lib/krane/cli/restart_command.rb
krane-2.1.9 lib/krane/cli/restart_command.rb
krane-2.1.8 lib/krane/cli/restart_command.rb
krane-2.1.7 lib/krane/cli/restart_command.rb
krane-2.1.6 lib/krane/cli/restart_command.rb
krane-2.1.5 lib/krane/cli/restart_command.rb
krane-2.1.4 lib/krane/cli/restart_command.rb
krane-2.1.3 lib/krane/cli/restart_command.rb
krane-2.1.2 lib/krane/cli/restart_command.rb
krane-2.1.1 lib/krane/cli/restart_command.rb
krane-2.1.0 lib/krane/cli/restart_command.rb
krane-2.0.0 lib/krane/cli/restart_command.rb
krane-1.1.4 lib/krane/cli/restart_command.rb
krane-1.1.3 lib/krane/cli/restart_command.rb
krane-1.1.2 lib/krane/cli/restart_command.rb
krane-1.1.1 lib/krane/cli/restart_command.rb
krane-1.1.0 lib/krane/cli/restart_command.rb
tobsch-krane-1.0.2 lib/krane/cli/restart_command.rb
tobsch-krane-1.0.1 lib/krane/cli/restart_command.rb