Sha256: 87279c9c3b9c855d2e0883713403b09a6fb70965fefd469a8f123b849ff4e58b

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 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",
          default: 'task-runner-template',
        },
        "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 "kubernetes-deploy/runner_task"
        runner = KubernetesDeploy::RunnerTask.new(
          namespace: namespace,
          context: context,
          max_watch_seconds: KubernetesDeploy::DurationParser.new(options["global-timeout"]).parse!.to_i,
        )

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kubernetes-deploy-0.29.0 lib/krane/cli/run_command.rb