Sha256: e09a6143a55c1dab54cd0ae691f2c0bc07c01ed8f04eff7edcdd71a97c6ea77d

Contents?: true

Size: 1.7 KB

Versions: 56

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

module Krane
  module CLI
    class RunCommand
      DEFAULT_RUN_TIMEOUT = '300s'

      OPTIONS = {
        "global-timeout" => {
          type: :string,
          banner: "duration",
          desc: "Timeout error is raised if the pod runs for longer than the specified number of seconds",
          default: DEFAULT_RUN_TIMEOUT,
        },
        "arguments" => {
          type: :string,
          banner: '"ARG1 ARG2 ARG3"',
          desc: "Override the default arguments for the command with a space-separated list of arguments",
        },
        "verify-result" => { type: :boolean, desc: "Wait for completion and verify pod success", default: true },
        "command" => { type: :array, desc: "Override the default command in the container image" },
        "template" => {
          type: :string,
          desc: "The template file you'll be rendering",
          required: true,
          aliases: :f,
        },
        "env-vars" => {
          type: :string,
          banner: "VAR=val,FOO=bar",
          desc: "A Comma-separated list of env vars",
          default: '',
        },
      }

      def self.from_options(namespace, context, options)
        require "krane/runner_task"
        runner = ::Krane::RunnerTask.new(
          namespace: namespace,
          context: context,
          global_timeout: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
        )

        runner.run!(
          verify_result: options['verify-result'],
          template: options['template'],
          command: options['command'],
          arguments: options['arguments']&.split(" "),
          env_vars: options['env-vars'].split(','),
        )
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

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