Sha256: 66ea3246d2f5b4c4d1a00b61c2860e79a61593059aa9d13fbe0e9ce6f0025fa5

Contents?: true

Size: 1.72 KB

Versions: 34

Compression:

Stored size: 1.72 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 deployment names to restart", default: [] },
        "statefulsets" => { type: :array, banner: "list of statefulsets",
                            desc: "List of statefulset names to restart", default: [] },
        "daemonsets" => { type: :array, banner: "list of daemonsets",
                          desc: "List of daemonset names to restart", default: [] },
        "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],
          statefulsets: options[:statefulsets],
          daemonsets: options[:daemonsets],
          selector: selector,
          verify_result: options["verify-result"]
        )
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
krane-3.7.2 lib/krane/cli/restart_command.rb
krane-3.7.1 lib/krane/cli/restart_command.rb
krane-3.7.0 lib/krane/cli/restart_command.rb
krane-3.6.2 lib/krane/cli/restart_command.rb
krane-3.6.1 lib/krane/cli/restart_command.rb
krane-3.5.2 lib/krane/cli/restart_command.rb
krane-3.5.1 lib/krane/cli/restart_command.rb
krane-3.5.0 lib/krane/cli/restart_command.rb
krane-3.4.2 lib/krane/cli/restart_command.rb
krane-3.4.1 lib/krane/cli/restart_command.rb
krane-3.4.0 lib/krane/cli/restart_command.rb
krane-3.3.0 lib/krane/cli/restart_command.rb
krane-3.2.0 lib/krane/cli/restart_command.rb
krane-3.1.0 lib/krane/cli/restart_command.rb
krane-3.0.1 lib/krane/cli/restart_command.rb
krane-3.0.0 lib/krane/cli/restart_command.rb
krane-2.4.9 lib/krane/cli/restart_command.rb
krane-2.4.8 lib/krane/cli/restart_command.rb
krane-2.4.7 lib/krane/cli/restart_command.rb
krane-2.4.6 lib/krane/cli/restart_command.rb