diff --git a/lib/krane/cli/run_command.rb b/lib/krane/cli/run_command.rb index 21c490ac6..7e5b20fe2 100644 --- a/lib/krane/cli/run_command.rb +++ b/lib/krane/cli/run_command.rb @@ -19,7 +19,7 @@ class RunCommand }, "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" }, - "filename" => { + "template" => { type: :string, desc: "The template file you'll be rendering", required: true, @@ -43,7 +43,7 @@ def self.from_options(namespace, context, options) runner.run!( verify_result: options['verify-result'], - filename: options['filename'], + template: options['template'], command: options['command'], arguments: options['arguments']&.split(" "), env_vars: options['env-vars'].split(','), diff --git a/lib/krane/runner_task.rb b/lib/krane/runner_task.rb index c29b4532d..8817adb38 100644 --- a/lib/krane/runner_task.rb +++ b/lib/krane/runner_task.rb @@ -43,24 +43,24 @@ def run(*args) # Runs the task, raising exceptions in case of issues # - # @param filename [String] The filename of the template you'll be rendering (*required*) + # @param template [String] The filename of the template you'll be rendering (*required*) # @param command [Array] Override the default command in the container image # @param arguments [Array] Override the default arguments for the command # @param env_vars [Array] List of env vars # @param verify_result [Boolean] Wait for completion and verify pod success # # @return [nil] - def run!(filename:, command:, arguments:, env_vars: [], verify_result: true) + def run!(template:, command:, arguments:, env_vars: [], verify_result: true) start = Time.now.utc @logger.reset @logger.phase_heading("Initializing task") @logger.info("Validating configuration") - verify_config!(filename) + verify_config!(template) @logger.info("Using namespace '#{@namespace}' in context '#{@context}'") - pod = build_pod(filename, command, arguments, env_vars, verify_result) + pod = build_pod(template, command, arguments, env_vars, verify_result) validate_pod(pod) @logger.phase_heading("Running pod") diff --git a/test/exe/run_test.rb b/test/exe/run_test.rb index 1d1019d7d..8a51bdfc2 100644 --- a/test/exe/run_test.rb +++ b/test/exe/run_test.rb @@ -34,9 +34,9 @@ def test_run_parses_arguments krane_run!(flags: '--arguments hello') end - def test_run_parses_filename - set_krane_run_expectations(run_args: { filename: 'some-name' }) - krane_run!(flags: '--filename some-name') + def test_run_parses_template + set_krane_run_expectations(run_args: { template: 'some-name' }) + krane_run!(flags: '--template some-name') end def test_run_parses_env_vars @@ -45,21 +45,21 @@ def test_run_parses_env_vars end def test_run_failure_with_not_enough_arguments_as_black_box - out, err, status = krane_black_box('run', '--filename some_template not_enough_arguments') + out, err, status = krane_black_box('run', '--template some_template not_enough_arguments') assert_equal(1, status.exitstatus) assert_empty(out) assert_match("ERROR", err) end def test_run_failure_with_too_many_args_as_black_box - out, err, status = krane_black_box('run', '--filename some_template ns ctx some_extra_arg') + out, err, status = krane_black_box('run', '--template some_template ns ctx some_extra_arg') assert_equal(1, status.exitstatus) assert_empty(out) assert_match("ERROR", err) end def test_run_failure_with_bad_timeout_as_black_box - out, err, status = krane_black_box('run', '--filename some_template ns ctx --global-timeout=mittens') + out, err, status = krane_black_box('run', '--template some_template ns ctx --global-timeout=mittens') assert_equal(1, status.exitstatus) assert_empty(out) assert_match("Error parsing duration", err) @@ -75,7 +75,7 @@ def set_krane_run_expectations(new_args: {}, run_args: {}) end def krane_run!(flags: '') - flags += " --filename #{TASK_TEMPLATE}" unless flags.include?('--filename') + flags += " --template #{TASK_TEMPLATE}" unless flags.include?('--template') krane = Krane::CLI::Krane.new( [run_task_config.namespace, run_task_config.context], flags.split @@ -96,7 +96,7 @@ def default_options(new_args = {}, run_args = {}) }.merge(new_args), run_args: { verify_result: true, - filename: TASK_TEMPLATE, + template: TASK_TEMPLATE, command: nil, arguments: nil, env_vars: [], diff --git a/test/helpers/task_runner_test_helper.rb b/test/helpers/task_runner_test_helper.rb index 08ef6900e..7af30ab88 100644 --- a/test/helpers/task_runner_test_helper.rb +++ b/test/helpers/task_runner_test_helper.rb @@ -21,7 +21,7 @@ def build_task_runner(context: KubeclientHelper::TEST_CONTEXT, ns: @namespace, g def run_params(log_lines: 5, log_interval: 0.1, verify_result: true) { - filename: 'hello-cloud-template-runner', + template: 'hello-cloud-template-runner', command: ['/bin/sh', '-c'], arguments: [ "i=1; " \ diff --git a/test/integration/krane_test.rb b/test/integration/krane_test.rb index cf4b67f73..765be833e 100644 --- a/test/integration/krane_test.rb +++ b/test/integration/krane_test.rb @@ -21,7 +21,7 @@ def test_run_success_black_box assert_deploy_success(deploy_fixtures("hello-cloud", subset: ["template-runner.yml", "configmap-data.yml"])) template = "hello-cloud-template-runner" out, err, status = krane_black_box("run", - "#{@namespace} #{KubeclientHelper::TEST_CONTEXT} --filename #{template} --command ls --arguments '-a /'") + "#{@namespace} #{KubeclientHelper::TEST_CONTEXT} --template #{template} --command ls --arguments '-a /'") assert_match("Success", err) assert_empty(out) assert_predicate(status, :success?) diff --git a/test/integration/runner_task_test.rb b/test/integration/runner_task_test.rb index bb64c7d7e..cde21748d 100644 --- a/test/integration/runner_task_test.rb +++ b/test/integration/runner_task_test.rb @@ -206,7 +206,7 @@ def test_run_fails_if_namespace_is_missing def test_run_fails_if_template_is_blank task_runner = build_task_runner - result = task_runner.run(filename: '', + result = task_runner.run(template: '', command: ['/bin/sh', '-c'], arguments: nil, env_vars: ["MY_CUSTOM_VARIABLE=MITTENS"]) @@ -224,7 +224,7 @@ def test_run_fails_if_template_is_blank def test_run_bang_fails_if_template_is_invalid task_runner = build_task_runner assert_raises(Krane::TaskConfigurationError) do - task_runner.run!(filename: '', + task_runner.run!(template: '', command: ['/bin/sh', '-c'], arguments: nil, env_vars: ["MY_CUSTOM_VARIABLE=MITTENS"]) @@ -271,7 +271,7 @@ def test_run_adds_env_vars_provided_to_the_task_container task_runner = build_task_runner result = task_runner.run( - filename: 'hello-cloud-template-runner', + template: 'hello-cloud-template-runner', command: ['/bin/sh', '-c'], arguments: ['echo "The value is: $MY_CUSTOM_VARIABLE"'], env_vars: ["MY_CUSTOM_VARIABLE=MITTENS"]